LibWeb: Absolutize LengthPercentage members of BorderRadiusStyleValues

This commit is contained in:
Callum Law 2025-08-04 21:13:42 +12:00 committed by Sam Atkins
commit c49afd7b28
Notes: github-actions[bot] 2025-08-06 16:45:40 +00:00
2 changed files with 7 additions and 11 deletions

View file

@ -20,16 +20,12 @@ String BorderRadiusStyleValue::to_string(SerializationMode mode) const
ValueComparingNonnullRefPtr<CSSStyleValue const> BorderRadiusStyleValue::absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const ValueComparingNonnullRefPtr<CSSStyleValue const> BorderRadiusStyleValue::absolutized(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const
{ {
if (m_properties.horizontal_radius.is_percentage() && m_properties.vertical_radius.is_percentage()) auto absolutized_horizontal_radius = m_properties.horizontal_radius.absolutized(viewport_rect, font_metrics, root_font_metrics);
return *this; auto absolutized_vertical_radius = m_properties.vertical_radius.absolutized(viewport_rect, font_metrics, root_font_metrics);
auto absolutized_horizontal_radius = m_properties.horizontal_radius;
auto absolutized_vertical_radius = m_properties.vertical_radius;
if (m_properties.horizontal_radius.is_length())
absolutized_horizontal_radius = m_properties.horizontal_radius.length().absolutized(viewport_rect, font_metrics, root_font_metrics);
if (m_properties.vertical_radius.is_length())
absolutized_vertical_radius = m_properties.vertical_radius.length().absolutized(viewport_rect, font_metrics, root_font_metrics);
if (absolutized_vertical_radius == m_properties.vertical_radius && absolutized_horizontal_radius == m_properties.horizontal_radius) if (absolutized_vertical_radius == m_properties.vertical_radius && absolutized_horizontal_radius == m_properties.horizontal_radius)
return *this; return *this;
return BorderRadiusStyleValue::create(absolutized_horizontal_radius, absolutized_vertical_radius); return BorderRadiusStyleValue::create(absolutized_horizontal_radius, absolutized_vertical_radius);
} }

View file

@ -2,8 +2,8 @@ Harness status: OK
Found 14 tests Found 14 tests
12 Pass 13 Pass
2 Fail 1 Fail
Pass Property border-radius value '1px' Pass Property border-radius value '1px'
Pass Property border-radius value '1px 2% 3px 4%' Pass Property border-radius value '1px 2% 3px 4%'
Pass Property border-radius value '5em / 1px 2% 3px 4%' Pass Property border-radius value '5em / 1px 2% 3px 4%'
@ -15,6 +15,6 @@ Pass Property border-radius value '1px 2% 1px 1px'
Pass Property border-radius value '1px 2% 2% 2% / 1px 2% 3px 2%' Pass Property border-radius value '1px 2% 2% 2% / 1px 2% 3px 2%'
Fail Property border-top-left-radius value 'calc(-0.5em + 10px)' Fail Property border-top-left-radius value 'calc(-0.5em + 10px)'
Pass Property border-top-right-radius value '20%' Pass Property border-top-right-radius value '20%'
Fail Property border-bottom-right-radius value 'calc(0.5em + 10px) 40%' Pass Property border-bottom-right-radius value 'calc(0.5em + 10px) 40%'
Pass Property border-bottom-left-radius value '50% 60px' Pass Property border-bottom-left-radius value '50% 60px'
Pass Property border-top-left-radius value '40px 0px' Pass Property border-top-left-radius value '40px 0px'