mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 12:25:53 +00:00
Bug 979161 part 4 - Add a non-flushing version of waitForAllPaints to paint_listener.js; r=mattwoodrow
This patch adds waitForAllPaints which does *not* call getBoundingClientRect since that can cause a flush. Sometimes this flush is undesirable since it can mask bugs in the code under test which should be performing this flush itself.
This commit is contained in:
parent
80173f8459
commit
730325e4c1
@ -2,6 +2,10 @@
|
||||
var accumulatedRect = null;
|
||||
var onpaint = function() {};
|
||||
var debug = false;
|
||||
const FlushModes = {
|
||||
FLUSH: 0,
|
||||
NOFLUSH: 1
|
||||
};
|
||||
|
||||
function paintListener(event) {
|
||||
if (event.target != window)
|
||||
@ -24,10 +28,15 @@
|
||||
}
|
||||
window.addEventListener("MozAfterPaint", paintListener, false);
|
||||
|
||||
function waitForAllPaintsFlushed(callback, subdoc) {
|
||||
document.documentElement.getBoundingClientRect();
|
||||
if (subdoc) {
|
||||
subdoc.documentElement.getBoundingClientRect();
|
||||
function waitForPaints(callback, subdoc, flushMode) {
|
||||
// The call to getBoundingClientRect will flush pending layout
|
||||
// notifications. Sometimes, however, this is undesirable since it can mask
|
||||
// bugs where the code under test should be performing the flush.
|
||||
if (flushMode === FlushModes.FLUSH) {
|
||||
document.documentElement.getBoundingClientRect();
|
||||
if (subdoc) {
|
||||
subdoc.documentElement.getBoundingClientRect();
|
||||
}
|
||||
}
|
||||
var utils = SpecialPowers.getDOMWindowUtils(window);
|
||||
if (!utils.isMozAfterPaintPending) {
|
||||
@ -43,7 +52,14 @@
|
||||
if (debug) {
|
||||
dump("waiting for paint...\n");
|
||||
}
|
||||
onpaint = function() { waitForAllPaintsFlushed(callback, subdoc); };
|
||||
onpaint = function() { waitForPaints(callback, subdoc, flushMode); };
|
||||
}
|
||||
window.waitForAllPaintsFlushed = waitForAllPaintsFlushed;
|
||||
|
||||
window.waitForAllPaintsFlushed = function(callback, subdoc) {
|
||||
waitForPaints(callback, subdoc, FlushModes.FLUSH);
|
||||
};
|
||||
|
||||
window.waitForAllPaints = function(callback) {
|
||||
waitForPaints(callback, null, FlushModes.NOFLUSH);
|
||||
};
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user