Chromium Code Reviews| Index: Source/core/svg/SVGLengthContext.cpp |
| diff --git a/Source/core/svg/SVGLengthContext.cpp b/Source/core/svg/SVGLengthContext.cpp |
| index 4bffd9cae72f1001a0be6c2596c167ac4e3d2c4d..67055d0e41c09925ac89b58845ae74bf51acc437 100644 |
| --- a/Source/core/svg/SVGLengthContext.cpp |
| +++ b/Source/core/svg/SVGLengthContext.cpp |
| @@ -52,10 +52,10 @@ FloatRect SVGLengthContext::resolveRectangle(const SVGElement* context, SVGUnitT |
| if (type != SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE && !viewport.isEmpty()) { |
| const FloatSize& viewportSize = viewport.size(); |
| return FloatRect( |
| - convertValueFromPercentageToUserUnits(x->valueAsPercentage(), x->unitMode(), viewportSize) + viewport.x(), |
| - convertValueFromPercentageToUserUnits(y->valueAsPercentage(), y->unitMode(), viewportSize) + viewport.y(), |
| - convertValueFromPercentageToUserUnits(width->valueAsPercentage(), width->unitMode(), viewportSize), |
| - convertValueFromPercentageToUserUnits(height->valueAsPercentage(), height->unitMode(), viewportSize)); |
| + convertValueFromPercentageToUserUnits(*x, viewportSize) + viewport.x(), |
| + convertValueFromPercentageToUserUnits(*y, viewportSize) + viewport.y(), |
| + convertValueFromPercentageToUserUnits(*width, viewportSize), |
| + convertValueFromPercentageToUserUnits(*height, viewportSize)); |
| } |
| SVGLengthContext lengthContext(context); |
| @@ -102,7 +102,7 @@ float SVGLengthContext::convertValueToUserUnits(float value, SVGLengthMode mode, |
| case LengthTypePX: |
| return value; |
| case LengthTypePercentage: |
| - return convertValueFromPercentageToUserUnits(value / 100, mode, exceptionState); |
| + return convertValueFromPercentageToUserUnits(value, mode, exceptionState) / 100; |
| case LengthTypeEMS: |
| return convertValueFromEMSToUserUnits(value, exceptionState); |
| case LengthTypeEXS: |
| @@ -201,6 +201,22 @@ float SVGLengthContext::convertValueFromPercentageToUserUnits(float value, SVGLe |
| return 0; |
| } |
| +float SVGLengthContext::convertValueFromPercentageToUserUnits(const SVGLength& value, const FloatSize& viewportSize) |
| +{ |
| + float resultValue; |
|
fs
2015/01/22 14:06:36
Nit: Unused.
Daniel Bratell
2015/01/22 14:15:45
Done.
|
| + switch (value.unitMode()) { |
| + case LengthModeWidth: |
| + return value.scaleByPercentage(viewportSize.width()); |
| + case LengthModeHeight: |
| + return value.scaleByPercentage(viewportSize.height()); |
| + case LengthModeOther: |
| + return value.scaleByPercentage(sqrtf(viewportSize.diagonalLengthSquared() / 2)); |
| + }; |
|
fs
2015/01/22 14:06:36
Nit: Redundant ;
Daniel Bratell
2015/01/22 14:15:45
Done.
|
| + |
| + ASSERT_NOT_REACHED(); |
| + return 0; |
| +} |
| + |
| static inline RenderStyle* renderStyleForLengthResolving(const SVGElement* context) |
| { |
| if (!context) |