ladybird/Libraries/LibWeb/CSS/Parser
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
..
ArbitrarySubstitutionFunctions.cpp LibWeb: Implement CSS inherit() function 2026-03-19 10:25:37 +01:00
ArbitrarySubstitutionFunctions.h LibWeb: Implement CSS inherit() function 2026-03-19 10:25:37 +01:00
ComponentValue.cpp LibWeb/CSS: Include guaranteed-invalid value in ComponentValue 2025-07-09 16:44:20 +01:00
ComponentValue.h LibWeb: Enable EXPLICIT_SYMBOL_EXPORT 2025-08-23 16:04:36 -06:00
DescriptorParsing.cpp LibWeb/CSS: Parse @font-face { font-weight } with two values 2026-02-24 10:05:09 +00:00
Dimension.h LibWeb/CSS: Add Parser::Dimension::to_string() 2024-12-18 12:21:22 +00:00
ErrorReporter.cpp WebContent+LibWeb/CSS: Add debug request to dump CSS errors 2025-08-04 10:50:09 +01:00
ErrorReporter.h LibWeb: Enable EXPLICIT_SYMBOL_EXPORT 2025-08-23 16:04:36 -06:00
GradientParsing.cpp LibWeb: Use generic <color-interpolation-method> parsing for gradients 2026-03-18 13:21:57 +00:00
Helpers.cpp LibWeb/CSS: Make CSSImportRule.media return its own MediaList 2025-12-08 13:30:53 +00:00
MediaParsing.cpp LibWeb: Lift parentheses parsing out of <media-feature> 2026-03-09 14:36:18 +00:00
Parser.cpp LibWeb: Skip declaration parsing in block contents when not applicable 2026-03-23 09:28:23 +01:00
Parser.h LibWeb: Use generic <color-interpolation-method> parsing for gradients 2026-03-18 13:21:57 +00:00
PropertyParsing.cpp LibWeb: Handle trailing whitespace in display value parsing 2026-03-21 21:42:44 -05:00
RuleContext.cpp LibWeb: Parse @font-feature-values at-rule 2026-02-17 12:25:27 +00:00
RuleContext.h LibWeb: Parse @font-feature-values at-rule 2026-02-17 12:25:27 +00:00
RuleParsing.cpp LibWeb: Add predefined @counter-styles to UA stylesheet 2026-02-23 11:21:09 +00:00
SelectorParsing.cpp LibWeb/CSS: Support legacy selector aliases for pseudo-classes 2025-12-18 14:50:27 +01:00
Syntax.cpp LibWeb: Include PropertyID.h in fewer header files 2025-10-27 14:50:54 +00:00
Syntax.h LibWeb: Include PropertyID.h in fewer header files 2025-10-27 14:50:54 +00:00
SyntaxParsing.cpp LibWeb: Include PropertyID.h in fewer header files 2025-10-27 14:50:54 +00:00
SyntaxParsing.h LibWeb: Enable EXPLICIT_SYMBOL_EXPORT 2025-08-23 16:04:36 -06:00
Token.cpp LibWeb/CSS: Construct all CSS Tokens in a consistent way 2025-07-09 15:04:57 +01:00
Token.h LibWeb: Enable EXPLICIT_SYMBOL_EXPORT 2025-08-23 16:04:36 -06:00
Tokenizer.cpp LibWeb: Include "url(" in the original source text of URL tokens 2025-12-10 20:50:02 +01:00
Tokenizer.h LibWeb: Include "url(" in the original source text of URL tokens 2025-12-10 20:50:02 +01:00
TokenStream.h LibWeb/CSS: Expose consumed tokens from TokenStream 2025-12-02 09:49:23 +00:00
Types.cpp LibWeb: Implement CSS inherit() function 2026-03-19 10:25:37 +01:00
Types.h LibWeb: Implement CSS inherit() function 2026-03-19 10:25:37 +01:00
ValueParsing.cpp LibWeb: Remove outdated FIXME about path() in basic-shape parser 2026-03-21 02:44:49 +00:00