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

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

Issue 87453003: Less magic numbers in converting CSS lengths of cm/mm/pc/pt types. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: Created 7 years, 1 month 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/CSSPrimitiveValue.cpp ('k') | Source/core/svg/SVGSVGElement.cpp » ('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 8146c8b22acf12743d974c9983e3d00cb2cc3561..2c817471055a2c01324000879df984c9aa9e87e7 100644
--- a/Source/core/svg/SVGLengthContext.cpp
+++ b/Source/core/svg/SVGLengthContext.cpp
@@ -111,15 +111,15 @@ float SVGLengthContext::convertValueToUserUnits(float value, SVGLengthMode mode,
case LengthTypeEXS:
return convertValueFromEXSToUserUnits(value, exceptionState);
case LengthTypeCM:
- return value * cssPixelsPerInch / 2.54f;
+ return value * cssPixelsPerCentimeter;
case LengthTypeMM:
- return value * cssPixelsPerInch / 25.4f;
+ return value * cssPixelsPerMillimeter;
case LengthTypeIN:
return value * cssPixelsPerInch;
case LengthTypePT:
- return value * cssPixelsPerInch / 72;
+ return value * cssPixelsPerPoint;
case LengthTypePC:
- return value * cssPixelsPerInch / 6;
+ return value * cssPixelsPerPica;
}
ASSERT_NOT_REACHED();
@@ -143,15 +143,15 @@ float SVGLengthContext::convertValueFromUserUnits(float value, SVGLengthMode mod
case LengthTypePX:
return value;
case LengthTypeCM:
- return value * 2.54f / cssPixelsPerInch;
+ return value / cssPixelsPerCentimeter;
case LengthTypeMM:
- return value * 25.4f / cssPixelsPerInch;
+ return value / cssPixelsPerMillimeter;
case LengthTypeIN:
return value / cssPixelsPerInch;
case LengthTypePT:
- return value * 72 / cssPixelsPerInch;
+ return value / cssPixelsPerPoint;
case LengthTypePC:
- return value * 6 / cssPixelsPerInch;
+ return value / cssPixelsPerPica;
}
ASSERT_NOT_REACHED();
« no previous file with comments | « Source/core/css/CSSPrimitiveValue.cpp ('k') | Source/core/svg/SVGSVGElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698