summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorTobias Christiansen <tobi@tobyase.de>2021-05-16 18:26:17 +0200
committerAndreas Kling <kling@serenityos.org>2021-05-20 22:08:02 +0200
commita49812cb0740be90963fc6b24a3baceff7936550 (patch)
treefc9ad0d61456034a11757e4591e320f1d4c036fd /Userland
parent7a566e54e5bbd271e861f0aaea5a5bd9a701547b (diff)
downloadserenity-a49812cb0740be90963fc6b24a3baceff7936550.zip
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.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/Painting/BorderPainting.cpp21
1 files changed, 13 insertions, 8 deletions
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);