From e8f04be3aec763d73991d458b883220674dbcdd7 Mon Sep 17 00:00:00 2001 From: Aliaksandr Kalenik Date: Sun, 31 Dec 2023 23:46:59 +0100 Subject: [PATCH] LibWeb/CSS: Fix crashing when calc() is used for border-radius `BorderRadiusStyleValue::absolutized` should not try to extract length from LengthPercentage that represents calculated. --- Tests/LibWeb/Ref/calc-border-radius.html | 20 +++++++++++++++++++ .../Ref/reference/calc-border-radius-ref.html | 19 ++++++++++++++++++ .../StyleValues/BorderRadiusStyleValue.cpp | 4 ++-- 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 Tests/LibWeb/Ref/calc-border-radius.html create mode 100644 Tests/LibWeb/Ref/reference/calc-border-radius-ref.html diff --git a/Tests/LibWeb/Ref/calc-border-radius.html b/Tests/LibWeb/Ref/calc-border-radius.html new file mode 100644 index 0000000000..8f38cf113b --- /dev/null +++ b/Tests/LibWeb/Ref/calc-border-radius.html @@ -0,0 +1,20 @@ + + + + + + + + +
+ + + diff --git a/Tests/LibWeb/Ref/reference/calc-border-radius-ref.html b/Tests/LibWeb/Ref/reference/calc-border-radius-ref.html new file mode 100644 index 0000000000..cb71206cb1 --- /dev/null +++ b/Tests/LibWeb/Ref/reference/calc-border-radius-ref.html @@ -0,0 +1,19 @@ + + + + + + + +
+ + + diff --git a/Userland/Libraries/LibWeb/CSS/StyleValues/BorderRadiusStyleValue.cpp b/Userland/Libraries/LibWeb/CSS/StyleValues/BorderRadiusStyleValue.cpp index 624efa670d..bc17c6a549 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValues/BorderRadiusStyleValue.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleValues/BorderRadiusStyleValue.cpp @@ -24,9 +24,9 @@ ValueComparingNonnullRefPtr BorderRadiusStyleValue::absolutize return *this; auto absolutized_horizontal_radius = m_properties.horizontal_radius; auto absolutized_vertical_radius = m_properties.vertical_radius; - if (!m_properties.horizontal_radius.is_percentage()) + 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_percentage()) + if (m_properties.vertical_radius.is_length()) absolutized_vertical_radius = m_properties.vertical_radius.length().absolutized(viewport_rect, font_metrics, root_font_metrics); return BorderRadiusStyleValue::create(absolutized_horizontal_radius, absolutized_vertical_radius); }