tor-browser

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

commit 6d0c417da901c3fc86201674589dd5399fa48876
parent 76ec61f47fa59e18c79d2793cea2dc7d12b19806
Author: Emilio Cobos Álvarez <emilio@crisal.io>
Date:   Mon,  3 Nov 2025 17:12:32 +0000

Bug 1997951 - Remove some view usage from dom/xul. r=smaug

ChromeObserver doesn't need to poke at views, it can use the same widget
getter as everything else.

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

Diffstat:
Mdom/xul/ChromeObserver.cpp | 23+++--------------------
Mdom/xul/ChromeObserver.h | 2+-
Mdom/xul/XULPopupElement.cpp | 1-
Mdom/xul/nsXULContentSink.cpp | 1-
Mdom/xul/nsXULPopupListener.cpp | 1-
5 files changed, 4 insertions(+), 24 deletions(-)

diff --git a/dom/xul/ChromeObserver.cpp b/dom/xul/ChromeObserver.cpp @@ -121,27 +121,10 @@ void ChromeObserver::SetCustomTitlebar(bool aCustomTitlebar) { } } -nsresult ChromeObserver::HideWindowChrome(bool aShouldHide) { - // only top level chrome documents can hide the window chrome - if (!mDocument->IsRootDisplayDocument()) return NS_OK; - - nsPresContext* presContext = mDocument->GetPresContext(); - - if (presContext && presContext->IsChrome()) { - nsIFrame* frame = mDocument->GetDocumentElement()->GetPrimaryFrame(); - - if (frame) { - nsView* view = frame->GetClosestView(); - - if (view) { - nsIWidget* w = view->GetWidget(); - NS_ENSURE_STATE(w); - w->HideWindowChrome(aShouldHide); - } - } +void ChromeObserver::HideWindowChrome(bool aShouldHide) { + if (nsCOMPtr<nsIWidget> mainWidget = GetWindowWidget()) { + mainWidget->HideWindowChrome(aShouldHide); } - - return NS_OK; } } // namespace mozilla::dom diff --git a/dom/xul/ChromeObserver.h b/dom/xul/ChromeObserver.h @@ -27,7 +27,7 @@ class ChromeObserver final : public nsStubMutationObserver { protected: nsIWidget* GetWindowWidget(); void SetHideTitlebarSeparator(bool); - nsresult HideWindowChrome(bool aShouldHide); + void HideWindowChrome(bool aShouldHide); void SetCustomTitlebar(bool); void SetMica(bool); ~ChromeObserver(); diff --git a/dom/xul/XULPopupElement.cpp b/dom/xul/XULPopupElement.cpp @@ -23,7 +23,6 @@ #include "nsMenuPopupFrame.h" #include "nsNameSpaceManager.h" #include "nsStringFwd.h" -#include "nsView.h" #ifdef MOZ_WAYLAND # include "mozilla/WidgetUtilsGtk.h" #endif diff --git a/dom/xul/nsXULContentSink.cpp b/dom/xul/nsXULContentSink.cpp @@ -37,7 +37,6 @@ #include "nsReadableUtils.h" #include "nsString.h" #include "nsUnicharUtils.h" -#include "nsViewManager.h" #include "nsXMLContentSink.h" #include "nsXULElement.h" #include "nsXULPrototypeDocument.h" // XXXbe temporary diff --git a/dom/xul/nsXULPopupListener.cpp b/dom/xul/nsXULPopupListener.cpp @@ -37,7 +37,6 @@ #include "nsFocusManager.h" #include "nsPIDOMWindow.h" #include "nsPresContext.h" -#include "nsViewManager.h" using namespace mozilla; using namespace mozilla::dom;