mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:17:45 +00:00
LibWeb: Allocate storage for pseudo element custom properties on demand
Most elements don't have pseudo elements with CSS custom properties. By only allocating this data structure when it's used, we can shrink most elements by 208 bytes each. :^)
This commit is contained in:
parent
9edfd5e360
commit
37505d9746
2 changed files with 13 additions and 3 deletions
|
@ -2050,20 +2050,27 @@ void Element::set_computed_css_values(RefPtr<CSS::StyleProperties> style)
|
|||
m_computed_css_values = move(style);
|
||||
}
|
||||
|
||||
auto Element::pseudo_element_custom_properties() const -> PseudoElementCustomProperties&
|
||||
{
|
||||
if (!m_pseudo_element_custom_properties)
|
||||
m_pseudo_element_custom_properties = make<PseudoElementCustomProperties>();
|
||||
return *m_pseudo_element_custom_properties;
|
||||
}
|
||||
|
||||
void Element::set_custom_properties(Optional<CSS::Selector::PseudoElement> pseudo_element, HashMap<FlyString, 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);
|
||||
pseudo_element_custom_properties()[to_underlying(pseudo_element.value())] = move(custom_properties);
|
||||
}
|
||||
|
||||
HashMap<FlyString, 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())];
|
||||
return pseudo_element_custom_properties()[to_underlying(pseudo_element.value())];
|
||||
}
|
||||
|
||||
// https://drafts.csswg.org/cssom-view/#dom-element-scroll
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue