LibWeb: Absolutize BackgroundSizeSVs in StyleComputer::absolutize_values

This commit is contained in:
Callum Law 2025-08-04 21:12:26 +12:00 committed by Sam Atkins
commit 315f811d69
Notes: github-actions[bot] 2025-08-06 16:45:47 +00:00
3 changed files with 13 additions and 1 deletions

View file

@ -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<CSSStyleValue const> 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);
}
}

View file

@ -28,6 +28,7 @@ public:
LengthPercentage size_y() const { return m_properties.size_y; }
virtual String to_string(SerializationMode) const override;
virtual ValueComparingNonnullRefPtr<CSSStyleValue const> 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; }

View file

@ -1 +1 @@
calc(1em - 1px) calc(1em - 1px)
15px 15px