Title: [142640] trunk
Revision
142640
Author
[email protected]
Date
2013-02-12 10:40:48 -0800 (Tue, 12 Feb 2013)

Log Message

Handle error recovery in @supports
https://bugs.webkit.org/show_bug.cgi?id=103934

Patch by Pablo Flouret <[email protected]> on 2013-02-12
Reviewed by Antti Koivisto.

Source/WebCore:

Tests 021, 024, 031, and 033 in
http://hg.csswg.org/test/file/5f94e4b03ed9/contributors/opera/submitted/css3-conditional
fail because there's no explicit error recovery in @support's grammar.
Opera and Firefox pass the tests.

No new tests, modified css3/supports{,-cssom}.html

* css/CSSGrammar.y.in:
* css/CSSParser.cpp:
(WebCore::CSSParser::createSupportsRule):
(WebCore::CSSParser::markSupportsRuleHeaderEnd):
(WebCore::CSSParser::popSupportsRuleData):
* css/CSSParser.h:

LayoutTests:

* css3/supports-cssom.html:
* css3/supports-expected.txt:
* css3/supports.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (142639 => 142640)


--- trunk/LayoutTests/ChangeLog	2013-02-12 18:34:43 UTC (rev 142639)
+++ trunk/LayoutTests/ChangeLog	2013-02-12 18:40:48 UTC (rev 142640)
@@ -1,3 +1,14 @@
+2013-02-12  Pablo Flouret  <[email protected]>
+
+        Handle error recovery in @supports
+        https://bugs.webkit.org/show_bug.cgi?id=103934
+
+        Reviewed by Antti Koivisto.
+
+        * css3/supports-cssom.html:
+        * css3/supports-expected.txt:
+        * css3/supports.html:
+
 2013-02-12  Emil A Eklund  <[email protected]>
 
         TransformState::move should not round offset to int

Modified: trunk/LayoutTests/css3/supports-cssom.html (142639 => 142640)


--- trunk/LayoutTests/css3/supports-cssom.html	2013-02-12 18:34:43 UTC (rev 142639)
+++ trunk/LayoutTests/css3/supports-cssom.html	2013-02-12 18:40:48 UTC (rev 142640)
@@ -16,9 +16,25 @@
 
     @supports  ((  (     padding: 0)    and (display: none)) or (display: rainbow))  {
         dfn { width:0; }
+
         @supports (width: 0) {
             br { height:0; }
         }
+
+        /* Rules with syntax errors should be ignored. */
+        @supports (display: none);
+        @supports (display: none)) ;
+        @supports;
+        @supports ;
+        @supports (display: none)) {}
+        @supports (display: )) {}
+        @supports ((display: none) and {}
+        @supports (display: none) {}
+        );
+        @supports ((display: none) and ;
+        @supports (display: none) {}
+        );
+
         ol { display:none; }
     }
 

Modified: trunk/LayoutTests/css3/supports-expected.txt (142639 => 142640)


--- trunk/LayoutTests/css3/supports-expected.txt	2013-02-12 18:34:43 UTC (rev 142639)
+++ trunk/LayoutTests/css3/supports-expected.txt	2013-02-12 18:40:48 UTC (rev 142640)
@@ -40,6 +40,14 @@
 PASS getComputedStyle(document.getElementById('t34')).content is "UNTOUCHED"
 PASS getComputedStyle(document.getElementById('t35')).content is "APPLIED"
 PASS getComputedStyle(document.getElementById('t36')).content is "UNTOUCHED"
+PASS getComputedStyle(document.getElementById('t37')).content is "APPLIED"
+PASS getComputedStyle(document.getElementById('t38')).content is "APPLIED"
+PASS getComputedStyle(document.getElementById('t39')).content is "APPLIED"
+PASS getComputedStyle(document.getElementById('t40')).content is "APPLIED"
+PASS getComputedStyle(document.getElementById('t41')).content is "APPLIED"
+PASS getComputedStyle(document.getElementById('t42')).content is "APPLIED"
+PASS getComputedStyle(document.getElementById('t43')).content is "UNTOUCHED"
+PASS getComputedStyle(document.getElementById('t44')).content is "UNTOUCHED"
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/css3/supports.html (142639 => 142640)


