tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 4861f0df57a2936cfd3e43f1c842b4328e000569
parent f50fe117b8e58157db9ed5d05713f24adf08195e
Author: Emilio Cobos Álvarez <emilio@crisal.io>
Date:   Tue,  4 Nov 2025 10:15:53 +0000

Bug 1998103 - Remove nsViewManager::IsPaintingAllowed(). r=layout-reviewers,tnikkel

It's only used for a non-fatal assertion and views are going away, so
this simplifies a bit. We already have checks for not painting during
layout via nsAutoLayoutPhase.

Differential Revision: https://phabricator.services.mozilla.com/D271200

Diffstat:
Mlayout/base/PresShell.cpp | 2--
Mview/nsViewManager.cpp | 21---------------------
Mview/nsViewManager.h | 47-----------------------------------------------
3 files changed, 0 insertions(+), 70 deletions(-)

diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp @@ -1973,7 +1973,6 @@ bool PresShell::ResizeReflowIgnoreOverride(nscoord aWidth, nscoord aHeight, // Kick off a top-down reflow AUTO_LAYOUT_PHASE_ENTRY_POINT(GetPresContext(), Reflow); - nsViewManager::AutoDisableRefresh refreshBlocker(mViewManager); mDirtyRoots.Remove(rootFrame); DoReflow(rootFrame, true, nullptr); @@ -10858,7 +10857,6 @@ bool PresShell::ProcessReflowCommands(bool aInterruptible) { nsAutoScriptBlocker scriptBlocker; WillDoReflow(); AUTO_LAYOUT_PHASE_ENTRY_POINT(GetPresContext(), Reflow); - nsViewManager::AutoDisableRefresh refreshBlocker(mViewManager); OverflowChangedTracker overflowTracker; diff --git a/view/nsViewManager.cpp b/view/nsViewManager.cpp @@ -56,7 +56,6 @@ nsViewManager::nsViewManager(nsDeviceContext* aContext) mPresShell(nullptr), mDelayedResize(NSCOORD_NONE, NSCOORD_NONE), mRootView(nullptr), - mRefreshDisableCount(0), mPainting(false), mRecursiveRefreshPending(false), mHasPendingWidgetGeometryChanges(false) { @@ -531,10 +530,6 @@ bool nsViewManager::PaintWindow(nsIWidget* aWidget, return false; } - NS_ASSERTION( - IsPaintingAllowed(), - "shouldn't be receiving paint events while painting is disallowed!"); - // Get the view pointer here since NS_WILL_PAINT might have // destroyed it during CallWillPaintOnObservers (bug 378273). nsView* view = nsView::GetViewFor(aWidget); @@ -711,22 +706,6 @@ bool nsViewManager::IsViewInserted(nsView* aView) { return false; } -nsViewManager* nsViewManager::IncrementDisableRefreshCount() { - if (!IsRootVM()) { - return RootViewManager()->IncrementDisableRefreshCount(); - } - - ++mRefreshDisableCount; - - return this; -} - -void nsViewManager::DecrementDisableRefreshCount() { - NS_ASSERTION(IsRootVM(), "Should only be called on root"); - --mRefreshDisableCount; - NS_ASSERTION(mRefreshDisableCount >= 0, "Invalid refresh disable count!"); -} - nsIWidget* nsViewManager::GetRootWidget() const { if (!mRootView) { return nullptr; diff --git a/view/nsViewManager.h b/view/nsViewManager.h @@ -202,44 +202,6 @@ class nsViewManager final { */ nsDeviceContext* GetDeviceContext() const { return mContext; } - /** - * A stack class for disallowing changes that would enter painting. For - * example, popup widgets shouldn't be resized during reflow, since doing so - * might cause synchronous painting inside reflow which is forbidden. - * While refresh is disabled, widget geometry changes are deferred and will - * be handled later, either from the refresh driver or from an NS_WILL_PAINT - * event. - * We don't want to defer widget geometry changes all the time. Resizing a - * popup from script doesn't need to be deferred, for example, especially - * since popup widget geometry is observable from script and expected to - * update synchronously. - */ - class MOZ_STACK_CLASS AutoDisableRefresh { - public: - explicit AutoDisableRefresh(nsViewManager* aVM) { - if (aVM) { - mRootVM = aVM->IncrementDisableRefreshCount(); - } - } - ~AutoDisableRefresh() { - if (mRootVM) { - mRootVM->DecrementDisableRefreshCount(); - } - } - - private: - AutoDisableRefresh(const AutoDisableRefresh& aOther); - const AutoDisableRefresh& operator=(const AutoDisableRefresh& aOther); - - RefPtr<nsViewManager> mRootVM; - }; - - private: - friend class AutoDisableRefresh; - - nsViewManager* IncrementDisableRefreshCount(); - void DecrementDisableRefreshCount(); - public: /** * Retrieve the widget at the root of the nearest enclosing @@ -340,13 +302,6 @@ class nsViewManager final { } bool IsRootVM() const { return !mRootViewManager; } - // Whether synchronous painting is allowed at the moment. For example, - // widget geometry changes can cause synchronous painting, so they need to - // be deferred while refresh is disabled. - bool IsPaintingAllowed() { - return RootViewManager()->mRefreshDisableCount == 0; - } - MOZ_CAN_RUN_SCRIPT void WillPaintWindow(nsIWidget* aWidget); MOZ_CAN_RUN_SCRIPT bool PaintWindow(nsIWidget* aWidget, const LayoutDeviceIntRegion& aRegion); @@ -374,8 +329,6 @@ class nsViewManager final { // The following members should not be accessed directly except by // the root view manager. Some have accessor functions to enforce // this, as noted. - - int32_t mRefreshDisableCount; // Use IsPainting() and SetPainting() to access mPainting. bool mPainting; bool mRecursiveRefreshPending;