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..1446cfb4205f859ca18d87297b941201b8c1b7fd 100644 |
| --- a/Source/core/svg/SVGLengthContext.cpp |
| +++ b/Source/core/svg/SVGLengthContext.cpp |
| @@ -96,15 +96,39 @@ float SVGLengthContext::resolveLength(const SVGElement* context, SVGUnitTypes::S |
| return x.valueAsPercentage(); |
| } |
| -float SVGLengthContext::valueForLength(const Length& length, SVGLengthMode mode) const |
| +static inline LayoutStyle* layoutStyleForLengthResolving(const SVGElement* context) |
|
fs
2015/02/25 13:43:11
Please restore this to where it originally was. (A
Erik Dahlström (inactive)
2015/02/25 13:54:50
Done.
|
| { |
| + 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, const LayoutStyle& style, SVGLengthMode mode) const |
| +{ |
| + return valueForLengthWithZoom(length, style.effectiveZoom(), mode); |
| +} |
| + |
| +float SVGLengthContext::valueForLengthWithZoom(const Length& length, float zoom, SVGLengthMode mode) const |
| +{ |
| + ASSERT(zoom != 0); |
| float dimension = 0; |
| if (length.isPercent()) { |
| FloatSize viewportSize; |
| determineViewport(viewportSize); |
| - dimension = dimensionForLengthMode(mode, viewportSize); |
| + // The viewport will be unaffected by zoom. |
| + dimension = dimensionForLengthMode(mode, viewportSize) * zoom; |
| } |
| - return floatValueForLength(length, dimension); |
| + return floatValueForLength(length, dimension) / zoom; |
| } |
| float SVGLengthContext::convertValueToUserUnits(float value, SVGLengthMode mode, SVGLengthType fromUnit) const |
| @@ -179,23 +203,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); |