From c49afd7b28737fb5a05d2238304c07f742afbd47 Mon Sep 17 00:00:00 2001 From: Callum Law Date: Mon, 4 Aug 2025 21:13:42 +1200 Subject: [PATCH] LibWeb: Absolutize LengthPercentage members of BorderRadiusStyleValues --- .../CSS/StyleValues/BorderRadiusStyleValue.cpp | 12 ++++-------- .../parsing/border-radius-computed.txt | 6 +++--- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Libraries/LibWeb/CSS/StyleValues/BorderRadiusStyleValue.cpp b/Libraries/LibWeb/CSS/StyleValues/BorderRadiusStyleValue.cpp index 2d06ddfde35..342365b8926 100644 --- a/Libraries/LibWeb/CSS/StyleValues/BorderRadiusStyleValue.cpp +++ b/Libraries/LibWeb/CSS/StyleValues/BorderRadiusStyleValue.cpp @@ -20,16 +20,12 @@ String BorderRadiusStyleValue::to_string(SerializationMode mode) const ValueComparingNonnullRefPtr 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()) - return *this; - 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); + auto absolutized_horizontal_radius = m_properties.horizontal_radius.absolutized(viewport_rect, font_metrics, root_font_metrics); + auto absolutized_vertical_radius = m_properties.vertical_radius.absolutized(viewport_rect, font_metrics, root_font_metrics); + if (absolutized_vertical_radius == m_properties.vertical_radius && absolutized_horizontal_radius == m_properties.horizontal_radius) return *this; + return BorderRadiusStyleValue::create(absolutized_horizontal_radius, absolutized_vertical_radius); } diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-backgrounds/parsing/border-radius-computed.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-backgrounds/parsing/border-radius-computed.txt index e2dbd0f858e..02907f80c75 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/css-backgrounds/parsing/border-radius-computed.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-backgrounds/parsing/border-radius-computed.txt @@ -2,8 +2,8 @@ Harness status: OK Found 14 tests -12 Pass -2 Fail +13 Pass +1 Fail Pass Property border-radius value '1px' Pass Property border-radius value '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%' Fail Property border-top-left-radius value 'calc(-0.5em + 10px)' 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-top-left-radius value '40px 0px' \ No newline at end of file