From 2ff9e1d038185c5a476d0fe5f103ff1b25b1ea95 Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Mon, 23 Jun 2025 14:06:56 +0100 Subject: [PATCH] LibWeb: Apply clip rect before painting images Previously, the clip property was ignored when painting images. --- Libraries/LibWeb/Painting/ImagePaintable.cpp | 2 ++ .../Ref/input/css/css-masking/clip-image.html | 14 ++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 Tests/LibWeb/Ref/input/css/css-masking/clip-image.html diff --git a/Libraries/LibWeb/Painting/ImagePaintable.cpp b/Libraries/LibWeb/Painting/ImagePaintable.cpp index 034f9e7c7b9..0ec5ef2c755 100644 --- a/Libraries/LibWeb/Painting/ImagePaintable.cpp +++ b/Libraries/LibWeb/Painting/ImagePaintable.cpp @@ -152,7 +152,9 @@ void ImagePaintable::paint(PaintContext& context, PaintPhase phase) const context.rounded_device_pixels(scaled_bitmap_height).value() }; + apply_own_clip_rect(context, phase); context.display_list_recorder().draw_scaled_immutable_bitmap(draw_rect, image_int_rect_device_pixels, *bitmap, scaling_mode); + clear_own_clip_rect(context, phase); } } } diff --git a/Tests/LibWeb/Ref/input/css/css-masking/clip-image.html b/Tests/LibWeb/Ref/input/css/css-masking/clip-image.html new file mode 100644 index 00000000000..16b7b55da62 --- /dev/null +++ b/Tests/LibWeb/Ref/input/css/css-masking/clip-image.html @@ -0,0 +1,14 @@ + + + +
blank page
+This shouldn't be visible +This also shouldn't be visible