Correct the calculation of rects for drawimage.

This commit is contained in:
Hyowon Kim 2015-06-01 15:58:38 +09:00
parent 713f18a58d
commit a512e9e507
4 changed files with 4 additions and 19 deletions

View file

@ -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),

View file

@ -1,5 +0,0 @@
[2d.drawImage.negativedest.html]
type: testharness
[Negative destination width/height represents the correct rectangle]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.drawImage.negativedir.html]
type: testharness
[Negative dimensions do not affect the direction of the image]
expected: FAIL

View file

@ -1,5 +0,0 @@
[2d.drawImage.negativesource.html]
type: testharness
[Negative source width/height represents the correct rectangle]
expected: FAIL