+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.
+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.
%}
-%expect 44
+%expect 46
%left UNIMPORTANT_TOK
%token WHITESPACE SGML_CD
+%token TOKEN_EOF 0
%token INCLUDES
%token DASHMATCH
%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
%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
/* empty */
| charset {
}
-;
+ ;
+
+closing_brace:
+ '}'
+ | %prec maybe_sgml TOKEN_EOF
+ ;
charset:
CHARSET_SYM maybe_space STRING maybe_space ';' {
if ($2 && p->m_styleSheet)
p->m_styleSheet->append($2);
}
+ | invalid_at_list
;
variables_list:
| 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:
;
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;
;
ruleset:
- selector_list '{' maybe_space declaration_list '}' {
+ selector_list '{' maybe_space declaration_list closing_brace {
$$ = static_cast<CSSParser*>(parser)->createStyleRule($1);
}
;
| decl_list error {
$$ = $1;
}
+ | decl_list invalid_block_list {
+ $$ = $1;
+ }
;
decl_list:
$$ = 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;
/* 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:
/* error handling rules */
+save_block:
+ closing_brace {
+ $$ = 0;
+ }
+ | error closing_brace {
+ $$ = 0;
+ }
+ ;
+
invalid_at:
ATKEYWORD error invalid_block {
$$ = 0;
}
;
+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
;
invalid_block:
- '{' error invalid_block_list error '}'
- | '{' error '}'
+ '{' error invalid_block_list error closing_brace
+ | '{' error closing_brace
;
invalid_block_list: