WebCore:
authorddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 27 Jul 2008 21:08:29 +0000 (21:08 +0000)
committerddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 27 Jul 2008 21:08:29 +0000 (21:08 +0000)
2008-07-21  Anatoli Papirovski  <apapirovski@mac.com>

        Reviewed by Dave Hyatt.

        Fix for https://bugs.webkit.org/show_bug.cgi?id=14346
        Modified the css parser:
        - not to fail when closing braces are not found for
          a declaration at the end of the file
        - not to accept "!important fail" as valid
        - to keep accepting @import when it comes after invalid @ rules
        - not to drop the whole @media block when there's an error before the
          closing brace
        + some other minor css parsing revisions.

        CSSGrammar.y tweaked by David Kilzer to fix Tiger builds.

        * css/CSSGrammar.y:

LayoutTests:

2008-07-21  Anatoli Papirovski  <apapirovski@mac.com>

        Reviewed by Dave Hyatt.

        Updated layout CSS2.1 test suite tests related to css parsing:
        https://bugs.webkit.org/show_bug.cgi?id=14346

        * platform/mac/css2.1/t040105-import-01-b-expected.checksum:
        * platform/mac/css2.1/t040105-import-01-b-expected.png:
        * platform/mac/css2.1/t040105-import-01-b-expected.txt:
        * platform/mac/css2.1/t0402-syntax-05-f-expected.checksum:
        * platform/mac/css2.1/t0402-syntax-05-f-expected.png:
        * platform/mac/css2.1/t0402-syntax-05-f-expected.txt:
        * platform/mac/css2.1/t0402-syntax-06-f-expected.checksum:
        * platform/mac/css2.1/t0402-syntax-06-f-expected.png:
        * platform/mac/css2.1/t0402-syntax-06-f-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@35403 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac/css2.1/t040105-import-01-b-expected.checksum
LayoutTests/platform/mac/css2.1/t040105-import-01-b-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/css2.1/t040105-import-01-b-expected.txt
LayoutTests/platform/mac/css2.1/t0402-syntax-05-f-expected.checksum
LayoutTests/platform/mac/css2.1/t0402-syntax-05-f-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/css2.1/t0402-syntax-05-f-expected.txt
LayoutTests/platform/mac/css2.1/t0402-syntax-06-f-expected.checksum
LayoutTests/platform/mac/css2.1/t0402-syntax-06-f-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/css2.1/t0402-syntax-06-f-expected.txt
WebCore/ChangeLog
WebCore/css/CSSGrammar.y

index c6d392a83aaf1dca6dd81547f137012a70bde9fe..9274617f82c38e16002cf8451a386110d5f8fac5 100644 (file)
@@ -1,3 +1,20 @@
+2008-07-27  Anatoli Papirovski  <apapirovski@mac.com>
+
+        Reviewed by Dave Hyatt.
+
+        Updated layout CSS2.1 test suite tests related to css parsing:
+        https://bugs.webkit.org/show_bug.cgi?id=14346
+
+        * platform/mac/css2.1/t040105-import-01-b-expected.checksum:
+        * platform/mac/css2.1/t040105-import-01-b-expected.png:
+        * platform/mac/css2.1/t040105-import-01-b-expected.txt:
+        * platform/mac/css2.1/t0402-syntax-05-f-expected.checksum:
+        * platform/mac/css2.1/t0402-syntax-05-f-expected.png:
+        * platform/mac/css2.1/t0402-syntax-05-f-expected.txt:
+        * platform/mac/css2.1/t0402-syntax-06-f-expected.checksum:
+        * platform/mac/css2.1/t0402-syntax-06-f-expected.png:
+        * platform/mac/css2.1/t0402-syntax-06-f-expected.txt:
+
 2008-07-26  Mark Rowe  <mrowe@apple.com>
 
         Update some layout test results.
