Files
ladybird/Libraries/LibWeb/CSS
Andreas Kling a5db4c874e LibWeb: Skip declaration parsing in block contents when not applicable
When parsing block contents, the CSS parser speculatively tries to parse
each item as a declaration first. If that fails, it restores the token
position and tries again as a qualified rule. This means every qualified
rule inside an at-rule block (e.g. @layer, @media) gets parsed twice:
once as a failed declaration (which consumes all tokens via
consume_the_remnants_of_a_bad_declaration), and then again successfully
as a rule.

Add a lookahead that checks for the `ident whitespace* ':'` pattern
before attempting declaration parsing. Since declarations must start
with this pattern per spec, we can skip the attempt entirely when it
doesn't match and go straight to qualified rule parsing.

This is a massive win on large Tailwind CSS stylesheets (like the one
used by chatgpt.com) where thousands of rules inside @layer blocks were
being double-parsed. On a 1.2MB Tailwind v4 stylesheet, parse time goes
from ~2000ms to ~95ms (21x speedup).
2026-03-23 09:28:23 +01:00
..
2025-09-24 12:27:05 +01:00
2025-09-24 12:27:05 +01:00
2025-09-24 12:27:05 +01:00
2025-09-24 12:27:05 +01:00
2025-09-24 12:27:05 +01:00
2026-02-18 08:02:45 -05:00
2026-02-18 08:02:45 -05:00
2026-02-18 08:02:45 -05:00