diff --git a/Libraries/LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.cpp b/Libraries/LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.cpp index be7ab21b268..7310b299983 100644 --- a/Libraries/LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.cpp +++ b/Libraries/LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.cpp @@ -26,4 +26,15 @@ String BackgroundSizeStyleValue::to_string(SerializationMode mode) const return MUST(String::formatted("{} {}", m_properties.size_x.to_string(mode), m_properties.size_y.to_string(mode))); } +ValueComparingNonnullRefPtr BackgroundSizeStyleValue::absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const +{ + auto absolutized_size_x = m_properties.size_x.absolutized(viewport_rect, font_metrics, root_font_metrics); + auto absolutized_size_y = m_properties.size_y.absolutized(viewport_rect, font_metrics, root_font_metrics); + + if (absolutized_size_x == m_properties.size_x && absolutized_size_y == m_properties.size_y) + return *this; + + return BackgroundSizeStyleValue::create(absolutized_size_x, absolutized_size_y); +} + } diff --git a/Libraries/LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.h b/Libraries/LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.h index 66a2164049f..2cba228c414 100644 --- a/Libraries/LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.h +++ b/Libraries/LibWeb/CSS/StyleValues/BackgroundSizeStyleValue.h @@ -28,6 +28,7 @@ public: LengthPercentage size_y() const { return m_properties.size_y; } virtual String to_string(SerializationMode) const override; + virtual ValueComparingNonnullRefPtr absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const override; bool properties_equal(BackgroundSizeStyleValue const& other) const { return m_properties == other.m_properties; } diff --git a/Tests/LibWeb/Text/expected/css/absolutized-background-size-value.txt b/Tests/LibWeb/Text/expected/css/absolutized-background-size-value.txt index d61d2080de9..c13b5fc0e57 100644 --- a/Tests/LibWeb/Text/expected/css/absolutized-background-size-value.txt +++ b/Tests/LibWeb/Text/expected/css/absolutized-background-size-value.txt @@ -1 +1 @@ -calc(1em - 1px) calc(1em - 1px) +15px 15px