Bug 1364260 - Don't require whitespace between keywords and parens in supports rule condition. r=dbaron
authorXidorn Quan <me@upsuper.org>
Thu, 20 Jul 2017 15:33:09 +1000
changeset 418543 9c16700eed142a21caf8334e0c339c30c0bc5c0a
parent 418542 6d506550be89474f4f4503a3492636d99f4ebf63
child 418544 1ec985416f30eb25b17f36fdd6bcaeb171fb1cdb
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1364260
milestone56.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 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>