1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 21:18:14 +00:00

LibWeb: Resolve CSS custom properties on pseudo elements

The resolved property sets are stored with the element in a
per-pseudo-element array (same as for pseudo element layout nodes).

Longer term, we should stop storing this with elements entirely and make
it temporary state in StyleComputer somehow, so we don't waste memory
keeping all the resolved properties around.

This makes various gradients show up on https://shopify.com/ :^)
This commit is contained in:
Andreas Kling 2023-05-17 17:05:36 +02:00
parent 6970f1b6c1
commit fb722e69f3
9 changed files with 170 additions and 29 deletions

View file

@ -1708,4 +1708,20 @@ void Element::set_computed_css_values(RefPtr<CSS::StyleProperties> style)
m_computed_css_values = move(style);
}
void Element::set_custom_properties(Optional<CSS::Selector::PseudoElement> pseudo_element, HashMap<DeprecatedFlyString, CSS::StyleProperty> custom_properties)
{
if (!pseudo_element.has_value()) {
m_custom_properties = move(custom_properties);
return;
}
m_pseudo_element_custom_properties[to_underlying(pseudo_element.value())] = move(custom_properties);
}
HashMap<DeprecatedFlyString, CSS::StyleProperty> const& Element::custom_properties(Optional<CSS::Selector::PseudoElement> pseudo_element) const
{
if (!pseudo_element.has_value())
return m_custom_properties;
return m_pseudo_element_custom_properties[to_underlying(pseudo_element.value())];
}
}