1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:47:45 +00:00

LibWeb: Perform CSS custom property cascade once instead of per-property

Previously we would re-run the entire CSS selector machinery for each
property resolved. Instead of doing that, we now resolve a final set of
custom property key/value pairs at the start of the cascade.
This commit is contained in:
Andreas Kling 2022-02-10 17:04:31 +01:00
parent b248661f11
commit 8d104b7de2
4 changed files with 53 additions and 71 deletions

View file

@ -111,15 +111,13 @@ public:
const ShadowRoot* shadow_root() const { return m_shadow_root; }
void set_shadow_root(RefPtr<ShadowRoot>);
Optional<CSS::StyleComputer::CustomPropertyResolutionTuple> resolve_custom_property(const String& custom_property_name) const
void add_custom_property(String custom_property_name, CSS::StyleProperty style_property)
{
return m_custom_properties.get(custom_property_name);
m_custom_properties.set(move(custom_property_name), move(style_property));
}
void add_custom_property(const String& custom_property_name, CSS::StyleComputer::CustomPropertyResolutionTuple style_property)
{
m_custom_properties.set(custom_property_name, style_property);
}
HashMap<String, CSS::StyleComputer::CustomPropertyResolutionTuple> const& custom_properties() const { return m_custom_properties; }
HashMap<String, CSS::StyleProperty> const& custom_properties() const { return m_custom_properties; }
HashMap<String, CSS::StyleProperty>& custom_properties() { return m_custom_properties; }
void queue_an_element_task(HTML::Task::Source, Function<void()>);
@ -146,7 +144,7 @@ private:
RefPtr<CSS::CSSStyleDeclaration> m_inline_style;
RefPtr<CSS::StyleProperties> m_specified_css_values;
HashMap<String, CSS::StyleComputer::CustomPropertyResolutionTuple> m_custom_properties;
HashMap<String, CSS::StyleProperty> m_custom_properties;
RefPtr<DOMTokenList> m_class_list;
Vector<FlyString> m_classes;