mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-13 03:29:49 +00:00
LibWeb: Make StyleProperties::m_property_values a bit smaller
Instead of wrapping every entry in Optional, use the null state of the style pointer for the same purpose. This shrinks StyleProperties by 1752 bytes per instance.
This commit is contained in:
parent
7be0aed4b6
commit
21bfa001b1
Notes:
sideshowbarker
2024-07-17 02:55:44 +09:00
Author: https://github.com/awesomekling
Commit: 21bfa001b1
Pull-request: https://github.com/SerenityOS/serenity/pull/23626
4 changed files with 44 additions and 50 deletions
|
@ -47,12 +47,12 @@ NonnullRefPtr<StyleProperties> StyleProperties::clone() const
|
|||
|
||||
bool StyleProperties::is_property_important(CSS::PropertyID property_id) const
|
||||
{
|
||||
return m_property_values[to_underlying(property_id)].has_value() && m_property_values[to_underlying(property_id)]->important == Important::Yes;
|
||||
return m_property_values[to_underlying(property_id)].style && m_property_values[to_underlying(property_id)].important == Important::Yes;
|
||||
}
|
||||
|
||||
bool StyleProperties::is_property_inherited(CSS::PropertyID property_id) const
|
||||
{
|
||||
return m_property_values[to_underlying(property_id)].has_value() && m_property_values[to_underlying(property_id)]->inherited == Inherited::Yes;
|
||||
return m_property_values[to_underlying(property_id)].style && m_property_values[to_underlying(property_id)].inherited == Inherited::Yes;
|
||||
}
|
||||
|
||||
void StyleProperties::set_property(CSS::PropertyID id, NonnullRefPtr<StyleValue const> value, CSS::CSSStyleDeclaration const* source_declaration, Inherited inherited, Important important)
|
||||
|
@ -75,26 +75,20 @@ NonnullRefPtr<StyleValue const> StyleProperties::property(CSS::PropertyID proper
|
|||
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)];
|
||||
// By the time we call this method, all properties have values assigned.
|
||||
VERIFY(value.has_value());
|
||||
return value->style;
|
||||
return *m_property_values[to_underlying(property_id)].style;
|
||||
}
|
||||
|
||||
RefPtr<StyleValue const> StyleProperties::maybe_null_property(CSS::PropertyID property_id) const
|
||||
{
|
||||
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)];
|
||||
if (value.has_value())
|
||||
return value->style;
|
||||
return {};
|
||||
return m_property_values[to_underlying(property_id)].style;
|
||||
}
|
||||
|
||||
CSS::CSSStyleDeclaration const* StyleProperties::property_source_declaration(CSS::PropertyID property_id) const
|
||||
{
|
||||
return m_property_values[to_underlying(property_id)].map([](auto& value) { return value.declaration; }).value_or(nullptr);
|
||||
return m_property_values[to_underlying(property_id)].declaration;
|
||||
}
|
||||
|
||||
CSS::Size StyleProperties::size_value(CSS::PropertyID id) const
|
||||
|
@ -628,15 +622,15 @@ bool StyleProperties::operator==(StyleProperties const& other) const
|
|||
for (size_t i = 0; i < m_property_values.size(); ++i) {
|
||||
auto const& my_style = m_property_values[i];
|
||||
auto const& other_style = other.m_property_values[i];
|
||||
if (!my_style.has_value()) {
|
||||
if (other_style.has_value())
|
||||
if (!my_style.style) {
|
||||
if (other_style.style)
|
||||
return false;
|
||||
continue;
|
||||
}
|
||||
if (!other_style.has_value())
|
||||
if (!other_style.style)
|
||||
return false;
|
||||
auto const& my_value = *my_style->style;
|
||||
auto const& other_value = *other_style->style;
|
||||
auto const& my_value = *my_style.style;
|
||||
auto const& other_value = *other_style.style;
|
||||
if (my_value.type() != other_value.type())
|
||||
return false;
|
||||
if (my_value != other_value)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue