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
This commit is contained in:
Emilio Cobos Álvarez 2019-06-13 02:30:25 +00:00
Родитель 6ce88e6013
Коммит 4e5f983137
4 изменённых файлов: 1 добавлений и 76 удалений

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

@ -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

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

@ -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<nsCOMPtr<nsIRunnable>> 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
}

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

@ -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<nsITimer> mApplyPluginGeometryTimer;
nsTHashtable<nsRefPtrHashKey<nsIContent>> mRegisteredPlugins;
nsTArray<nsCOMPtr<nsIRunnable>> mWillPaintObservers;
nsRevocableEventPtr<RunWillPaintObservers> mWillPaintFallbackEvent;
};
#ifdef MOZ_REFLOW_PERF

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

@ -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 {