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

Unified Diff: Source/core/css/CSSPrimitiveValue.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/CSSHelper.h ('k') | Source/core/svg/SVGLengthContext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/CSSPrimitiveValue.cpp
diff --git a/Source/core/css/CSSPrimitiveValue.cpp b/Source/core/css/CSSPrimitiveValue.cpp
index 16612d6a7e3d4dda348cf4d94f451d71f32394a0..597e145ba0a461f230d860beb25c2b200944d8e9 100644
--- a/Source/core/css/CSSPrimitiveValue.cpp
+++ b/Source/core/css/CSSPrimitiveValue.cpp
@@ -588,20 +588,19 @@ double CSSPrimitiveValue::computeLengthDouble(const RenderStyle* style, const Re
factor = 1.0;
break;
case CSS_CM:
- factor = cssPixelsPerInch / 2.54; // (2.54 cm/in)
+ factor = cssPixelsPerCentimeter;
break;
case CSS_MM:
- factor = cssPixelsPerInch / 25.4;
+ factor = cssPixelsPerMillimeter;
break;
case CSS_IN:
factor = cssPixelsPerInch;
break;
case CSS_PT:
- factor = cssPixelsPerInch / 72.0;
+ factor = cssPixelsPerPoint;
break;
case CSS_PC:
- // 1 pc == 12 pt
- factor = cssPixelsPerInch * 12.0 / 72.0;
+ factor = cssPixelsPerPica;
break;
case CSS_CALC_PERCENTAGE_WITH_LENGTH:
case CSS_CALC_PERCENTAGE_WITH_NUMBER:
@@ -642,13 +641,13 @@ double CSSPrimitiveValue::conversionToCanonicalUnitsScaleFactor(unsigned short u
case CSS_HZ:
break;
case CSS_CM:
- factor = cssPixelsPerInch / 2.54; // (2.54 cm/in)
+ factor = cssPixelsPerCentimeter;
break;
case CSS_DPCM:
- factor = 2.54 / cssPixelsPerInch; // (2.54 cm/in)
+ factor = 1 / cssPixelsPerCentimeter;
break;
case CSS_MM:
- factor = cssPixelsPerInch / 25.4;
+ factor = cssPixelsPerMillimeter;
break;
case CSS_IN:
factor = cssPixelsPerInch;
@@ -657,10 +656,10 @@ double CSSPrimitiveValue::conversionToCanonicalUnitsScaleFactor(unsigned short u
factor = 1 / cssPixelsPerInch;
break;
case CSS_PT:
- factor = cssPixelsPerInch / 72.0;
+ factor = cssPixelsPerPoint;
break;
case CSS_PC:
- factor = cssPixelsPerInch * 12.0 / 72.0; // 1 pc == 12 pt
+ factor = cssPixelsPerPica;
break;
case CSS_RAD:
factor = 180 / piDouble;
« no previous file with comments | « Source/core/css/CSSHelper.h ('k') | Source/core/svg/SVGLengthContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698