Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1665)

Unified Diff: Source/core/svg/SVGLengthContext.cpp

Issue 933313003: Simplify SVGLengthContext::valueForLength (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/svg/SVGLengthContext.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/SVGLengthContext.cpp
diff --git a/Source/core/svg/SVGLengthContext.cpp b/Source/core/svg/SVGLengthContext.cpp
index e3c7dce1f101ed0bd8e860f08e775bc99ff163e5..e3651cc0eb5285e95117e7b81e09edb7bc6f1f7a 100644
--- a/Source/core/svg/SVGLengthContext.cpp
+++ b/Source/core/svg/SVGLengthContext.cpp
@@ -96,18 +96,15 @@ float SVGLengthContext::resolveLength(const SVGElement* context, SVGUnitTypes::S
return x.valueAsPercentage();
}
-float SVGLengthContext::valueForLength(const Length& length, SVGLengthMode mode)
+float SVGLengthContext::valueForLength(const Length& length, SVGLengthMode mode) const
{
- if (length.isAuto())
- return 0;
-
- FloatSize viewportSize;
- determineViewport(viewportSize);
-
- if (length.isPercent())
- return length.value() * dimensionForLengthMode(mode, viewportSize) / 100;
-
- return floatValueForLength(length, dimensionForLengthMode(mode, viewportSize));
+ float dimension = 0;
+ if (length.isPercent()) {
+ FloatSize viewportSize;
+ determineViewport(viewportSize);
+ dimension = dimensionForLengthMode(mode, viewportSize);
+ }
+ return floatValueForLength(length, dimension);
}
float SVGLengthContext::convertValueToUserUnits(float value, SVGLengthMode mode, SVGLengthType fromUnit) const
« no previous file with comments | « Source/core/svg/SVGLengthContext.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698