From 1b65e844adeab1b9ec64702104d00937ee851043 Mon Sep 17 00:00:00 2001 From: Mike Conley Date: Wed, 28 Feb 2018 16:15:51 -0500 Subject: [PATCH] Bug 1442020 - Ensure neither style nor layout flushes are required when running promiseDocumentFlushed callbacks. r=bz MozReview-Commit-ID: INGpltVvNmZ --HG-- extra : rebase_source : 2f67f7c28211d0b78cd906c4b6e8da8eda7430f3 --- dom/base/nsGlobalWindowInner.cpp | 6 ++++-- dom/base/test/browser_promiseDocumentFlushed.js | 8 ++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/dom/base/nsGlobalWindowInner.cpp b/dom/base/nsGlobalWindowInner.cpp index ee2fd4aabc7c..c9a41bb0adfc 100644 --- a/dom/base/nsGlobalWindowInner.cpp +++ b/dom/base/nsGlobalWindowInner.cpp @@ -7434,7 +7434,8 @@ nsGlobalWindowInner::PromiseDocumentFlushed(PromiseDocumentFlushedCallback& aCal UniquePtr flushResolver( new PromiseDocumentFlushedResolver(resultPromise, aCallback)); - if (!shell->NeedFlush(FlushType::Style)) { + if (!shell->NeedFlush(FlushType::Style) && + !shell->NeedFlush(FlushType::Layout)) { flushResolver->Call(); return resultPromise.forget(); } @@ -7489,7 +7490,8 @@ nsGlobalWindowInner::DidRefresh() nsIPresShell* shell = mDoc->GetShell(); MOZ_ASSERT(shell); - if (shell->NeedStyleFlush() || shell->HasPendingReflow()) { + if (shell->NeedFlush(FlushType::Style) || + shell->NeedFlush(FlushType::Layout)) { // By the time our observer fired, something has already invalidated // style and maybe layout. We'll wait until the next refresh driver // tick instead. diff --git a/dom/base/test/browser_promiseDocumentFlushed.js b/dom/base/test/browser_promiseDocumentFlushed.js index a1c0ea362b19..b24480c84a62 100644 --- a/dom/base/test/browser_promiseDocumentFlushed.js +++ b/dom/base/test/browser_promiseDocumentFlushed.js @@ -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."); } /**