WebCore:
authorddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Jul 2008 09:34:36 +0000 (09:34 +0000)
committerddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 21 Jul 2008 09:34:36 +0000 (09:34 +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.

        * 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@35261 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
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
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
LayoutTests/platform/mac/css2.1/t0402-syntax-06-f-expected.txt
WebCore/ChangeLog
WebCore/css/CSSGrammar.y

index 8801c70b1aac2f6846694c792027a1cd43df749b..2d4f09606b23ac525cc03f2b53777fdcf7e4c209 100644 (file)
@@ -1,3 +1,20 @@
+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:
+
 2008-07-20  Oliver Hunt  <oliver@apple.com>
 
         RS=Dan Bernstein.
index bf95762a28fcb71350b085732bccff9c0024901e..484b81bccb937538ed183aa0ed787b7d8fcbbc52 100644 (file)
@@ -1 +1 @@
-48c586c471d31538fa826a547aa46c60
\ No newline at end of file
+7c6c531b985d3cf4a81611af231d0459
\ No newline at end of file
index 9bfce68a285dbfb3e3c645156b78c52a844c0a98..2901ac328b8e0c4afc292a77f8ad72e5240a1500 100644 (file)
Binary files a/LayoutTests/platform/mac/css2.1/t040105-import-01-b-expected.png 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
index ebf79d0410bd9c7e78ca6d4bb7bf8fbaf0ea930e..9c6865437899b16a75e9e6fd6e2f35b12f8d515c 100644 (file)
Binary files a/LayoutTests/platform/mac/css2.1/t0402-syntax-05-f-expected.png 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
index ebf79d0410bd9c7e78ca6d4bb7bf8fbaf0ea930e..9c6865437899b16a75e9e6fd6e2f35b12f8d515c 100644 (file)
Binary files a/LayoutTests/platform/mac/css2.1/t0402-syntax-06-f-expected.png 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 08d4cb1a6cfc528766dd54a6bdf3d5aa94ef01f9..f40ce8ebd2c1689badb4475053ebb72e1629adcd 100644 (file)
@@ -1,3 +1,19 @@
+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.
+
+        * css/CSSGrammar.y:
+
 2008-07-20  Steve Falkenburg  <sfalken@apple.com>
 
         Touch file to force rebuild for vsprops change.
index f59a03208df962252bbdf81913ce5e58500a31f4..582f662ddae37ad90352d81badd013440cfc04de 100644 (file)
@@ -85,11 +85,12 @@ static int cssyylex(YYSTYPE* yylval, void* parser)
 
 %}
 
-%expect 44
+%expect 46
 
 %left UNIMPORTANT_TOK
 
 %token WHITESPACE SGML_CD
+%token TOKEN_EOF 0
 
 %token INCLUDES
 %token DASHMATCH
@@ -168,10 +169,14 @@ 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_import
+%type <rule> invalid_media
 %type <rule> rule
 %type <rule> valid_rule
+%type <rule> block_rule
+%type <rule> block_valid_rule
 %type <rule> variables_rule
 
 %type <string> maybe_ns_prefix
@@ -193,7 +198,7 @@ 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 <ruleList> block_rule_list 
 
 %type <integer> property
 
@@ -300,7 +305,12 @@ maybe_charset:
    /* empty */
   | charset {
   }
-;
+  ;
+
+closing_brace:
+    '}'
+  | %prec maybe_sgml TOKEN_EOF
+  ;
 
 charset:
   CHARSET_SYM maybe_space STRING maybe_space ';' {
@@ -322,6 +332,7 @@ import_list:
      if ($2 && p->m_styleSheet)
          p->m_styleSheet->append($2);
  }
+ | invalid_at_list
  ;
 
 variables_list:
@@ -361,16 +372,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:
@@ -570,26 +611,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;
@@ -641,7 +670,7 @@ unary_operator:
   ;
 
 ruleset:
-    selector_list '{' maybe_space declaration_list '}' {
+    selector_list '{' maybe_space declaration_list closing_brace {
         $$ = static_cast<CSSParser*>(parser)->createStyleRule($1);
     }
   ;
@@ -1054,6 +1083,9 @@ declaration_list:
     | decl_list error {
         $$ = $1;
     }
+    | decl_list invalid_block_list {
+        $$ = $1;
+    }
     ;
 
 decl_list:
@@ -1108,6 +1140,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;
@@ -1122,6 +1159,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:
@@ -1256,6 +1298,15 @@ hexcolor:
 
 /* error handling rules */
 
+save_block:
+    closing_brace {
+        $$ = 0;
+    }
+  | error closing_brace {
+        $$ = 0;
+    }
+    ;
+
 invalid_at:
     ATKEYWORD error invalid_block {
         $$ = 0;
@@ -1265,16 +1316,28 @@ invalid_at:
     }
     ;
 
+invalid_at_list:
+  /* empty */
+  | 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
@@ -1289,8 +1352,8 @@ invalid_rule:
     ;
 
 invalid_block:
-    '{' error invalid_block_list error '}'
-  | '{' error '}'
+    '{' error invalid_block_list error closing_brace
+  | '{' error closing_brace
     ;
 
 invalid_block_list: