[css-nesting] Keep parsing after {}-block for rules with invalid selector
When encountering a rule with an invalid selector, we currently recover
by consuming until the next semicolon, which isn't correct. Instead,
we should simply do nothing, and keep parsing right after the {}-block.
The spec used to be less clear about this, but at least at the time
of writing, nothing invokes the skip-until-semicolon behavior except
for rule preludes that look like custom properties.
This CL fixes this issue by adding a invalid_rule_error
out-param
to ConsumeStyleRule. There are two other things that are worth noting:
- The "consume a qualified rule" algorithm in the spec mentions
anested
flag which modifies its behavior. This flag is
actually equivalent tosemicolon_aborts_nested_selector
in our parser, so I've renamed this. - During handling of
custom_property_ambiguity
, nested=false case,
we're supposed to consume a block, and do nothing.
This can't be tested using CSSParserImpl's public API, since
failing to consume a block there would just cause the next attempt
at parsing a rule to consume an empty prelude (then the block).
But I don't think we should rely on that, hence I'm using unit
tests to cover that line.
[1] https://drafts.csswg.org/css-syntax/#consume-qualified-rule
Test: external/wpt/css/css-syntax/custom-property-rule-ambiguity.html
Change-Id: I04dc0c3745be5eafe792fd6c40971545274d9794
Fixed: 343979378
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5881815
Commit-Queue: Anders Hartvoll Ruud andruud@chromium.org
Reviewed-by: Steinar H Gunderson sesse@chromium.org
Cr-Commit-Position: refs/heads/main@{#1359288}