aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
authorHyowon Kim <hw1008.kim@samsung.com>2015-06-01 15:58:38 +0900
committerHyowon Kim <hw1008.kim@samsung.com>2015-06-01 15:58:38 +0900
commita512e9e507b2539ff475ef51bb62f0017a593ec6 (patch)
treeff125b1b0b1a74d957d63e8c08a6ce039042a8bc /components/script/dom
parent713f18a58d9ba39d0f2cd1cc987774a28a9035ee (diff)
downloadservo-a512e9e507b2539ff475ef51bb62f0017a593ec6.tar.gz
servo-a512e9e507b2539ff475ef51bb62f0017a593ec6.zip
Correct the calculation of rects for drawimage.
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/canvasrenderingcontext2d.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/components/script/dom/canvasrenderingcontext2d.rs b/components/script/dom/canvasrenderingcontext2d.rs
index 7ddce7791c9..74389abaae2 100644
--- a/components/script/dom/canvasrenderingcontext2d.rs
+++ b/components/script/dom/canvasrenderingcontext2d.rs
@@ -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),