tor-browser

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

commit 8b3cbfa58a8dd73ee2ebb7c0bbc4dd04d7271714
parent b7f6d2d170499d5c2dc8f27092c8a1741e0212fa
Author: Emilio Cobos Álvarez <emilio@crisal.io>
Date:   Tue, 25 Nov 2025 22:35:15 +0000

Bug 2000626 - Clean up more now dead view / viewmanager code. r=jwatt

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

Diffstat:
Mview/nsView.cpp | 44+++++++-------------------------------------
Mview/nsView.h | 15++-------------
Mview/nsViewManager.cpp | 19-------------------
Mview/nsViewManager.h | 25-------------------------
4 files changed, 9 insertions(+), 94 deletions(-)

diff --git a/view/nsView.cpp b/view/nsView.cpp @@ -27,14 +27,8 @@ using namespace mozilla; using namespace mozilla::widget; -nsView::nsView(nsViewManager* aViewManager) - : mViewManager(aViewManager), mForcedRepaint(false) { +nsView::nsView(nsViewManager* aViewManager) : mViewManager(aViewManager) { MOZ_COUNT_CTOR(nsView); - - // Views should be transparent by default. Not being transparent is - // a promise that the view will paint all its pixels opaquely. Views - // should make this promise explicitly by calling - // SetViewContentTransparency. } nsView::~nsView() { @@ -54,27 +48,10 @@ nsView::~nsView() { } // Destroy and release the widget - DestroyWidget(); + DetachWidget(); } -class DestroyWidgetRunnable : public Runnable { - public: - NS_DECL_NSIRUNNABLE - - explicit DestroyWidgetRunnable(nsIWidget* aWidget) - : mozilla::Runnable("DestroyWidgetRunnable"), mWidget(aWidget) {} - - private: - nsCOMPtr<nsIWidget> mWidget; -}; - -NS_IMETHODIMP DestroyWidgetRunnable::Run() { - mWidget->Destroy(); - mWidget = nullptr; - return NS_OK; -} - -void nsView::DestroyWidget() { +void nsView::DetachWidget() { if (mWindow) { // If we are not attached to a base window, we're going to tear down our // widget here. However, if we're attached to somebody elses widget, we @@ -160,14 +137,7 @@ PresShell* nsView::GetPresShell() { return GetViewManager()->GetPresShell(); } bool nsView::WindowResized(nsIWidget* aWidget, int32_t aWidth, int32_t aHeight) { - // The root view may not be set if this is the resize associated with - // window creation - SetForcedRepaint(true); - if (this != mViewManager->GetRootView()) { - return false; - } - - PresShell* ps = mViewManager->GetPresShell(); + PresShell* ps = GetPresShell(); if (!ps) { return false; } @@ -277,7 +247,7 @@ void nsView::DidPaintWindow() { void nsView::DidCompositeWindow(mozilla::layers::TransactionId aTransactionId, const TimeStamp& aCompositeStart, const TimeStamp& aCompositeEnd) { - PresShell* presShell = mViewManager->GetPresShell(); + PresShell* presShell = GetPresShell(); if (!presShell) { return; } @@ -309,7 +279,7 @@ nsEventStatus nsView::HandleEvent(WidgetGUIEvent* aEvent) { void nsView::SafeAreaInsetsChanged( const LayoutDeviceIntMargin& aSafeAreaInsets) { - PresShell* presShell = mViewManager->GetPresShell(); + PresShell* presShell = GetPresShell(); if (!presShell) { return; } @@ -341,7 +311,7 @@ bool nsView::IsPrimaryFramePaintSuppressed() const { void nsView::CallOnAllRemoteChildren( const std::function<CallState(dom::BrowserParent*)>& aCallback) { - PresShell* presShell = mViewManager->GetPresShell(); + PresShell* presShell = GetPresShell(); if (!presShell) { return; } diff --git a/view/nsView.h b/view/nsView.h @@ -142,12 +142,8 @@ class nsView final : public nsIWidgetListener { */ nsSize GetSize() const { return mSize; } - /** - * Destroys the associated widget for this view. If this method is - * not called explicitly, the widget when be destroyed when its - * view gets destroyed. - */ - void DestroyWidget(); + // Stops listening to mWidget and clears it. + void DetachWidget(); /** * Attach/detach a top level widget from this view. When attached, the view @@ -177,10 +173,6 @@ class nsView final : public nsIWidgetListener { */ bool HasWidget() const { return mWindow != nullptr; } - void SetForcedRepaint(bool aForceRepaint) { mForcedRepaint = aForceRepaint; } - - void SetNeedsWindowPropertiesSync(); - #ifdef DEBUG /** * Output debug info to FILE @@ -226,8 +218,6 @@ class nsView final : public nsIWidgetListener { private: explicit nsView(nsViewManager* = nullptr); - bool ForcedRepaint() { return mForcedRepaint; } - void SetSize(const nsSize& aSize) { mSize = aSize; } void CallOnAllRemoteChildren( @@ -238,7 +228,6 @@ class nsView final : public nsIWidgetListener { nsCOMPtr<nsIWidget> mWindow; nsCOMPtr<nsIWidget> mPreviousWindow; nsSize mSize; - bool mForcedRepaint; bool mIsDirty = false; }; diff --git a/view/nsViewManager.cpp b/view/nsViewManager.cpp @@ -150,25 +150,6 @@ void nsViewManager::FlushDelayedResize() { } } -nsViewManager* nsViewManager::RootViewManager() const { - const auto* cur = this; - while (auto* parent = cur->GetParentViewManager()) { - cur = parent; - } - return const_cast<nsViewManager*>(cur); -} - -nsViewManager* nsViewManager::GetParentViewManager() const { - if (!mPresShell) { - return nullptr; - } - auto* pc = mPresShell->GetPresContext(); - if (auto* parent = pc->GetParentPresContext()) { - return parent->PresShell()->GetViewManager(); - } - return nullptr; -} - void nsViewManager::PaintWindow(nsIWidget* aWidget) { RefPtr ps = mPresShell; if (!ps) { diff --git a/view/nsViewManager.h b/view/nsViewManager.h @@ -37,14 +37,6 @@ class nsViewManager final { nsViewManager(); /** - * Initialize the ViewManager - * Note: this instance does not hold a reference to the presshell - * because it holds a reference to this instance. - * @result The result of the initialization, NS_OK if no errors - */ - nsresult Init(); - - /** * Create an ordinary view * @param aSize initial size for view * XXX We should eliminate this parameter; you can set the bounds @@ -108,29 +100,12 @@ class nsViewManager final { static uint32_t GetLastUserEventTime() { return gLastUserEventTime; } static void MaybeUpdateLastUserEventTime(mozilla::WidgetGUIEvent*); - /** - * Flush the accumulated dirty region to the widget and update widget - * geometry. - */ - MOZ_CAN_RUN_SCRIPT void ProcessPendingUpdates(); - private: static uint32_t gLastUserEventTime; - /** - * Call WillPaint() on all view observers under this vm root. - */ - MOZ_CAN_RUN_SCRIPT_BOUNDARY void CallWillPaintOnObservers(); - static void CollectVMsForWillPaint(nsView* aView, nsViewManager* aParentVM, - nsTArray<RefPtr<nsViewManager>>& aVMs); - MOZ_CAN_RUN_SCRIPT_BOUNDARY void DoSetWindowDimensions(const nsSize&); bool ShouldDelayResize() const; - nsViewManager* RootViewManager() const; - nsViewManager* GetParentViewManager() const; - bool IsRootVM() const { return !GetParentViewManager(); } - MOZ_CAN_RUN_SCRIPT void WillPaintWindow(nsIWidget* aWidget); MOZ_CAN_RUN_SCRIPT void PaintWindow(nsIWidget* aWidget); MOZ_CAN_RUN_SCRIPT void DidPaintWindow();