From 2a3abf09ff4c3cd6439ba995da5d90c948b931c6 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Fri, 14 Jan 2022 20:18:19 +0000 Subject: [PATCH] LibWeb: Remove BorderRadiusStyleValue::to_length() hack Layout::Node still treats border radii as having a single value instead of horizontal and vertical, but one less hack is nice, and helps with conversion to LengthPercentage. :^) --- Userland/Libraries/LibWeb/CSS/StyleValue.h | 3 --- Userland/Libraries/LibWeb/Layout/Node.cpp | 16 ++++++++-------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Userland/Libraries/LibWeb/CSS/StyleValue.h b/Userland/Libraries/LibWeb/CSS/StyleValue.h index 0e195b84e3..502846a024 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleValue.h +++ b/Userland/Libraries/LibWeb/CSS/StyleValue.h @@ -574,9 +574,6 @@ public: Length const& vertical_radius() const { return m_vertical_radius; } bool is_elliptical() const { return m_is_elliptical; } - // FIXME: Remove this once we support elliptical border-radius in Layout/Node. - virtual Length to_length() const override { return horizontal_radius(); } - virtual String to_string() const override { return String::formatted("{} / {}", m_horizontal_radius.to_string(), m_vertical_radius.to_string()); diff --git a/Userland/Libraries/LibWeb/Layout/Node.cpp b/Userland/Libraries/LibWeb/Layout/Node.cpp index 27dfbeaaf1..b94e987521 100644 --- a/Userland/Libraries/LibWeb/Layout/Node.cpp +++ b/Userland/Libraries/LibWeb/Layout/Node.cpp @@ -341,20 +341,20 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& specified_style) // FIXME: BorderXRadius properties are now BorderRadiusStyleValues, so make use of that. auto border_bottom_left_radius = specified_style.property(CSS::PropertyID::BorderBottomLeftRadius); - if (border_bottom_left_radius.has_value()) - computed_values.set_border_bottom_left_radius(border_bottom_left_radius.value()->to_length()); + if (border_bottom_left_radius.has_value() && border_bottom_left_radius.value()->is_border_radius()) + computed_values.set_border_bottom_left_radius(border_bottom_left_radius.value()->as_border_radius().horizontal_radius()); auto border_bottom_right_radius = specified_style.property(CSS::PropertyID::BorderBottomRightRadius); - if (border_bottom_right_radius.has_value()) - computed_values.set_border_bottom_right_radius(border_bottom_right_radius.value()->to_length()); + if (border_bottom_right_radius.has_value() && border_bottom_right_radius.value()->is_border_radius()) + computed_values.set_border_bottom_right_radius(border_bottom_right_radius.value()->as_border_radius().horizontal_radius()); auto border_top_left_radius = specified_style.property(CSS::PropertyID::BorderTopLeftRadius); - if (border_top_left_radius.has_value()) - computed_values.set_border_top_left_radius(border_top_left_radius.value()->to_length()); + if (border_top_left_radius.has_value() && border_top_left_radius.value()->is_border_radius()) + computed_values.set_border_top_left_radius(border_top_left_radius.value()->as_border_radius().horizontal_radius()); auto border_top_right_radius = specified_style.property(CSS::PropertyID::BorderTopRightRadius); - if (border_top_right_radius.has_value()) - computed_values.set_border_top_right_radius(border_top_right_radius.value()->to_length()); + if (border_top_right_radius.has_value() && border_top_right_radius.value()->is_border_radius()) + computed_values.set_border_top_right_radius(border_top_right_radius.value()->as_border_radius().horizontal_radius()); computed_values.set_display(specified_style.display());