diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp index 3deade42e819..fc7b9ee68ff2 100644 --- a/layout/base/PresShell.cpp +++ b/layout/base/PresShell.cpp @@ -3924,46 +3924,21 @@ void PresShell::UnsuppressAndInvalidate() { PROFILER_MARKER_UNTYPED("UnsuppressAndInvalidate", GRAPHICS); mPaintingSuppressed = false; - - if (mPresContext->IsRootContentDocumentCrossProcess()) { - nsWeakPtr weakDoc = do_GetWeakReference(mDocument); - // Tell the parent process about the unsuppression, but make sure to have - // done a refresh driver tick first at least. That should improve the - // chances that we have something meaningful to display. - mPresContext->RegisterManagedPostRefreshObserver( - new ManagedPostRefreshObserver( - mPresContext, [weakDoc](bool aWasCanceled) { - if (aWasCanceled) { - return ManagedPostRefreshObserver::Unregister::Yes; - } - - nsCOMPtr doc = do_QueryReferent(weakDoc); - if (!doc) { - return ManagedPostRefreshObserver::Unregister::Yes; - } - nsPresContext* pctx = doc->GetPresContext(); - if (!pctx) { - return ManagedPostRefreshObserver::Unregister::Yes; - } - - if (auto* bc = BrowserChild::GetFrom(doc->GetDocShell())) { - if (doc->IsInitialDocument()) { - bc->SendDidUnsuppressPaintingNormalPriority(); - } else { - bc->SendDidUnsuppressPainting(); - } - } - - return ManagedPostRefreshObserver::Unregister::Yes; - })); - mPresContext->SetWantsExtraTick(); - } - if (nsIFrame* rootFrame = mFrameConstructor->GetRootFrame()) { // let's assume that outline on a root frame is not supported rootFrame->InvalidateFrame(); } + if (mPresContext->IsRootContentDocumentCrossProcess()) { + if (auto* bc = BrowserChild::GetFrom(mDocument->GetDocShell())) { + if (mDocument->IsInitialDocument()) { + bc->SendDidUnsuppressPaintingNormalPriority(); + } else { + bc->SendDidUnsuppressPainting(); + } + } + } + // now that painting is unsuppressed, focus may be set on the document if (nsPIDOMWindowOuter* win = mDocument->GetWindow()) { win->SetReadyForFocus(); diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 72ecb16c037e..54441c0d41a4 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -282,7 +282,6 @@ nsPresContext::nsPresContext(dom::Document* aDocument, nsPresContextType aType) mHadContentfulPaint(false), mHadNonTickContentfulPaint(false), mHadContentfulPaintComposite(false), - mWantsExtraTick(false), #ifdef DEBUG mInitialized(false), #endif @@ -410,7 +409,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsPresContext) tmp->Destroy(); NS_IMPL_CYCLE_COLLECTION_UNLINK_END - bool nsPresContext::IsChrome() const { return Document()->IsInChromeDocShell(); } diff --git a/layout/base/nsPresContext.h b/layout/base/nsPresContext.h index 7662e072dd02..842a46420aa0 100644 --- a/layout/base/nsPresContext.h +++ b/layout/base/nsPresContext.h @@ -1086,14 +1086,6 @@ class nsPresContext : public nsISupports, public mozilla::SupportsWeakPtr { return mFontFeatureValuesLookup; } - void SetWantsExtraTick() { mWantsExtraTick = true; } - - bool TakeWantsExtraTick() { - bool retVal = mWantsExtraTick; - mWantsExtraTick = false; - return retVal; - } - protected: friend class nsRunnableMethod; void ThemeChangedInternal(); @@ -1378,8 +1370,6 @@ class nsPresContext : public nsISupports, public mozilla::SupportsWeakPtr { // Has NotifyDidPaintForSubtree been called for a contentful paint? unsigned mHadContentfulPaintComposite : 1; - unsigned mWantsExtraTick : 1; - #ifdef DEBUG unsigned mInitialized : 1; #endif diff --git a/layout/base/nsRefreshDriver.cpp b/layout/base/nsRefreshDriver.cpp index 0e5f7fc2fee0..84a569597e88 100644 --- a/layout/base/nsRefreshDriver.cpp +++ b/layout/base/nsRefreshDriver.cpp @@ -1529,19 +1529,12 @@ void nsRefreshDriver::EnsureTimerStarted(EnsureTimerStartedFlags aFlags) { mRefreshTimerStartedCause = profiler_capture_backtrace(); } - if (IsFrozen() || !mPresContext) { - // If we don't want to start it now, or we've been disconnected. - StopTimer(); - return; - } - // will it already fire, and no other changes needed? if (mActiveTimer && !(aFlags & eForceAdjustTimer)) { - // If we're being called from within a user input handler or someone - // explicitly asked for an extra tick, and we think there's time to rush an - // extra tick immediately, then schedule a runnable to run the extra tick. - if ((mPresContext->TakeWantsExtraTick() || mUserInputProcessingCount) && - CanDoExtraTick()) { + // If we're being called from within a user input handler, and we think + // there's time to rush an extra tick immediately, then schedule a runnable + // to run the extra tick. + if (mUserInputProcessingCount && CanDoExtraTick()) { RefPtr self = this; NS_DispatchToCurrentThreadQueue( NS_NewRunnableFunction( @@ -1563,6 +1556,12 @@ void nsRefreshDriver::EnsureTimerStarted(EnsureTimerStartedFlags aFlags) { return; } + if (IsFrozen() || !mPresContext) { + // If we don't want to start it now, or we've been disconnected. + StopTimer(); + return; + } + if (mPresContext->Document()->IsBeingUsedAsImage()) { // Image documents receive ticks from clients' refresh drivers. // XXXdholbert Exclude SVG-in-opentype fonts from this optimization, until