mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 18:18:12 +00: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:
parent
8d0ff98eff
commit
6034fc0ee6
7 changed files with 333 additions and 92 deletions
|
@ -47,11 +47,11 @@ u32 Selector::specificity() const
|
|||
return ids * 0x10000 + classes * 0x100 + tag_names;
|
||||
}
|
||||
|
||||
Selector::SimpleSelector::NthChildPattern Selector::SimpleSelector::NthChildPattern::parse(StringView const& args)
|
||||
Selector::SimpleSelector::ANPlusBPattern Selector::SimpleSelector::ANPlusBPattern::parse(StringView const& args)
|
||||
{
|
||||
// FIXME: Remove this when the DeprecatedCSSParser is gone.
|
||||
// The new Parser::parse_nth_child_pattern() does the same as this, using Tokens.
|
||||
CSS::Selector::SimpleSelector::NthChildPattern pattern;
|
||||
CSS::Selector::SimpleSelector::ANPlusBPattern pattern;
|
||||
if (args.equals_ignoring_case("odd")) {
|
||||
pattern.step_size = 2;
|
||||
pattern.offset = 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue