mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-16 13:09:41 +00:00
LibWeb: Store BackgroundSizeStyleValue
sub-values directly
Storing these within LengthPercentage is unnecessary
This commit is contained in:
parent
309ff33278
commit
2ebf446cbf
Notes:
github-actions[bot]
2025-10-07 09:51:23 +00:00
Author: https://github.com/Calme1709
Commit: 2ebf446cbf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6375
Reviewed-by: https://github.com/AtkinsSJ ✅
5 changed files with 21 additions and 52 deletions
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
BackgroundSizeStyleValue::BackgroundSizeStyleValue(LengthPercentageOrAuto size_x, LengthPercentageOrAuto size_y)
|
||||
BackgroundSizeStyleValue::BackgroundSizeStyleValue(ValueComparingNonnullRefPtr<StyleValue const> size_x, ValueComparingNonnullRefPtr<StyleValue const> size_y)
|
||||
: StyleValueWithDefaultOperators(Type::BackgroundSize)
|
||||
, m_properties { .size_x = move(size_x), .size_y = move(size_y) }
|
||||
{
|
||||
|
@ -21,21 +21,15 @@ BackgroundSizeStyleValue::~BackgroundSizeStyleValue() = default;
|
|||
|
||||
String BackgroundSizeStyleValue::to_string(SerializationMode mode) const
|
||||
{
|
||||
if (m_properties.size_x.is_auto() && m_properties.size_y.is_auto())
|
||||
if (m_properties.size_x->has_auto() && m_properties.size_y->has_auto())
|
||||
return "auto"_string;
|
||||
return MUST(String::formatted("{} {}", m_properties.size_x.to_string(mode), m_properties.size_y.to_string(mode)));
|
||||
return MUST(String::formatted("{} {}", m_properties.size_x->to_string(mode), m_properties.size_y->to_string(mode)));
|
||||
}
|
||||
|
||||
ValueComparingNonnullRefPtr<StyleValue const> BackgroundSizeStyleValue::absolutized(ComputationContext const& computation_context) const
|
||||
{
|
||||
auto absolutize = [&](auto& size) -> LengthPercentageOrAuto {
|
||||
if (size.is_auto())
|
||||
return size;
|
||||
return size.length_percentage().absolutized(computation_context);
|
||||
};
|
||||
|
||||
auto absolutized_size_x = absolutize(m_properties.size_x);
|
||||
auto absolutized_size_y = absolutize(m_properties.size_y);
|
||||
auto absolutized_size_x = m_properties.size_x->absolutized(computation_context);
|
||||
auto absolutized_size_y = m_properties.size_y->absolutized(computation_context);
|
||||
|
||||
if (absolutized_size_x == m_properties.size_x && absolutized_size_y == m_properties.size_y)
|
||||
return *this;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue