ladybird/Libraries/LibWeb/CSS/Parser
Sam Atkins 4edafb35cd LibWeb/CSS: Use PendingSubstitutionValue for unresolved shorthands
Previously, we would just assign the UnresolvedStyleValue to each
longhand, which was completely wrong but happened to work if it was a
ShorthandStyleValue (because that's basically a list of "set property X
to Y", and doesn't care which property it's the value of).

For example, the included `var-in-margin-shorthand.html` test would:
1. Set `margin-top` to `var(--a) 10px`
2. Resolve it to `margin-top: 5px 10px`
3. Reject that as invalid

What now happens is:
1. Set `margin-top` to a PendingSubstitutionValue
2. Resolve `margin` to `5px 10px`
3. Expand that out into its longhands
4. `margin-top` is `5px` 🎉

In order to support this, `for_each_property_expanding_shorthands()` now
runs the callback for the shorthand too if it's an unresolved or
pending-substitution value. This is so that we can store those in the
CascadedProperties until they can be resolved - otherwise, by the time
we want to resolve them, we don't have them any more.

`cascade_declarations()` has an unfortunate hack: it tracks, for each
declaration, which properties have already been given values, so that
it can avoid overwriting an actual value with a pending one. This is
necessary because of the unfortunate way that CSSStyleProperties holds
expanded longhands, and not just the original declarations. The spec
disagrees with itself about this, but we do need to do that expansion
for `element.style` to work correctly. This HashTable is unfortunate
but it does solve the problem until a better solution can be found.
2025-05-14 11:46:47 +01:00
..
ComponentValue.cpp Everywhere: Hoist the Libraries folder to the top-level 2024-11-10 12:50:45 +01:00
ComponentValue.h Meta: Enforce newlines around namespaces 2025-05-14 02:01:59 -06:00
DescriptorParsing.cpp LibWeb: Make storage of CSS::StyleValues const-correct 2025-04-16 10:41:44 -06:00
Dimension.h LibWeb/CSS: Add Parser::Dimension::to_string() 2024-12-18 12:21:22 +00:00
GradientParsing.cpp LibWeb: Make storage of CSS::StyleValues const-correct 2025-04-16 10:41:44 -06:00
Helpers.cpp LibWeb/CSS: Combine the CSSRuleList constructors 2025-04-23 10:55:45 +01:00
MediaParsing.cpp LibWeb/CSS: Combine the CSSRuleList constructors 2025-04-23 10:55:45 +01:00
Parser.cpp LibWeb/CSS: Remove URL parameter to the CSS Parser 2025-05-03 12:01:43 +01:00
Parser.h Meta: Enforce newlines around namespaces 2025-05-14 02:01:59 -06:00
PropertyParsing.cpp LibWeb: Parse and propagate touch-action CSS property 2025-05-06 12:22:01 +01:00
RuleContext.cpp LibWeb/CSS: Move RuleContext type out of Parser.h 2025-04-23 10:55:45 +01:00
RuleContext.h LibWeb/CSS: Move RuleContext type out of Parser.h 2025-04-23 10:55:45 +01:00
RuleParsing.cpp LibWeb/CSS: Move RuleContext type out of Parser.h 2025-04-23 10:55:45 +01:00
SelectorParsing.cpp LibWeb: Implement functional pseudo-element parsing 2025-03-25 07:54:13 +00:00
Token.cpp Everywhere: Hoist the Libraries folder to the top-level 2024-11-10 12:50:45 +01:00
Token.h Everywhere: Hoist the Libraries folder to the top-level 2024-11-10 12:50:45 +01:00
Tokenizer.cpp LibWeb: Treat CSS at-rule names as case-insensitive 2025-03-10 12:42:57 +01:00
Tokenizer.h Meta: Enforce newlines around namespaces 2025-05-14 02:01:59 -06:00
TokenStream.h LibWeb/CSS: Make CSS Parser non-copyable/movable 2025-02-06 16:47:25 +00:00
Types.cpp LibWeb/CSS: Move functions for detecting var()/attr() into Token types 2025-03-28 09:15:02 +00:00
Types.h LibWeb/CSS: Move functions for detecting var()/attr() into Token types 2025-03-28 09:15:02 +00:00
ValueParsing.cpp LibWeb/CSS: Use PendingSubstitutionValue for unresolved shorthands 2025-05-14 11:46:47 +01:00