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

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

Issue 896773002: [svg2] Make 'x' and 'y' presentation attributes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase 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') | Source/core/svg/SVGMaskElement.h » ('j') | 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 a37ddb11a53d53012ad56419fc5730e5ac6d01b0..e11f90e4d300dc929f9c3f74dea55e76964669ae 100644
--- a/Source/core/svg/SVGLengthContext.cpp
+++ b/Source/core/svg/SVGLengthContext.cpp
@@ -27,6 +27,7 @@
#include "core/layout/LayoutObject.h"
#include "core/layout/style/LayoutStyle.h"
#include "core/svg/SVGSVGElement.h"
+#include "platform/LengthFunctions.h"
#include "platform/fonts/FontMetrics.h"
namespace blink {
@@ -95,6 +96,20 @@ float SVGLengthContext::resolveLength(const SVGElement* context, SVGUnitTypes::S
return x.valueAsPercentage();
}
+float SVGLengthContext::valueForLength(const Length& length, SVGLengthMode mode)
+{
+ 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 SVGLengthContext::convertValueToUserUnits(float value, SVGLengthMode mode, SVGLengthType fromUnit) const
{
switch (fromUnit) {
« no previous file with comments | « Source/core/svg/SVGLengthContext.h ('k') | Source/core/svg/SVGMaskElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698