From a49812cb0740be90963fc6b24a3baceff7936550 Mon Sep 17 00:00:00 2001 From: Tobias Christiansen Date: Sun, 16 May 2021 18:26:17 +0200 Subject: LibWeb: Take border-radius into account when painting borders This applies to thicker borders. When drawing them we now don't chamfer the corner if there is a border-radius present. --- .../Libraries/LibWeb/Painting/BorderPainting.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'Userland') diff --git a/Userland/Libraries/LibWeb/Painting/BorderPainting.cpp b/Userland/Libraries/LibWeb/Painting/BorderPainting.cpp index a5c68f1c36..ba2760d3bf 100644 --- a/Userland/Libraries/LibWeb/Painting/BorderPainting.cpp +++ b/Userland/Libraries/LibWeb/Painting/BorderPainting.cpp @@ -99,10 +99,15 @@ void paint_border(PaintContext& context, BorderEdge edge, const Gfx::FloatRect& float p1_step = 0; float p2_step = 0; + bool has_top_left_radius = !style.border_top_left_radius().is_undefined(); + bool has_top_right_radius = !style.border_top_right_radius().is_undefined(); + bool has_bottom_left_radius = !style.border_bottom_left_radius().is_undefined(); + bool has_bottom_right_radius = !style.border_bottom_right_radius().is_undefined(); + switch (edge) { case BorderEdge::Top: - p1_step = style.border_left().width / (float)int_width; - p2_step = style.border_right().width / (float)int_width; + p1_step = has_top_left_radius ? 0 : style.border_left().width / (float)int_width; + p2_step = has_top_right_radius ? 0 : style.border_right().width / (float)int_width; for (int i = 0; i < int_width; ++i) { draw_line(p1, p2); p1.translate_by(p1_step, 1); @@ -110,8 +115,8 @@ void paint_border(PaintContext& context, BorderEdge edge, const Gfx::FloatRect& } break; case BorderEdge::Right: - p1_step = style.border_top().width / (float)int_width; - p2_step = style.border_bottom().width / (float)int_width; + p1_step = has_top_right_radius ? 0 : style.border_top().width / (float)int_width; + p2_step = has_bottom_right_radius ? 0 : style.border_bottom().width / (float)int_width; for (int i = int_width - 1; i >= 0; --i) { draw_line(p1, p2); p1.translate_by(-1, p1_step); @@ -119,8 +124,8 @@ void paint_border(PaintContext& context, BorderEdge edge, const Gfx::FloatRect& } break; case BorderEdge::Bottom: - p1_step = style.border_left().width / (float)int_width; - p2_step = style.border_right().width / (float)int_width; + p1_step = has_bottom_left_radius ? 0 : style.border_left().width / (float)int_width; + p2_step = has_bottom_right_radius ? 0 : style.border_right().width / (float)int_width; for (int i = int_width - 1; i >= 0; --i) { draw_line(p1, p2); p1.translate_by(p1_step, -1); @@ -128,8 +133,8 @@ void paint_border(PaintContext& context, BorderEdge edge, const Gfx::FloatRect& } break; case BorderEdge::Left: - p1_step = style.border_top().width / (float)int_width; - p2_step = style.border_bottom().width / (float)int_width; + p1_step = has_top_left_radius ? 0 : style.border_top().width / (float)int_width; + p2_step = has_bottom_left_radius ? 0 : style.border_bottom().width / (float)int_width; for (int i = 0; i < int_width; ++i) { draw_line(p1, p2); p1.translate_by(1, p1_step); -- cgit v1.2.3