mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 18:17:22 +02:00
LibWeb: Make CSS 'An+B' parsing spec-compliant
Parsing this pattern from CSS tokens turns out to be slightly crazy, but thankfully well documented in the spec. The spec lists the cases in order of simple -> complicated, but this would cause problems in code, since `<n-dimension> <signed-.integer>` would never by reached, as `<n-dimension>` comes before. Instead, I have grouped them by their first token. Also renamed the NthChildPattern class to ANPlusBPattern, to match spec terminology.
This commit is contained in:
committed by
Andreas Kling
parent
8d0ff98eff
commit
6034fc0ee6
Notes:
sideshowbarker
2024-07-18 07:42:39 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/6034fc0ee68 Pull-request: https://github.com/SerenityOS/serenity/pull/9073 Reviewed-by: https://github.com/TobyAsE Reviewed-by: https://github.com/alimpfard
@@ -1046,10 +1046,10 @@ public:
|
||||
pseudo_class.type = CSS::Selector::SimpleSelector::PseudoClass::Type::LastOfType;
|
||||
} else if (pseudo_name.starts_with("nth-child", CaseSensitivity::CaseInsensitive)) {
|
||||
pseudo_class.type = CSS::Selector::SimpleSelector::PseudoClass::Type::NthChild;
|
||||
pseudo_class.nth_child_pattern = CSS::Selector::SimpleSelector::NthChildPattern::parse(capture_selector_args(pseudo_name));
|
||||
pseudo_class.nth_child_pattern = CSS::Selector::SimpleSelector::ANPlusBPattern::parse(capture_selector_args(pseudo_name));
|
||||
} else if (pseudo_name.starts_with("nth-last-child", CaseSensitivity::CaseInsensitive)) {
|
||||
pseudo_class.type = CSS::Selector::SimpleSelector::PseudoClass::Type::NthLastChild;
|
||||
pseudo_class.nth_child_pattern = CSS::Selector::SimpleSelector::NthChildPattern::parse(capture_selector_args(pseudo_name));
|
||||
pseudo_class.nth_child_pattern = CSS::Selector::SimpleSelector::ANPlusBPattern::parse(capture_selector_args(pseudo_name));
|
||||
} else if (pseudo_name.equals_ignoring_case("before")) {
|
||||
simple_selector.pseudo_element = CSS::Selector::SimpleSelector::PseudoElement::Before;
|
||||
} else if (pseudo_name.equals_ignoring_case("after")) {
|
||||
|
||||
Reference in New Issue
Block a user