mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-05 23:59:49 +00:00
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:
parent
7aed541ed0
commit
8536e23674
Notes:
github-actions[bot]
2025-05-16 22:31:53 +00:00
Author: https://github.com/AtkinsSJ
Commit: 8536e23674
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4780
7 changed files with 25 additions and 21 deletions
|
@ -812,13 +812,15 @@ static inline bool matches_pseudo_class(CSS::Selector::SimpleSelector::PseudoCla
|
|||
case CSS::PseudoClass::Dir: {
|
||||
// "Values other than ltr and rtl are not invalid, but do not match anything."
|
||||
// - https://www.w3.org/TR/selectors-4/#the-dir-pseudo
|
||||
if (!first_is_one_of(pseudo_class.keyword, CSS::Keyword::Ltr, CSS::Keyword::Rtl))
|
||||
if (!pseudo_class.ident.has_value())
|
||||
return false;
|
||||
if (!first_is_one_of(pseudo_class.ident->keyword, CSS::Keyword::Ltr, CSS::Keyword::Rtl))
|
||||
return false;
|
||||
switch (element.directionality()) {
|
||||
case DOM::Element::Directionality::Ltr:
|
||||
return pseudo_class.keyword == CSS::Keyword::Ltr;
|
||||
return pseudo_class.ident->keyword == CSS::Keyword::Ltr;
|
||||
case DOM::Element::Directionality::Rtl:
|
||||
return pseudo_class.keyword == CSS::Keyword::Rtl;
|
||||
return pseudo_class.ident->keyword == CSS::Keyword::Rtl;
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue