mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Correct the calculation of rects for drawimage.
This commit is contained in:
parent
713f18a58d
commit
a512e9e507
4 changed files with 4 additions and 19 deletions
|
@ -140,8 +140,8 @@ impl CanvasRenderingContext2D {
|
|||
|
||||
// The source rectangle is the rectangle whose corners are the four points (sx, sy),
|
||||
// (sx+sw, sy), (sx+sw, sy+sh), (sx, sy+sh).
|
||||
let source_rect = Rect(Point2D(sx, sy),
|
||||
Size2D(sw, sh));
|
||||
let source_rect = Rect(Point2D(sx.min(sx+sw), sy.min(sy+sh)),
|
||||
Size2D(sw.abs(), sh.abs()));
|
||||
|
||||
// When the source rectangle is outside the source image,
|
||||
// the source rectangle must be clipped to the source image
|
||||
|
@ -158,8 +158,8 @@ impl CanvasRenderingContext2D {
|
|||
|
||||
// The destination rectangle is the rectangle whose corners are the four points (dx, dy),
|
||||
// (dx+dw, dy), (dx+dw, dy+dh), (dx, dy+dh).
|
||||
let dest_rect = Rect(Point2D(dx, dy),
|
||||
Size2D(dest_rect_width_scaled, dest_rect_height_scaled));
|
||||
let dest_rect = Rect(Point2D(dx.min(dx+dest_rect_width_scaled), dy.min(dy+dest_rect_height_scaled)),
|
||||
Size2D(dest_rect_width_scaled.abs(), dest_rect_height_scaled.abs()));
|
||||
|
||||
let source_rect = Rect(Point2D(source_rect_clipped.origin.x,
|
||||
source_rect_clipped.origin.y),
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
[2d.drawImage.negativedest.html]
|
||||
type: testharness
|
||||
[Negative destination width/height represents the correct rectangle]
|
||||
expected: FAIL
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
[2d.drawImage.negativedir.html]
|
||||
type: testharness
|
||||
[Negative dimensions do not affect the direction of the image]
|
||||
expected: FAIL
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
[2d.drawImage.negativesource.html]
|
||||
type: testharness
|
||||
[Negative source width/height represents the correct rectangle]
|
||||
expected: FAIL
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue