LibWeb: Apply clip rect before painting images

Previously, the clip property was ignored when painting images.
This commit is contained in:
Tim Ledbetter 2025-06-23 14:06:56 +01:00 committed by Sam Atkins
commit 2ff9e1d038
Notes: github-actions[bot] 2025-06-24 11:57:59 +00:00
2 changed files with 16 additions and 0 deletions

View file

@ -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);
}
}
}

View file

@ -0,0 +1,14 @@
<!DOCTYPE html>
<link rel="match" href="../../../../Assets/blank.html" />
<style>
img {
position: absolute;
clip: rect(0px, 0px, 0px, 0px)
}
.translated {
translate: 120px 120px;
}
</style>
<div>blank page</div>
<img alt="This shouldn't be visible" src="../../../../Assets/120.png">
<img class="translated" alt="This also shouldn't be visible" src="../../../../Assets/120.png">