Changeset 140049 in webkit
- Timestamp:
- Jan 17, 2013, 2:51:03 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r140045 r140049 1 2013-01-17 Stephen Chenney <schenney@chromium.org> 2 3 SVGViewSpec fails when corresponding element has been removed 4 https://bugs.webkit.org/show_bug.cgi?id=106957 5 6 Reviewed by Dirk Schulze. 7 8 Test for the situation in which the target of an SVGViewSpec is 9 removed while the view spec lives on in JS. 10 11 * svg/dom/SVGViewSpec-invalid-ref-crash-expected.txt: Added. 12 * svg/dom/SVGViewSpec-invalid-ref-crash.html: Added. 13 1 14 2013-01-17 Julien Chaffraix <jchaffraix@webkit.org> 2 15 -
trunk/Source/WebCore/ChangeLog
r140048 r140049 1 2013-01-17 Stephen Chenney <schenney@chromium.org> 2 3 SVGViewSpec fails when corresponding element has been removed 4 https://bugs.webkit.org/show_bug.cgi?id=106957 5 6 Reviewed by Dirk Schulze. 7 8 When JS holds an SVGViewSpec object while deleting the object that 9 defines the spec (an SVGSVGElement, or one of a few others) the 10 pointer to the target is cleared in the SVGViewSpec but the methods 11 that serve JS queries do not check and try to access the now null 12 target. This atch fixes the prooblem, throwing JS exceptions where 13 possible and returning null where necessary. 14 15 Test: svg/dom/SVGViewSpec-invalid-ref-crash.html 16 17 * svg/SVGViewSpec.cpp: 18 (WebCore): 19 (WebCore::SVGViewSpec::viewTarget): Check for null target and throw an exception. 20 (WebCore::SVGViewSpec::transform): Check for null target and return 21 null. It is not possible to throw an exception here because it leads 22 to an invalid cast in the code generated from IDLs. 23 (WebCore::SVGViewSpec::viewBoxAnimated): Check for null target and throw an exception. 24 (WebCore::SVGViewSpec::preserveAspectRatioAnimated): Check for null target and throw an exception. 25 (WebCore::SVGViewSpec::lookupOrCreateViewBoxWrapper): ASSERT non-null target 26 (WebCore::SVGViewSpec::lookupOrCreatePreserveAspectRatioWrapper): ASSERT non-null target 27 (WebCore::SVGViewSpec::lookupOrCreateTransformWrapper): ASSERT non-null target 28 * svg/SVGViewSpec.h: 29 (SVGViewSpec): Add Exception arguments to getter methods. 30 * svg/SVGViewSpec.idl: Mark attributes as throwing exceptions. 31 1 32 2013-01-17 Alec Flett <alecflett@chromium.org> 2 33 -
trunk/Source/WebCore/svg/SVGViewSpec.cpp
r133976 r140049 134 134 } 135 135 136 void SVGViewSpec::setPreserveAspectRatioString(const String& preserve)137 {138 SVGPreserveAspectRatio preserveAspectRatio;139 preserveAspectRatio.parse(preserve);140 setPreserveAspectRatioBaseValue(preserveAspectRatio);141 }142 143 136 String SVGViewSpec::preserveAspectRatioString() const 144 137 { … … 146 139 } 147 140 148 SVGElement* SVGViewSpec::viewTarget() const 141 SVGElement* SVGViewSpec::viewTarget(ExceptionCode& ec) const 142 { 143 if (!m_contextElement) { 144 ec = INVALID_STATE_ERR; 145 return 0; 146 } 147 return static_cast<SVGElement*>(m_contextElement->treeScope()->getElementById(m_viewTargetString)); 148 } 149 150 SVGTransformListPropertyTearOff* SVGViewSpec::transform() 149 151 { 150 152 if (!m_contextElement) 151 153 return 0; 152 return static_cast<SVGElement*>(m_contextElement->treeScope()->getElementById(m_viewTargetString));153 }154 155 SVGTransformListPropertyTearOff* SVGViewSpec::transform()156 {157 154 // Return the animVal here, as its readonly by default - which is exactly what we want here. 158 155 return static_cast<SVGTransformListPropertyTearOff*>(static_pointer_cast<SVGAnimatedTransformList>(lookupOrCreateTransformWrapper(this))->animVal()); 159 156 } 160 157 158 PassRefPtr<SVGAnimatedRect> SVGViewSpec::viewBoxAnimated(ExceptionCode& ec) 159 { 160 if (!m_contextElement) { 161 ec = INVALID_STATE_ERR; 162 return 0; 163 } 164 return static_pointer_cast<SVGAnimatedRect>(lookupOrCreateViewBoxWrapper(this)); 165 } 166 167 PassRefPtr<SVGAnimatedPreserveAspectRatio> SVGViewSpec::preserveAspectRatioAnimated(ExceptionCode& ec) 168 { 169 if (!m_contextElement) { 170 ec = INVALID_STATE_ERR; 171 return 0; 172 } 173 return static_pointer_cast<SVGAnimatedPreserveAspectRatio>(lookupOrCreatePreserveAspectRatioWrapper(this)); 174 } 175 161 176 PassRefPtr<SVGAnimatedProperty> SVGViewSpec::lookupOrCreateViewBoxWrapper(void* maskedOwnerType) 162 177 { 163 178 ASSERT(maskedOwnerType); 164 179 SVGViewSpec* ownerType = static_cast<SVGViewSpec*>(maskedOwnerType); 180 ASSERT(ownerType->contextElement()); 165 181 return SVGAnimatedProperty::lookupOrCreateWrapper<SVGElement, SVGAnimatedRect, FloatRect>(ownerType->contextElement(), viewBoxPropertyInfo(), ownerType->m_viewBox); 166 182 } … … 170 186 ASSERT(maskedOwnerType); 171 187 SVGViewSpec* ownerType = static_cast<SVGViewSpec*>(maskedOwnerType); 188 ASSERT(ownerType->contextElement()); 172 189 return SVGAnimatedProperty::lookupOrCreateWrapper<SVGElement, SVGAnimatedPreserveAspectRatio, SVGPreserveAspectRatio>(ownerType->contextElement(), preserveAspectRatioPropertyInfo(), ownerType->m_preserveAspectRatio); 173 190 } … … 177 194 ASSERT(maskedOwnerType); 178 195 SVGViewSpec* ownerType = static_cast<SVGViewSpec*>(maskedOwnerType); 196 ASSERT(ownerType->contextElement()); 179 197 return SVGAnimatedProperty::lookupOrCreateWrapper<SVGElement, SVGAnimatedTransformList, SVGTransformList>(ownerType->contextElement(), transformPropertyInfo(), ownerType->m_transform); 180 198 } -
trunk/Source/WebCore/svg/SVGViewSpec.h
r118735 r140049 50 50 void reset(); 51 51 52 SVGElement* viewTarget( ) const;52 SVGElement* viewTarget(ExceptionCode&) const; 53 53 String viewBoxString() const; 54 54 55 void setPreserveAspectRatioString(const String&);56 55 String preserveAspectRatioString() const; 57 56 … … 75 74 76 75 // Custom animated 'viewBox' property. 77 PassRefPtr<SVGAnimatedRect> viewBoxAnimated() 78 { 79 return static_pointer_cast<SVGAnimatedRect>(lookupOrCreateViewBoxWrapper(this)); 80 } 81 76 PassRefPtr<SVGAnimatedRect> viewBoxAnimated(ExceptionCode&); 82 77 FloatRect& viewBox() { return m_viewBox; } 83 78 FloatRect viewBoxBaseValue() const { return m_viewBox; } … … 85 80 86 81 // Custom animated 'preserveAspectRatio' property. 87 PassRefPtr<SVGAnimatedPreserveAspectRatio> preserveAspectRatioAnimated() 88 { 89 return static_pointer_cast<SVGAnimatedPreserveAspectRatio>(lookupOrCreatePreserveAspectRatioWrapper(this)); 90 } 91 82 PassRefPtr<SVGAnimatedPreserveAspectRatio> preserveAspectRatioAnimated(ExceptionCode&); 92 83 SVGPreserveAspectRatio& preserveAspectRatio() { return m_preserveAspectRatio; } 93 84 SVGPreserveAspectRatio preserveAspectRatioBaseValue() const { return m_preserveAspectRatio; } -
trunk/Source/WebCore/svg/SVGViewSpec.idl
r131172 r140049 31 31 ] interface SVGViewSpec { 32 32 readonly attribute SVGTransformList transform; 33 readonly attribute SVGElement viewTarget; 33 readonly attribute SVGElement viewTarget 34 getter raises(DOMException); 34 35 readonly attribute DOMString viewBoxString; 35 36 readonly attribute DOMString preserveAspectRatioString; … … 42 43 43 44 // SVGFitToViewBox 44 readonly attribute SVGAnimatedRect viewBox; 45 readonly attribute SVGAnimatedPreserveAspectRatio preserveAspectRatio; 45 readonly attribute SVGAnimatedRect viewBox 46 getter raises(DOMException); 47 readonly attribute SVGAnimatedPreserveAspectRatio preserveAspectRatio 48 getter raises(DOMException); 46 49 }; 47 50
Note:
See TracChangeset
for help on using the changeset viewer.