Bug 56839. Part 3: Make reftest harness draw with scrollbars and use the window's layer tree, when possible. r=dbaron

This commit is contained in:
Robert O'Callahan 2010-06-18 21:25:16 +12:00
parent 8c0f73eb30
commit 14f325ad0f
10 changed files with 97 additions and 10 deletions

View File

@ -0,0 +1,6 @@
<!DOCTYPE HTML>
<html>
<body>
<div style="width:1px; height:1px; background:lime; position:absolute; left:0; top:0;"></div>
</body>
</html>

View File

@ -0,0 +1,6 @@
<!DOCTYPE HTML>
<html>
<body>
<div style="width:1px; height:1px; background:red; position:absolute; left:0; top:0;"></div>
</body>
</html>

View File

@ -0,0 +1,6 @@
<!DOCTYPE HTML>
<html>
<body>
<div style="width:1px; height:1px; background:lime; position:absolute; left:799px; top:0;"></div>
</body>
</html>

View File

@ -0,0 +1,6 @@
<!DOCTYPE HTML>
<html>
<body>
<div style="width:1px; height:1px; background:red; position:absolute; left:799px; top:0;"></div>
</body>
</html>

View File

@ -0,0 +1,6 @@
<!DOCTYPE HTML>
<html>
<body>
<div style="width:1px; height:1px; background:lime; position:absolute; left:799px; top:999px;"></div>
</body>
</html>

View File

@ -0,0 +1,6 @@
<!DOCTYPE HTML>
<html>
<body>
<div style="width:1px; height:1px; background:red; position:absolute; left:799px; top:999px;"></div>
</body>
</html>

View File

@ -0,0 +1,6 @@
<!DOCTYPE HTML>
<html>
<body>
<div style="width:1px; height:1px; background:lime; position:absolute; left:0; top:999px;"></div>
</body>
</html>

View File

@ -0,0 +1,6 @@
<!DOCTYPE HTML>
<html>
<body>
<div style="width:1px; height:1px; background:red; position:absolute; left:0; top:999px;"></div>
</body>
</html>

View File

@ -64,3 +64,9 @@ include scripttests.list
# test url-prefix # test url-prefix
include urlprefixtests.list include urlprefixtests.list
# test that all corners are visible
!= corners-1.html corners-1-ref.html
!= corners-2.html corners-2-ref.html
!= corners-3.html corners-3-ref.html
!= corners-4.html corners-4-ref.html

View File

@ -109,6 +109,8 @@ var gSlowestTestTime = 0;
var gSlowestTestURL; var gSlowestTestURL;
var gClearingForAssertionCheck = false; var gClearingForAssertionCheck = false;
var gDrawWindowFlags;
const TYPE_REFTEST_EQUAL = '=='; const TYPE_REFTEST_EQUAL = '==';
const TYPE_REFTEST_NOTEQUAL = '!='; const TYPE_REFTEST_NOTEQUAL = '!=';
const TYPE_LOAD = 'load'; // test without a reference (just test that it does const TYPE_LOAD = 'load'; // test without a reference (just test that it does
@ -931,8 +933,42 @@ function UpdateCanvasCache(url, canvas)
} }
} }
// Compute drawWindow flags lazily so the window is set up and can be
// measured accurately
function DoDrawWindow(ctx, win, x, y, w, h)
{
if (typeof gDrawWindowFlags == "undefined") {
gDrawWindowFlags = ctx.DRAWWINDOW_DRAW_CARET |
ctx.DRAWWINDOW_DRAW_VIEW;
var flags = "DRAWWINDOW_DRAW_CARET | DRAWWINDOW_DRAW_VIEW";
var win = gBrowser.contentWindow;
if (win.innerWidth == gCurrentCanvas.width &&
win.innerHeight == gCurrentCanvas.height) {
// We can use the window's retained layers
// because the window is big enough to display the entire reftest
gDrawWindowFlags |= ctx.DRAWWINDOW_USE_WIDGET_LAYERS;
flags += " | DRAWWINDOW_USE_WIDGET_LAYERS";
}
dump("REFTEST INFO | drawWindow flags = " + flags + "\n");
}
var scrollX = 0;
var scrollY = 0;
if (!(gDrawWindowFlags & ctx.DRAWWINDOW_DRAW_VIEW)) {
scrollX = win.scrollX;
scrollY = win.scrollY;
}
ctx.drawWindow(win, scrollX + x, scrollY + y, w, h, "rgb(255,255,255)",
gDrawWindowFlags);
}
function InitCurrentCanvasWithSnapshot() function InitCurrentCanvasWithSnapshot()
{ {
if (gURLs[0].type == TYPE_LOAD || gURLs[0].type == TYPE_SCRIPT) {
// We don't want to snapshot this kind of test
return;
}
gCurrentCanvas = AllocateCanvas(); gCurrentCanvas = AllocateCanvas();
/* XXX This needs to be rgb(255,255,255) because otherwise we get /* XXX This needs to be rgb(255,255,255) because otherwise we get
@ -946,12 +982,9 @@ function InitCurrentCanvasWithSnapshot()
// window, so scale the drawing to show the zoom (making each canvas pixel be one // window, so scale the drawing to show the zoom (making each canvas pixel be one
// device pixel instead) // device pixel instead)
ctx.scale(scale, scale); ctx.scale(scale, scale);
ctx.drawWindow(win, win.scrollX, win.scrollY, DoDrawWindow(ctx, win, 0, 0,
Math.ceil(gCurrentCanvas.width / scale), Math.ceil(gCurrentCanvas.width / scale),
Math.ceil(gCurrentCanvas.height / scale), Math.ceil(gCurrentCanvas.height / scale));
"rgb(255,255,255)",
ctx.DRAWWINDOW_DRAW_CARET |
ctx.DRAWWINDOW_USE_WIDGET_LAYERS);
ctx.restore(); ctx.restore();
} }
@ -962,6 +995,9 @@ function roundTo(x, fraction)
function UpdateCurrentCanvasForEvent(event) function UpdateCurrentCanvasForEvent(event)
{ {
if (!gCurrentCanvas)
return;
var win = gBrowser.contentWindow; var win = gBrowser.contentWindow;
var ctx = gCurrentCanvas.getContext("2d"); var ctx = gCurrentCanvas.getContext("2d");
var scale = gBrowser.markupDocumentViewer.fullZoom; var scale = gBrowser.markupDocumentViewer.fullZoom;
@ -978,10 +1014,7 @@ function UpdateCurrentCanvasForEvent(event)
ctx.save(); ctx.save();
ctx.scale(scale, scale); ctx.scale(scale, scale);
ctx.translate(left, top); ctx.translate(left, top);
ctx.drawWindow(win, left + win.scrollX, top + win.scrollY, DoDrawWindow(ctx, win, left, top, right - left, bottom - top);
right - left, bottom - top,
"rgb(255,255,255)",
ctx.DRAWWINDOW_DRAW_CARET);
ctx.restore(); ctx.restore();
} }
} }