Bug 1363292 - Have unprefixed linear-gradient accept zero as angle value. r=dholbert draft
authorXidorn Quan <me@upsuper.org>
Mon, 29 May 2017 14:28:19 +1000
changeset 586848 f5e7d976a591123ad311e5effb55fb09199495c3
parent 586847 00ea3bfe7ee977704a3bca6b0dec2c6524990b53
child 631123 7fe52ef04f63d6e1e3bc8b683b93e0b5bbd60bf9
push id61548
push userxquan@mozilla.com
push dateWed, 31 May 2017 06:25:49 +0000
reviewersdholbert
bugs1363292
milestone55.0a1
Bug 1363292 - Have unprefixed linear-gradient accept zero as angle value. r=dholbert MozReview-Commit-ID: GRHi9GbkrnG
layout/style/nsCSSParser.cpp
layout/style/test/property_database.js
layout/style/test/stylo-failures.md
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -10244,17 +10244,18 @@ CSSParserImpl::ParseLinearGradient(nsCSS
 
   if (!(aFlags & eGradient_AnyLegacy)) {
     // We're parsing an unprefixed linear-gradient, and we tried & failed to
     // parse a 'to' token above. Put the token back & try to re-parse our
     // expression as <angle>? <color-stop-list>
     UngetToken();
 
     // <angle> ,
-    if (ParseSingleTokenVariant(cssGradient->mAngle, VARIANT_ANGLE, nullptr) &&
+    if (ParseSingleTokenVariant(cssGradient->mAngle,
+                                VARIANT_ANGLE_OR_ZERO, nullptr) &&
         !ExpectSymbol(',', true)) {
       SkipUntil(')');
       return false;
     }
 
     return ParseGradientColorStops(cssGradient, aValue);
   }
 
--- a/layout/style/test/property_database.js
+++ b/layout/style/test/property_database.js
@@ -127,16 +127,19 @@ var validGradientAndElementValues = [
   "linear-gradient(.414rad, red 50%, 50%, blue 50%)",
   "linear-gradient(.414rad, red 50%, 20%, blue 50%)",
   "linear-gradient(.414rad, red 50%, 30%, blue 10%)",
   "linear-gradient(to right bottom, red, 20%, green 50%, 65%, blue)",
   "linear-gradient(to right bottom, red, 20%, green 10%, blue)",
   "linear-gradient(to right bottom, red, 50%, green 50%, 50%, blue)",
   "linear-gradient(to right bottom, red, 0%, green 50%, 100%, blue)",
 
+  /* Unitless 0 is valid as an <angle> */
+  "linear-gradient(0, red, blue)",
+
   "radial-gradient(red, blue)",
   "radial-gradient(red, yellow, blue)",
   "radial-gradient(red 1px, yellow 20%, blue 24em, green)",
   "radial-gradient(red, yellow, green, blue 50%)",
   "radial-gradient(red -50%, yellow -25%, green, blue)",
   "radial-gradient(red -99px, yellow, green, blue 120%)",
   "radial-gradient(#ffff00, #ef3, rgba(10, 20, 30, 0.4))",
 
@@ -233,18 +236,18 @@ var invalidGradientAndElementValues = [
   "-moz-element(#a+a)",
   "-moz-element(#a())",
   /* no quirks mode colors */
   "linear-gradient(red, ff00ff)",
   /* no quirks mode colors */
   "radial-gradient(at 10% bottom, ffffff, black) scroll no-repeat",
   /* no quirks mode lengths */
   "linear-gradient(red -99, yellow, green, blue 120%)",
-  /* Unitless 0 is invalid as an <angle> */
-  "linear-gradient(0, red, blue)",
+  /* Unitless nonzero numbers are valid as an <angle> */
+  "linear-gradient(30, red, blue)",
   /* There must be a comma between gradient-line (e.g. <angle>) and colors */
   "linear-gradient(30deg red, blue)",
   "linear-gradient(to top left red, blue)",
   "linear-gradient(to right red, blue)",
   /* Invalid color, calc() or -moz-image-rect() function */
   "linear-gradient(red, rgb(0, rubbish, 0) 50%, red)",
   "linear-gradient(red, red calc(50% + rubbish), red)",
   "linear-gradient(to top calc(50% + rubbish), red, blue)",
--- a/layout/style/test/stylo-failures.md
+++ b/layout/style/test/stylo-failures.md
@@ -130,17 +130,16 @@ to mochitest command.
 
 ## Assertions
 
 ## Need Gecko change
 
 * Servo is correct but Gecko is wrong
   * Gecko rejects calc() in -webkit-gradient bug 1363349
     * test_property_syntax_errors.html `-webkit-gradient` [20]
-* test_property_syntax_errors.html `linear-gradient(0,`: unitless zero as degree bug 1363292 [10]
 * test_specified_value_serialization.html `-webkit-radial-gradient`: bug 1367299 [1]
 * test_variables.html `var(--var6)`: irrelevant test for stylo bug 1367306 [1]
 
 ## Unknown / Unsure
 
 * test_selectors_on_anonymous_content.html: xbl and :nth-child [1]
 * test_parse_rule.html `rgb(0, 128, 0)`: color properties not getting computed [5]
 * test_selectors.html `:nth-child`: &lt;an+b&gt; parsing difference bug 1364009 [14]