From b2168e5b305befe481d317f997797cb6c09a7f47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Tue, 9 Jan 2024 12:26:27 +0000 Subject: [PATCH] Bug 1869796 - Inline CalculateChromeFlagsHelper. r=smaug The only caller already is calculating a lot of other flags. Differential Revision: https://phabricator.services.mozilla.com/D197871 --- .../windowwatcher/nsWindowWatcher.cpp | 77 ++++++++----------- .../windowwatcher/nsWindowWatcher.h | 4 - 2 files changed, 30 insertions(+), 51 deletions(-) diff --git a/toolkit/components/windowwatcher/nsWindowWatcher.cpp b/toolkit/components/windowwatcher/nsWindowWatcher.cpp index a305e38abcda..725138e90b31 100644 --- a/toolkit/components/windowwatcher/nsWindowWatcher.cpp +++ b/toolkit/components/windowwatcher/nsWindowWatcher.cpp @@ -1783,47 +1783,6 @@ nsresult nsWindowWatcher::URIfromURL(const nsACString& aURL, return NS_NewURI(aURI, aURL, nullptr, baseURI); } -// static -uint32_t nsWindowWatcher::CalculateChromeFlagsHelper( - uint32_t aInitialFlags, const WindowFeatures& aFeatures, - bool* presenceFlag) { - uint32_t chromeFlags = aInitialFlags; - - if (aFeatures.GetBoolWithDefault("titlebar", false, presenceFlag)) { - chromeFlags |= nsIWebBrowserChrome::CHROME_TITLEBAR; - } - if (aFeatures.GetBoolWithDefault("close", false, presenceFlag)) { - chromeFlags |= nsIWebBrowserChrome::CHROME_WINDOW_CLOSE; - } - if (aFeatures.GetBoolWithDefault("toolbar", false, presenceFlag)) { - chromeFlags |= nsIWebBrowserChrome::CHROME_TOOLBAR; - } - if (aFeatures.GetBoolWithDefault("location", false, presenceFlag)) { - chromeFlags |= nsIWebBrowserChrome::CHROME_LOCATIONBAR; - } - if (aFeatures.GetBoolWithDefault("personalbar", false, presenceFlag)) { - chromeFlags |= nsIWebBrowserChrome::CHROME_PERSONAL_TOOLBAR; - } - if (aFeatures.GetBoolWithDefault("status", false, presenceFlag)) { - chromeFlags |= nsIWebBrowserChrome::CHROME_STATUSBAR; - } - if (aFeatures.GetBoolWithDefault("menubar", false, presenceFlag)) { - chromeFlags |= nsIWebBrowserChrome::CHROME_MENUBAR; - } - if (aFeatures.GetBoolWithDefault("resizable", false, presenceFlag)) { - chromeFlags |= nsIWebBrowserChrome::CHROME_WINDOW_RESIZE; - } - if (aFeatures.GetBoolWithDefault("minimizable", false, presenceFlag)) { - chromeFlags |= nsIWebBrowserChrome::CHROME_WINDOW_MINIMIZE; - } - - if (aFeatures.GetBoolWithDefault("scrollbars", true, presenceFlag)) { - chromeFlags |= nsIWebBrowserChrome::CHROME_SCROLLBARS; - } - - return chromeFlags; -} - // static bool nsWindowWatcher::ShouldOpenPopup(const WindowFeatures& aFeatures) { if (aFeatures.IsEmpty()) { @@ -1925,8 +1884,36 @@ uint32_t nsWindowWatcher::CalculateChromeFlagsForSystem( } /* Next, allow explicitly named options to override the initial settings */ - chromeFlags = - CalculateChromeFlagsHelper(chromeFlags, aFeatures, &presenceFlag); + if (aFeatures.GetBoolWithDefault("titlebar", false, &presenceFlag)) { + chromeFlags |= nsIWebBrowserChrome::CHROME_TITLEBAR; + } + if (aFeatures.GetBoolWithDefault("close", false, &presenceFlag)) { + chromeFlags |= nsIWebBrowserChrome::CHROME_WINDOW_CLOSE; + } + if (aFeatures.GetBoolWithDefault("toolbar", false, &presenceFlag)) { + chromeFlags |= nsIWebBrowserChrome::CHROME_TOOLBAR; + } + if (aFeatures.GetBoolWithDefault("location", false, &presenceFlag)) { + chromeFlags |= nsIWebBrowserChrome::CHROME_LOCATIONBAR; + } + if (aFeatures.GetBoolWithDefault("personalbar", false, &presenceFlag)) { + chromeFlags |= nsIWebBrowserChrome::CHROME_PERSONAL_TOOLBAR; + } + if (aFeatures.GetBoolWithDefault("status", false, &presenceFlag)) { + chromeFlags |= nsIWebBrowserChrome::CHROME_STATUSBAR; + } + if (aFeatures.GetBoolWithDefault("menubar", false, &presenceFlag)) { + chromeFlags |= nsIWebBrowserChrome::CHROME_MENUBAR; + } + if (aFeatures.GetBoolWithDefault("resizable", false, &presenceFlag)) { + chromeFlags |= nsIWebBrowserChrome::CHROME_WINDOW_RESIZE; + } + if (aFeatures.GetBoolWithDefault("minimizable", false, &presenceFlag)) { + chromeFlags |= nsIWebBrowserChrome::CHROME_WINDOW_MINIMIZE; + } + if (aFeatures.GetBoolWithDefault("scrollbars", true, &presenceFlag)) { + chromeFlags |= nsIWebBrowserChrome::CHROME_SCROLLBARS; + } // Determine whether the window is a private browsing window if (aFeatures.GetBoolWithDefault("private", false, &presenceFlag)) { @@ -2030,10 +2017,6 @@ uint32_t nsWindowWatcher::CalculateChromeFlagsForSystem( } } - /* missing - chromeFlags->copy_history - */ - return chromeFlags; } diff --git a/toolkit/components/windowwatcher/nsWindowWatcher.h b/toolkit/components/windowwatcher/nsWindowWatcher.h index e34865f510be..fa19b1480e07 100644 --- a/toolkit/components/windowwatcher/nsWindowWatcher.h +++ b/toolkit/components/windowwatcher/nsWindowWatcher.h @@ -96,10 +96,6 @@ class nsWindowWatcher : public nsIWindowWatcher, nsIWebBrowserChrome* aParentChrome, uint32_t aChromeFlags, nsIOpenWindowInfo* aOpenWindowInfo, nsIWebBrowserChrome** aResult); - static uint32_t CalculateChromeFlagsHelper( - uint32_t aInitialFlags, const mozilla::dom::WindowFeatures& aFeatures, - bool* presenceFlag = nullptr); - protected: nsTArray mEnumeratorList; nsWatcherWindowEntry* mOldestWindow;