summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorMacDue <macdue@dueutil.tech>2022-07-04 21:08:27 +0100
committerAndreas Kling <kling@serenityos.org>2022-07-04 23:09:06 +0200
commit3600c34c1dbd11cb61f0e09f96195b7464370fa4 (patch)
treefe389950a44370580c954de618a1dad0f24a0f23 /Userland
parent8c8dde59d27f1f756f6816416ebd21c2cbb9ef55 (diff)
downloadserenity-3600c34c1dbd11cb61f0e09f96195b7464370fa4.zip
LibWeb: Support adding a border-radius to <canvas> elements
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/Painting/CanvasPaintable.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/Painting/CanvasPaintable.cpp b/Userland/Libraries/LibWeb/Painting/CanvasPaintable.cpp
index 6699673f31..ea211666b1 100644
--- a/Userland/Libraries/LibWeb/Painting/CanvasPaintable.cpp
+++ b/Userland/Libraries/LibWeb/Painting/CanvasPaintable.cpp
@@ -31,14 +31,17 @@ void CanvasPaintable::paint(PaintContext& context, PaintPhase phase) const
PaintableBox::paint(context, phase);
if (phase == PaintPhase::Foreground) {
+ auto canvas_rect = absolute_rect().to_rounded<int>();
+ ScopedCornerRadiusClip corner_clip { context.painter(), canvas_rect, normalized_border_radii_data() };
+
// FIXME: This should be done at a different level. Also rect() does not include padding etc!
- if (!context.viewport_rect().intersects(enclosing_int_rect(absolute_rect())))
+ if (!context.viewport_rect().intersects(canvas_rect))
return;
if (layout_box().dom_node().bitmap()) {
// FIXME: Remove this const_cast.
const_cast<HTML::HTMLCanvasElement&>(layout_box().dom_node()).present();
- context.painter().draw_scaled_bitmap(absolute_rect().to_rounded<int>(), *layout_box().dom_node().bitmap(), layout_box().dom_node().bitmap()->rect(), 1.0f, to_gfx_scaling_mode(computed_values().image_rendering()));
+ context.painter().draw_scaled_bitmap(canvas_rect, *layout_box().dom_node().bitmap(), layout_box().dom_node().bitmap()->rect(), 1.0f, to_gfx_scaling_mode(computed_values().image_rendering()));
}
}
}