Chromium Code Reviews| Index: Source/core/svg/SVGLengthContext.cpp |
| diff --git a/Source/core/svg/SVGLengthContext.cpp b/Source/core/svg/SVGLengthContext.cpp |
| index e3651cc0eb5285e95117e7b81e09edb7bc6f1f7a..870e4fb6ce1ce008a17c1b02127c67bfc8f8d4c3 100644 |
| --- a/Source/core/svg/SVGLengthContext.cpp |
| +++ b/Source/core/svg/SVGLengthContext.cpp |
| @@ -96,15 +96,37 @@ float SVGLengthContext::resolveLength(const SVGElement* context, SVGUnitTypes::S |
| return x.valueAsPercentage(); |
| } |
| +static inline LayoutStyle* layoutStyleForLengthResolving(const SVGElement* context) |
| +{ |
| + if (!context) |
| + return 0; |
| + |
| + const ContainerNode* currentContext = context; |
| + do { |
| + if (currentContext->renderer()) |
| + return currentContext->renderer()->style(); |
| + currentContext = currentContext->parentNode(); |
| + } while (currentContext); |
| + |
| + // There must be at least a LayoutSVGRoot renderer, carrying a style. |
| + ASSERT_NOT_REACHED(); |
| + return 0; |
| +} |
| + |
| float SVGLengthContext::valueForLength(const Length& length, SVGLengthMode mode) const |
| { |
| + LayoutStyle* style = layoutStyleForLengthResolving(m_context); |
|
fs
2015/02/24 17:29:28
Should rather be passing a LayoutStyle& to here.
Erik Dahlström (inactive)
2015/02/25 09:17:36
Done.
|
| + if (!style) |
| + return 0; |
| + |
| float dimension = 0; |
| if (length.isPercent()) { |
| FloatSize viewportSize; |
| determineViewport(viewportSize); |
| + viewportSize.scale(style->effectiveZoom()); |
| dimension = dimensionForLengthMode(mode, viewportSize); |
| } |
| - return floatValueForLength(length, dimension); |
| + return floatValueForLength(length, dimension) / style->effectiveZoom(); |
| } |
| float SVGLengthContext::convertValueToUserUnits(float value, SVGLengthMode mode, SVGLengthType fromUnit) const |
| @@ -179,23 +201,6 @@ float SVGLengthContext::convertValueFromUserUnits(float value, SVGLengthMode mod |
| return 0; |
| } |
| -static inline LayoutStyle* layoutStyleForLengthResolving(const SVGElement* context) |
| -{ |
| - if (!context) |
| - return 0; |
| - |
| - const ContainerNode* currentContext = context; |
| - do { |
| - if (currentContext->renderer()) |
| - return currentContext->renderer()->style(); |
| - currentContext = currentContext->parentNode(); |
| - } while (currentContext); |
| - |
| - // There must be at least a LayoutSVGRoot renderer, carrying a style. |
| - ASSERT_NOT_REACHED(); |
| - return 0; |
| -} |
| - |
| float SVGLengthContext::convertValueFromUserUnitsToEMS(float value) const |
| { |
| LayoutStyle* style = layoutStyleForLengthResolving(m_context); |