зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #6239 - Correct the calculation of rects for drawimage (from hyowon:drawimage_rects); r=jdm
https://html.spec.whatwg.org/multipage/#dom-context-2d-drawimage The source and destination rectangles have four points (x, y), (x+w, y), (x+w, y+h), (x, y+h), which doesn't mean rect(x, y, w, h). cc @yichoi Source-Repo: https://github.com/servo/servo Source-Revision: 2a8d5952892e050a3d604741dd1007e3bd563315
This commit is contained in:
Родитель
44bb82aa42
Коммит
1ffadc119a
|
@ -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),
|
||||
|
|
Загрузка…
Ссылка в новой задаче