Title: [153822] trunk
Revision
153822
Author
[email protected]
Date
2013-08-08 07:49:44 -0700 (Thu, 08 Aug 2013)

Log Message

REGRESSION (r121551) Incorrect handling of invalid media query list.
https://bugs.webkit.org/show_bug.cgi?id=119164

Reviewed by Antti Koivisto.

Differentiate between syntactically invalid media queries and media queries with empty expressions.

Introduce a dedicated function for valid, but empty _expression_ queries, so that passing NULL MediaQuerySet
object to CSSParser::createMediaRule() can indicate invalid media query.

Source/WebCore:

Test: fast/media/invalid-media-query-list.html

* css/CSSGrammar.y.in:
* css/CSSParser.cpp:
(WebCore::CSSParser::createMediaRule):
(WebCore::CSSParser::createEmptyMediaRule):
* css/CSSParser.h:

LayoutTests:

* fast/media/invalid-media-query-list-expected.html: Added.
* fast/media/invalid-media-query-list.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (153821 => 153822)


--- trunk/LayoutTests/ChangeLog	2013-08-08 13:30:15 UTC (rev 153821)
+++ trunk/LayoutTests/ChangeLog	2013-08-08 14:49:44 UTC (rev 153822)
@@ -1,3 +1,18 @@
+2013-08-08  Zalan Bujtas  <[email protected]>
+
+        REGRESSION (r121551) Incorrect handling of invalid media query list.
+        https://bugs.webkit.org/show_bug.cgi?id=119164
+
+        Reviewed by Antti Koivisto.
+
+        Differentiate between syntactically invalid media queries and media queries with empty expressions.
+
+        Introduce a dedicated function for valid, but empty _expression_ queries, so that passing NULL MediaQuerySet
+        object to CSSParser::createMediaRule() can indicate invalid media query.
+
+        * fast/media/invalid-media-query-list-expected.html: Added.
+        * fast/media/invalid-media-query-list.html: Added.
+
 2013-08-08  Zoltan Arvai  <[email protected]>
 
         [Qt] Unreviewed rebaselining after r153647.

Added: trunk/LayoutTests/fast/media/invalid-media-query-list-expected.html (0 => 153822)


--- trunk/LayoutTests/fast/media/invalid-media-query-list-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/media/invalid-media-query-list-expected.html	2013-08-08 14:49:44 UTC (rev 153822)
@@ -0,0 +1,23 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <style>
+        div { 
+            height: 20px;
+            border: solid 1px black;
+        }
+
+        .foo {
+             background-color: green;
+        }
+    </style>
+</head>
+<body>
+<p>This tests if we ignore syntactically invalid media query lists with multiple media queries and missing media types.</p>
+<div class='foo'></div>
+<div class='foo'></div>
+<div class='foo'></div>
+<div></div>
+<div></div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/media/invalid-media-query-list.html (0 => 153822)


--- trunk/LayoutTests/fast/media/invalid-media-query-list.html	                        (rev 0)
+++ trunk/LayoutTests/fast/media/invalid-media-query-list.html	2013-08-08 14:49:44 UTC (rev 153822)
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <style>
+        div { 
+            height: 20px;
+            border: solid 1px black;
+        }
+
+        @media screen and (min-width: 480px), screen and (device-width: 768px) {
+            #valid1 {
+                background-color: green;
+            }
+        }
+
+        @media screen {
+            #valid2 {
+                background-color: green;
+            }
+        }
+
+        @media {
+            #valid3 {
+                background-color: green;
+            }
+        }
+
+        @media screen and (min-width: 480px) screen and (device-width: 768px) {
+            #invalid1 {
+                background-color: red;
+            }
+        }
+        
+        @media screen and (min-width: 480px) and (device-width: 768px) {
+            #invalid2 {
+                background-color: red;
+            }
+        }
+    </style>
+</head>
+<body>
+<p>This tests if we ignore syntactically invalid media query lists with multiple media queries and missing media types.</p>
+<div id='valid1'></div>
+<div id='valid2'></div>
+<div id='valid3'></div>
+<div id='invalid1'></div>
+<div id='invalid2'></div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (153821 => 153822)


