RESOLVED CONFIGURATION CHANGED 116950
CSS parser improvements
https://bugs.webkit.org/show_bug.cgi?id=116950
Summary CSS parser improvements
Ryosuke Niwa
Reported 2013-05-29 02:02:52 PDT
https://chromium.googlesource.com/chromium/blink/+/2124f56d5addbd586705906f23a1871839e9194f CSS grammar refactoring: introducing at_rule_recovery to avoid duplocation. https://chromium.googlesource.com/chromium/blink/+/7a57c0325bf710372ff698dfb046ea223f2ea79e Correct handling invalid blocks outside declaration_lists. Declaration list already skips inner () and [] blocks as whole. The same needs to be done with invalid blocks in all other places. https://chromium.googlesource.com/chromium/blink/+/2e8c6ea3a6b392947fa9b48f0a150734ca896654 Filtering out CSS warnings for properties with "\9" ath the end. This hack is used in bootstrap for IE-only properties. https://chromium.googlesource.com/chromium/blink/+/58be8263b7dfbd0a924a1ae8851fc041a8dac2fd Error recovery in CSS selector blocks. I'm not ready to fix error recovery outsize '[]' and '()' blocks (even some '()' don't work) yet becouse it interfer with @-rules. So some test fail expected to fail. https://chromium.googlesource.com/chromium/blink/+/eeb33305b19074cac9184453b11f786446e4d4f8 Error recovery in @supports delcaration. https://chromium.googlesource.com/chromium/blink/+/b0f07bc3b29dea22ae7c2918744f61ceafef45e3 Refactoring: removing const_cast from CSSPasrerString https://chromium.googlesource.com/chromium/blink/+/a8762e7ece0c2598f8d29063bca039c5c6f47787 Fixing error recovery in CSS selectors. Also fixed ignored_charset rule. Otherwise test css3/supports-cssom.html and fast/css/nested-at-rules.html fail because the grammar used to reduce nested @charset by invalid_rule. https://chromium.googlesource.com/chromium/blink/+/73088ed90e46d8c881987088e629c7b465b33c62 Reporing invalid CSS selectors. It seems that anything not starting with "@" looks like a selector for the parser. I don't report warning in at-rules yet. However I added error type in advance InvalidRuleError to make visible if something reduces by "invalid_rule" instead of "invalid_at". https://chromium.googlesource.com/chromium/blink/+/a12c11195768c1bfb956ad4c5eeb0185bdc58c51 Error recovery in @-rules. This CL doesn't care about recovery in {}-blocks. So some tests expected to fail. It also preparation for error reporting in that rules. https://chromium.googlesource.com/chromium/blink/+/9569b31a96104b56775dca59c0e540ce7c3fd40d Adding initializer for CSSParserValue. https://chromium.googlesource.com/chromium/blink/+/b72198e815773b03b7d3f1eedfb0d9cd753f89d1 Fixing error recovery in block_rule_list. Prevoius code with save_block didn't work. Now having "block_rule_list error rule_error_recovery" on the stack the parser may reduce it to "block_rule_list invalid_rule" if the tail looks like invalid_block (next token is '{') or to "block_rule_body" if next token is '}'. https://chromium.googlesource.com/chromium/blink/+/f392572c3bdb9db442cbf4d5a56602bae8e95e3e Error reporting in @supports rule header.
Attachments
Ryosuke Niwa
Comment 1 2013-06-11 17:31:08 PDT
More: https://chromium.googlesource.com/chromium/blink/+/9569b31a96104b56775dca59c0e540ce7c3fd40d Adding initializer for CSSParserValue. https://chromium.googlesource.com/chromium/blink/+/f392572c3bdb9db442cbf4d5a56602bae8e95e3e Error reporting in @supports rule header. https://chromium.googlesource.com/chromium/blink/+/b72198e815773b03b7d3f1eedfb0d9cd753f89d1 Fixing error recovery in block_rule_list. Prevoius code with save_block didn't work. Now having "block_rule_list error rule_error_recovery" on the stack the parser may reduce it to "block_rule_list invalid_rule" if the tail looks like invalid_block (next token is '{') or to "block_rule_body" if next token is '}'. https://chromium.googlesource.com/chromium/blink/+/d1ba305dbb02e30bc02e87c2848fe476be3f1d93 Fixing error recovery in media query. https://chromium.googlesource.com/chromium/blink/+/38cc6cdbb0e1e4ff359ce5b6473c12188741296b Resolving a conflict with page_selector in CSS grammar. if page selector is /* empty */ it is ambiguously surrounded by 2 maybe_space. https://chromium.googlesource.com/chromium/blink/+/b486b6bd86c572de3895bf5bea2a72766c352cd9 Fixing 2 conflicts in CSS grammar (DISTRIBUTEDFUNCTION). "relative_selector" is based on "selector" which handles trailing whitespace. Rules for CUEFUNCTION, NOTFUNCTION and ANYFUNCTION do have maybe_space before ')'. It is because they use simple_selector_list which is different (doesn't handle trailing whitespace). Also removed "selector_with_trailing_whitespace" because it is longer than simply "selector WHITESPACE" what it represents. https://chromium.googlesource.com/chromium/blink/+/2e4087aa70c014724125f8f986a3d92213fbe1c7 Fixing 15 conflicts in CSS grammar. expr nonterminal eats trailing whitespace itself. https://chromium.googlesource.com/chromium/blink/+/e7d83e05b27327869ec5502dbb9b7af9e75a5f27 Fixing error recovery in @-webkit-filter rule. https://chromium.googlesource.com/chromium/blink/+/075514814a58e94e0a22f2689b986971d1f0d2bb Fixing one more conflict in CSS grammar. Grammar allows to reduce CSS like '@charset "xxx"; ...' to both maybe_charset and ignored_charset. Adding error into ignored charset resolves this conflict. https://chromium.googlesource.com/chromium/blink/+/577b69fc1b03d7da268e8641470ae0cfffda083d Simplifying error recovery in declaration list. Now declaration handles all errors (instead of splitting error hendling among declaration, delaration_list and decl_list). Changed error message when syntax error appear in a property value (now it is reported as invalid property value with whole value quited). Previously it was used only for symantic errors. CSS error filtering moved into frontend in order to make possible to test the change. The place where filtering happen is not the place where other messages are filtered. It needed in order to not affect warning counter (should filtering be moved entirely into ConsoleModel? I think situation when error counter shows 15 messages but console shoow 3 is confusing).
Ryosuke Niwa
Comment 2 2013-06-11 17:31:55 PDT
Media queries: https://chromium.googlesource.com/chromium/blink/+/d5b875f11a5db471daeae47c1721e965a0ea3daf Tokenize "and(" as a FUNCTION in media queries. https://chromium.googlesource.com/chromium/blink/+/74d9c9df922ee4a48c21be86d94c17d2ce19434c Improved parse error handling for CSSMQ. Corrected the grammar for media queries and media query lists. Do recognize "and(" as function tokens. The existing code erroneously split it into "and" and "(" inside media queries. Keep returning 0 instead of "not all" for @-webkit-mediaquery parse errors to avoid that things like deleteMedium("#?:/") delete "not all" queries.
Ryosuke Niwa
Comment 3 2013-06-18 20:53:08 PDT
https://chromium.googlesource.com/chromium/blink/+/c435d057894aeca6a9343ebd53ff17425f506ce5 Using bison's error mechanism rather than NULL pointers for bubbling errors in CSS declaration expressions. https://chromium.googlesource.com/chromium/blink/+/cc3ed50d4fb2679387e9dad6e0a490ee3f887a11 Refactoring CSSGrammar.y.in: exctracting code to filling CSSPasrerValue. https://chromium.googlesource.com/chromium/blink/+/191f694d29f18574c2f08a81963f60a7b6d1ffd4 Generating CSS warnings for @-rule headers. Warnings for the @namespace rule are not generated for now. https://chromium.googlesource.com/chromium/blink/+/f25c395ab80285b59dda7a8df57825ff36b0bc2c Simplifying error recovery in selectors. Like with declarations (https://chromiumcodereview.appspot.com/16387006/) selectors use 2 strategies to handle errors simultaniously: bison's error and returning NULL values. It almost doubles error recovery code and makes it hard to test.
Ryosuke Niwa
Comment 4 2013-06-25 23:13:47 PDT
https://chromium.googlesource.com/chromium/blink/+/5d79ddfcd8492d041bb2e6281d96c01357b1c87d Cleanup in CSSGrammar.y.in Removed lines like "$$ = $1;" because $$ is $1 by default. Removed always-true conditions. Removed trailing whitespaces.
Ryosuke Niwa
Comment 5 2022-08-21 12:25:23 PDT
We've adopted Blink's CSS parser.
Note You need to log in before you can comment on or make changes to this bug.