Bug 472244. Flush out MozAfterPaint for previously painted areas before we go ahead and fire MozReftestInvalidate to test invalidation. Also make canvas.drawWindow take float parameters so we can more precisely specify the area to render when 'device pixels' don't match CSS pixel boundaries. r=dbaron,vlad

This commit is contained in:
Robert O'Callahan 2009-01-07 21:31:36 +13:00
parent 860b4f595f
commit 4659c94f44
4 changed files with 37 additions and 22 deletions

View File

@ -3349,8 +3349,8 @@ FlushLayoutForTree(nsIDOMWindow* aWindow)
}
NS_IMETHODIMP
nsCanvasRenderingContext2D::DrawWindow(nsIDOMWindow* aWindow, PRInt32 aX, PRInt32 aY,
PRInt32 aW, PRInt32 aH,
nsCanvasRenderingContext2D::DrawWindow(nsIDOMWindow* aWindow, float aX, float aY,
float aW, float aH,
const nsAString& aBGColor,
PRUint32 flags)
{

View File

@ -60,7 +60,7 @@ interface nsIDOMTextMetrics : nsISupports
readonly attribute float width;
};
[scriptable, uuid(66e6d87c-759c-43a7-b3d3-3348180b35df)]
[scriptable, uuid(3e7d5d06-8846-4cff-8739-44756cbf494f)]
interface nsIDOMCanvasRenderingContext2D : nsISupports
{
// back-reference to the canvas element for which
@ -202,7 +202,7 @@ interface nsIDOMCanvasRenderingContext2D : nsISupports
* This API cannot currently be used by Web content. It is chrome
* only.
*/
void drawWindow(in nsIDOMWindow window, in long x, in long y,
in long w, in long h, in DOMString bgColor,
void drawWindow(in nsIDOMWindow window, in float x, in float y,
in float w, in float h, in DOMString bgColor,
[optional] in unsigned long flags);
};

View File

@ -38,4 +38,4 @@ HTTP(..) == filter-2.xhtml filter-2-ref.xhtml
# test that the MozReftestInvalidate event fires
== invalidation.html about:blank
random == zoom-invalidation.html zoom-invalidation-ref.html # bug 472244
== zoom-invalidation.html zoom-invalidation-ref.html

View File

@ -529,6 +529,18 @@ function OnDocumentLoad(event)
utils.processUpdates();
}
function WhenMozAfterPaintFlushed(continuation) {
if (utils.isMozAfterPaintPending) {
function handler() {
gBrowser.removeEventListener("MozAfterPaint", handler, false);
continuation();
}
gBrowser.addEventListener("MozAfterPaint", handler, false);
} else {
continuation();
}
}
function AfterPaintListener(event) {
if (event.target.document != currentDoc) {
// ignore paint events for subframes or old documents in the window.
@ -574,25 +586,28 @@ function OnDocumentLoad(event)
function StartWaitingForTestEnd() {
FlushRendering();
gBrowser.addEventListener("MozAfterPaint", AfterPaintListener, false);
contentRootElement.addEventListener("DOMAttrModified", AttrModifiedListener, false);
function continuation() {
gBrowser.addEventListener("MozAfterPaint", AfterPaintListener, false);
contentRootElement.addEventListener("DOMAttrModified", AttrModifiedListener, false);
// Take a snapshot of the window in its current state
InitCurrentCanvasWithSnapshot();
// Take a snapshot of the window in its current state
InitCurrentCanvasWithSnapshot();
if (!shouldWait()) {
// reftest-wait was already removed (during the interval between OnDocumentLoaded
// calling setTimeout(StartWaitingForTestEnd,0) below, and this function
// actually running), so let's fake a direct notification of the attribute
// change.
AttrModifiedListener();
return;
if (!shouldWait()) {
// reftest-wait was already removed (during the interval between OnDocumentLoaded
// calling setTimeout(StartWaitingForTestEnd,0) below, and this function
// actually running), so let's fake a direct notification of the attribute
// change.
AttrModifiedListener();
return;
}
// Notify the test document that now is a good time to test some invalidation
var notification = document.createEvent("Events");
notification.initEvent("MozReftestInvalidate", true, false);
contentRootElement.dispatchEvent(notification);
}
// Notify the test document that now is a good time to test some invalidation
var notification = document.createEvent("Events");
notification.initEvent("MozReftestInvalidate", true, false);
contentRootElement.dispatchEvent(notification);
WhenMozAfterPaintFlushed(continuation);
}
// After this load event has finished being dispatched, painting is normally