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

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

Issue 861213003: Fix problems with flakes in SVG LayoutTests by reordering arithmetic. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rephrased comment. Created 5 years, 11 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 4bffd9cae72f1001a0be6c2596c167ac4e3d2c4d..9c1a4d15c19902e297c787185e7235ac2ac2bef3 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:
@@ -195,7 +195,22 @@ float SVGLengthContext::convertValueFromPercentageToUserUnits(float value, SVGLe
return value * viewportSize.height();
case LengthModeOther:
return value * sqrtf(viewportSize.diagonalLengthSquared() / 2);
- };
+ }
+
+ ASSERT_NOT_REACHED();
+ return 0;
+}
+
+float SVGLengthContext::convertValueFromPercentageToUserUnits(const SVGLength& value, const FloatSize& viewportSize)
+{
+ 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));
+ }
ASSERT_NOT_REACHED();
return 0;
« 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