Bug 1364260 - Don't require whitespace between keywords and parens in supports rule condition. r?dbaron draft
authorXidorn Quan <me@upsuper.org>
Thu, 20 Jul 2017 15:33:09 +1000
changeset 611948 3bdc6c0f5b07b55b1a65cff9c914ee2e8dd28995
parent 611947 f09df595949629ebaa421327876540d873f7bf42
child 638260 722c7b5d42bbeb86cc865da5f54eef3f29097e9d
push id69331
push userxquan@mozilla.com
push dateThu, 20 Jul 2017 05:33:42 +0000
reviewersdbaron
bugs1364260
milestone56.0a1
Bug 1364260 - Don't require whitespace between keywords and parens in supports rule condition. r?dbaron MozReview-Commit-ID: B7GsrDQ6NuO
layout/style/nsCSSParser.cpp
layout/style/test/stylo-failures.md
layout/style/test/test_supports_rules.html
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -4475,37 +4475,32 @@ CSSParserImpl::ParseSupportsCondition(bo
     return result;
   }
 
   REPORT_UNEXPECTED_TOKEN(PESupportsConditionExpectedStart);
   return false;
 }
 
 // supports_condition_negation
-//   : 'not' S+ supports_condition_in_parens
+//   : 'not' supports_condition_in_parens
 //   ;
 bool
 CSSParserImpl::ParseSupportsConditionNegation(bool& aConditionMet)
 {
   if (!GetToken(true)) {
     REPORT_UNEXPECTED_EOF(PESupportsConditionNotEOF);
     return false;
   }
 
   if (mToken.mType != eCSSToken_Ident ||
       !mToken.mIdent.LowerCaseEqualsLiteral("not")) {
     REPORT_UNEXPECTED_TOKEN(PESupportsConditionExpectedNot);
     return false;
   }
 
-  if (!RequireWhitespace()) {
-    REPORT_UNEXPECTED(PESupportsWhitespaceRequired);
-    return false;
-  }
-
   if (ParseSupportsConditionInParens(aConditionMet)) {
     aConditionMet = !aConditionMet;
     return true;
   }
 
   return false;
 }
 
@@ -4657,24 +4652,24 @@ CSSParserImpl::ParseSupportsConditionInP
   }
 
   UngetToken();
   return ParseSupportsConditionInParens(aConditionMet) &&
          ParseSupportsConditionTerms(aConditionMet);
 }
 
 // supports_condition_terms
-//   : S+ 'and' supports_condition_terms_after_operator('and')
-//   | S+ 'or' supports_condition_terms_after_operator('or')
+//   : 'and' supports_condition_terms_after_operator('and')
+//   | 'or' supports_condition_terms_after_operator('or')
 //   |
 //   ;
 bool
 CSSParserImpl::ParseSupportsConditionTerms(bool& aConditionMet)
 {
-  if (!RequireWhitespace() || !GetToken(false)) {
+  if (!GetToken(true)) {
     return true;
   }
 
   if (mToken.mType != eCSSToken_Ident) {
     UngetToken();
     return true;
   }
 
@@ -4686,28 +4681,23 @@ CSSParserImpl::ParseSupportsConditionTer
     return ParseSupportsConditionTermsAfterOperator(aConditionMet, eOr);
   }
 
   UngetToken();
   return true;
 }
 
 // supports_condition_terms_after_operator(operator)
-//   : S+ supports_condition_in_parens ( <operator> supports_condition_in_parens )*
+//   : supports_condition_in_parens ( <operator> supports_condition_in_parens )*
 //   ;
 bool
 CSSParserImpl::ParseSupportsConditionTermsAfterOperator(
                          bool& aConditionMet,
                          CSSParserImpl::SupportsConditionTermOperator aOperator)
 {
-  if (!RequireWhitespace()) {
-    REPORT_UNEXPECTED(PESupportsWhitespaceRequired);
-    return false;
-  }
-
   const char* token = aOperator == eAnd ? "and" : "or";
   for (;;) {
     bool termConditionMet = false;
     if (!ParseSupportsConditionInParens(termConditionMet)) {
       return false;
     }
     aConditionMet = aOperator == eAnd ? aConditionMet && termConditionMet :
                                         aConditionMet || termConditionMet;
--- a/layout/style/test/stylo-failures.md
+++ b/layout/style/test/stylo-failures.md
@@ -45,17 +45,17 @@ to mochitest command.
   * test_grid_item_shorthands.html [23]
   * test_grid_shorthand_serialization.html [28]
 * Unsupported values
   * SVG-in-OpenType values not supported servo/servo#15211 bug 1338764
     * test_value_storage.html `context-` [7]
     * test_bug798843_pref.html [3]
 * Incorrect parsing
   * different parsing bug 1364260
-    * test_supports_rules.html [6]
+    * test_supports_rules.html [1]
     * test_condition_text.html [1]
 * Incorrect serialization
   * place-{content,items,self} shorthands bug 1363971
     * test_align_shorthand_serialization.html [6]
   * system font serialization with subprop specified bug 1382080
     * test_system_font_serialization.html [3]
   * radial gradients are not serialized using modern unprefixed style bug 1380259
     * test_computed_style.html `gradient` [1]
--- a/layout/style/test/test_supports_rules.html
+++ b/layout/style/test/test_supports_rules.html
@@ -58,29 +58,29 @@ function runTest() {
        "@supports condition \"" + condition + "\" should be balanced");
   }
 
   check_balanced_condition("not (color: green)", false);
   check_balanced_condition("not (colour: green)", true);
   check_balanced_condition("not(color: green)", false);
   check_balanced_condition("not(colour: green)", false);
   check_balanced_condition("not/* */(color: green)", false);
-  check_balanced_condition("not/* */(colour: green)", false);
+  check_balanced_condition("not/* */(colour: green)", true);
   check_balanced_condition("not /* */ (color: green)", false);
   check_balanced_condition("not /* */ (colour: green)", true);
   check_balanced_condition("(color: green) and (color: blue)", true);
   check_balanced_condition("(color: green) /* */ /* */ and /* */ /* */ (color: blue)", true);
   check_balanced_condition("(color: green) and(color: blue)", false);
-  check_balanced_condition("(color: green) and/* */(color: blue)", false);
-  check_balanced_condition("(color: green)and (color: blue)", false);
+  check_balanced_condition("(color: green) and/* */(color: blue)", true);
+  check_balanced_condition("(color: green)and (color: blue)", true);
   check_balanced_condition("(color: green) or (color: blue)", true);
   check_balanced_condition("(color: green) /* */ /* */ or /* */ /* */ (color: blue)", true);
   check_balanced_condition("(color: green) or(color: blue)", false);
-  check_balanced_condition("(color: green) or/* */(color: blue)", false);
-  check_balanced_condition("(color: green)or (color: blue)", false);
+  check_balanced_condition("(color: green) or/* */(color: blue)", true);
+  check_balanced_condition("(color: green)or (color: blue)", true);
 
   SimpleTest.finish();
 }
 
 SimpleTest.waitForExplicitFinish();
 runTest();
 </script>
 </pre>