mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibWeb: Normalize negative drawImage() source/destination dimensions
This commit is contained in:
parent
e93f44112d
commit
976912f3e9
Notes:
github-actions[bot]
2025-10-22 10:30:20 +00:00
Author: https://github.com/tcl3
Commit: 976912f3e9
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6543
Reviewed-by: https://github.com/gmta ✅
10 changed files with 539 additions and 0 deletions
|
|
@ -171,6 +171,22 @@ WebIDL::ExceptionOr<void> CanvasRenderingContext2D::draw_image_internal(CanvasIm
|
|||
// The source rectangle is the rectangle whose corners are the four points (sx, sy), (sx+sw, sy), (sx+sw, sy+sh), (sx, sy+sh).
|
||||
// The destination rectangle is the rectangle whose corners are the four points (dx, dy), (dx+dw, dy), (dx+dw, dy+dh), (dx, dy+dh).
|
||||
// NOTE: Implemented in drawImage() overloads
|
||||
if (source_width < 0) {
|
||||
source_x += source_width;
|
||||
source_width = abs(source_width);
|
||||
}
|
||||
if (source_height < 0) {
|
||||
source_y += source_height;
|
||||
source_height = abs(source_height);
|
||||
}
|
||||
if (destination_width < 0) {
|
||||
destination_x += destination_width;
|
||||
destination_width = abs(destination_width);
|
||||
}
|
||||
if (destination_height < 0) {
|
||||
destination_y += destination_height;
|
||||
destination_height = abs(destination_height);
|
||||
}
|
||||
|
||||
// The source rectangle is the rectangle whose corners are the four points (sx, sy), (sx+sw, sy), (sx+sw, sy+sh), (sx, sy+sh).
|
||||
auto source_rect = Gfx::FloatRect { source_x, source_y, source_width, source_height };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue