LibWeb/CSS: Parse an ident in :dir(), not a keyword

The spec requires us to accept any ident here, not just ltr/rtl, and
also serialize it back out. That means we need to keep the original
string around.

In order to not call keyword_from_string() every time we want to match
a :dir() selector, we still attempt to parse the keyword and keep it
around.

A small behaviour change is that now we'll serialize the ident with its
original casing, instead of always lowercase. Chrome and Firefox
disagree on this, so I think either is fine until that can be
officially decided.

Gets us 2 WPT passes (including 1 from the as-yet-unmerged :dir() test).
This commit is contained in:
Sam Atkins 2025-05-16 14:57:18 +01:00 committed by Andreas Kling
commit 8536e23674
Notes: github-actions[bot] 2025-05-16 22:31:53 +00:00
7 changed files with 25 additions and 21 deletions

View file

@ -463,7 +463,7 @@ String Selector::SimpleSelector::serialize() const
s.append(serialize_a_group_of_selectors(pseudo_class.argument_selector_list));
break;
case PseudoClassMetadata::ParameterType::Ident:
s.append(string_from_keyword(pseudo_class.keyword.value()));
s.append(serialize_an_identifier(pseudo_class.ident->string_value));
break;
case PseudoClassMetadata::ParameterType::LanguageRanges:
// The serialization of a comma-separated list of each arguments serialization as a string, preserving relative order.