From ea497c36715e129620c7e9b783c1413db9d3de14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 10 Jun 2019 03:06:25 +0000 Subject: [PATCH] Bug 1488953 - Use a script runner for scrollport events. r=mats This is consistent with the scroll area events too, and allows us to remove the WillPaintObserver stuff. Differential Revision: https://phabricator.services.mozilla.com/D5271 --HG-- extra : moz-landing-system : lando --- layout/base/PresShell.cpp | 17 ---------------- layout/base/nsPresContext.cpp | 23 ---------------------- layout/base/nsPresContext.h | 30 ----------------------------- layout/generic/nsGfxScrollFrame.cpp | 7 +------ 4 files changed, 1 insertion(+), 76 deletions(-) diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp index dd83d9bd7891..5d208fbb3508 100644 --- a/layout/base/PresShell.cpp +++ b/layout/base/PresShell.cpp @@ -4462,12 +4462,6 @@ nsresult PresShell::RenderDocument(const nsRect& aRect, NS_ENSURE_TRUE(!(aFlags & RenderDocumentFlags::IsUntrusted), NS_ERROR_NOT_IMPLEMENTED); - nsRootPresContext* rootPresContext = mPresContext->GetRootPresContext(); - if (rootPresContext) { - rootPresContext->FlushWillPaintObservers(); - if (mIsDestroying) return NS_OK; - } - nsAutoScriptBlocker blockScripts; // Set up the rectangle as the path in aThebesContext @@ -8837,17 +8831,6 @@ void PresShell::WillPaint() { return; } - nsRootPresContext* rootPresContext = mPresContext->GetRootPresContext(); - if (!rootPresContext) { - // In some edge cases, such as when we don't have a root frame yet, - // we can't find the root prescontext. There's nothing to do in that - // case. - return; - } - - rootPresContext->FlushWillPaintObservers(); - if (mIsDestroying) return; - // Process reflows, if we have them, to reduce flicker due to invalidates and // reflow being interspersed. Note that we _do_ allow this to be // interruptible; if we can't do all the reflows it's better to flicker a bit diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 2a7cacb8350b..ea91dbe83332 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -2709,27 +2709,6 @@ void nsRootPresContext::CollectPluginGeometryUpdates( #endif // #ifndef XP_MACOSX } -void nsRootPresContext::AddWillPaintObserver(nsIRunnable* aRunnable) { - if (!mWillPaintFallbackEvent.IsPending()) { - mWillPaintFallbackEvent = new RunWillPaintObservers(this); - Document()->Dispatch(TaskCategory::Other, - do_AddRef(mWillPaintFallbackEvent)); - } - mWillPaintObservers.AppendElement(aRunnable); -} - -/** - * Run all runnables that need to get called before the next paint. - */ -void nsRootPresContext::FlushWillPaintObservers() { - mWillPaintFallbackEvent = nullptr; - nsTArray> observers; - observers.SwapElements(mWillPaintObservers); - for (uint32_t i = 0; i < observers.Length(); ++i) { - observers[i]->Run(); - } -} - size_t nsRootPresContext::SizeOfExcludingThis( MallocSizeOf aMallocSizeOf) const { return nsPresContext::SizeOfExcludingThis(aMallocSizeOf); @@ -2737,6 +2716,4 @@ size_t nsRootPresContext::SizeOfExcludingThis( // Measurement of the following members may be added later if DMD finds it is // worthwhile: // - mRegisteredPlugins - // - mWillPaintObservers - // - mWillPaintFallbackEvent } diff --git a/layout/base/nsPresContext.h b/layout/base/nsPresContext.h index a100aa8e5e9d..8aea00347ae6 100644 --- a/layout/base/nsPresContext.h +++ b/layout/base/nsPresContext.h @@ -1354,18 +1354,6 @@ class nsRootPresContext final : public nsPresContext { virtual bool IsRoot() override { return true; } - /** - * Add a runnable that will get called before the next paint. They will get - * run eventually even if painting doesn't happen. They might run well before - * painting happens. - */ - void AddWillPaintObserver(nsIRunnable* aRunnable); - - /** - * Run all runnables that need to get called before the next paint. - */ - void FlushWillPaintObservers(); - virtual size_t SizeOfExcludingThis( mozilla::MallocSizeOf aMallocSizeOf) const override; @@ -1379,28 +1367,10 @@ class nsRootPresContext final : public nsPresContext { */ void CancelApplyPluginGeometryTimer(); - class RunWillPaintObservers : public mozilla::Runnable { - public: - explicit RunWillPaintObservers(nsRootPresContext* aPresContext) - : Runnable("nsPresContextType::RunWillPaintObservers"), - mPresContext(aPresContext) {} - void Revoke() { mPresContext = nullptr; } - NS_IMETHOD Run() override { - if (mPresContext) { - mPresContext->FlushWillPaintObservers(); - } - return NS_OK; - } - // The lifetime of this reference is handled by an nsRevocableEventPtr - nsRootPresContext* MOZ_NON_OWNING_REF mPresContext; - }; - friend class nsPresContext; nsCOMPtr mApplyPluginGeometryTimer; nsTHashtable> mRegisteredPlugins; - nsTArray> mWillPaintObservers; - nsRevocableEventPtr mWillPaintFallbackEvent; }; #ifdef MOZ_REFLOW_PERF diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index db1ab2be6845..082a90a7af0d 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -5311,13 +5311,8 @@ void ScrollFrameHelper::PostOverflowEvent() { return; } - nsRootPresContext* rpc = mOuter->PresContext()->GetRootPresContext(); - if (!rpc) { - return; - } - mAsyncScrollPortEvent = new AsyncScrollPortEvent(this); - rpc->AddWillPaintObserver(mAsyncScrollPortEvent.get()); + nsContentUtils::AddScriptRunner(mAsyncScrollPortEvent.get()); } nsIFrame* ScrollFrameHelper::GetFrameForDir() const {