Changeset 35403 in webkit


Ignore:
Timestamp:
Jul 27, 2008 2:08:29 PM (16 years ago)
Author:
ddkilzer@apple.com
Message:

WebCore:

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:
Location:
trunk
Files:
3 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r35401 r35403  
     12008-07-27  Anatoli Papirovski  <apapirovski@mac.com>
     2
     3        Reviewed by Dave Hyatt.
     4
     5        Updated layout CSS2.1 test suite tests related to css parsing:
     6        https://bugs.webkit.org/show_bug.cgi?id=14346
     7
     8        * platform/mac/css2.1/t040105-import-01-b-expected.checksum:
     9        * platform/mac/css2.1/t040105-import-01-b-expected.png:
     10        * platform/mac/css2.1/t040105-import-01-b-expected.txt:
     11        * platform/mac/css2.1/t0402-syntax-05-f-expected.checksum:
     12        * platform/mac/css2.1/t0402-syntax-05-f-expected.png:
     13        * platform/mac/css2.1/t0402-syntax-05-f-expected.txt:
     14        * platform/mac/css2.1/t0402-syntax-06-f-expected.checksum:
     15        * platform/mac/css2.1/t0402-syntax-06-f-expected.png:
     16        * platform/mac/css2.1/t0402-syntax-06-f-expected.txt:
     17
    1182008-07-26  Mark Rowe  <mrowe@apple.com>
    219
  • trunk/LayoutTests/platform/mac/css2.1/t040105-import-01-b-expected.checksum

    r35266 r35403  
    1 48c586c471d31538fa826a547aa46c60
     17c6c531b985d3cf4a81611af231d0459
  • trunk/LayoutTests/platform/mac/css2.1/t040105-import-01-b-expected.txt

    r35266 r35403  
    44  RenderBlock {HTML} at (0,0) size 800x50
    55    RenderBody {BODY} at (8,16) size 784x18
    6       RenderBlock {P} at (0,0) size 784x18
     6      RenderBlock {P} at (0,0) size 784x18 [color=#008000]
    77        RenderText {#text} at (0,0) size 136x18
    88          text run at (0,0) width 136: "This should be green."
  • trunk/LayoutTests/platform/mac/css2.1/t0402-syntax-05-f-expected.checksum

    r35266 r35403  
    1 3445deb21395438f6e171e928bb89c2f
     117855c59caf75f290cd968f9b98ed820
  • trunk/LayoutTests/platform/mac/css2.1/t0402-syntax-05-f-expected.txt

    r35266 r35403  
    44  RenderBlock {HTML} at (0,0) size 800x50
    55    RenderBody {BODY} at (8,16) size 784x18
    6       RenderBlock {P} at (0,0) size 784x18 [color=#800000]
     6      RenderBlock {P} at (0,0) size 784x18 [color=#008000]
    77        RenderText {#text} at (0,0) size 159x18
    88          text run at (0,0) width 159: "This text should be green"
  • trunk/LayoutTests/platform/mac/css2.1/t0402-syntax-06-f-expected.checksum

    r35266 r35403  
    1 3445deb21395438f6e171e928bb89c2f
     117855c59caf75f290cd968f9b98ed820
  • trunk/LayoutTests/platform/mac/css2.1/t0402-syntax-06-f-expected.txt

    r35266 r35403  
    44  RenderBlock {HTML} at (0,0) size 800x50
    55    RenderBody {BODY} at (8,16) size 784x18
    6       RenderBlock {P} at (0,0) size 784x18 [color=#800000]
     6      RenderBlock {P} at (0,0) size 784x18 [color=#008000]
    77        RenderText {#text} at (0,0) size 159x18
    88          text run at (0,0) width 159: "This text should be green"
  • trunk/WebCore/ChangeLog

    r35402 r35403  
     12008-07-27  Anatoli Papirovski  <apapirovski@mac.com>
     2
     3        Reviewed by Dave Hyatt.
     4
     5        Fix for https://bugs.webkit.org/show_bug.cgi?id=14346
     6        Modified the css parser:
     7        - not to fail when closing braces are not found for
     8          a declaration at the end of the file
     9        - not to accept "!important fail" as valid
     10        - to keep accepting @import when it comes after invalid @ rules
     11        - not to drop the whole @media block when there's an error before the
     12          closing brace
     13        + some other minor css parsing revisions.
     14
     15        CSSGrammar.y tweaked by David Kilzer to fix Tiger builds.
     16
     17        * css/CSSGrammar.y:
     18
    1192008-07-27  Jan Michael Alonzo  <jmalonzo@webkit.org>
    220
  • trunk/WebCore/css/CSSGrammar.y

    r35351 r35403  
    8686%}
    8787
    88 %expect 46
     88%expect 49
    8989
    9090%left UNIMPORTANT_TOK
    9191
    9292%token WHITESPACE SGML_CD
     93%token TOKEN_EOF 0
    9394
    9495%token INCLUDES
     
    172173%type <rule> font_face
    173174%type <rule> invalid_rule
     175%type <rule> save_block
    174176%type <rule> invalid_at
     177%type <rule> invalid_at_list
    175178%type <rule> invalid_import
     179%type <rule> invalid_media
    176180%type <rule> rule
    177181%type <rule> valid_rule
     182%type <ruleList> block_rule_list
     183%type <rule> block_rule
     184%type <rule> block_valid_rule
    178185%type <rule> variables_rule
    179186%type <mediaList> variables_media_list
     
    198205%type <mediaQueryExpList> maybe_and_media_query_exp_list
    199206
    200 %type <ruleList> ruleset_list
    201 
    202207%type <integer> property
    203208
     
    313318  | charset {
    314319  }
    315 ;
     320  ;
     321
     322closing_brace:
     323    '}'
     324  | %prec maybe_sgml TOKEN_EOF
     325  ;
    316326
    317327charset:
     
    335345         p->m_styleSheet->append($2);
    336346 }
     347 | invalid_at_list {
     348 }
    337349 ;
    338350
     
    374386  ;
    375387
     388block_rule_list:
     389    /* empty */ { $$ = 0; }
     390  | block_rule_list block_rule maybe_sgml {
     391      $$ = $1;
     392      if ($2) {
     393          if (!$$)
     394              $$ = static_cast<CSSParser*>(parser)->createRuleList();
     395          $$->append($2);
     396      }
     397  }
     398  ;
     399
     400block_valid_rule:
     401    ruleset
     402  | page
     403  | font_face
     404  ;
     405
     406block_rule:
     407    block_valid_rule
     408  | invalid_rule
     409  | invalid_at
     410  | invalid_import
     411  | invalid_media
     412  ;
     413
     414
    376415import:
    377416    IMPORT_SYM maybe_space string_or_uri maybe_space maybe_media_list ';' {
    378417        $$ = static_cast<CSSParser*>(parser)->createImportRule($3, $5);
    379418    }
     419  | IMPORT_SYM maybe_space string_or_uri maybe_space maybe_media_list invalid_block {
     420        $$ = 0;
     421    }
     422  | IMPORT_SYM error ';' {
     423        $$ = 0;
     424    }
    380425  | IMPORT_SYM error invalid_block {
    381         $$ = 0;
    382     }
    383   | IMPORT_SYM error ';' {
    384426        $$ = 0;
    385427    }
     
    597639
    598640media:
    599     MEDIA_SYM maybe_space media_list '{' maybe_space ruleset_list '}' {
     641    MEDIA_SYM maybe_space media_list '{' maybe_space block_rule_list save_block {
    600642        $$ = static_cast<CSSParser*>(parser)->createMediaRule($3, $6);
    601643    }
    602     | MEDIA_SYM maybe_space '{' maybe_space ruleset_list '}' {
     644    | MEDIA_SYM maybe_space '{' maybe_space block_rule_list save_block {
    603645        $$ = static_cast<CSSParser*>(parser)->createMediaRule(0, $5);
    604     }
    605     ;
    606 
    607 ruleset_list:
    608     /* empty */ { $$ = 0; }
    609     | ruleset_list ruleset maybe_space {
    610         $$ = $1;
    611         if ($2) {
    612             if (!$$)
    613                 $$ = static_cast<CSSParser*>(parser)->createRuleList();
    614             $$->append($2);
    615         }
    616646    }
    617647    ;
     
    668698
    669699ruleset:
    670     selector_list '{' maybe_space declaration_list '}' {
     700    selector_list '{' maybe_space declaration_list closing_brace {
    671701        $$ = static_cast<CSSParser*>(parser)->createStyleRule($1);
    672702    }
     
    10811111        $$ = $1;
    10821112    }
     1113    | decl_list invalid_block_list {
     1114        $$ = $1;
     1115    }
    10831116    ;
    10841117
     
    11351168    }
    11361169    |
     1170    property ':' maybe_space expr prio error {
     1171        /* When we encounter something like p {color: red !important fail;} we should drop the declaration */
     1172        $$ = false;
     1173    }
     1174    |
    11371175    IMPORTANT_SYM maybe_space {
    11381176        /* Handle this case: div { text-align: center; !important } Just reduce away the stray !important. */
     
    11471185    property ':' maybe_space error {
    11481186        /* if we come across rules with invalid values like this case: p { weight: *; }, just discard the rule */
     1187        $$ = false;
     1188    }
     1189    |
     1190    property invalid_block {
     1191        /* if we come across: div { color{;color:maroon} }, ignore everything within curly brackets */
    11491192        $$ = false;
    11501193    }
     
    12941337/* error handling rules */
    12951338
     1339save_block:
     1340    closing_brace {
     1341        $$ = 0;
     1342    }
     1343  | error closing_brace {
     1344        $$ = 0;
     1345    }
     1346    ;
     1347
    12961348invalid_at:
    12971349    ATKEYWORD error invalid_block {
     
    13031355    ;
    13041356
     1357invalid_at_list:
     1358    invalid_at maybe_sgml
     1359  | invalid_at_list invalid_at maybe_sgml
     1360  ;
     1361
    13051362invalid_import:
    13061363    import {
     
    13091366    ;
    13101367
     1368invalid_media:
     1369    media {
     1370        $$ = 0;
     1371    }
     1372    ;
     1373
    13111374invalid_rule:
    13121375    error invalid_block {
    13131376        $$ = 0;
    13141377    }
     1378
    13151379/*
    13161380  Seems like the two rules below are trying too much and violating
     
    13271391
    13281392invalid_block:
    1329     '{' error invalid_block_list error '}'
    1330   | '{' error '}'
     1393    '{' error invalid_block_list error closing_brace
     1394  | '{' error closing_brace
    13311395    ;
    13321396
Note: See TracChangeset for help on using the changeset viewer.