--- trunk/LayoutTests/css3/supports.html	2013-02-12 18:34:43 UTC (rev 142639)
+++ trunk/LayoutTests/css3/supports.html	2013-02-12 18:40:48 UTC (rev 142640)
@@ -172,6 +172,57 @@
             #t36 { content: "FAIL" }
         }
     }
+
+    /* Invalid syntax error recovery */
+
+    @supports (display: none);
+    @supports (display: none) and ( (display: none) ) {
+        #t37 { content: "APPLIED" }
+    }
+
+    @supports (display: none)) ;
+    @supports (display: none) {
+        #t38 { content: "APPLIED" }
+    }
+
+    @supports;
+    @supports (display: none) {
+        #t39 { content: "APPLIED" }
+    }
+
+    @supports ;
+    @supports (display: none) {
+        #t40 { content: "APPLIED" }
+    }
+
+    @supports (display: none)) {
+        #t41 { content: "FAIL" }
+    }
+    @supports (display: none) {
+        #t41 { content: "APPLIED" }
+    }
+
+    @supports (display: )) {
+        #t42 { content: "FAIL" }
+    }
+    @supports (display: none) {
+        #t42 { content: "APPLIED" }
+    }
+
+    @supports ((display: none) and {
+        #t43 { content: "FAIL" }
+    }
+    @supports (display: none) {
+        #t43 { content: "FAIL" }
+    }
+    );
+
+    @supports ((display: none) and ;
+    @supports (display: none) {
+        #t44 { content: "FAIL" }
+    }
+    );
+
 </style>
 </head>
 <body>
@@ -179,8 +230,8 @@
 
 <script>
     description("Test the @supports rule.");
-    var numTests = 37;
-    var untouchedTests = [1, 3, 5, 8, 12, 13, 14, 18, 28, 29, 34, 36]; // Tests whose content shouldn't change from the UNTOUCHED default.
+    var numTests = 45;
+    var untouchedTests = [1, 3, 5, 8, 12, 13, 14, 18, 28, 29, 34, 36, 43, 44]; // Tests whose content shouldn't change from the UNTOUCHED default.
 
     var container = document.getElementById("test_container");
     for (var i=0; i < numTests; i++) {

Modified: trunk/Source/WebCore/ChangeLog (142639 => 142640)


--- trunk/Source/WebCore/ChangeLog	2013-02-12 18:34:43 UTC (rev 142639)
+++ trunk/Source/WebCore/ChangeLog	2013-02-12 18:40:48 UTC (rev 142640)
@@ -1,3 +1,24 @@
+2013-02-12  Pablo Flouret  <[email protected]>
+
+        Handle error recovery in @supports
+        https://bugs.webkit.org/show_bug.cgi?id=103934
+
+        Reviewed by Antti Koivisto.
+
+        Tests 021, 024, 031, and 033 in
+        http://hg.csswg.org/test/file/5f94e4b03ed9/contributors/opera/submitted/css3-conditional
+        fail because there's no explicit error recovery in @support's grammar.
+        Opera and Firefox pass the tests.
+
+        No new tests, modified css3/supports{,-cssom}.html
+
+        * css/CSSGrammar.y.in:
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::createSupportsRule):
+        (WebCore::CSSParser::markSupportsRuleHeaderEnd):
+        (WebCore::CSSParser::popSupportsRuleData):
+        * css/CSSParser.h:
+
 2013-02-12  Eric Carlson  <[email protected]>
 
         [Mac] guard against NULL languages array

Modified: trunk/Source/WebCore/css/CSSGrammar.y.in (142639 => 142640)


--- trunk/Source/WebCore/css/CSSGrammar.y.in	2013-02-12 18:34:43 UTC (rev 142639)
+++ trunk/Source/WebCore/css/CSSGrammar.y.in	2013-02-12 18:40:48 UTC (rev 142640)
@@ -249,6 +249,7 @@
 %type <boolean> supports_conjunction
 %type <boolean> supports_disjunction
 %type <boolean> supports_declaration_condition
+%type <boolean> supports_error
 #endif
 
 %type <string> keyframe_name
@@ -692,8 +693,16 @@
     before_supports_rule SUPPORTS_SYM maybe_space supports_condition at_supports_rule_header_end '{' at_rule_body_start maybe_space block_rule_list save_block {
         $$ = parser->createSupportsRule($4, $9);
     }
+    | before_supports_rule SUPPORTS_SYM supports_error {
+        parser->popRuleData();
+        parser->popSupportsRuleData();
+    }
     ;
 
+supports_error:
+    error ';'
+    | error invalid_block
+
 before_supports_rule:
     /* empty */ {
         parser->markRuleHeaderStart(CSSRuleSourceData::SUPPORTS_RULE);
@@ -744,6 +753,7 @@
         $$ = $3;
     }
     | supports_declaration_condition
+    | '(' error ')'
     ;
 
 supports_declaration_condition:

Modified: trunk/Source/WebCore/css/CSSParser.cpp (142639 => 142640)


--- trunk/Source/WebCore/css/CSSParser.cpp	2013-02-12 18:34:43 UTC (rev 142639)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2013-02-12 18:40:48 UTC (rev 142640)
@@ -10861,12 +10861,7 @@
 {
     m_allowImportRules = m_allowNamespaceDeclarations = false;
 
-    ASSERT(!m_supportsRuleDataStack->isEmpty());
-    RefPtr<CSSRuleSourceData> data = ""
-    m_supportsRuleDataStack->removeLast();
-    if (m_supportsRuleDataStack->isEmpty())
-        m_supportsRuleDataStack.clear();
-
+    RefPtr<CSSRuleSourceData> data = ""
     RefPtr<StyleRuleSupports> rule;
     String conditionText;
     unsigned conditionOffset = data->ruleHeaderRange.start + 9;
@@ -10903,13 +10898,22 @@
 
 void CSSParser::markSupportsRuleHeaderEnd()
 {
-    ASSERT(!m_supportsRuleDataStack->isEmpty());
+    ASSERT(m_supportsRuleDataStack && !m_supportsRuleDataStack->isEmpty());
 
     if (is8BitSource())
         m_supportsRuleDataStack->last()->ruleHeaderRange.end = tokenStart<LChar>() - m_dataStart8.get();
     else
         m_supportsRuleDataStack->last()->ruleHeaderRange.end = tokenStart<UChar>() - m_dataStart16.get();
 }
+
+PassRefPtr<CSSRuleSourceData> CSSParser::popSupportsRuleData()
+{
+    ASSERT(m_supportsRuleDataStack && !m_supportsRuleDataStack->isEmpty());
+    RefPtr<CSSRuleSourceData> data = ""
+    m_supportsRuleDataStack->removeLast();
+    return data.release();
+}
+
 #endif
 
 CSSParser::RuleList* CSSParser::createRuleList()

Modified: trunk/Source/WebCore/css/CSSParser.h (142639 => 142640)


--- trunk/Source/WebCore/css/CSSParser.h	2013-02-12 18:34:43 UTC (rev 142639)
+++ trunk/Source/WebCore/css/CSSParser.h	2013-02-12 18:40:48 UTC (rev 142640)
@@ -300,6 +300,7 @@
     StyleRuleBase* createSupportsRule(bool conditionIsSupported, RuleList*);
     void markSupportsRuleHeaderStart();
     void markSupportsRuleHeaderEnd();
+    PassRefPtr<CSSRuleSourceData> popSupportsRuleData();
 #endif
 #if ENABLE(SHADOW_DOM)
     StyleRuleBase* createHostRule(RuleList* rules);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to