Bug 459619. Add zoom support to reftest harness. r+sr=dbaron

This commit is contained in:
Robert O'Callahan 2008-10-16 09:49:42 +13:00
parent 360bd6a255
commit fd567efec5
3 changed files with 27 additions and 7 deletions

View File

@ -6,6 +6,9 @@
== test-async.xul test-async-ref.xul
== test-async.html test-async-ref.html
# test that zoom works (and really zooms, not just scales)
== test-zoom.html test-zoom-ref.html
# Makes sure that the file: protocol handler and HTTP server both
# choose HTML vs. XHTML processing based on the file extensions.
!= html-vs-xhtml-by-extension.html html-vs-xhtml-by-extension.xhtml

View File

@ -333,12 +333,17 @@ function DoneTests()
goQuitApplication();
}
function CanvasToURL(canvas)
{
var ctx = whichCanvas.getContext("2d");
return canvas.toDataURL();
function setupZoom(contentRootElement) {
if (!contentRootElement.hasAttribute('reftest-zoom'))
return;
gBrowser.markupDocumentViewer.fullZoom =
contentRootElement.getAttribute('reftest-zoom');
}
function resetZoom() {
gBrowser.markupDocumentViewer.fullZoom = 1.0;
}
function OnDocumentLoad(event)
{
if (event.target != gBrowser.contentDocument)
@ -383,6 +388,8 @@ function OnDocumentLoad(event)
gBrowser.docShell.contentViewer.setPageMode(true, ps);
}
setupZoom(contentRootElement);
if (shouldWait()) {
// The testcase will let us know when the test snapshot should be made.
// Register a mutation listener to know when the 'reftest-wait' class
@ -441,8 +448,18 @@ function DocumentLoaded()
* black bars at the bottom of every test that are different size
* for the first test and the rest (scrollbar-related??) */
var win = gBrowser.contentWindow;
canvas.getContext("2d").drawWindow(win, win.scrollX, win.scrollY,
canvas.width, canvas.height, "rgb(255,255,255)");
var ctx = canvas.getContext("2d");
var scale = gBrowser.markupDocumentViewer.fullZoom;
ctx.save();
// drawWindow always draws one canvas pixel for each CSS pixel in the source
// 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,
canvas.width, canvas.height, "rgb(255,255,255)");
ctx.restore();
resetZoom();
switch (gState) {
case 1:

2
nsprpub/configure vendored
View File

@ -6016,7 +6016,7 @@ s%\[%\\&%g
s%\]%\\&%g
s%\$%$$%g
EOF
DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' ' | tr '\015' ' '`
DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '`
rm -f conftest.defs