Bug 1442020 - Ensure neither style nor layout flushes are required when running promiseDocumentFlushed callbacks. r=bz

MozReview-Commit-ID: INGpltVvNmZ

--HG--
extra : rebase_source : 283c263a33b924e50170ae26f049d98b825f6f1d
This commit is contained in:
Mike Conley 2018-02-28 16:15:51 -05:00
Родитель 25081fdb10
Коммит b797442465
3 изменённых файлов: 21 добавлений и 6 удалений

Просмотреть файл

@ -7428,7 +7428,7 @@ nsGlobalWindowInner::PromiseDocumentFlushed(PromiseDocumentFlushedCallback& aCal
UniquePtr<PromiseDocumentFlushedResolver> flushResolver(
new PromiseDocumentFlushedResolver(resultPromise, aCallback));
if (!shell->NeedFlush(FlushType::Style)) {
if (!shell->NeedStyleFlush() && !shell->NeedLayoutFlush()) {
flushResolver->Call();
return resultPromise.forget();
}
@ -7523,10 +7523,11 @@ nsGlobalWindowInner::DidRefresh()
nsIPresShell* shell = mDoc->GetShell();
MOZ_ASSERT(shell);
if (shell->NeedStyleFlush() || shell->HasPendingReflow()) {
if (shell->NeedStyleFlush() || shell->NeedLayoutFlush()) {
// By the time our observer fired, something has already invalidated
// style and maybe layout. We'll wait until the next refresh driver
// tick instead.
// style or layout - or perhaps we're still in the middle of a flush that
// was interrupted. In either case, we'll wait until the next refresh driver
// tick instead and try again.
rejectionGuard.release();
return;
}

Просмотреть файл

@ -31,7 +31,9 @@ const gWindowUtils = window.QueryInterface(Ci.nsIInterfaceRequestor)
*/
function assertNoFlushesRequired() {
Assert.ok(!gWindowUtils.needsFlush(Ci.nsIDOMWindowUtils.FLUSH_STYLE),
"No flushes are required.");
"No style flushes are required.");
Assert.ok(!gWindowUtils.needsFlush(Ci.nsIDOMWindowUtils.FLUSH_LAYOUT),
"No layout flushes are required.");
}
/**
@ -39,8 +41,10 @@ function assertNoFlushesRequired() {
* are required.
*/
function assertFlushesRequired() {
Assert.ok(gWindowUtils.needsFlush(Ci.nsIDOMWindowUtils.FLUSH_STYLE),
"Style flush required.");
Assert.ok(gWindowUtils.needsFlush(Ci.nsIDOMWindowUtils.FLUSH_LAYOUT),
"Style and layout flushes are required.");
"Layout flush required.");
}
/**

Просмотреть файл

@ -620,6 +620,12 @@ public:
}
bool NeedStyleFlush() const { return mNeedStyleFlush; }
/**
* Returns true if we might need to flush layout, even if we haven't scheduled
* one yet (as opposed to HasPendingReflow, which returns true if a flush is
* scheduled or will soon be scheduled).
*/
bool NeedLayoutFlush() const { return mNeedLayoutFlush; }
/**
* Callbacks will be called even if reflow itself fails for
@ -1638,6 +1644,10 @@ public:
mIsNeverPainting = aNeverPainting;
}
/**
* True if a reflow event has been scheduled, or is going to be scheduled
* to run in the future.
*/
bool HasPendingReflow() const
{ return mObservingLayoutFlushes || mReflowContinueTimer; }