LibWeb/CSS: Correct parsing of @supports selector()

A couple of fixes here:
- Parse a `<complex-selector>` instead of a `<selector-list>`
- Don't match if any unknown `::-webkit-*` pseudo-elements are found
This commit is contained in:
Sam Atkins 2025-03-14 14:37:24 +00:00
parent b6fb4baeb7
commit db597843d6
Notes: github-actions[bot] 2025-03-17 10:01:11 +00:00
8 changed files with 100 additions and 4 deletions

View file

@ -304,9 +304,13 @@ OwnPtr<BooleanExpression> Parser::parse_supports_feature(TokenStream<ComponentVa
builder.append(item.to_string());
transaction.commit();
TokenStream selector_tokens { first_token.function().value };
return Supports::Selector::create(
builder.to_string_without_validation(),
!parse_a_selector_list(selector_tokens, SelectorType::Standalone).is_error());
auto maybe_selector = parse_complex_selector(selector_tokens, SelectorType::Standalone);
// A CSS processor is considered to support a CSS selector if it accepts that all aspects of that selector,
// recursively, (rather than considering any of its syntax to be unknown or invalid) and that selector doesnt
// contain unknown -webkit- pseudo-elements.
// https://drafts.csswg.org/css-conditional-4/#dfn-support-selector
bool matches = !maybe_selector.is_error() && !maybe_selector.value()->contains_unknown_webkit_pseudo_element();
return Supports::Selector::create(builder.to_string_without_validation(), matches);
}
// `<supports-font-tech-fn> = font-tech( <font-tech> )`