--- trunk/Source/WebCore/ChangeLog	2013-08-08 13:30:15 UTC (rev 153821)
+++ trunk/Source/WebCore/ChangeLog	2013-08-08 14:49:44 UTC (rev 153822)
@@ -1,3 +1,23 @@
+2013-08-08  Zalan Bujtas  <[email protected]>
+
+        REGRESSION (r121551) Incorrect handling of invalid media query list.
+        https://bugs.webkit.org/show_bug.cgi?id=119164
+
+        Reviewed by Antti Koivisto.
+
+        Differentiate between syntactically invalid media queries and media queries with empty expressions.
+
+        Introduce a dedicated function for valid, but empty _expression_ queries, so that passing NULL MediaQuerySet
+        object to CSSParser::createMediaRule() can indicate invalid media query.
+
+        Test: fast/media/invalid-media-query-list.html
+
+        * css/CSSGrammar.y.in:
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::createMediaRule):
+        (WebCore::CSSParser::createEmptyMediaRule):
+        * css/CSSParser.h:
+
 2013-08-08  Gyuyoung Kim  <[email protected]>
 
         Introduce toSVGMPathElement(), and use it

Modified: trunk/Source/WebCore/css/CSSGrammar.y.in (153821 => 153822)


--- trunk/Source/WebCore/css/CSSGrammar.y.in	2013-08-08 13:30:15 UTC (rev 153821)
+++ trunk/Source/WebCore/css/CSSGrammar.y.in	2013-08-08 14:49:44 UTC (rev 153822)
@@ -728,7 +728,7 @@
         $$ = parser->createMediaRule($4, $9);
     }
     | before_media_rule MEDIA_SYM at_rule_header_end_maybe_space '{' at_rule_body_start maybe_space block_rule_list save_block {
-        $$ = parser->createMediaRule(0, $7);
+        $$ = parser->createEmptyMediaRule($7);
     }
     | before_media_rule MEDIA_SYM at_rule_header_end_maybe_space ';' {
         $$ = 0;

Modified: trunk/Source/WebCore/css/CSSParser.cpp (153821 => 153822)


--- trunk/Source/WebCore/css/CSSParser.cpp	2013-08-08 13:30:15 UTC (rev 153821)
+++ trunk/Source/WebCore/css/CSSParser.cpp	2013-08-08 14:49:44 UTC (rev 153822)
@@ -11499,18 +11499,24 @@
 {
     m_allowImportRules = m_allowNamespaceDeclarations = false;
     RefPtr<StyleRuleMedia> rule;
-    if (rules)
-        rule = StyleRuleMedia::create(media ? media : MediaQuerySet::create(), *rules);
-    else {
-        RuleList emptyRules;
-        rule = StyleRuleMedia::create(media ? media : MediaQuerySet::create(), emptyRules);
-    }
+    RuleList emptyRules;
+    if (!media) {
+        // To comply with w3c test suite expectation, create an empty media query
+        // even when it is syntactically incorrect.
+        rule = StyleRuleMedia::create(MediaQuerySet::create(), emptyRules);
+    } else
+        rule = StyleRuleMedia::create(media, rules ? *rules : emptyRules);
     StyleRuleMedia* result = rule.get();
     m_parsedRules.append(rule.release());
     processAndAddNewRuleToSourceTreeIfNeeded();
     return result;
 }
 
+StyleRuleBase* CSSParser::createEmptyMediaRule(RuleList* rules)
+{
+    return createMediaRule(MediaQuerySet::create().get(), rules);
+}
+
 #if ENABLE(CSS3_CONDITIONAL_RULES)
 StyleRuleBase* CSSParser::createSupportsRule(bool conditionIsSupported, RuleList* rules)
 {

Modified: trunk/Source/WebCore/css/CSSParser.h (153821 => 153822)


--- trunk/Source/WebCore/css/CSSParser.h	2013-08-08 13:30:15 UTC (rev 153821)
+++ trunk/Source/WebCore/css/CSSParser.h	2013-08-08 14:49:44 UTC (rev 153822)
@@ -320,6 +320,7 @@
 
     typedef Vector<RefPtr<StyleRuleBase> > RuleList;
     StyleRuleBase* createMediaRule(MediaQuerySet*, RuleList*);
+    StyleRuleBase* createEmptyMediaRule(RuleList*);
     RuleList* createRuleList();
     StyleRuleBase* createStyleRule(Vector<OwnPtr<CSSParserSelector> >* selectors);
     StyleRuleBase* createFontFaceRule();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to