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

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

Issue 947983002: Move zoom handling for x and y properties to svg (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase + add NeedsRebaseline 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/css/resolver/StyleBuilderConverter.cpp ('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 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);
« no previous file with comments | « Source/core/css/resolver/StyleBuilderConverter.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698