Bug 1897657 - Remove PresShell::mReflowContinueTimer. r=dholbert

In bug 1895870 I (somewhat unintentionally) made this code not called at
all.

Instead of scheduling a 30ms timer if reflow was interrupted, we just
schedule a reflow for the next refresh driver tick via
EnsureLayoutFlush(). Which is what would happen anyways before my change
in presence of other changes (like page loading appending content or
what not).

I think thus that the new behavior is more predictable (the 30ms timer
was never quite measured, it was introduced in bug 499447).

So, just simplify the code.

Differential Revision: https://phabricator.services.mozilla.com/D210890
This commit is contained in:
Emilio Cobos Álvarez 2024-05-20 06:41:27 +00:00
parent 00b18126ec
commit e5d519d1c8
2 changed files with 8 additions and 44 deletions

View file

@ -1255,12 +1255,6 @@ void PresShell::Destroy() {
// If our paint suppression timer is still active, kill it. // If our paint suppression timer is still active, kill it.
CancelPaintSuppressionTimer(); CancelPaintSuppressionTimer();
// Same for our reflow continuation timer
if (mReflowContinueTimer) {
mReflowContinueTimer->Cancel();
mReflowContinueTimer = nullptr;
}
mSynthMouseMoveEvent.Revoke(); mSynthMouseMoveEvent.Revoke();
mUpdateApproximateFrameVisibilityEvent.Revoke(); mUpdateApproximateFrameVisibilityEvent.Revoke();
@ -9714,11 +9708,13 @@ void PresShell::DidDoReflow(bool aInterruptible) {
UnsuppressAndInvalidate(); UnsuppressAndInvalidate();
} }
} else { } else {
// If any new reflow commands were enqueued during the reflow, schedule // If any new reflow commands were enqueued during the reflow (or we didn't
// another reflow event to process them. Note that we want to do this // reflow everything because we were interrupted), schedule another reflow
// after DidDoReflow(), since that method can change whether there are // event to process them.
// dirty roots around by flushing, and there's no point in posting a //
// reflow event just to have the flush revoke it. // Note that we want to do this after DidDoReflow(), since that method can
// change whether there are dirty roots around by flushing, and there's no
// point in posting a reflow event just to have the flush revoke it.
EnsureLayoutFlush(); EnsureLayoutFlush();
} }
} }
@ -9737,25 +9733,6 @@ DOMHighResTimeStamp PresShell::GetPerformanceNowUnclamped() {
return now; return now;
} }
bool PresShell::ScheduleReflowOffTimer() {
MOZ_ASSERT(!mObservingStyleFlushes, "Shouldn't get here");
ASSERT_REFLOW_SCHEDULED_STATE();
if (mReflowContinueTimer) {
return true;
}
nsresult rv = NS_NewTimerWithFuncCallback(
getter_AddRefs(mReflowContinueTimer),
[](nsITimer* aTimer, void* aPresShell) {
RefPtr<PresShell> self = static_cast<PresShell*>(aPresShell);
MOZ_ASSERT(aTimer == self->mReflowContinueTimer, "Unexpected timer");
self->mReflowContinueTimer = nullptr;
self->EnsureLayoutFlush();
},
this, 30, nsITimer::TYPE_ONE_SHOT, "ReflowContinueCallback",
GetMainThreadSerialEventTarget());
return NS_SUCCEEDED(rv);
}
bool PresShell::DoReflow(nsIFrame* target, bool aInterruptible, bool PresShell::DoReflow(nsIFrame* target, bool aInterruptible,
OverflowChangedTracker* aOverflowTracker) { OverflowChangedTracker* aOverflowTracker) {
[[maybe_unused]] nsIURI* uri = mDocument->GetDocumentURI(); [[maybe_unused]] nsIURI* uri = mDocument->GetDocumentURI();
@ -9791,11 +9768,6 @@ bool PresShell::DoReflow(nsIFrame* target, bool aInterruptible,
FlushPendingScrollAnchorSelections(); FlushPendingScrollAnchorSelections();
if (mReflowContinueTimer) {
mReflowContinueTimer->Cancel();
mReflowContinueTimer = nullptr;
}
const bool isRoot = target == mFrameConstructor->GetRootFrame(); const bool isRoot = target == mFrameConstructor->GetRootFrame();
MOZ_ASSERT(isRoot || aOverflowTracker, MOZ_ASSERT(isRoot || aOverflowTracker,

View file

@ -1235,9 +1235,7 @@ class PresShell final : public nsStubDocumentObserver,
mIsNeverPainting = aNeverPainting; mIsNeverPainting = aNeverPainting;
} }
bool MightHavePendingFontLoads() const { bool MightHavePendingFontLoads() const { return ObservingStyleFlushes(); }
return ObservingStyleFlushes() || mReflowContinueTimer;
}
void SyncWindowProperties(bool aSync); void SyncWindowProperties(bool aSync);
struct WindowSizeConstraints { struct WindowSizeConstraints {
@ -2959,12 +2957,6 @@ class PresShell final : public nsStubDocumentObserver,
// The `performance.now()` value when we last started to process reflows. // The `performance.now()` value when we last started to process reflows.
DOMHighResTimeStamp mLastReflowStart{0.0}; DOMHighResTimeStamp mLastReflowStart{0.0};
// At least on Win32 and Mac after interupting a reflow we need to post
// the resume reflow event off a timer to avoid event starvation because
// posted messages are processed before other messages when the modal
// moving/sizing loop is running, see bug 491700 for details.
nsCOMPtr<nsITimer> mReflowContinueTimer;
#ifdef DEBUG #ifdef DEBUG
// We track allocated pointers in a diagnostic hash set, to assert against // We track allocated pointers in a diagnostic hash set, to assert against
// missing/double frees. This set is allocated infallibly in the PresShell // missing/double frees. This set is allocated infallibly in the PresShell