mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-26 04:35:41 +03:00
LibWeb: Keep StyleProperties animated properties in a HashMap
Instead of a gigantic array with space for every possible CSS property being animated at the same time. This shrinks StyleProperties by 3480 bytes per instance.
This commit is contained in:
parent
dd8504c68d
commit
7be0aed4b6
Notes:
sideshowbarker
2024-07-17 07:43:44 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/7be0aed4b6 Pull-request: https://github.com/SerenityOS/serenity/pull/23626
@ -62,19 +62,17 @@ void StyleProperties::set_property(CSS::PropertyID id, NonnullRefPtr<StyleValue
|
||||
|
||||
void StyleProperties::set_animated_property(CSS::PropertyID id, NonnullRefPtr<StyleValue const> value)
|
||||
{
|
||||
m_animated_property_values[to_underlying(id)] = move(value);
|
||||
m_animated_property_values.set(id, move(value));
|
||||
}
|
||||
|
||||
void StyleProperties::reset_animated_properties()
|
||||
{
|
||||
for (auto& animated_property : m_animated_property_values)
|
||||
animated_property.clear();
|
||||
m_animated_property_values.clear();
|
||||
}
|
||||
|
||||
NonnullRefPtr<StyleValue const> StyleProperties::property(CSS::PropertyID property_id) const
|
||||
{
|
||||
auto animated_value = m_animated_property_values[to_underlying(property_id)];
|
||||
if (animated_value.has_value())
|
||||
if (auto animated_value = m_animated_property_values.get(property_id).value_or(nullptr))
|
||||
return *animated_value;
|
||||
|
||||
auto value = m_property_values[to_underlying(property_id)];
|
||||
@ -85,8 +83,7 @@ NonnullRefPtr<StyleValue const> StyleProperties::property(CSS::PropertyID proper
|
||||
|
||||
RefPtr<StyleValue const> StyleProperties::maybe_null_property(CSS::PropertyID property_id) const
|
||||
{
|
||||
auto animated_value = m_animated_property_values[to_underlying(property_id)];
|
||||
if (animated_value.has_value())
|
||||
if (auto animated_value = m_animated_property_values.get(property_id).value_or(nullptr))
|
||||
return *animated_value;
|
||||
|
||||
auto value = m_property_values[to_underlying(property_id)];
|
||||
|
@ -186,7 +186,7 @@ private:
|
||||
friend class StyleComputer;
|
||||
|
||||
PropertyValues m_property_values;
|
||||
Array<Optional<NonnullRefPtr<StyleValue const>>, to_underlying(CSS::last_property_id) + 1> m_animated_property_values;
|
||||
HashMap<CSS::PropertyID, NonnullRefPtr<StyleValue const>> m_animated_property_values;
|
||||
|
||||
Optional<CSS::Overflow> overflow(CSS::PropertyID) const;
|
||||
Vector<CSS::ShadowData> shadow(CSS::PropertyID, Layout::Node const&) const;
|
||||
|
Loading…
Reference in New Issue
Block a user