From 239293451ebb1559f0627cd19f90edc520545e2d Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Wed, 10 Dec 2014 07:50:47 -0500 Subject: [PATCH] Bug 1109263 - Clamp the reftest drawWindow call to the canvas. r=dbaron In some cases the area reported by MozAfterPaint can be extremely large. Since that area determines what we pass to drawWindow, we could end up trying to drawWindow an area that is too large for drawWindow to handle. Instead, this patch clamps that area to the canvas size so that we don't unnecessarily try to paint (and fail at painting) the whole invalid area. --- layout/tools/reftest/reftest.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/layout/tools/reftest/reftest.js b/layout/tools/reftest/reftest.js index a93a0e32e9a2..70037bf80226 100644 --- a/layout/tools/reftest/reftest.js +++ b/layout/tools/reftest/reftest.js @@ -1480,6 +1480,12 @@ function UpdateCurrentCanvasForInvalidation(rects) var right = Math.ceil(r.right); var bottom = Math.ceil(r.bottom); + // Clamp the values to the canvas size + left = Math.max(0, Math.min(left, gCurrentCanvas.width)); + top = Math.max(0, Math.min(top, gCurrentCanvas.height)); + right = Math.max(0, Math.min(right, gCurrentCanvas.width)); + bottom = Math.max(0, Math.min(bottom, gCurrentCanvas.height)); + ctx.save(); ctx.translate(left, top); DoDrawWindow(ctx, left, top, right - left, bottom - top);