1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:07:35 +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:
Sam Atkins 2021-07-24 21:22:44 +01:00 committed by Andreas Kling
parent 8d0ff98eff
commit 6034fc0ee6
7 changed files with 333 additions and 92 deletions

View file

@ -54,7 +54,7 @@ String Token::to_debug_string() const
case Type::Number:
builder.append("Number: ");
builder.append(m_value.to_string());
builder.append(m_unit.to_string());
builder.append(m_number_type == NumberType::Integer ? " (int)" : " (float)");
return builder.to_string();
case Type::Percentage:
builder.append("Percentage: ");