Bug 806068 part 1: Add support for unprefixed "initial" keyword in CSS (retaining prefixed keyword as an alias, for now). r=dholbert
authorJet Villegas <jet@mozilla.com>
Tue, 30 Oct 2012 16:40:33 +0100
changeset 111974 01780269281730fd69e4a45b2cbf7d8ff538d0ff
parent 111973 885fb1477a951e25ddca4cdd9b3e59114c212fde
child 111975 4e7c99e44c65ad2d3c97193c913cac5d292a9244
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersdholbert
bugs806068
milestone19.0a1
Bug 806068 part 1: Add support for unprefixed "initial" keyword in CSS (retaining prefixed keyword as an alias, for now). r=dholbert
layout/style/nsCSSKeywordList.h
layout/style/nsCSSParser.cpp
layout/style/nsCSSValue.cpp
layout/style/test/test_bug160403.html
layout/style/test/test_initial_storage.html
--- a/layout/style/nsCSSKeywordList.h
+++ b/layout/style/nsCSSKeywordList.h
@@ -280,16 +280,17 @@ CSS_KEY(interlace, interlace)
 CSS_KEY(inactive, inactive)
 CSS_KEY(inactiveborder, inactiveborder)
 CSS_KEY(inactivecaption, inactivecaption)
 CSS_KEY(inactivecaptiontext, inactivecaptiontext)
 CSS_KEY(infinite, infinite)
 CSS_KEY(infobackground, infobackground)
 CSS_KEY(infotext, infotext)
 CSS_KEY(inherit, inherit)
+CSS_KEY(initial, initial)
 CSS_KEY(inline, inline)
 CSS_KEY(inline-axis, inline_axis)
 CSS_KEY(inline-block, inline_block)
 CSS_KEY(inline-flex, inline_flex)
 CSS_KEY(inline-table, inline_table)
 CSS_KEY(inset, inset)
 CSS_KEY(inside, inside)
 CSS_KEY(interpolatematrix, interpolatematrix)
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -4710,17 +4710,18 @@ CSSParserImpl::ParseVariant(nsCSSValue& 
       if ((aVariantMask & VARIANT_INHERIT) != 0) {
         // XXX Should we check IsParsingCompoundProperty, or do all
         // callers handle it?  (Not all callers set it, though, since
         // they want the quirks that are disabled by setting it.)
         if (eCSSKeyword_inherit == keyword) {
           aValue.SetInheritValue();
           return true;
         }
-        else if (eCSSKeyword__moz_initial == keyword) { // anything that can inherit can also take an initial val.
+        else if (eCSSKeyword__moz_initial == keyword ||
+                 eCSSKeyword_initial == keyword) { // anything that can inherit can also take an initial val.
           aValue.SetInitialValue();
           return true;
         }
       }
       if ((aVariantMask & VARIANT_NONE) != 0) {
         if (eCSSKeyword_none == keyword) {
           aValue.SetNoneValue();
           return true;
@@ -6479,17 +6480,18 @@ CSSParserImpl::ParseBackgroundItem(CSSPa
       // show up as one.
       break;
     }
 
     if (tt == eCSSToken_Ident) {
       nsCSSKeyword keyword = nsCSSKeywords::LookupKeyword(mToken.mIdent);
       int32_t dummy;
       if (keyword == eCSSKeyword_inherit ||
-          keyword == eCSSKeyword__moz_initial) {
+          keyword == eCSSKeyword__moz_initial ||
+          keyword == eCSSKeyword_initial) {
         return false;
       } else if (keyword == eCSSKeyword_none) {
         if (haveImage)
           return false;
         haveImage = true;
         if (!ParseSingleValueProperty(aState.mImage->mValue,
                                       eCSSProperty_background_image)) {
           NS_NOTREACHED("should be able to parse");
@@ -7273,31 +7275,31 @@ CSSParserImpl::ParseBorderImageRepeat(bo
   return true;
 }
 
 bool
 CSSParserImpl::ParseBorderImage()
 {
   nsAutoParseCompoundProperty compound(this);
 
-  // border-image: inherit | -moz-initial |
+  // border-image: inherit | initial |
   // <border-image-source> ||
   // <border-image-slice>
   //   [ / <border-image-width> |
   //     / <border-image-width>? / <border-image-outset> ]? ||
   // <border-image-repeat>
 
   nsCSSValue value;
   if (ParseVariant(value, VARIANT_INHERIT, nullptr)) {
     AppendValue(eCSSProperty_border_image_source, value);
     AppendValue(eCSSProperty_border_image_slice, value);
     AppendValue(eCSSProperty_border_image_width, value);
     AppendValue(eCSSProperty_border_image_outset, value);
     AppendValue(eCSSProperty_border_image_repeat, value);
-    // Keyword "inherit" (and "-moz-initial") can't be mixed, so we are done.
+    // Keyword "inherit" (and "initial") can't be mixed, so we are done.
     return true;
   }
 
   // No empty property.
   if (CheckEndProperty()) {
     return false;
   }
 
@@ -7857,16 +7859,17 @@ CSSParserImpl::ParseRect(nsCSSProperty a
         val.SetAutoValue();
         break;
       case eCSSKeyword_inherit:
         if (!ExpectEndProperty()) {
           return false;
         }
         val.SetInheritValue();
         break;
+      case eCSSKeyword_initial:
       case eCSSKeyword__moz_initial:
         if (!ExpectEndProperty()) {
           return false;
         }
         val.SetInitialValue();
         break;
       default:
         UngetToken();
@@ -8692,17 +8695,17 @@ CSSParserImpl::ParseFamily(nsCSSValue& a
     return false;
 
   if (eCSSToken_Ident == mToken.mType) {
     nsCSSKeyword keyword = nsCSSKeywords::LookupKeyword(mToken.mIdent);
     if (keyword == eCSSKeyword_inherit) {
       aValue.SetInheritValue();
       return true;
     }
-    if (keyword == eCSSKeyword__moz_initial) {
+    if (keyword == eCSSKeyword__moz_initial || keyword == eCSSKeyword_initial) {
       aValue.SetInitialValue();
       return true;
     }
     if (keyword == eCSSKeyword__moz_use_system_font &&
         !IsParsingCompoundProperty()) {
       aValue.SetSystemFontValue();
       return true;
     }
@@ -9511,17 +9514,17 @@ AppendValueToList(nsCSSValue& aContainer
 CSSParserImpl::ParseAnimationOrTransitionShorthandResult
 CSSParserImpl::ParseAnimationOrTransitionShorthand(
                  const nsCSSProperty* aProperties,
                  const nsCSSValue* aInitialValues,
                  nsCSSValue* aValues,
                  size_t aNumProperties)
 {
   nsCSSValue tempValue;
-  // first see if 'inherit' or '-moz-initial' is specified.  If one is,
+  // first see if 'inherit' or 'initial' is specified.  If one is,
   // it can be the only thing specified, so don't attempt to parse any
   // additional properties
   if (ParseVariant(tempValue, VARIANT_INHERIT, nullptr)) {
     for (uint32_t i = 0; i < aNumProperties; ++i) {
       AppendValue(aProperties[i], tempValue);
     }
     return eParseAnimationOrTransitionShorthand_Inherit;
   }
--- a/layout/style/nsCSSValue.cpp
+++ b/layout/style/nsCSSValue.cpp
@@ -1067,17 +1067,17 @@ nsCSSValue::AppendToString(nsCSSProperty
         break;
     }
   }
 
   switch (unit) {
     case eCSSUnit_Null:         break;
     case eCSSUnit_Auto:         aResult.AppendLiteral("auto");     break;
     case eCSSUnit_Inherit:      aResult.AppendLiteral("inherit");  break;
-    case eCSSUnit_Initial:      aResult.AppendLiteral("-moz-initial"); break;
+    case eCSSUnit_Initial:      aResult.AppendLiteral("initial");  break;
     case eCSSUnit_None:         aResult.AppendLiteral("none");     break;
     case eCSSUnit_Normal:       aResult.AppendLiteral("normal");   break;
     case eCSSUnit_System_Font:  aResult.AppendLiteral("-moz-use-system-font"); break;
     case eCSSUnit_All:          aResult.AppendLiteral("all"); break;
     case eCSSUnit_Dummy:
     case eCSSUnit_DummyInherit:
       NS_ABORT_IF_FALSE(false, "should never serialize");
       break;
--- a/layout/style/test/test_bug160403.html
+++ b/layout/style/test/test_bug160403.html
@@ -50,23 +50,23 @@ is(style.getPropertyPriority("border-sty
 element.setAttribute("style", "border-top-style: dotted ! important; border-right-style: dotted ! important; border-bottom-style: dotted ! important; border-left-style: dotted ! important");
 is(style.getPropertyValue("border-top-style"), "dotted");
 is(style.getPropertyPriority("border-top-style"), "important");
 is(style.getPropertyValue("border-right-style"), "dotted");
 is(style.getPropertyPriority("border-right-style"), "important");
 isnot(style.getPropertyValue("border-style"), "");
 is(style.getPropertyPriority("border-style"), "important");
 
-// Also test that we check consistency of inherit and -moz-initial.
+// Also test that we check consistency of inherit and initial.
 element.setAttribute("style", "border-top-style: dotted; border-right-style: dotted; border-bottom-style: dotted; border-left-style: dotted");
 isnot(style.getPropertyValue("border-style"), "", "serialize shorthand when all values not inherit/initial");
 element.setAttribute("style", "border-top-style: inherit; border-right-style: inherit; border-bottom-style: inherit; border-left-style: inherit");
 is(style.getPropertyValue("border-style"), "inherit", "serialize shorthand as inherit");
 element.setAttribute("style", "border-top-style: -moz-initial; border-right-style: -moz-initial; border-bottom-style: -moz-initial; border-left-style: -moz-initial");
-is(style.getPropertyValue("border-style"), "-moz-initial", "serialize shorthand as initial");
+is(style.getPropertyValue("border-style"), "initial", "serialize shorthand as initial");
 element.setAttribute("style", "border-top-style: dotted; border-right-style: dotted; border-bottom-style: dotted; border-left-style: inherit");
 is(style.getPropertyValue("border-style"), "", "don't serialize shorthand when partly inherit");
 element.setAttribute("style", "border-top-style: -moz-initial; border-right-style: dotted; border-bottom-style: -moz-initial; border-left-style: -moz-initial");
 is(style.getPropertyValue("border-style"), "", "don't serialize shorthand when partly initial");
 
 </script>
 </pre>
 </body>
--- a/layout/style/test/test_initial_storage.html
+++ b/layout/style/test/test_initial_storage.html
@@ -1,31 +1,31 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=375363
 -->
 <head>
-  <title>Test for parsing, storage, and serialization of CSS '-moz-initial'</title>
+  <title>Test for parsing, storage, and serialization of CSS 'initial'</title>
   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
   <script type="text/javascript" src="property_database.js"></script>
   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=375363">Mozilla Bug 375363</a>
 <p id="display"></p>
 <div id="content" style="display: none">
 
 <div id="testnode"></div>
   
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
-/** Test for parsing, storage, and serialization of CSS '-moz-initial' **/
+/** Test for parsing, storage, and serialization of CSS 'initial' **/
 
 var gDeclaration = document.getElementById("testnode").style;
 
 function test_property(property)
 {
   var info = gCSSProperties[property];
 
   function check_initial(sproperty) {
@@ -35,40 +35,40 @@ function test_property(property)
     is(val, gDeclaration[sinfo.domProp],
        "consistency between decl.getPropertyValue('" + sproperty + "') and decl." + sinfo.domProp);
   }
   check_initial(property);
   if ("subproperties" in info)
     for (var idx in info.subproperties)
       check_initial(info.subproperties[idx]);
 
-  gDeclaration.setProperty(property, "-moz-initial", "");
+  gDeclaration.setProperty(property, "initial", "");
 
   function check_set(sproperty) {
     var sinfo = gCSSProperties[sproperty];
     val = gDeclaration.getPropertyValue(sproperty);
-    is(val, "-moz-initial",
-       "-moz-initial reported back for property '" + sproperty + "'");
+    is(val, "initial",
+       "initial reported back for property '" + sproperty + "'");
     is(val, gDeclaration[sinfo.domProp],
        "consistency between decl.getPropertyValue('" + sproperty +
        "') and decl." + sinfo.domProp);
   }
   check_set(property);
   if ("subproperties" in info)
     for (var idx in info.subproperties)
       check_set(info.subproperties[idx]);
 
   // We don't care particularly about the whitespace or the placement of
   // semicolons, but for simplicity we'll test the current behavior.
   if ("alias_for" in info) {
-    is(gDeclaration.cssText, info.alias_for + ": -moz-initial;",
-      "declaration should serialize to exactly what went in (for -moz-initial)");
+    is(gDeclaration.cssText, info.alias_for + ": initial;",
+      "declaration should serialize to exactly what went in (for initial)");
   } else {
-    is(gDeclaration.cssText, property + ": -moz-initial;",
-      "declaration should serialize to exactly what went in (for -moz-initial)");
+    is(gDeclaration.cssText, property + ": initial;",
+      "declaration should serialize to exactly what went in (for initial)");
   }
 
   gDeclaration.removeProperty(property);
 
   function check_final(sproperty) {
     var sinfo = gCSSProperties[sproperty];
     var val = gDeclaration.getPropertyValue(sproperty);
     is(val, "", "value of '" + sproperty + "' after removal of value");