Browse Source

LibWeb: Add .shrink() to BorderRadiusData and BorderRadiiData

MacDue 3 năm trước cách đây
mục cha
commit
0070c28714

+ 14 - 0
Userland/Libraries/LibWeb/Painting/BorderPainting.h

@@ -28,6 +28,12 @@ struct BorderRadiusData {
     {
     {
         return static_cast<int>(horizontal_radius) > 0 && static_cast<int>(vertical_radius) > 0;
         return static_cast<int>(horizontal_radius) > 0 && static_cast<int>(vertical_radius) > 0;
     }
     }
+
+    inline void shrink(float horizontal, float vertical)
+    {
+        horizontal_radius = max(0, horizontal_radius - horizontal);
+        vertical_radius = max(0, vertical_radius - vertical);
+    }
 };
 };
 
 
 struct BorderRadiiData {
 struct BorderRadiiData {
@@ -40,6 +46,14 @@ struct BorderRadiiData {
     {
     {
         return top_left || top_right || bottom_right || bottom_left;
         return top_left || top_right || bottom_right || bottom_left;
     }
     }
+
+    inline void shrink(float top, float right, float bottom, float left)
+    {
+        top_left.shrink(left, top);
+        top_right.shrink(right, top);
+        bottom_right.shrink(right, bottom);
+        bottom_left.shrink(left, bottom);
+    }
 };
 };
 
 
 BorderRadiiData normalized_border_radii_data(Layout::Node const&, Gfx::FloatRect const&, CSS::BorderRadiusData top_left_radius, CSS::BorderRadiusData top_right_radius, CSS::BorderRadiusData bottom_right_radius, CSS::BorderRadiusData bottom_left_radius);
 BorderRadiiData normalized_border_radii_data(Layout::Node const&, Gfx::FloatRect const&, CSS::BorderRadiusData top_left_radius, CSS::BorderRadiusData top_right_radius, CSS::BorderRadiusData bottom_right_radius, CSS::BorderRadiusData bottom_left_radius);