From c3d3dba89e9b824e728413c38e9a5e88f7112b0b Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Mon, 28 Jun 2010 12:32:16 +1200 Subject: [PATCH] Bug 568392. Part 3: Make reftest harness draw with scrollbars and use the window's layer tree, when possible. r=dbaron --- .../reftest-sanity/corners-1-ref.html | 6 +++ layout/reftests/reftest-sanity/corners-1.html | 6 +++ .../reftest-sanity/corners-2-ref.html | 6 +++ layout/reftests/reftest-sanity/corners-2.html | 6 +++ .../reftest-sanity/corners-3-ref.html | 6 +++ layout/reftests/reftest-sanity/corners-3.html | 6 +++ .../reftest-sanity/corners-4-ref.html | 6 +++ layout/reftests/reftest-sanity/corners-4.html | 6 +++ layout/reftests/reftest-sanity/reftest.list | 6 +++ layout/tools/reftest/reftest.js | 52 +++++++++++++++---- layout/tools/reftest/reftest.xul | 6 ++- 11 files changed, 100 insertions(+), 12 deletions(-) create mode 100644 layout/reftests/reftest-sanity/corners-1-ref.html create mode 100644 layout/reftests/reftest-sanity/corners-1.html create mode 100644 layout/reftests/reftest-sanity/corners-2-ref.html create mode 100644 layout/reftests/reftest-sanity/corners-2.html create mode 100644 layout/reftests/reftest-sanity/corners-3-ref.html create mode 100644 layout/reftests/reftest-sanity/corners-3.html create mode 100644 layout/reftests/reftest-sanity/corners-4-ref.html create mode 100644 layout/reftests/reftest-sanity/corners-4.html diff --git a/layout/reftests/reftest-sanity/corners-1-ref.html b/layout/reftests/reftest-sanity/corners-1-ref.html new file mode 100644 index 000000000000..e002df8150d7 --- /dev/null +++ b/layout/reftests/reftest-sanity/corners-1-ref.html @@ -0,0 +1,6 @@ + + + +
+ + diff --git a/layout/reftests/reftest-sanity/corners-1.html b/layout/reftests/reftest-sanity/corners-1.html new file mode 100644 index 000000000000..d1461fc19a2e --- /dev/null +++ b/layout/reftests/reftest-sanity/corners-1.html @@ -0,0 +1,6 @@ + + + +
+ + diff --git a/layout/reftests/reftest-sanity/corners-2-ref.html b/layout/reftests/reftest-sanity/corners-2-ref.html new file mode 100644 index 000000000000..b60aef75291a --- /dev/null +++ b/layout/reftests/reftest-sanity/corners-2-ref.html @@ -0,0 +1,6 @@ + + + +
+ + diff --git a/layout/reftests/reftest-sanity/corners-2.html b/layout/reftests/reftest-sanity/corners-2.html new file mode 100644 index 000000000000..b0e7545b7239 --- /dev/null +++ b/layout/reftests/reftest-sanity/corners-2.html @@ -0,0 +1,6 @@ + + + +
+ + diff --git a/layout/reftests/reftest-sanity/corners-3-ref.html b/layout/reftests/reftest-sanity/corners-3-ref.html new file mode 100644 index 000000000000..a2ea68c33848 --- /dev/null +++ b/layout/reftests/reftest-sanity/corners-3-ref.html @@ -0,0 +1,6 @@ + + + +
+ + diff --git a/layout/reftests/reftest-sanity/corners-3.html b/layout/reftests/reftest-sanity/corners-3.html new file mode 100644 index 000000000000..605f2a267a96 --- /dev/null +++ b/layout/reftests/reftest-sanity/corners-3.html @@ -0,0 +1,6 @@ + + + +
+ + diff --git a/layout/reftests/reftest-sanity/corners-4-ref.html b/layout/reftests/reftest-sanity/corners-4-ref.html new file mode 100644 index 000000000000..acb444e8f451 --- /dev/null +++ b/layout/reftests/reftest-sanity/corners-4-ref.html @@ -0,0 +1,6 @@ + + + +
+ + diff --git a/layout/reftests/reftest-sanity/corners-4.html b/layout/reftests/reftest-sanity/corners-4.html new file mode 100644 index 000000000000..73cd286e4081 --- /dev/null +++ b/layout/reftests/reftest-sanity/corners-4.html @@ -0,0 +1,6 @@ + + + +
+ + diff --git a/layout/reftests/reftest-sanity/reftest.list b/layout/reftests/reftest-sanity/reftest.list index d8112887a833..8f9acf5f7fbd 100644 --- a/layout/reftests/reftest-sanity/reftest.list +++ b/layout/reftests/reftest-sanity/reftest.list @@ -64,3 +64,9 @@ include scripttests.list # test url-prefix 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 diff --git a/layout/tools/reftest/reftest.js b/layout/tools/reftest/reftest.js index 9d195dcd143f..0272c4289ae7 100644 --- a/layout/tools/reftest/reftest.js +++ b/layout/tools/reftest/reftest.js @@ -109,6 +109,8 @@ var gSlowestTestTime = 0; var gSlowestTestURL; var gClearingForAssertionCheck = false; +var gDrawWindowFlags; + const TYPE_REFTEST_EQUAL = '=='; const TYPE_REFTEST_NOTEQUAL = '!='; const TYPE_LOAD = 'load'; // test without a reference (just test that it does @@ -931,8 +933,41 @@ 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"; + if (window.innerWidth == gCurrentCanvas.width && + window.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() { + if (gURLs[0].type == TYPE_LOAD || gURLs[0].type == TYPE_SCRIPT) { + // We don't want to snapshot this kind of test + return; + } + gCurrentCanvas = AllocateCanvas(); /* XXX This needs to be rgb(255,255,255) because otherwise we get @@ -946,12 +981,9 @@ function InitCurrentCanvasWithSnapshot() // window, so scale the drawing to show the zoom (making each canvas pixel be one // device pixel instead) ctx.scale(scale, scale); - ctx.drawWindow(win, win.scrollX, win.scrollY, - Math.ceil(gCurrentCanvas.width / scale), - Math.ceil(gCurrentCanvas.height / scale), - "rgb(255,255,255)", - ctx.DRAWWINDOW_DRAW_CARET | - ctx.DRAWWINDOW_USE_WIDGET_LAYERS); + DoDrawWindow(ctx, win, 0, 0, + Math.ceil(gCurrentCanvas.width / scale), + Math.ceil(gCurrentCanvas.height / scale)); ctx.restore(); } @@ -962,6 +994,9 @@ function roundTo(x, fraction) function UpdateCurrentCanvasForEvent(event) { + if (!gCurrentCanvas) + return; + var win = gBrowser.contentWindow; var ctx = gCurrentCanvas.getContext("2d"); var scale = gBrowser.markupDocumentViewer.fullZoom; @@ -978,10 +1013,7 @@ function UpdateCurrentCanvasForEvent(event) ctx.save(); ctx.scale(scale, scale); ctx.translate(left, top); - ctx.drawWindow(win, left + win.scrollX, top + win.scrollY, - right - left, bottom - top, - "rgb(255,255,255)", - ctx.DRAWWINDOW_DRAW_CARET); + DoDrawWindow(ctx, win, left, top, right - left, bottom - top); ctx.restore(); } } diff --git a/layout/tools/reftest/reftest.xul b/layout/tools/reftest/reftest.xul index c05282bfbd84..3ced21095a73 100644 --- a/layout/tools/reftest/reftest.xul +++ b/layout/tools/reftest/reftest.xul @@ -48,9 +48,11 @@ onunload="OnRefTestUnload();" width="800" height="1000" - style="background:white" + style="background:white; overflow:hidden" >