Changeset 150803 in webkit


Ignore:
Timestamp:
May 28, 2013 7:31:11 AM (11 years ago)
Author:
sergio@webkit.org
Message:

Invalid block doesn't make declaration invalid
https://bugs.webkit.org/show_bug.cgi?id=115709

Reviewed by Andreas Kling.

From Blink r149446 by <serya@chromium.org>

Source/WebCore:

Added a new rule "declaration_recovery:" which covers any kind of
"invalid_block_list maybe_space" sequence. By appending this new
rule to every rule reductable to "declaration:" we can remove some
redundant rules and improve error recovery of some others that
were only accepting exactly one error.

One of the rules being removed was preventing invalid blocks in a
declaration to invalidate the whole declaration. The rule was
reporting the syntax error but at the same time accepting the
invalid block as part of a valid declaration.

  • css/CSSGrammar.y.in:

LayoutTests:

  • fast/css/parsing-error-recovery.html: Added 2 new test cases.
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r150797 r150803  
     12013-05-28  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        Invalid block doesn't make declaration invalid
     4        https://bugs.webkit.org/show_bug.cgi?id=115709
     5
     6        Reviewed by Andreas Kling.
     7
     8        From Blink r149446 by <serya@chromium.org>
     9
     10        * fast/css/parsing-error-recovery.html: Added 2 new test cases.
     11
    1122013-05-28  Ádám Kallai  <kadam@inf.u-szeged.hu>
    213
  • trunk/LayoutTests/fast/css/parsing-error-recovery.html

    r147028 r150803  
    4949        }
    5050
     51        #test6 {
     52            display: none !important;
     53            display: block !important {invalid_block};
     54        }
     55
     56        #test7 {
     57            display: none !important;
     58        }
     59        #test7 {
     60            display: block !important {invalid_block}
     61        }
     62
    5163        /* Successfully parsed */
    5264        #last {
     
    6173  <div class="to_be_hidden" id="test4">FAIL: Test 4</div>
    6274  <div class="to_be_hidden" id="test5">FAIL: Test 5</div>
     75  <div class="to_be_hidden" id="test6">FAIL: Test 6</div>
     76  <div class="to_be_hidden" id="test7">FAIL: Test 7</div>
    6377  <div class="to_be_shown" id="last">PASS</div>
    6478</body>
  • trunk/Source/WebCore/ChangeLog

    r150801 r150803  
     12013-05-28  Sergio Villar Senin  <svillar@igalia.com>
     2
     3        Invalid block doesn't make declaration invalid
     4        https://bugs.webkit.org/show_bug.cgi?id=115709
     5
     6        Reviewed by Andreas Kling.
     7
     8        From Blink r149446 by <serya@chromium.org>
     9
     10        Added a new rule "declaration_recovery:" which covers any kind of
     11        "invalid_block_list maybe_space" sequence. By appending this new
     12        rule to every rule reductable to "declaration:" we can remove some
     13        redundant rules and improve error recovery of some others that
     14        were only accepting exactly one error.
     15
     16        One of the rules being removed was preventing invalid blocks in a
     17        declaration to invalidate the whole declaration. The rule was
     18        reporting the syntax error but at the same time accepting the
     19        invalid block as part of a valid declaration.
     20
     21        * css/CSSGrammar.y.in:
     22
    1232013-05-28  Andreas Kling  <akling@apple.com>
    224
  • trunk/Source/WebCore/css/CSSGrammar.y.in

    r150791 r150803  
    8989
    9090#if ENABLE_SHADOW_DOM
    91 %expect 68
     91%expect 65
    9292#else
    93 %expect 67
     93%expect 64
    9494#endif
    9595
     
    337337%type <string> attr_name
    338338
    339 %type <location> errors
    340339%type <location> error_location
    341340
     
    15461545        $$ = $1;
    15471546    }
    1548     | declaration error_location invalid_block_list maybe_space {
    1549         parser->syntaxError($2);
    1550         $$ = false;
    1551     }
    1552     | declaration error_location invalid_block_list ';' maybe_space {
    1553         parser->syntaxError($2);
    1554         $$ = false;
    1555     }
    15561547    | decl_list_recovery ';' maybe_space {
    15571548        parser->markPropertyStart();
     
    16051596    }
    16061597    |
    1607     property errors {
    1608         parser->syntaxError($2);
     1598    property declaration_recovery {
    16091599        $$ = false;
    16101600    }
    16111601    |
    1612     property ':' maybe_space errors expr prio {
    1613         /* The default movable type template has letter-spacing: .none;  Handle this by looking for
    1614         error tokens at the start of an expr, recover the expr and then treat as an error, cleaning
    1615         up and deleting the shifted expr.  */
    1616         parser->syntaxError($4);
    1617         parser->markPropertyEnd(false, false);
    1618         $$ = false;
    1619     }
    1620     |
    1621     property ':' maybe_space expr prio error {
     1602    property ':' maybe_space expr prio declaration_recovery {
    16221603        /* When we encounter something like p {color: red !important fail;} we should drop the declaration */
    16231604        parser->markPropertyEnd(false, false);
     
    16251606    }
    16261607    |
    1627     IMPORTANT_SYM maybe_space error_location {
     1608    IMPORTANT_SYM maybe_space declaration_recovery {
    16281609        /* Handle this case: div { text-align: center; !important } Just reduce away the stray !important. */
    1629         parser->syntaxError($3);
    16301610        $$ = false;
    16311611    }
    16321612    |
    1633     property ':' maybe_space error_location {
    1634         /* div { font-family: } Just reduce away this property with no value. */
    1635         parser->syntaxError($4);
     1613    property ':' maybe_space declaration_recovery {
     1614        /* if we come across rules with invalid values like this case: p { weight: *; }, just discard the rule */
    16361615        parser->markPropertyEnd(false, false);
    16371616        $$ = false;
    16381617    }
    1639     |
    1640     property ':' maybe_space errors {
    1641         /* if we come across rules with invalid values like this case: p { weight: *; }, just discard the rule */
    1642         parser->syntaxError($4);
    1643         parser->markPropertyEnd(false, false);
    1644         $$ = false;
    1645     }
    1646     |
    1647     property error_location invalid_block {
    1648         /* if we come across: div { color{;color:maroon} }, ignore everything within curly brackets */
     1618  ;
     1619
     1620declaration_recovery:
     1621    error error_location {
    16491622        parser->syntaxError($2);
    1650         $$ = false;
    1651     }
     1623    }
     1624    | declaration_recovery invalid_block
     1625    | declaration_recovery error
    16521626  ;
    16531627
     
    20021976;
    20031977
    2004 errors:
    2005     error error_location {
    2006         $$ = $2;
    2007     }
    2008     ;
    2009 
    20101978error_location: {
    20111979        $$ = parser->currentLocation();
Note: See TracChangeset for help on using the changeset viewer.