Changeset 160774 in webkit
- Timestamp:
- Dec 18, 2013 10:14:12 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r160771 r160774 1 2013-12-18 Tamas Gergely <tgergely.u-szeged@partner.samsung.com> 2 3 Fix ASSERTION FAILED in WebCore::SVGLengthContext::determineViewport 4 https://bugs.webkit.org/show_bug.cgi?id=120284 5 6 Reviewed by Philip Rogers. 7 8 Added tests of handling root <svg> elements. 9 Blink merge: https://chromium.googlesource.com/chromium/blink/+/a7dedf81eb7008276bb6854f0e46465e039788f8 10 11 * svg/custom/svg-length-value-handled-expected.txt: Added. 12 * svg/custom/svg-length-value-handled.svg: Added. 13 Tests whether root svg elements sizes are handled. 14 * svg/dom/svg-root-lengths-expected.txt: Added. 15 * svg/dom/svg-root-lengths.html: Added. 16 Tests the correct handling of root svg elements sizes. 17 1 18 2013-12-18 Darin Adler <darin@apple.com> 2 19 -
trunk/Source/WebCore/ChangeLog
r160771 r160774 1 2013-12-18 Tamas Gergely <tgergely.u-szeged@partner.samsung.com> 2 3 Fix ASSERTION FAILED in WebCore::SVGLengthContext::determineViewport 4 https://bugs.webkit.org/show_bug.cgi?id=120284 5 6 Reviewed by Philip Rogers. 7 8 Added handling of root <svg> elements. 9 Blink merge: https://chromium.googlesource.com/chromium/blink/+/a7dedf81eb7008276bb6854f0e46465e039788f8 10 11 SVGLengthContext::determineViewport() currently asserts that we're not 12 resolving lengths for the topmost element, but there's nothing to 13 prevent such calls. 14 15 The patch updates determineViewport() to handle root elements geracefully 16 (using their current viewport). It also changes the signature slightly 17 to operate directly on a FloatSize, reducing some of the boiler-plate 18 client code. 19 20 Tests: svg/custom/svg-length-value-handled.svg 21 svg/dom/svg-root-lengths.html 22 23 * svg/SVGLengthContext.cpp: 24 (WebCore::SVGLengthContext::convertValueFromUserUnitsToPercentage): 25 (WebCore::SVGLengthContext::convertValueFromPercentageToUserUnits): 26 (WebCore::SVGLengthContext::determineViewport): 27 * svg/SVGLengthContext.h: 28 * svg/graphics/filters/SVGFEImage.cpp: 29 (WebCore::FEImage::platformApplySoftware): 30 1 31 2013-12-18 Darin Adler <darin@apple.com> 2 32 -
trunk/Source/WebCore/svg/SVGLengthContext.cpp
r158163 r160774 162 162 float SVGLengthContext::convertValueFromUserUnitsToPercentage(float value, SVGLengthMode mode, ExceptionCode& ec) const 163 163 { 164 float width = 0; 165 float height = 0; 166 if (!determineViewport(width, height)) { 164 FloatSize viewportSize; 165 if (!determineViewport(viewportSize)) { 167 166 ec = NOT_SUPPORTED_ERR; 168 167 return 0; … … 171 170 switch (mode) { 172 171 case LengthModeWidth: 173 return value / width* 100;172 return value / viewportSize.width() * 100; 174 173 case LengthModeHeight: 175 return value / height* 100;174 return value / viewportSize.height() * 100; 176 175 case LengthModeOther: 177 return value / (sqrtf( (width * width + height * height) / 2)) * 100;176 return value / (sqrtf(viewportSize.diagonalLengthSquared() / 2)) * 100; 178 177 }; 179 178 … … 184 183 float SVGLengthContext::convertValueFromPercentageToUserUnits(float value, SVGLengthMode mode, ExceptionCode& ec) const 185 184 { 186 float width = 0; 187 float height = 0; 188 if (!determineViewport(width, height)) { 185 FloatSize viewportSize; 186 if (!determineViewport(viewportSize)) { 189 187 ec = NOT_SUPPORTED_ERR; 190 188 return 0; … … 193 191 switch (mode) { 194 192 case LengthModeWidth: 195 return value * width;193 return value * viewportSize.width(); 196 194 case LengthModeHeight: 197 return value * height;195 return value * viewportSize.height(); 198 196 case LengthModeOther: 199 return value * sqrtf( (width * width + height * height) / 2);197 return value * sqrtf(viewportSize.diagonalLengthSquared() / 2); 200 198 }; 201 199 … … 281 279 } 282 280 283 bool SVGLengthContext::determineViewport( float& width, float& height) const281 bool SVGLengthContext::determineViewport(FloatSize& viewportSize) const 284 282 { 285 283 if (!m_context) … … 288 286 // If an overriden viewport is given, it has precedence. 289 287 if (!m_overridenViewport.isEmpty()) { 290 width = m_overridenViewport.width(); 291 height = m_overridenViewport.height(); 288 viewportSize = m_overridenViewport.size(); 292 289 return true; 293 290 } 294 291 295 // SVGLengthContext should NEVER be used to resolve width/height values for <svg> elements, 296 // as they require special treatment, due the relationship with the CSS width/height properties. 297 ASSERT(m_context->document().documentElement() != m_context); 292 // Root <svg> element lengths are resolved against the top level viewport. 293 if (m_context->isOutermostSVGSVGElement()) { 294 viewportSize = toSVGSVGElement(m_context)->currentViewportSize(); 295 return true; 296 } 298 297 299 298 // Take size from nearest viewport element. … … 301 300 if (!viewportElement || !isSVGSVGElement(viewportElement)) 302 301 return false; 303 302 304 303 const SVGSVGElement* svg = toSVGSVGElement(viewportElement); 305 FloatSizeviewportSize = svg->currentViewBoxRect().size();304 viewportSize = svg->currentViewBoxRect().size(); 306 305 if (viewportSize.isEmpty()) 307 306 viewportSize = svg->currentViewportSize(); 308 307 309 width = viewportSize.width();310 height = viewportSize.height();311 308 return true; 312 309 } -
trunk/Source/WebCore/svg/SVGLengthContext.h
r106113 r160774 69 69 float convertValueFromUserUnits(float, SVGLengthMode, SVGLengthType toUnit, ExceptionCode&) const; 70 70 71 bool determineViewport( float& width, float& height) const;71 bool determineViewport(FloatSize&) const; 72 72 73 73 private: -
trunk/Source/WebCore/svg/graphics/filters/SVGFEImage.cpp
r159277 r160774 129 129 if (contextNode->hasRelativeLengths()) { 130 130 SVGLengthContext lengthContext(contextNode); 131 float width = 0; 132 float height = 0; 131 FloatSize viewportSize; 133 132 134 133 // If we're referencing an element with percentage units, eg. <rect with="30%"> those values were resolved against the viewport. 135 134 // Build up a transformation that maps from the viewport space to the filter primitive subregion. 136 if (lengthContext.determineViewport( width, height))137 resultImage->context()->concatCTM(makeMapBetweenRects(FloatRect( 0, 0, width, height), destRect));135 if (lengthContext.determineViewport(viewportSize)) 136 resultImage->context()->concatCTM(makeMapBetweenRects(FloatRect(FloatPoint(), viewportSize), destRect)); 138 137 } 139 138
Note: See TracChangeset
for help on using the changeset viewer.