Bug 1274526 - Part 1: Implement support for 'q' absolute length units in CSS; r=heycam
authorEdgar Chen <echen@mozilla.com>
Mon, 23 May 2016 15:18:34 +0800
changeset 337724 929092ee1097600f0b7a97e4e9b214c9ea1a517c
parent 337723 d34a9962361534223971dee4fbbff85de9b12c06
child 337725 bfa847fd5f532ad4b2d95e565aedd7bd54051a01
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1274526
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1274526 - Part 1: Implement support for 'q' absolute length units in CSS; r=heycam MozReview-Commit-ID: vTDufVkAuv
dom/mathml/nsMathMLElement.cpp
layout/style/nsCSSParser.cpp
layout/style/nsCSSValue.cpp
layout/style/nsCSSValue.h
layout/style/test/test_pixel_lengths.html
--- a/dom/mathml/nsMathMLElement.cpp
+++ b/dom/mathml/nsMathMLElement.cpp
@@ -468,16 +468,17 @@ nsMathMLElement::ParseNumericValue(const
   else if (unit.EqualsLiteral("em")) cssUnit = eCSSUnit_EM;
   else if (unit.EqualsLiteral("ex")) cssUnit = eCSSUnit_XHeight;
   else if (unit.EqualsLiteral("px")) cssUnit = eCSSUnit_Pixel;
   else if (unit.EqualsLiteral("in")) cssUnit = eCSSUnit_Inch;
   else if (unit.EqualsLiteral("cm")) cssUnit = eCSSUnit_Centimeter;
   else if (unit.EqualsLiteral("mm")) cssUnit = eCSSUnit_Millimeter;
   else if (unit.EqualsLiteral("pt")) cssUnit = eCSSUnit_Point;
   else if (unit.EqualsLiteral("pc")) cssUnit = eCSSUnit_Pica;
+  else if (unit.EqualsLiteral("q")) cssUnit = eCSSUnit_Quarter;
   else { // unexpected unit
     if (!(aFlags & PARSE_SUPPRESS_WARNINGS)) {
       ReportLengthParseError(aString, aDocument);
     }
     return false;
   }
 
   aCSSValue.SetFloatValue(floatValue, cssUnit);
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -7470,16 +7470,17 @@ const UnitInfo UnitData[] = {
   { STR_WITH_LEN("rem"), eCSSUnit_RootEM, VARIANT_LENGTH },
   { STR_WITH_LEN("mm"), eCSSUnit_Millimeter, VARIANT_LENGTH },
   { STR_WITH_LEN("mozmm"), eCSSUnit_PhysicalMillimeter, VARIANT_LENGTH },
   { STR_WITH_LEN("vw"), eCSSUnit_ViewportWidth, VARIANT_LENGTH },
   { STR_WITH_LEN("vh"), eCSSUnit_ViewportHeight, VARIANT_LENGTH },
   { STR_WITH_LEN("vmin"), eCSSUnit_ViewportMin, VARIANT_LENGTH },
   { STR_WITH_LEN("vmax"), eCSSUnit_ViewportMax, VARIANT_LENGTH },
   { STR_WITH_LEN("pc"), eCSSUnit_Pica, VARIANT_LENGTH },
+  { STR_WITH_LEN("q"), eCSSUnit_Quarter, VARIANT_LENGTH },
   { STR_WITH_LEN("deg"), eCSSUnit_Degree, VARIANT_ANGLE },
   { STR_WITH_LEN("grad"), eCSSUnit_Grad, VARIANT_ANGLE },
   { STR_WITH_LEN("rad"), eCSSUnit_Radian, VARIANT_ANGLE },
   { STR_WITH_LEN("turn"), eCSSUnit_Turn, VARIANT_ANGLE },
   { STR_WITH_LEN("hz"), eCSSUnit_Hertz, VARIANT_FREQUENCY },
   { STR_WITH_LEN("khz"), eCSSUnit_Kilohertz, VARIANT_FREQUENCY },
   { STR_WITH_LEN("s"), eCSSUnit_Seconds, VARIANT_TIME },
   { STR_WITH_LEN("ms"), eCSSUnit_Milliseconds, VARIANT_TIME }
--- a/layout/style/nsCSSValue.cpp
+++ b/layout/style/nsCSSValue.cpp
@@ -341,16 +341,17 @@ nscoord nsCSSValue::GetPixelLength() con
   double scaleFactor;
   switch (mUnit) {
   case eCSSUnit_Pixel: return nsPresContext::CSSPixelsToAppUnits(mValue.mFloat);
   case eCSSUnit_Pica: scaleFactor = 16.0; break;
   case eCSSUnit_Point: scaleFactor = 4/3.0; break;
   case eCSSUnit_Inch: scaleFactor = 96.0; break;
   case eCSSUnit_Millimeter: scaleFactor = 96/25.4; break;
   case eCSSUnit_Centimeter: scaleFactor = 96/2.54; break;
+  case eCSSUnit_Quarter: scaleFactor = 96/101.6; break;
   default:
     NS_ERROR("should never get here");
     return 0;
   }
   return nsPresContext::CSSPixelsToAppUnits(float(mValue.mFloat*scaleFactor));
 }
 
 void nsCSSValue::DoReset()
@@ -1793,16 +1794,17 @@ nsCSSValue::AppendToString(nsCSSProperty
     case eCSSUnit_GridTemplateAreas:     break;
 
     case eCSSUnit_Inch:         aResult.AppendLiteral("in");   break;
     case eCSSUnit_Millimeter:   aResult.AppendLiteral("mm");   break;
     case eCSSUnit_PhysicalMillimeter: aResult.AppendLiteral("mozmm");   break;
     case eCSSUnit_Centimeter:   aResult.AppendLiteral("cm");   break;
     case eCSSUnit_Point:        aResult.AppendLiteral("pt");   break;
     case eCSSUnit_Pica:         aResult.AppendLiteral("pc");   break;
+    case eCSSUnit_Quarter:      aResult.AppendLiteral("q");    break;
 
     case eCSSUnit_ViewportWidth:  aResult.AppendLiteral("vw");   break;
     case eCSSUnit_ViewportHeight: aResult.AppendLiteral("vh");   break;
     case eCSSUnit_ViewportMin:    aResult.AppendLiteral("vmin"); break;
     case eCSSUnit_ViewportMax:    aResult.AppendLiteral("vmax"); break;
 
     case eCSSUnit_EM:           aResult.AppendLiteral("em");   break;
     case eCSSUnit_XHeight:      aResult.AppendLiteral("ex");   break;
@@ -1977,16 +1979,17 @@ nsCSSValue::SizeOfExcludingThis(mozilla:
     case eCSSUnit_Char:
     case eCSSUnit_RootEM:
     case eCSSUnit_Point:
     case eCSSUnit_Inch:
     case eCSSUnit_Millimeter:
     case eCSSUnit_Centimeter:
     case eCSSUnit_Pica:
     case eCSSUnit_Pixel:
+    case eCSSUnit_Quarter:
     case eCSSUnit_Degree:
     case eCSSUnit_Grad:
     case eCSSUnit_Turn:
     case eCSSUnit_Radian:
     case eCSSUnit_Hertz:
     case eCSSUnit_Kilohertz:
     case eCSSUnit_Seconds:
     case eCSSUnit_Milliseconds:
--- a/layout/style/nsCSSValue.h
+++ b/layout/style/nsCSSValue.h
@@ -391,17 +391,18 @@ enum nsCSSUnit {
   eCSSUnit_RootEM       = 803,    // (float) == root element font size
 
   // Screen relative measure
   eCSSUnit_Point        = 900,    // (float) 4/3 of a CSS pixel
   eCSSUnit_Inch         = 901,    // (float) 96 CSS pixels
   eCSSUnit_Millimeter   = 902,    // (float) 96/25.4 CSS pixels
   eCSSUnit_Centimeter   = 903,    // (float) 96/2.54 CSS pixels
   eCSSUnit_Pica         = 904,    // (float) 12 points == 16 CSS pixls
-  eCSSUnit_Pixel        = 905,    // (float) CSS pixel unit
+  eCSSUnit_Quarter      = 905,    // (float) 96/101.6 CSS pixels
+  eCSSUnit_Pixel        = 906,    // (float) CSS pixel unit
 
   // Angular units
   eCSSUnit_Degree       = 1000,    // (float) 360 per circle
   eCSSUnit_Grad         = 1001,    // (float) 400 per circle
   eCSSUnit_Radian       = 1002,    // (float) 2*pi per circle
   eCSSUnit_Turn         = 1003,    // (float) 1 per circle
 
   // Frequency units
--- a/layout/style/test/test_pixel_lengths.html
+++ b/layout/style/test/test_pixel_lengths.html
@@ -8,16 +8,17 @@
 <body>
 <div id="display">
 
 <div id="pt" style="width:90pt; height:90pt; background:lime;">pt</div>
 <div id="pc" style="width:5pc; height:5pc; background:yellow;">pc</div>
 <div id="mm" style="width:25.4mm; height:25.4mm; background:orange;">mm</div>
 <div id="cm" style="width:2.54cm; height:2.54cm; background:purple;">cm</div>
 <div id="in" style="width:1in; height:1in; background:magenta;">in</div>
+<div id="q" style="width:101.6q; height:101.6q; background:blue;">q</div>
 
 <div id="mozmm" style="width:25.4mozmm; height:25.4mozmm; background:cyan;">mozmm</div>
 
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 var oldDPI = SpecialPowers.getIntPref("layout.css.dpi");
@@ -32,16 +33,17 @@ function check(id, val) {
 }
 
 function checkPixelRelativeUnits() {
   check("pt", 120);
   check("pc", 80);
   check("mm", 96);
   check("cm", 96);
   check("in", 96);
+  check("q", 96);
 }
 
 checkPixelRelativeUnits();
 
 SimpleTest.waitForExplicitFinish();
 
 SpecialPowers.pushPrefEnv({'set': [['layout.css.dpi', dpi=96]]}, test1);