index bf95762a28fcb71350b085732bccff9c0024901e..484b81bccb937538ed183aa0ed787b7d8fcbbc52 100644 (file)
@@ -1 +1 @@
-48c586c471d31538fa826a547aa46c60
\ No newline at end of file
+7c6c531b985d3cf4a81611af231d0459
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/css2.1/t040105-import-01-b-expected.png b/LayoutTests/platform/mac/css2.1/t040105-import-01-b-expected.png
new file mode 100644 (file)
index 0000000..2901ac3
Binary files /dev/null and b/LayoutTests/platform/mac/css2.1/t040105-import-01-b-expected.png differ
index a7a1558c3fe2fbe197760b7d5dc4105d0ae940c4..342338142c5c131040f63fd182f1181524c218a9 100644 (file)
@@ -3,6 +3,6 @@ layer at (0,0) size 800x600
 layer at (0,0) size 800x50
   RenderBlock {HTML} at (0,0) size 800x50
     RenderBody {BODY} at (8,16) size 784x18
-      RenderBlock {P} at (0,0) size 784x18
+      RenderBlock {P} at (0,0) size 784x18 [color=#008000]
         RenderText {#text} at (0,0) size 136x18
           text run at (0,0) width 136: "This should be green."
index 3bb17291f7d3050b614ddf8e9da27d2cc8cb6fda..45cf432dd3a9989e2705597e87a96f38b1fef02c 100644 (file)
@@ -1 +1 @@
-3445deb21395438f6e171e928bb89c2f
\ No newline at end of file
+17855c59caf75f290cd968f9b98ed820
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/css2.1/t0402-syntax-05-f-expected.png b/LayoutTests/platform/mac/css2.1/t0402-syntax-05-f-expected.png
new file mode 100644 (file)
index 0000000..9c68654
Binary files /dev/null and b/LayoutTests/platform/mac/css2.1/t0402-syntax-05-f-expected.png differ
index 68c005a9b0436760afdd9cef5ce8293358ac86e8..5a17d6f4ea79a399ca8b583d6310f796aa1f451e 100644 (file)
@@ -3,6 +3,6 @@ layer at (0,0) size 800x600
 layer at (0,0) size 800x50
   RenderBlock {HTML} at (0,0) size 800x50
     RenderBody {BODY} at (8,16) size 784x18
-      RenderBlock {P} at (0,0) size 784x18 [color=#800000]
+      RenderBlock {P} at (0,0) size 784x18 [color=#008000]
         RenderText {#text} at (0,0) size 159x18
           text run at (0,0) width 159: "This text should be green"
index 3bb17291f7d3050b614ddf8e9da27d2cc8cb6fda..45cf432dd3a9989e2705597e87a96f38b1fef02c 100644 (file)
@@ -1 +1 @@
-3445deb21395438f6e171e928bb89c2f
\ No newline at end of file
+17855c59caf75f290cd968f9b98ed820
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/css2.1/t0402-syntax-06-f-expected.png b/LayoutTests/platform/mac/css2.1/t0402-syntax-06-f-expected.png
new file mode 100644 (file)
index 0000000..9c68654
Binary files /dev/null and b/LayoutTests/platform/mac/css2.1/t0402-syntax-06-f-expected.png differ
index 68c005a9b0436760afdd9cef5ce8293358ac86e8..5a17d6f4ea79a399ca8b583d6310f796aa1f451e 100644 (file)
@@ -3,6 +3,6 @@ layer at (0,0) size 800x600
 layer at (0,0) size 800x50
   RenderBlock {HTML} at (0,0) size 800x50
     RenderBody {BODY} at (8,16) size 784x18
-      RenderBlock {P} at (0,0) size 784x18 [color=#800000]
+      RenderBlock {P} at (0,0) size 784x18 [color=#008000]
         RenderText {#text} at (0,0) size 159x18
           text run at (0,0) width 159: "This text should be green"
index 7e364d77605c84a071c86d555ee924937e115ab7..5b5f7d958bc586c951c766798c8ba055547fe7df 100644 (file)
@@ -1,3 +1,21 @@
+2008-07-27  Anatoli Papirovski  <apapirovski@mac.com>
+
+        Reviewed by Dave Hyatt.
+
+        Fix for https://bugs.webkit.org/show_bug.cgi?id=14346
+        Modified the css parser:
+        - not to fail when closing braces are not found for 
+          a declaration at the end of the file
+        - not to accept "!important fail" as valid
+        - to keep accepting @import when it comes after invalid @ rules
+        - not to drop the whole @media block when there's an error before the 
+          closing brace
+        + some other minor css parsing revisions.
+
+        CSSGrammar.y tweaked by David Kilzer to fix Tiger builds.
+
+        * css/CSSGrammar.y:
+
 2008-07-27  Jan Michael Alonzo  <jmalonzo@webkit.org>
 
         Reviewed by Eric Seidel.
index 7d70b31d22ceaab9cdf06aaa3b38d7a080ac979b..2c1a17bb75238f2015240e207f8de15e109b2595 100644 (file)
@@ -85,11 +85,12 @@ static int cssyylex(YYSTYPE* yylval, void* parser)
 
 %}
 
-%expect 46
+%expect 49
 
 %left UNIMPORTANT_TOK
 
 %token WHITESPACE SGML_CD
+%token TOKEN_EOF 0
 
 %token INCLUDES
 %token DASHMATCH
@@ -171,10 +172,16 @@ static int cssyylex(YYSTYPE* yylval, void* parser)
 %type <rule> page
 %type <rule> font_face
 %type <rule> invalid_rule
+%type <rule> save_block
 %type <rule> invalid_at
+%type <rule> invalid_at_list
 %type <rule> invalid_import
+%type <rule> invalid_media
 %type <rule> rule
 %type <rule> valid_rule
+%type <ruleList> block_rule_list 
+%type <rule> block_rule
+%type <rule> block_valid_rule
 %type <rule> variables_rule
 %type <mediaList> variables_media_list
 
@@ -197,8 +204,6 @@ static int cssyylex(YYSTYPE* yylval, void* parser)
 %type <mediaQueryExpList> media_query_exp_list
 %type <mediaQueryExpList> maybe_and_media_query_exp_list
 
-%type <ruleList> ruleset_list
-
 %type <integer> property
 
 %type <selector> specifier
@@ -312,7 +317,12 @@ maybe_charset:
    /* empty */
   | charset {
   }
-;
+  ;
+
+closing_brace:
+    '}'
+  | %prec maybe_sgml TOKEN_EOF
+  ;
 
 charset:
   CHARSET_SYM maybe_space STRING maybe_space ';' {
@@ -334,6 +344,8 @@ import_list:
      if ($2 && p->m_styleSheet)
          p->m_styleSheet->append($2);
  }
+ | invalid_at_list {
+ }
  ;
 
 variables_list:
@@ -373,16 +385,46 @@ rule:
   | invalid_import
   ;
 
+block_rule_list: 
+    /* empty */ { $$ = 0; }
+  | block_rule_list block_rule maybe_sgml {
+      $$ = $1;
+      if ($2) {
+          if (!$$)
+              $$ = static_cast<CSSParser*>(parser)->createRuleList();
+          $$->append($2);
+      }
+  }
+  ;
+
+block_valid_rule:
+    ruleset
+  | page
+  | font_face
+  ;
+
+block_rule:
+    block_valid_rule
+  | invalid_rule
+  | invalid_at
+  | invalid_import
+  | invalid_media
+  ;
+
+
 import:
     IMPORT_SYM maybe_space string_or_uri maybe_space maybe_media_list ';' {
         $$ = static_cast<CSSParser*>(parser)->createImportRule($3, $5);
     }
-  | IMPORT_SYM error invalid_block {
+  | IMPORT_SYM maybe_space string_or_uri maybe_space maybe_media_list invalid_block {
         $$ = 0;
     }
   | IMPORT_SYM error ';' {
         $$ = 0;
     }
+  | IMPORT_SYM error invalid_block {
+        $$ = 0;
+    }
   ;
 
 variables_rule:
@@ -596,26 +638,14 @@ media_list:
     ;
 
 media:
-    MEDIA_SYM maybe_space media_list '{' maybe_space ruleset_list '}' {
+    MEDIA_SYM maybe_space media_list '{' maybe_space block_rule_list save_block {
         $$ = static_cast<CSSParser*>(parser)->createMediaRule($3, $6);
     }
-    | MEDIA_SYM maybe_space '{' maybe_space ruleset_list '}' {
+    | MEDIA_SYM maybe_space '{' maybe_space block_rule_list save_block {
         $$ = static_cast<CSSParser*>(parser)->createMediaRule(0, $5);
     }
     ;
 
-ruleset_list:
-    /* empty */ { $$ = 0; }
-    | ruleset_list ruleset maybe_space {
-        $$ = $1;
-        if ($2) {
-            if (!$$)
-                $$ = static_cast<CSSParser*>(parser)->createRuleList();
-            $$->append($2);
-        }
-    }
-    ;
-
 medium:
   IDENT maybe_space {
       $$ = $1;
@@ -667,7 +697,7 @@ unary_operator:
   ;
 
 ruleset:
-    selector_list '{' maybe_space declaration_list '}' {
+    selector_list '{' maybe_space declaration_list closing_brace {
         $$ = static_cast<CSSParser*>(parser)->createStyleRule($1);
     }
   ;
@@ -1080,6 +1110,9 @@ declaration_list:
     | decl_list error {
         $$ = $1;
     }
+    | decl_list invalid_block_list {
+        $$ = $1;
+    }
     ;
 
 decl_list:
@@ -1134,6 +1167,11 @@ declaration:
         $$ = false;
     }
     |
+    property ':' maybe_space expr prio error {
+        /* When we encounter something like p {color: red !important fail;} we should drop the declaration */
+        $$ = false;
+    }
+    |
     IMPORTANT_SYM maybe_space {
         /* Handle this case: div { text-align: center; !important } Just reduce away the stray !important. */
         $$ = false;
@@ -1148,6 +1186,11 @@ declaration:
         /* if we come across rules with invalid values like this case: p { weight: *; }, just discard the rule */
         $$ = false;
     }
+    |
+    property invalid_block {
+        /* if we come across: div { color{;color:maroon} }, ignore everything within curly brackets */
+        $$ = false;
+    }
   ;
 
 property:
@@ -1293,6 +1336,15 @@ hexcolor:
 
 /* error handling rules */
 
+save_block:
+    closing_brace {
+        $$ = 0;
+    }
+  | error closing_brace {
+        $$ = 0;
+    }
+    ;
+
 invalid_at:
     ATKEYWORD error invalid_block {
         $$ = 0;
@@ -1302,16 +1354,28 @@ invalid_at:
     }
     ;
 
+invalid_at_list:
+    invalid_at maybe_sgml
+  | invalid_at_list invalid_at maybe_sgml
+  ;
+
 invalid_import:
     import {
         $$ = 0;
     }
     ;
 
+invalid_media:
+    media {
+        $$ = 0;
+    }
+    ;
+
 invalid_rule:
     error invalid_block {
         $$ = 0;
     }
+
 /*
   Seems like the two rules below are trying too much and violating
   http://www.hixie.ch/tests/evil/mixed/csserrorhandling.html
@@ -1326,8 +1390,8 @@ invalid_rule:
     ;
 
 invalid_block:
-    '{' error invalid_block_list error '}'
-  | '{' error '}'
+    '{' error invalid_block_list error closing_brace
+  | '{' error closing_brace
     ;
 
 invalid_block_list: