From 7e21de3ed5ad0d28f303496deb211c943cb4c15a Mon Sep 17 00:00:00 2001 From: Edgar Chen Date: Mon, 23 May 2016 15:18:34 +0800 Subject: [PATCH] Bug 1274526 - Part 1: Implement support for 'q' absolute length units in CSS; r=heycam MozReview-Commit-ID: vTDufVkAuv --- dom/mathml/nsMathMLElement.cpp | 1 + layout/style/nsCSSParser.cpp | 1 + layout/style/nsCSSValue.cpp | 3 +++ layout/style/nsCSSValue.h | 3 ++- layout/style/test/test_pixel_lengths.html | 2 ++ 5 files changed, 9 insertions(+), 1 deletion(-) diff --git a/dom/mathml/nsMathMLElement.cpp b/dom/mathml/nsMathMLElement.cpp index 4ae0f89295f3..1882050e9d81 100644 --- a/dom/mathml/nsMathMLElement.cpp +++ b/dom/mathml/nsMathMLElement.cpp @@ -473,6 +473,7 @@ nsMathMLElement::ParseNumericValue(const nsString& aString, 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); diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index 1ec301595c1e..0c6d6bc50538 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -7475,6 +7475,7 @@ const UnitInfo UnitData[] = { { 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 }, diff --git a/layout/style/nsCSSValue.cpp b/layout/style/nsCSSValue.cpp index 03cc26f53eab..7240ecb9aa25 100644 --- a/layout/style/nsCSSValue.cpp +++ b/layout/style/nsCSSValue.cpp @@ -346,6 +346,7 @@ nscoord nsCSSValue::GetPixelLength() const 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; @@ -1798,6 +1799,7 @@ nsCSSValue::AppendToString(nsCSSProperty aProperty, nsAString& aResult, 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; @@ -1982,6 +1984,7 @@ nsCSSValue::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const case eCSSUnit_Centimeter: case eCSSUnit_Pica: case eCSSUnit_Pixel: + case eCSSUnit_Quarter: case eCSSUnit_Degree: case eCSSUnit_Grad: case eCSSUnit_Turn: diff --git a/layout/style/nsCSSValue.h b/layout/style/nsCSSValue.h index e42c6b931fdf..d198a1ffc533 100644 --- a/layout/style/nsCSSValue.h +++ b/layout/style/nsCSSValue.h @@ -396,7 +396,8 @@ enum nsCSSUnit { 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 diff --git a/layout/style/test/test_pixel_lengths.html b/layout/style/test/test_pixel_lengths.html index 03c01777f313..37f9ec83ff0b 100644 --- a/layout/style/test/test_pixel_lengths.html +++ b/layout/style/test/test_pixel_lengths.html @@ -13,6 +13,7 @@
mm
cm
in
+
q
mozmm
@@ -37,6 +38,7 @@ function checkPixelRelativeUnits() { check("mm", 96); check("cm", 96); check("in", 96); + check("q", 96); } checkPixelRelativeUnits();