Ver código fonte

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. :^)
Sam Atkins 3 anos atrás
pai
commit
2a3abf09ff

+ 0 - 3
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());

+ 8 - 8
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());