From 0207ce545130d2d13a8da4cf07f937ae7a70cda1 Mon Sep 17 00:00:00 2001 From: Dorel Luca Date: Mon, 4 Nov 2019 19:18:56 +0200 Subject: [PATCH] Backed out 2 changesets (bug 1470510) for build bustage on /build/src/widget/cocoa/nsChildView.mm. CLOSED TREE Backed out changeset 5967bf633574 (bug 1470510) Backed out changeset 067a556bb614 (bug 1470510) --HG-- rename : xpfe/appshell/nsIAppWindow.idl => xpfe/appshell/nsIXULWindow.idl rename : xpfe/appshell/AppWindow.cpp => xpfe/appshell/nsXULWindow.cpp rename : xpfe/appshell/AppWindow.h => xpfe/appshell/nsXULWindow.h extra : amend_source : 752d828c6a0726c3f2df57a25741e38b36b75d6b --- accessible/generic/RootAccessible.cpp | 10 +- browser/base/content/browser.js | 4 +- browser/components/BrowserGlue.jsm | 8 +- .../components/downloads/DownloadsTaskbar.jsm | 2 +- .../extensions/parent/ext-browser.js | 2 +- .../browser/browser_ext_windows_create.js | 2 +- ...privatebrowsing_context_and_chromeFlags.js | 4 +- browser/components/search/SearchTelemetry.jsm | 12 +- .../components/sessionstore/SessionStore.jsm | 10 +- browser/components/tests/startupRecorder.js | 4 +- devtools/server/actors/webbrowser.js | 14 +- docshell/base/nsDocShell.cpp | 2 +- docshell/base/nsDocShellTreeOwner.cpp | 4 +- .../browser_test-content-chromeflags.js | 2 +- dom/base/Document.cpp | 18 +- dom/base/Document.h | 6 +- dom/base/nsCCUncollectableMarker.cpp | 4 +- dom/base/nsFocusManager.cpp | 8 +- dom/base/nsFrameLoader.cpp | 4 +- dom/base/nsGlobalWindowInner.cpp | 1 + dom/base/nsGlobalWindowOuter.cpp | 14 +- dom/ipc/BrowserParent.cpp | 10 +- dom/ipc/ContentParent.cpp | 2 +- dom/xul/XULPersist.cpp | 20 +- .../talos/talos/tests/devtools/addon/api.js | 2 +- testing/talos/talos/tests/twinopen/api.js | 2 +- toolkit/components/browser/nsWebBrowser.cpp | 2 +- .../components/extensions/ExtensionParent.jsm | 4 +- .../extensions/parent/ext-tabs-base.js | 10 +- .../components/printingui/nsPrintProgress.cpp | 6 +- .../components/prompts/test/chromeScript.js | 2 +- .../sessionstore/SessionStoreListener.cpp | 4 +- toolkit/components/startup/nsAppStartup.cpp | 16 +- .../windowwatcher/nsWindowWatcher.cpp | 16 +- .../browser_new_content_window_chromeflags.js | 2 +- .../test/browser_new_remote_window_flags.js | 2 +- .../test/test_alwaysOnTop_windows.html | 2 +- .../test/test_modal_windows.html | 2 +- toolkit/components/xulstore/new/XULStore.jsm | 2 +- toolkit/components/xulstore/old/XULStore.jsm | 2 +- .../content/tests/chrome/findbar_window.xul | 2 +- toolkit/content/widgets/findbar.js | 2 +- toolkit/xre/nsINativeAppSupport.idl | 2 + widget/android/nsWindow.cpp | 10 +- widget/cocoa/nsCocoaUtils.mm | 6 +- widget/cocoa/nsCocoaWindow.mm | 6 +- widget/nsBaseWidget.cpp | 16 +- widget/nsIWidgetListener.cpp | 4 +- widget/nsIWidgetListener.h | 6 +- widget/tests/TestAppShellSteadyState.cpp | 8 +- widget/windows/WidgetTraceEvent.cpp | 4 +- widget/windows/WindowsUIUtils.cpp | 1 + xpfe/appshell/moz.build | 5 +- xpfe/appshell/nsAppShellService.cpp | 40 +- xpfe/appshell/nsAppShellService.h | 10 +- xpfe/appshell/nsAppShellWindowEnumerator.cpp | 58 +- xpfe/appshell/nsAppShellWindowEnumerator.h | 32 +- xpfe/appshell/nsChromeTreeOwner.cpp | 188 ++- xpfe/appshell/nsChromeTreeOwner.h | 12 +- xpfe/appshell/nsContentTreeOwner.cpp | 234 ++-- xpfe/appshell/nsContentTreeOwner.h | 12 +- xpfe/appshell/nsIAppShellService.idl | 10 +- xpfe/appshell/nsIWindowMediator.idl | 36 +- xpfe/appshell/nsIWindowMediatorListener.idl | 6 +- .../{nsIAppWindow.idl => nsIXULWindow.idl} | 12 +- xpfe/appshell/nsWebShellWindow.cpp | 818 ++++++++++++ xpfe/appshell/nsWebShellWindow.h | 133 ++ xpfe/appshell/nsWindowMediator.cpp | 38 +- xpfe/appshell/nsWindowMediator.h | 16 +- .../{AppWindow.cpp => nsXULWindow.cpp} | 1113 +++-------------- xpfe/appshell/{AppWindow.h => nsXULWindow.h} | 147 +-- 71 files changed, 1673 insertions(+), 1557 deletions(-) rename xpfe/appshell/{nsIAppWindow.idl => nsIXULWindow.idl} (96%) create mode 100644 xpfe/appshell/nsWebShellWindow.cpp create mode 100644 xpfe/appshell/nsWebShellWindow.h rename xpfe/appshell/{AppWindow.cpp => nsXULWindow.cpp} (66%) rename xpfe/appshell/{AppWindow.h => nsXULWindow.h} (56%) diff --git a/accessible/generic/RootAccessible.cpp b/accessible/generic/RootAccessible.cpp index bbbcd3d82d94..b8c7d7ea0589 100644 --- a/accessible/generic/RootAccessible.cpp +++ b/accessible/generic/RootAccessible.cpp @@ -45,7 +45,7 @@ #include "nsGlobalWindow.h" #ifdef MOZ_XUL -# include "nsIAppWindow.h" +# include "nsIXULWindow.h" #endif using namespace mozilla; @@ -97,18 +97,18 @@ role RootAccessible::NativeRole() const { uint32_t RootAccessible::GetChromeFlags() const { // Return the flag set for the top level window as defined // by nsIWebBrowserChrome::CHROME_WINDOW_[FLAGNAME] - // Not simple: nsIAppWindow is not just a QI from nsIDOMWindow + // Not simple: nsIXULWindow is not just a QI from nsIDOMWindow nsCOMPtr docShell = nsCoreUtils::GetDocShellFor(mDocumentNode); NS_ENSURE_TRUE(docShell, 0); nsCOMPtr treeOwner; docShell->GetTreeOwner(getter_AddRefs(treeOwner)); NS_ENSURE_TRUE(treeOwner, 0); - nsCOMPtr appWin(do_GetInterface(treeOwner)); - if (!appWin) { + nsCOMPtr xulWin(do_GetInterface(treeOwner)); + if (!xulWin) { return 0; } uint32_t chromeFlags; - appWin->GetChromeFlags(&chromeFlags); + xulWin->GetChromeFlags(&chromeFlags); return chromeFlags; } #endif diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index a27bc5e741f7..1eb3d3a3a436 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -1759,7 +1759,7 @@ var gBrowserInit = { // This needs setting up before we create the first remote browser. window.docShell.treeOwner .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIAppWindow).XULBrowserWindow = window.XULBrowserWindow; + .getInterface(Ci.nsIXULWindow).XULBrowserWindow = window.XULBrowserWindow; window.browserDOMWindow = new nsBrowserAccess(); gBrowser = window._gBrowser; @@ -2534,7 +2534,7 @@ var gBrowserInit = { window.XULBrowserWindow = null; window.docShell.treeOwner .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIAppWindow).XULBrowserWindow = null; + .getInterface(Ci.nsIXULWindow).XULBrowserWindow = null; window.browserDOMWindow = null; }, }; diff --git a/browser/components/BrowserGlue.jsm b/browser/components/BrowserGlue.jsm index 60d66fef340f..3f1da8deaee9 100644 --- a/browser/components/BrowserGlue.jsm +++ b/browser/components/BrowserGlue.jsm @@ -449,11 +449,11 @@ let LEGACY_ACTORS = { // Set the size to use when the user leaves the maximized mode. // The persisted size is the outer size, but the height/width // attributes set the inner size. - let appWin = win.docShell.treeOwner + let xulWin = win.docShell.treeOwner .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIAppWindow); - height -= appWin.outerToInnerHeightDifferenceInCSSPixels; - width -= appWin.outerToInnerWidthDifferenceInCSSPixels; + .getInterface(Ci.nsIXULWindow); + height -= xulWin.outerToInnerHeightDifferenceInCSSPixels; + width -= xulWin.outerToInnerWidthDifferenceInCSSPixels; docElt.setAttribute("height", height); docElt.setAttribute("width", width); } else { diff --git a/browser/components/downloads/DownloadsTaskbar.jsm b/browser/components/downloads/DownloadsTaskbar.jsm index 380c4c679178..970e3dc5c0b1 100644 --- a/browser/components/downloads/DownloadsTaskbar.jsm +++ b/browser/components/downloads/DownloadsTaskbar.jsm @@ -131,7 +131,7 @@ var DownloadsTaskbar = { // Activate the indicator on the specified window. let docShell = aWindow.docShell.treeOwner .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIAppWindow).docShell; + .getInterface(Ci.nsIXULWindow).docShell; this._taskbarProgress = gWinTaskbar.getTaskbarProgress(docShell); // If the DownloadSummary object has already been created, we should update diff --git a/browser/components/extensions/parent/ext-browser.js b/browser/components/extensions/parent/ext-browser.js index 54ecc80a7d23..63f78e91e65c 100644 --- a/browser/components/extensions/parent/ext-browser.js +++ b/browser/components/extensions/parent/ext-browser.js @@ -1009,7 +1009,7 @@ class Window extends WindowBase { } get alwaysOnTop() { - return this.appWindow.zLevel >= Ci.nsIAppWindow.raisedZ; + return this.xulWindow.zLevel >= Ci.nsIXULWindow.raisedZ; } get isLastFocused() { diff --git a/browser/components/extensions/test/browser/browser_ext_windows_create.js b/browser/components/extensions/test/browser/browser_ext_windows_create.js index 57d8caf5f073..1c06d3686d75 100644 --- a/browser/components/extensions/test/browser/browser_ext_windows_create.js +++ b/browser/components/extensions/test/browser/browser_ext_windows_create.js @@ -172,7 +172,7 @@ add_task(async function testWindowCreate() { if (expected.chromeFlags) { let { chromeFlags } = latestWindow.docShell.treeOwner .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIAppWindow); + .getInterface(Ci.nsIXULWindow); for (let flag of expected.chromeFlags) { ok( chromeFlags & Ci.nsIWebBrowserChrome[flag], diff --git a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_context_and_chromeFlags.js b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_context_and_chromeFlags.js index e840dc9a34aa..f43f8c8159f1 100644 --- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_context_and_chromeFlags.js +++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_context_and_chromeFlags.js @@ -2,7 +2,7 @@ /** * Given some window in the parent process, ensure that - * the nsIAppWindow has the CHROME_PRIVATE_WINDOW chromeFlag, + * the nsIXULWindow has the CHROME_PRIVATE_WINDOW chromeFlag, * and that the usePrivateBrowsing property is set to true on * both the window's nsILoadContext, as well as on the initial * browser's content docShell nsILoadContext. @@ -15,7 +15,7 @@ function assertWindowIsPrivate(win) { let winDocShell = win.docShell; let chromeFlags = winDocShell.treeOwner .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIAppWindow).chromeFlags; + .getInterface(Ci.nsIXULWindow).chromeFlags; if (!win.gBrowser.selectedBrowser.hasContentOpener) { Assert.ok( diff --git a/browser/components/search/SearchTelemetry.jsm b/browser/components/search/SearchTelemetry.jsm index 9346a08b5e30..2eeb18b0cd9b 100644 --- a/browser/components/search/SearchTelemetry.jsm +++ b/browser/components/search/SearchTelemetry.jsm @@ -244,10 +244,10 @@ class TelemetryHandler { * This is called when a new window is opened, and handles registration of * that window if it is a browser window. * - * @param {nsIAppWindow} appWin The xul window that was opened. + * @param {nsIXULWindow} xulWin The xul window that was opened. */ - onOpenWindow(appWin) { - let win = appWin.docShell.domWindow; + onOpenWindow(xulWin) { + let win = xulWin.docShell.domWindow; win.addEventListener( "load", () => { @@ -268,10 +268,10 @@ class TelemetryHandler { * Listener that is called when a window is closed, and handles deregistration of * that window if it is a browser window. * - * @param {nsIAppWindow} appWin The xul window that was closed. + * @param {nsIXULWindow} xulWin The xul window that was closed. */ - onCloseWindow(appWin) { - let win = appWin.docShell.domWindow; + onCloseWindow(xulWin) { + let win = xulWin.docShell.domWindow; if ( win.document.documentElement.getAttribute("windowtype") != diff --git a/browser/components/sessionstore/SessionStore.jsm b/browser/components/sessionstore/SessionStore.jsm index c1c11e49a142..f5e4ae04a011 100644 --- a/browser/components/sessionstore/SessionStore.jsm +++ b/browser/components/sessionstore/SessionStore.jsm @@ -5259,7 +5259,7 @@ var SessionStoreInternal = { }, /** - * on popup windows, the AppWindow's attributes seem not to be set correctly + * on popup windows, the XULWindow's attributes seem not to be set correctly * we use thus JSDOMWindow attributes for sizemode and normal window attributes * (and hope for reasonable values when maximized/minimized - since then * outerWidth/outerHeight aren't the dimensions of the restored window) @@ -5298,13 +5298,13 @@ var SessionStoreInternal = { } // Width and height attribute report the inner size, but we want // to store the outer size, so add the difference. - let appWin = aWindow.docShell.treeOwner + let xulWin = aWindow.docShell.treeOwner .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIAppWindow); + .getInterface(Ci.nsIXULWindow); let diff = aAttribute == "width" - ? appWin.outerToInnerWidthDifferenceInCSSPixels - : appWin.outerToInnerHeightDifferenceInCSSPixels; + ? xulWin.outerToInnerWidthDifferenceInCSSPixels + : xulWin.outerToInnerHeightDifferenceInCSSPixels; return attr + diff; } } diff --git a/browser/components/tests/startupRecorder.js b/browser/components/tests/startupRecorder.js index 3bc132a3066c..48d99ff9674a 100644 --- a/browser/components/tests/startupRecorder.js +++ b/browser/components/tests/startupRecorder.js @@ -123,8 +123,8 @@ startupRecorder.prototype = { // not other types (for example, the gfx sanity test window) if (topic == firstPaintNotification) { // In the case we're handling xul-window-visible, we'll have been handed - // an nsIAppWindow instead of an nsIDOMWindow. - if (subject instanceof Ci.nsIAppWindow) { + // an nsIXULWindow instead of an nsIDOMWindow. + if (subject instanceof Ci.nsIXULWindow) { subject = subject .QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIDOMWindow); diff --git a/devtools/server/actors/webbrowser.js b/devtools/server/actors/webbrowser.js index b9f5b36e72cf..782e719b38e3 100644 --- a/devtools/server/actors/webbrowser.js +++ b/devtools/server/actors/webbrowser.js @@ -289,12 +289,12 @@ BrowserTabList.prototype._getChildren = function(window) { }; BrowserTabList.prototype.getList = function(browserActorOptions) { - const topAppWindow = Services.wm.getMostRecentWindow( + const topXULWindow = Services.wm.getMostRecentWindow( DebuggerServer.chromeWindowType ); let selectedBrowser = null; - if (topAppWindow) { - selectedBrowser = this._getSelectedBrowser(topAppWindow); + if (topXULWindow) { + selectedBrowser = this._getSelectedBrowser(topXULWindow); } // As a sanity check, make sure all the actors presently in our map get @@ -416,11 +416,11 @@ BrowserTabList.prototype.getTab = function( }); } - const topAppWindow = Services.wm.getMostRecentWindow( + const topXULWindow = Services.wm.getMostRecentWindow( DebuggerServer.chromeWindowType ); - if (topAppWindow) { - const selectedBrowser = this._getSelectedBrowser(topAppWindow); + if (topXULWindow) { + const selectedBrowser = this._getSelectedBrowser(topXULWindow); return this._getActorForBrowser(selectedBrowser, browserActorOptions); } return Promise.reject({ @@ -781,7 +781,7 @@ BrowserTabList.prototype.onOpenWindow = DevToolsUtils.makeInfallible(function( BrowserTabList.prototype.onCloseWindow = DevToolsUtils.makeInfallible(function( window ) { - if (window instanceof Ci.nsIAppWindow) { + if (window instanceof Ci.nsIXULWindow) { window = window.docShell.domWindow; } diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 218194668bb2..30e3e058f4b8 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -4984,7 +4984,7 @@ nsDocShell::SetParentNativeWindow(nativeWindow aParentNativeWindow) { NS_IMETHODIMP nsDocShell::GetNativeHandle(nsAString& aNativeHandle) { - // the nativeHandle should be accessed from nsIAppWindow + // the nativeHandle should be accessed from nsIXULWindow return NS_ERROR_NOT_IMPLEMENTED; } diff --git a/docshell/base/nsDocShellTreeOwner.cpp b/docshell/base/nsDocShellTreeOwner.cpp index dfc5245c28c3..13935ce24070 100644 --- a/docshell/base/nsDocShellTreeOwner.cpp +++ b/docshell/base/nsDocShellTreeOwner.cpp @@ -360,7 +360,7 @@ nsDocShellTreeOwner::SizeShellTo(nsIDocShellTreeItem* aShellItem, int32_t aCX, if (browserChild) { // The XUL window to resize is in the parent process, but there we // won't be able to get aShellItem to do the hack in - // AppWindow::SizeShellTo, so let's send the width and height of + // nsXULWindow::SizeShellTo, so let's send the width and height of // aShellItem too. nsCOMPtr shellAsWin(do_QueryInterface(aShellItem)); NS_ENSURE_TRUE(shellAsWin, NS_ERROR_FAILURE); @@ -588,7 +588,7 @@ nsDocShellTreeOwner::SetParentNativeWindow(nativeWindow aParentNativeWindow) { NS_IMETHODIMP nsDocShellTreeOwner::GetNativeHandle(nsAString& aNativeHandle) { - // the nativeHandle should be accessed from nsIAppWindow + // the nativeHandle should be accessed from nsIXULWindow return NS_ERROR_NOT_IMPLEMENTED; } diff --git a/docshell/test/navigation/browser_test-content-chromeflags.js b/docshell/test/navigation/browser_test-content-chromeflags.js index af527b2dbc87..19cb37d5c900 100644 --- a/docshell/test/navigation/browser_test-content-chromeflags.js +++ b/docshell/test/navigation/browser_test-content-chromeflags.js @@ -33,7 +33,7 @@ add_task(async function() { let chromeFlags = win.docShell.treeOwner .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIAppWindow).chromeFlags; + .getInterface(Ci.nsIXULWindow).chromeFlags; let expected = CHROME_ALL; diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp index f929df5243c9..c67b24de060e 100644 --- a/dom/base/Document.cpp +++ b/dom/base/Document.cpp @@ -312,7 +312,7 @@ #ifdef MOZ_XUL # include "mozilla/dom/XULBroadcastManager.h" # include "mozilla/dom/XULPersist.h" -# include "nsIAppWindow.h" +# include "nsIXULWindow.h" # include "nsIChromeRegistry.h" # include "nsXULPrototypeDocument.h" # include "nsXULCommandDispatcher.h" @@ -8381,7 +8381,7 @@ void Document::SetMayStartLayout(bool aMayStartLayout) { // Before starting layout, check whether we're a toplevel chrome // window. If we are, setup some state so that we don't have to restyle // the whole tree after StartLayout. - if (nsCOMPtr win = GetAppWindowIfToplevelChrome()) { + if (nsCOMPtr win = GetXULWindowIfToplevelChrome()) { // We're the chrome document! win->BeforeStartLayout(); } @@ -14275,23 +14275,23 @@ already_AddRefed Document::Evaluate( aType, aResult, rv); } -already_AddRefed Document::GetAppWindowIfToplevelChrome() const { +already_AddRefed Document::GetXULWindowIfToplevelChrome() const { nsCOMPtr item = GetDocShell(); if (!item) { return nullptr; } nsCOMPtr owner; item->GetTreeOwner(getter_AddRefs(owner)); - nsCOMPtr appWin = do_GetInterface(owner); - if (!appWin) { + nsCOMPtr xulWin = do_GetInterface(owner); + if (!xulWin) { return nullptr; } - nsCOMPtr appWinShell; - appWin->GetDocShell(getter_AddRefs(appWinShell)); - if (!SameCOMIdentity(appWinShell, item)) { + nsCOMPtr xulWinShell; + xulWin->GetDocShell(getter_AddRefs(xulWinShell)); + if (!SameCOMIdentity(xulWinShell, item)) { return nullptr; } - return appWin.forget(); + return xulWin.forget(); } Document* Document::GetTopLevelContentDocument() { diff --git a/dom/base/Document.h b/dom/base/Document.h index f468665c9d07..030a62bc756d 100644 --- a/dom/base/Document.h +++ b/dom/base/Document.h @@ -133,7 +133,7 @@ class nsWindowSizes; class nsDOMCaretPosition; class nsViewportInfo; class nsIGlobalObject; -class nsIAppWindow; +class nsIXULWindow; class nsXULPrototypeDocument; class nsXULPrototypeElement; class PermissionDelegateHandler; @@ -3536,9 +3536,9 @@ class Document : public nsINode, Document* GetTopLevelContentDocument(); const Document* GetTopLevelContentDocument() const; - // Returns the associated app window if this is a top-level chrome document, + // Returns the associated XUL window if this is a top-level chrome document, // null otherwise. - already_AddRefed GetAppWindowIfToplevelChrome() const; + already_AddRefed GetXULWindowIfToplevelChrome() const; already_AddRefed CreateElement( const nsAString& aTagName, const ElementCreationOptionsOrString& aOptions, diff --git a/dom/base/nsCCUncollectableMarker.cpp b/dom/base/nsCCUncollectableMarker.cpp index 076f4179abce..acf259662c36 100644 --- a/dom/base/nsCCUncollectableMarker.cpp +++ b/dom/base/nsCCUncollectableMarker.cpp @@ -18,7 +18,7 @@ #include "nsISHEntry.h" #include "nsIWindowWatcher.h" #include "mozilla/Services.h" -#include "nsIAppWindow.h" +#include "nsIXULWindow.h" #include "nsIAppShellService.h" #include "nsAppShellCID.h" #include "nsContentUtils.h" @@ -351,7 +351,7 @@ nsresult nsCCUncollectableMarker::Observe(nsISupports* aSubject, bool hasHiddenWindow = false; appShell->GetHasHiddenWindow(&hasHiddenWindow); if (hasHiddenWindow) { - nsCOMPtr hw; + nsCOMPtr hw; appShell->GetHiddenWindow(getter_AddRefs(hw)); nsCOMPtr shell; hw->GetDocShell(getter_AddRefs(shell)); diff --git a/dom/base/nsFocusManager.cpp b/dom/base/nsFocusManager.cpp index 22e9da783552..2b57d1942a12 100644 --- a/dom/base/nsFocusManager.cpp +++ b/dom/base/nsFocusManager.cpp @@ -24,7 +24,7 @@ #include "nsIWebNavigation.h" #include "nsCaret.h" #include "nsIBaseWindow.h" -#include "nsIAppWindow.h" +#include "nsIXULWindow.h" #include "nsViewManager.h" #include "nsFrameSelection.h" #include "mozilla/dom/Document.h" @@ -700,10 +700,10 @@ nsFocusManager::WindowRaised(mozIDOMWindowProxy* aWindow) { NS_ASSERTION(currentWindow, "window raised with no window current"); if (!currentWindow) return NS_OK; - // If there is no nsIAppWindow, then this is an embedded or child process + // If there is no nsIXULWindow, then this is an embedded or child process // window. Pass false for aWindowRaised so that commands get updated. - nsCOMPtr appWin(do_GetInterface(baseWindow)); - Focus(currentWindow, currentFocus, 0, true, false, appWin != nullptr, true); + nsCOMPtr xulWin(do_GetInterface(baseWindow)); + Focus(currentWindow, currentFocus, 0, true, false, xulWin != nullptr, true); return NS_OK; } diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp index 0a15ee4641e3..514927fa1733 100644 --- a/dom/base/nsFrameLoader.cpp +++ b/dom/base/nsFrameLoader.cpp @@ -39,7 +39,7 @@ #include "nsSubDocumentFrame.h" #include "nsError.h" #include "nsISHistory.h" -#include "nsIAppWindow.h" +#include "nsIXULWindow.h" #include "nsIMozBrowserFrame.h" #include "nsISHistory.h" #include "nsIScriptError.h" @@ -2598,7 +2598,7 @@ bool nsFrameLoader::TryRemoteBrowserInternal() { !parentOwner) { return false; } - nsCOMPtr window(do_GetInterface(parentOwner)); + nsCOMPtr window(do_GetInterface(parentOwner)); if (window && NS_FAILED(window->GetChromeFlags(&chromeFlags))) { return false; } diff --git a/dom/base/nsGlobalWindowInner.cpp b/dom/base/nsGlobalWindowInner.cpp index db4130f1d2de..501ee91803cc 100644 --- a/dom/base/nsGlobalWindowInner.cpp +++ b/dom/base/nsGlobalWindowInner.cpp @@ -160,6 +160,7 @@ #include "mozilla/EventStateManager.h" #include "nsIObserverService.h" #include "nsFocusManager.h" +#include "nsIXULWindow.h" #include "nsITimedChannel.h" #include "nsServiceManagerUtils.h" #ifdef MOZ_XUL diff --git a/dom/base/nsGlobalWindowOuter.cpp b/dom/base/nsGlobalWindowOuter.cpp index b3e5efb5482b..3b08bc2e2e34 100644 --- a/dom/base/nsGlobalWindowOuter.cpp +++ b/dom/base/nsGlobalWindowOuter.cpp @@ -154,7 +154,7 @@ #include "mozilla/EventStateManager.h" #include "nsIObserverService.h" #include "nsFocusManager.h" -#include "nsIAppWindow.h" +#include "nsIXULWindow.h" #include "nsITimedChannel.h" #include "nsServiceManagerUtils.h" #include "mozilla/dom/CustomEvent.h" @@ -1546,7 +1546,7 @@ void nsGlobalWindowOuter::SetInitialPrincipalToSubject( // We should never create windows with an expanded principal. // If we have a system principal, make sure we're not using it for a content // docshell. - // NOTE: Please keep this logic in sync with AppWindow::Initialize(). + // NOTE: Please keep this logic in sync with nsWebShellWindow::Initialize(). if (nsContentUtils::IsExpandedPrincipal(newWindowPrincipal) || (nsContentUtils::IsSystemPrincipal(newWindowPrincipal) && GetDocShell()->ItemType() != nsIDocShellTreeItem::typeChrome)) { @@ -4404,9 +4404,9 @@ nsresult nsGlobalWindowOuter::SetFullscreenInternal(FullscreenReason aReason, // Prevent chrome documents which are still loading from resizing // the window after we set fullscreen mode. nsCOMPtr treeOwnerAsWin = GetTreeOwnerWindow(); - nsCOMPtr appWin(do_GetInterface(treeOwnerAsWin)); - if (aFullscreen && appWin) { - appWin->SetIntrinsicallySized(false); + nsCOMPtr xulWin(do_GetInterface(treeOwnerAsWin)); + if (aFullscreen && xulWin) { + xulWin->SetIntrinsicallySized(false); } // Set this before so if widget sends an event indicating its @@ -6795,10 +6795,10 @@ void nsGlobalWindowOuter::ActivateOrDeactivate(bool aActivate) { // Get the top level widget's nsGlobalWindowOuter nsCOMPtr topLevelWindow; - // widgetListener should be an AppWindow + // widgetListener should be a nsXULWindow nsIWidgetListener* listener = topLevelWidget->GetWidgetListener(); if (listener) { - nsCOMPtr window = listener->GetAppWindow(); + nsCOMPtr window = listener->GetXULWindow(); nsCOMPtr req(do_QueryInterface(window)); topLevelWindow = do_GetInterface(req); } diff --git a/dom/ipc/BrowserParent.cpp b/dom/ipc/BrowserParent.cpp index 5cec39318a29..4704d0fa6f90 100644 --- a/dom/ipc/BrowserParent.cpp +++ b/dom/ipc/BrowserParent.cpp @@ -72,7 +72,7 @@ #include "nsIWebBrowserChrome.h" #include "nsIWebProtocolHandlerRegistrar.h" #include "nsIXULBrowserWindow.h" -#include "nsIAppWindow.h" +#include "nsIXULWindow.h" #include "nsViewManager.h" #include "nsVariant.h" #include "nsIWidget.h" @@ -410,7 +410,7 @@ nsIXULBrowserWindow* BrowserParent::GetXULBrowserWindow() { return nullptr; } - nsCOMPtr window = do_GetInterface(treeOwner); + nsCOMPtr window = do_GetInterface(treeOwner); if (!window) { return nullptr; } @@ -798,9 +798,9 @@ mozilla::ipc::IPCResult BrowserParent::RecvSizeShellTo( height = mDimensions.height; } - nsCOMPtr appWin(do_GetInterface(treeOwner)); - NS_ENSURE_TRUE(appWin, IPC_OK()); - appWin->SizeShellToWithLimit(width, height, aShellItemWidth, + nsCOMPtr xulWin(do_GetInterface(treeOwner)); + NS_ENSURE_TRUE(xulWin, IPC_OK()); + xulWin->SizeShellToWithLimit(width, height, aShellItemWidth, aShellItemHeight); return IPC_OK(); diff --git a/dom/ipc/ContentParent.cpp b/dom/ipc/ContentParent.cpp index 046434bca2d2..30f6a44f4ef0 100644 --- a/dom/ipc/ContentParent.cpp +++ b/dom/ipc/ContentParent.cpp @@ -178,7 +178,7 @@ #include "nsIURIFixup.h" #include "nsIURL.h" #include "nsIDocShellTreeOwner.h" -#include "nsIAppWindow.h" +#include "nsIXULWindow.h" #include "nsIDOMChromeWindow.h" #include "nsIWindowWatcher.h" #include "nsPIWindowWatcher.h" diff --git a/dom/xul/XULPersist.cpp b/dom/xul/XULPersist.cpp index 3c12f537a63a..81648bac2308 100644 --- a/dom/xul/XULPersist.cpp +++ b/dom/xul/XULPersist.cpp @@ -13,7 +13,7 @@ # include "nsIStringEnumerator.h" #endif -#include "nsIAppWindow.h" +#include "nsIXULWindow.h" namespace mozilla { namespace dom { @@ -25,12 +25,12 @@ static bool IsRootElement(Element* aElement) { static bool ShouldPersistAttribute(Element* aElement, nsAtom* aAttribute) { if (IsRootElement(aElement)) { // This is not an element of the top document, its owner is - // not an AppWindow. Persist it. + // not an nsXULWindow. Persist it. if (aElement->OwnerDoc()->GetInProcessParentDocument()) { return true; } // The following attributes of xul:window should be handled in - // AppWindow::SavePersistentAttributes instead of here. + // nsXULWindow::SavePersistentAttributes instead of here. if (aAttribute == nsGkAtoms::screenX || aAttribute == nsGkAtoms::screenY || aAttribute == nsGkAtoms::width || aAttribute == nsGkAtoms::height || aAttribute == nsGkAtoms::sizemode) { @@ -66,7 +66,7 @@ void XULPersist::AttributeChanged(dom::Element* aElement, int32_t aNameSpaceID, // // XXX Namespace handling broken :-( nsAutoString persist; - // Persistence of attributes of xul:window is handled in AppWindow. + // Persistence of attributes of xul:window is handled in nsXULWindow. if (aElement->GetAttr(kNameSpaceID_None, nsGkAtoms::persist, persist) && ShouldPersistAttribute(aElement, aAttribute) && !persist.IsEmpty() && // XXXldb This should check that it's a token, not just a substring. @@ -135,10 +135,10 @@ void XULPersist::Persist(Element* aElement, int32_t aNameSpaceID, return; } - // Persisting attributes to top level windows is handled by AppWindow. + // Persisting attributes to top level windows is handled by nsXULWindow. if (IsRootElement(aElement)) { - if (nsCOMPtr win = - mDocument->GetAppWindowIfToplevelChrome()) { + if (nsCOMPtr win = + mDocument->GetXULWindowIfToplevelChrome()) { return; } } @@ -300,10 +300,10 @@ nsresult XULPersist::ApplyPersistentAttributesToElements( } // Applying persistent attributes to top level windows is handled - // by AppWindow. + // by nsXULWindow. if (IsRootElement(element)) { - if (nsCOMPtr win = - mDocument->GetAppWindowIfToplevelChrome()) { + if (nsCOMPtr win = + mDocument->GetXULWindowIfToplevelChrome()) { continue; } } diff --git a/testing/talos/talos/tests/devtools/addon/api.js b/testing/talos/talos/tests/devtools/addon/api.js index 1faee44a0d67..159c598e0973 100644 --- a/testing/talos/talos/tests/devtools/addon/api.js +++ b/testing/talos/talos/tests/devtools/addon/api.js @@ -13,7 +13,7 @@ this.damp = class extends ExtensionAPI { damp: { startTest() { let { rootURI } = context.extension; - let window = context.appWindow; + let window = context.xulWindow; if (!("Damp" in window)) { let script = rootURI.resolve("content/damp.js"); Services.scriptloader.loadSubScript(script, window); diff --git a/testing/talos/talos/tests/twinopen/api.js b/testing/talos/talos/tests/twinopen/api.js index 3cfcc17b45c5..f8949e66f732 100644 --- a/testing/talos/talos/tests/twinopen/api.js +++ b/testing/talos/talos/tests/twinopen/api.js @@ -55,7 +55,7 @@ async function startTest(context) { Cu.forceGC(); Cu.forceCC(); Cu.forceShrinkingGC(); - let win = context.appWindow; + let win = context.xulWindow; await openDelay(win); let mozAfterPaint = waitForBrowserPaint(); diff --git a/toolkit/components/browser/nsWebBrowser.cpp b/toolkit/components/browser/nsWebBrowser.cpp index 8bb18cf4a30e..164103108678 100644 --- a/toolkit/components/browser/nsWebBrowser.cpp +++ b/toolkit/components/browser/nsWebBrowser.cpp @@ -1079,7 +1079,7 @@ nsWebBrowser::SetParentNativeWindow(nativeWindow aParentNativeWindow) { NS_IMETHODIMP nsWebBrowser::GetNativeHandle(nsAString& aNativeHandle) { - // the nativeHandle should be accessed from nsIAppWindow + // the nativeHandle should be accessed from nsIXULWindow return NS_ERROR_NOT_IMPLEMENTED; } diff --git a/toolkit/components/extensions/ExtensionParent.jsm b/toolkit/components/extensions/ExtensionParent.jsm index a10184ede611..f4be5324b378 100644 --- a/toolkit/components/extensions/ExtensionParent.jsm +++ b/toolkit/components/extensions/ExtensionParent.jsm @@ -808,14 +808,14 @@ class ExtensionPageContextParent extends ProxyContextParent { } // The window that contains this context. This may change due to moving tabs. - get appWindow() { + get xulWindow() { let win = this.xulBrowser.ownerGlobal; return win.docShell.rootTreeItem.domWindow; } get currentWindow() { if (this.viewType !== "background") { - return this.appWindow; + return this.xulWindow; } } diff --git a/toolkit/components/extensions/parent/ext-tabs-base.js b/toolkit/components/extensions/parent/ext-tabs-base.js index 7957bde9f477..bbf118632330 100644 --- a/toolkit/components/extensions/parent/ext-tabs-base.js +++ b/toolkit/components/extensions/parent/ext-tabs-base.js @@ -843,14 +843,14 @@ class WindowBase { } /** - * @property {nsIAppWindow} appWindow - * The nsIAppWindow object for this browser window. + * @property {nsIXULWindow} xulWindow + * The nsIXULWindow object for this browser window. * @readonly */ - get appWindow() { + get xulWindow() { return this.window.docShell.treeOwner .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIAppWindow); + .getInterface(Ci.nsIXULWindow); } /** @@ -876,7 +876,7 @@ class WindowBase { * @readonly */ get type() { - let { chromeFlags } = this.appWindow; + let { chromeFlags } = this.xulWindow; if (chromeFlags & Ci.nsIWebBrowserChrome.CHROME_OPENAS_DIALOG) { return "popup"; diff --git a/toolkit/components/printingui/nsPrintProgress.cpp b/toolkit/components/printingui/nsPrintProgress.cpp index 1ae4c2f09dff..92e52915d65a 100644 --- a/toolkit/components/printingui/nsPrintProgress.cpp +++ b/toolkit/components/printingui/nsPrintProgress.cpp @@ -11,7 +11,7 @@ #include "nsIDocShell.h" #include "nsIDocShellTreeOwner.h" #include "nsIInterfaceRequestorUtils.h" -#include "nsIAppWindow.h" +#include "nsIXULWindow.h" #include "nsXPCOM.h" #include "nsISupportsPrimitives.h" #include "nsIComponentManager.h" @@ -75,8 +75,8 @@ NS_IMETHODIMP nsPrintProgress::OpenProgressDialog( nsCOMPtr owner; docShell->GetTreeOwner(getter_AddRefs(owner)); - nsCOMPtr ownerAppWindow = do_GetInterface(owner); - nsCOMPtr ownerWindow = do_GetInterface(ownerAppWindow); + nsCOMPtr ownerXULWindow = do_GetInterface(owner); + nsCOMPtr ownerWindow = do_GetInterface(ownerXULWindow); NS_ENSURE_STATE(ownerWindow); nsCOMPtr piOwnerWindow = diff --git a/toolkit/components/prompts/test/chromeScript.js b/toolkit/components/prompts/test/chromeScript.js index ce21a084c737..04c82e9bedfb 100644 --- a/toolkit/components/prompts/test/chromeScript.js +++ b/toolkit/components/prompts/test/chromeScript.js @@ -138,7 +138,7 @@ function getPromptState(ui) { // We can't just check window.opener because that'll be // a content window, which therefore isn't exposed (it'll lie and // be null). - let flags = treeOwner.getInterface(Ci.nsIAppWindow).chromeFlags; + let flags = treeOwner.getInterface(Ci.nsIXULWindow).chromeFlags; state.chrome = (flags & Ci.nsIWebBrowserChrome.CHROME_OPENAS_CHROME) != 0; state.dialog = (flags & Ci.nsIWebBrowserChrome.CHROME_OPENAS_DIALOG) != 0; state.chromeDependent = diff --git a/toolkit/components/sessionstore/SessionStoreListener.cpp b/toolkit/components/sessionstore/SessionStoreListener.cpp index 9ff518359a29..e3b8f4738630 100644 --- a/toolkit/components/sessionstore/SessionStoreListener.cpp +++ b/toolkit/components/sessionstore/SessionStoreListener.cpp @@ -17,7 +17,7 @@ #include "nsIPrefService.h" #include "nsIPrefBranch.h" #include "nsITimer.h" -#include "nsIAppWindow.h" +#include "nsIXULWindow.h" #include "nsIWebProgress.h" #include "nsPresContext.h" #include "nsPrintfCString.h" @@ -666,7 +666,7 @@ bool TabListener::UpdateSessionStore(uint32_t aFlushId, bool aIsFinal) { if (!treeOwner) { return false; } - nsCOMPtr window(do_GetInterface(treeOwner)); + nsCOMPtr window(do_GetInterface(treeOwner)); if (!window) { return false; } diff --git a/toolkit/components/startup/nsAppStartup.cpp b/toolkit/components/startup/nsAppStartup.cpp index 7a91518dfa97..cc1048ad5fb8 100644 --- a/toolkit/components/startup/nsAppStartup.cpp +++ b/toolkit/components/startup/nsAppStartup.cpp @@ -21,7 +21,7 @@ #include "nsIWindowMediator.h" #include "nsIWindowWatcher.h" #include "nsIXULRuntime.h" -#include "nsIAppWindow.h" +#include "nsIXULWindow.h" #include "nsNativeCharsetUtils.h" #include "nsThreadUtils.h" #include "nsAutoPtr.h" @@ -318,7 +318,7 @@ nsAppStartup::Quit(uint32_t aMode) { bool usefulHiddenWindow; appShell->GetApplicationProvidedHiddenWindow(&usefulHiddenWindow); - nsCOMPtr hiddenWindow; + nsCOMPtr hiddenWindow; appShell->GetHiddenWindow(getter_AddRefs(hiddenWindow)); // If the remaining windows are useful, we won't quit: if (!hiddenWindow || usefulHiddenWindow) { @@ -597,16 +597,16 @@ nsAppStartup::CreateChromeWindow(nsIWebBrowserChrome* aParent, return NS_ERROR_FAILURE; } - nsCOMPtr newWindow; + nsCOMPtr newWindow; if (aParent) { - nsCOMPtr appParent(do_GetInterface(aParent)); - NS_ASSERTION(appParent, - "window created using non-app parent. that's unexpected, but " + nsCOMPtr xulParent(do_GetInterface(aParent)); + NS_ASSERTION(xulParent, + "window created using non-XUL parent. that's unexpected, but " "may work."); - if (appParent) - appParent->CreateNewWindow(aChromeFlags, aOpeningTab, aOpener, + if (xulParent) + xulParent->CreateNewWindow(aChromeFlags, aOpeningTab, aOpener, aNextRemoteTabId, getter_AddRefs(newWindow)); // And if it fails, don't try again without a parent. It could fail // intentionally (bug 115969). diff --git a/toolkit/components/windowwatcher/nsWindowWatcher.cpp b/toolkit/components/windowwatcher/nsWindowWatcher.cpp index b8214d3d5a30..69f9e77495b0 100644 --- a/toolkit/components/windowwatcher/nsWindowWatcher.cpp +++ b/toolkit/components/windowwatcher/nsWindowWatcher.cpp @@ -71,7 +71,7 @@ #include "mozilla/dom/BrowserHost.h" #include "mozilla/dom/DocGroup.h" #include "mozilla/dom/TabGroup.h" -#include "nsIAppWindow.h" +#include "nsIXULWindow.h" #include "nsIXULBrowserWindow.h" #include "nsGlobalWindow.h" #include "ReferrerInfo.h" @@ -911,17 +911,17 @@ nsresult nsWindowWatcher::OpenWindowInternal( } if (newChrome) { - nsCOMPtr appWin = do_GetInterface(newChrome); - if (appWin) { + nsCOMPtr xulWin = do_GetInterface(newChrome); + if (xulWin) { nsCOMPtr xulBrowserWin; - appWin->GetXULBrowserWindow(getter_AddRefs(xulBrowserWin)); + xulWin->GetXULBrowserWindow(getter_AddRefs(xulBrowserWin)); if (xulBrowserWin) { nsPIDOMWindowOuter* openerWindow = aForceNoOpener ? nullptr : parentWindow.get(); xulBrowserWin->ForceInitialBrowserNonRemote(openerWindow); } } - /* It might be a chrome AppWindow, in which case it won't have + /* It might be a chrome nsXULWindow, in which case it won't have an nsIDOMWindow (primary content shell). But in that case, it'll be able to hand over an nsIDocShellTreeItem directly. */ nsCOMPtr newWindow(do_GetInterface(newChrome)); @@ -2372,9 +2372,9 @@ void nsWindowWatcher::SizeOpenedWindow(nsIDocShellTreeOwner* aTreeOwner, } if (aIsCallerChrome) { - nsCOMPtr appWin = do_GetInterface(treeOwnerAsWin); - if (appWin && aSizeSpec.mLockAspectRatio) { - appWin->LockAspectRatio(true); + nsCOMPtr xulWin = do_GetInterface(treeOwnerAsWin); + if (xulWin && aSizeSpec.mLockAspectRatio) { + xulWin->LockAspectRatio(true); } } diff --git a/toolkit/components/windowwatcher/test/browser_new_content_window_chromeflags.js b/toolkit/components/windowwatcher/test/browser_new_content_window_chromeflags.js index d015d0a7f9ab..ae65e054bdb3 100644 --- a/toolkit/components/windowwatcher/test/browser_new_content_window_chromeflags.js +++ b/toolkit/components/windowwatcher/test/browser_new_content_window_chromeflags.js @@ -152,7 +152,7 @@ registerCleanupFunction(() => { function getParentChromeFlags(win) { return win.docShell.treeOwner .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIAppWindow).chromeFlags; + .getInterface(Ci.nsIXULWindow).chromeFlags; } /** diff --git a/toolkit/components/windowwatcher/test/browser_new_remote_window_flags.js b/toolkit/components/windowwatcher/test/browser_new_remote_window_flags.js index bf75556f47aa..c9e7d18c4d08 100644 --- a/toolkit/components/windowwatcher/test/browser_new_remote_window_flags.js +++ b/toolkit/components/windowwatcher/test/browser_new_remote_window_flags.js @@ -20,7 +20,7 @@ function assertFlags(win) { let loadContext = docShell.QueryInterface(Ci.nsILoadContext); let chromeFlags = docShell.treeOwner .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIAppWindow).chromeFlags; + .getInterface(Ci.nsIXULWindow).chromeFlags; Assert.ok( loadContext.useRemoteTabs, "Should be using remote tabs on the load context" diff --git a/toolkit/components/windowwatcher/test/test_alwaysOnTop_windows.html b/toolkit/components/windowwatcher/test/test_alwaysOnTop_windows.html index ccccc7722872..2f6d5daab9de 100644 --- a/toolkit/components/windowwatcher/test/test_alwaysOnTop_windows.html +++ b/toolkit/components/windowwatcher/test/test_alwaysOnTop_windows.html @@ -20,7 +20,7 @@ Tests the alwaysOnTop window feature for the Windows OS. let docShell = win.docShell; let chromeFlags = docShell.treeOwner .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIAppWindow) + .getInterface(Ci.nsIXULWindow) .chromeFlags; let hasFlag = !!(chromeFlags & Ci.nsIWebBrowserChrome.CHROME_ALWAYS_ON_TOP); is(hasFlag, expected, "Window should have CHROME_ALWAYS_ON_TOP flag."); diff --git a/toolkit/components/windowwatcher/test/test_modal_windows.html b/toolkit/components/windowwatcher/test/test_modal_windows.html index 134c0c75411c..dfc15955c464 100644 --- a/toolkit/components/windowwatcher/test/test_modal_windows.html +++ b/toolkit/components/windowwatcher/test/test_modal_windows.html @@ -20,7 +20,7 @@ that is opened reports itself as being modal. BrowserTestUtils.domWindowOpened().then((win) => { let treeOwner = win.docShell.treeOwner; let chromeFlags = treeOwner.QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIAppWindow) + .getInterface(Ci.nsIXULWindow) .chromeFlags; ok(chromeFlags & Ci.nsIWebBrowserChrome.CHROME_MODAL, "Should have the modal chrome flag"); diff --git a/toolkit/components/xulstore/new/XULStore.jsm b/toolkit/components/xulstore/new/XULStore.jsm index 9b017af73472..63299eed5e11 100644 --- a/toolkit/components/xulstore/new/XULStore.jsm +++ b/toolkit/components/xulstore/new/XULStore.jsm @@ -56,7 +56,7 @@ const XULStore = { const value = node.getAttribute(attr); if (node.localName == "window") { - log("Persisting attributes to windows is handled by AppWindow."); + log("Persisting attributes to windows is handled by nsXULWindow."); return; } diff --git a/toolkit/components/xulstore/old/XULStore.jsm b/toolkit/components/xulstore/old/XULStore.jsm index b2cf24e423e5..7bdb63a0b662 100644 --- a/toolkit/components/xulstore/old/XULStore.jsm +++ b/toolkit/components/xulstore/old/XULStore.jsm @@ -142,7 +142,7 @@ XULStore.prototype = { const value = node.getAttribute(attr); if (node.localName == "window") { - this.log("Persisting attributes to windows is handled by AppWindow."); + this.log("Persisting attributes to windows is handled by nsXULWindow."); return; } diff --git a/toolkit/content/tests/chrome/findbar_window.xul b/toolkit/content/tests/chrome/findbar_window.xul index 9dc734513ad5..1c289b43c9a3 100644 --- a/toolkit/content/tests/chrome/findbar_window.xul +++ b/toolkit/content/tests/chrome/findbar_window.xul @@ -66,7 +66,7 @@ window.docShell .treeOwner .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIAppWindow) + .getInterface(Ci.nsIXULWindow) .XULBrowserWindow = gXULBrowserWindow; gFindBar = document.getElementById("FindToolbar"); diff --git a/toolkit/content/widgets/findbar.js b/toolkit/content/widgets/findbar.js index 55a056458eb2..baf8d46ad93b 100644 --- a/toolkit/content/widgets/findbar.js +++ b/toolkit/content/widgets/findbar.js @@ -784,7 +784,7 @@ try { this._xulBrowserWindow = window.docShell.treeOwner .QueryInterface(Ci.nsIInterfaceRequestor) - .getInterface(Ci.nsIAppWindow).XULBrowserWindow; + .getInterface(Ci.nsIXULWindow).XULBrowserWindow; } catch (ex) {} if (!this._xulBrowserWindow) { return false; diff --git a/toolkit/xre/nsINativeAppSupport.idl b/toolkit/xre/nsINativeAppSupport.idl index 7cfce02ab4ff..eb47a49e58d8 100644 --- a/toolkit/xre/nsINativeAppSupport.idl +++ b/toolkit/xre/nsINativeAppSupport.idl @@ -44,6 +44,8 @@ * "soft" shutdown, passwords are flushed. */ +interface nsIXULWindow; + [scriptable, uuid(5fdf8480-1f98-11d4-8077-00600811a9c3)] interface nsINativeAppSupport : nsISupports { // Startup/shutdown. diff --git a/widget/android/nsWindow.cpp b/widget/android/nsWindow.cpp index 4fe659cfb7ab..f1bfe65b0f88 100644 --- a/widget/android/nsWindow.cpp +++ b/widget/android/nsWindow.cpp @@ -50,7 +50,7 @@ using mozilla::dom::ContentParent; #include "nsISupportsPrimitives.h" #include "nsIWidgetListener.h" #include "nsIWindowWatcher.h" -#include "nsIAppWindow.h" +#include "nsIXULWindow.h" #include "nsAppShell.h" #include "nsFocusManager.h" @@ -1285,11 +1285,11 @@ void nsWindow::GeckoViewSupport::Open( aInitData); if (window->mWidgetListener) { - nsCOMPtr appWindow(window->mWidgetListener->GetAppWindow()); - if (appWindow) { - // Our window is not intrinsically sized, so tell AppWindow to + nsCOMPtr xulWindow(window->mWidgetListener->GetXULWindow()); + if (xulWindow) { + // Our window is not intrinsically sized, so tell nsXULWindow to // not set a size for us. - appWindow->SetIntrinsicallySized(false); + xulWindow->SetIntrinsicallySized(false); } } } diff --git a/widget/cocoa/nsCocoaUtils.mm b/widget/cocoa/nsCocoaUtils.mm index ea4445e682c8..4f4a15a7f09d 100644 --- a/widget/cocoa/nsCocoaUtils.mm +++ b/widget/cocoa/nsCocoaUtils.mm @@ -22,7 +22,7 @@ #include "nsIAppShellService.h" #include "nsIOSPermissionRequest.h" #include "nsIRunnable.h" -#include "nsIAppWindow.h" +#include "nsIXULWindow.h" #include "nsIBaseWindow.h" #include "nsIServiceManager.h" #include "nsMenuUtilsX.h" @@ -274,7 +274,7 @@ nsIWidget* nsCocoaUtils::GetHiddenWindowWidget() { return nullptr; } - nsCOMPtr hiddenWindow; + nsCOMPtr hiddenWindow; appShell->GetHiddenWindow(getter_AddRefs(hiddenWindow)); if (!hiddenWindow) { // Don't warn, this happens during shutdown, bug 358607. @@ -284,7 +284,7 @@ nsIWidget* nsCocoaUtils::GetHiddenWindowWidget() { nsCOMPtr baseHiddenWindow; baseHiddenWindow = do_GetInterface(hiddenWindow); if (!baseHiddenWindow) { - NS_WARNING("Couldn't get nsIBaseWindow from hidden window (nsIAppWindow)"); + NS_WARNING("Couldn't get nsIBaseWindow from hidden window (nsIXULWindow)"); return nullptr; } diff --git a/widget/cocoa/nsCocoaWindow.mm b/widget/cocoa/nsCocoaWindow.mm index 6f6b8fee8145..aa430cade2be 100644 --- a/widget/cocoa/nsCocoaWindow.mm +++ b/widget/cocoa/nsCocoaWindow.mm @@ -19,7 +19,7 @@ #include "nsIAppShellService.h" #include "nsIBaseWindow.h" #include "nsIInterfaceRequestorUtils.h" -#include "nsIAppWindow.h" +#include "nsIXULWindow.h" #include "nsToolkit.h" #include "nsTouchBarNativeAPIDefines.h" #include "nsPIDOMWindow.h" @@ -665,7 +665,7 @@ void nsCocoaWindow::SetModal(bool aState) { // appears over behave as they should. We can't rely on native methods to // do this, for the following reason: The OS runs modal non-sheet windows // in an event loop (using [NSApplication runModalForWindow:] or similar - // methods) that's incompatible with the modal event loop in AppWindow:: + // methods) that's incompatible with the modal event loop in nsXULWindow:: // ShowModal() (each of these event loops is "exclusive", and can't run at // the same time as other (similar) event loops). if (mWindowType != eWindowType_sheet) { @@ -1653,7 +1653,7 @@ void nsCocoaWindow::BackingScaleFactorChanged() { mBackingScaleFactor = newScale; - if (!mWidgetListener || mWidgetListener->GetAppWindow()) { + if (!mWidgetListener || mWidgetListener->GetXULWindow()) { return; } diff --git a/widget/nsBaseWidget.cpp b/widget/nsBaseWidget.cpp index 9fa26fae645a..ad2eb0db167a 100644 --- a/widget/nsBaseWidget.cpp +++ b/widget/nsBaseWidget.cpp @@ -34,7 +34,7 @@ #include "ClientLayerManager.h" #include "mozilla/layers/Compositor.h" #include "nsIXULRuntime.h" -#include "nsIAppWindow.h" +#include "nsIXULWindow.h" #include "nsIBaseWindow.h" #include "nsXULPopupManager.h" #include "nsIWidgetListener.h" @@ -1642,10 +1642,10 @@ nsIRollupListener* nsBaseWidget::GetActiveRollupListener() { void nsBaseWidget::NotifyWindowDestroyed() { if (!mWidgetListener) return; - nsCOMPtr window = mWidgetListener->GetAppWindow(); - nsCOMPtr appWindow(do_QueryInterface(window)); - if (appWindow) { - appWindow->Destroy(); + nsCOMPtr window = mWidgetListener->GetXULWindow(); + nsCOMPtr xulWindow(do_QueryInterface(window)); + if (xulWindow) { + xulWindow->Destroy(); } } @@ -2028,11 +2028,11 @@ void nsBaseWidget::NotifyLiveResizeStarted() { if (!mWidgetListener) { return; } - nsCOMPtr appWindow = mWidgetListener->GetAppWindow(); - if (!appWindow) { + nsCOMPtr xulWindow = mWidgetListener->GetXULWindow(); + if (!xulWindow) { return; } - mLiveResizeListeners = appWindow->GetLiveResizeListeners(); + mLiveResizeListeners = xulWindow->GetLiveResizeListeners(); for (uint32_t i = 0; i < mLiveResizeListeners.Length(); i++) { mLiveResizeListeners[i]->LiveResizeStarted(); } diff --git a/widget/nsIWidgetListener.cpp b/widget/nsIWidgetListener.cpp index 708718724466..926df5b249b4 100644 --- a/widget/nsIWidgetListener.cpp +++ b/widget/nsIWidgetListener.cpp @@ -8,14 +8,14 @@ #include "nsRegion.h" #include "nsView.h" #include "nsIWidget.h" -#include "nsIAppWindow.h" +#include "nsIXULWindow.h" #include "mozilla/BasicEvents.h" #include "mozilla/PresShell.h" using namespace mozilla; -nsIAppWindow* nsIWidgetListener::GetAppWindow() { return nullptr; } +nsIXULWindow* nsIWidgetListener::GetXULWindow() { return nullptr; } nsView* nsIWidgetListener::GetView() { return nullptr; } diff --git a/widget/nsIWidgetListener.h b/widget/nsIWidgetListener.h index ddea62d9b6b6..d7aa615cd17b 100644 --- a/widget/nsIWidgetListener.h +++ b/widget/nsIWidgetListener.h @@ -16,7 +16,7 @@ class nsView; class nsIWidget; -class nsIAppWindow; +class nsIXULWindow; namespace mozilla { class PresShell; @@ -45,11 +45,11 @@ enum nsWindowZ { class nsIWidgetListener { public: /** - * If this listener is for an nsIAppWindow, return it. If this is null, then + * If this listener is for an nsIXULWindow, return it. If this is null, then * this is likely a listener for a view, which can be determined using * GetView. If both methods return null, this will be an nsWebBrowser. */ - virtual nsIAppWindow* GetAppWindow(); + virtual nsIXULWindow* GetXULWindow(); /** * If this listener is for an nsView, return it. diff --git a/widget/tests/TestAppShellSteadyState.cpp b/widget/tests/TestAppShellSteadyState.cpp index 550dc33adb59..058fd22d9682 100644 --- a/widget/tests/TestAppShellSteadyState.cpp +++ b/widget/tests/TestAppShellSteadyState.cpp @@ -16,7 +16,7 @@ #include "nsIRunnable.h" #include "nsIURI.h" #include "nsIWebBrowserChrome.h" -#include "nsIAppWindow.h" +#include "nsIXULWindow.h" #include "nsAppShellCID.h" #include "nsIInterfaceRequestorUtils.h" @@ -361,14 +361,14 @@ bool Test4Internal(nsIAppShell* aAppShell) { uint32_t flags = nsIWebBrowserChrome::CHROME_DEFAULT; - nsCOMPtr appWindow; + nsCOMPtr xulWindow; if (NS_FAILED(appService->CreateTopLevelWindow( - nullptr, uri, flags, 100, 100, nullptr, getter_AddRefs(appWindow)))) { + nullptr, uri, flags, 100, 100, nullptr, getter_AddRefs(xulWindow)))) { fail("Failed to create new window"); return false; } - nsCOMPtr window = do_GetInterface(appWindow); + nsCOMPtr window = do_GetInterface(xulWindow); if (!window) { fail("Can't get dom window!"); return false; diff --git a/widget/windows/WidgetTraceEvent.cpp b/widget/windows/WidgetTraceEvent.cpp index 4509791d5979..3d9e47c6872a 100644 --- a/widget/windows/WidgetTraceEvent.cpp +++ b/widget/windows/WidgetTraceEvent.cpp @@ -20,7 +20,7 @@ #include "nsIDocShell.h" #include "nsISupportsImpl.h" #include "nsIWidget.h" -#include "nsIAppWindow.h" +#include "nsIXULWindow.h" #include "nsServiceManagerUtils.h" #include "nsThreadUtils.h" #include "nsWindowDefs.h" @@ -42,7 +42,7 @@ class HWNDGetter : public mozilla::Runnable { // Jump through some hoops to locate the hidden window. nsCOMPtr appShell( do_GetService(NS_APPSHELLSERVICE_CONTRACTID)); - nsCOMPtr hiddenWindow; + nsCOMPtr hiddenWindow; nsresult rv = appShell->GetHiddenWindow(getter_AddRefs(hiddenWindow)); if (NS_FAILED(rv)) { diff --git a/widget/windows/WindowsUIUtils.cpp b/widget/windows/WindowsUIUtils.cpp index a5ec4a98f8ed..e7074e03036e 100644 --- a/widget/windows/WindowsUIUtils.cpp +++ b/widget/windows/WindowsUIUtils.cpp @@ -16,6 +16,7 @@ #include "nsIDocShell.h" #include "nsIAppShellService.h" #include "nsAppShellCID.h" +#include "nsIXULWindow.h" #include "mozilla/Services.h" #include "mozilla/WidgetUtils.h" #include "mozilla/WindowsVersion.h" diff --git a/xpfe/appshell/moz.build b/xpfe/appshell/moz.build index 64757a5cf588..ca09649e4fd9 100644 --- a/xpfe/appshell/moz.build +++ b/xpfe/appshell/moz.build @@ -11,11 +11,11 @@ MOCHITEST_CHROME_MANIFESTS += ['test/chrome.ini'] XPIDL_SOURCES += [ 'nsIAppShellService.idl', - 'nsIAppWindow.idl', 'nsIWindowlessBrowser.idl', 'nsIWindowMediator.idl', 'nsIWindowMediatorListener.idl', 'nsIXULBrowserWindow.idl', + 'nsIXULWindow.idl', ] XPIDL_MODULE = 'appshell' @@ -26,12 +26,13 @@ EXPORTS += [ ] UNIFIED_SOURCES += [ - 'AppWindow.cpp', 'nsAppShellService.cpp', 'nsAppShellWindowEnumerator.cpp', 'nsChromeTreeOwner.cpp', 'nsContentTreeOwner.cpp', + 'nsWebShellWindow.cpp', 'nsWindowMediator.cpp', + 'nsXULWindow.cpp', ] XPCOM_MANIFESTS += [ diff --git a/xpfe/appshell/nsAppShellService.cpp b/xpfe/appshell/nsAppShellService.cpp index 9dbb20e1cb45..08375d295845 100644 --- a/xpfe/appshell/nsAppShellService.cpp +++ b/xpfe/appshell/nsAppShellService.cpp @@ -17,7 +17,7 @@ #include "nsIWindowWatcher.h" #include "nsPIWindowWatcher.h" #include "nsPIDOMWindow.h" -#include "AppWindow.h" +#include "nsWebShellWindow.h" #include "nsWidgetInitData.h" #include "nsWidgetsCID.h" @@ -133,7 +133,7 @@ nsAppShellService::CreateHiddenWindow() { rv = NS_NewURI(getter_AddRefs(url), hiddenWindowURL); NS_ENSURE_SUCCESS(rv, rv); - RefPtr newWindow; + RefPtr newWindow; rv = JustCreateTopWindow(nullptr, url, chromeMask, initialWidth, initialHeight, true, nullptr, nullptr, getter_AddRefs(newWindow)); @@ -166,16 +166,16 @@ nsAppShellService::DestroyHiddenWindow() { */ NS_IMETHODIMP nsAppShellService::CreateTopLevelWindow( - nsIAppWindow* aParent, nsIURI* aUrl, uint32_t aChromeMask, + nsIXULWindow* aParent, nsIURI* aUrl, uint32_t aChromeMask, int32_t aInitialWidth, int32_t aInitialHeight, nsIRemoteTab* aOpeningTab, - mozIDOMWindowProxy* aOpenerWindow, nsIAppWindow** aResult) + mozIDOMWindowProxy* aOpenerWindow, nsIXULWindow** aResult) { nsresult rv; StartupTimeline::RecordOnce(StartupTimeline::CREATE_TOP_LEVEL_WINDOW); - RefPtr newWindow; + RefPtr newWindow; rv = JustCreateTopWindow(aParent, aUrl, aChromeMask, aInitialWidth, aInitialHeight, false, aOpeningTab, aOpenerWindow, getter_AddRefs(newWindow)); @@ -184,7 +184,7 @@ nsAppShellService::CreateTopLevelWindow( if (NS_SUCCEEDED(rv)) { // the addref resulting from this is the owning addref for this window RegisterTopLevelWindow(*aResult); - nsCOMPtr parent; + nsCOMPtr parent; if (aChromeMask & nsIWebBrowserChrome::CHROME_DEPENDENT) parent = aParent; (*aResult)->SetZLevel(CalculateWindowZLevel(parent, aChromeMask)); } @@ -485,15 +485,15 @@ nsAppShellService::CreateWindowlessBrowser(bool aIsChrome, return NS_OK; } -uint32_t nsAppShellService::CalculateWindowZLevel(nsIAppWindow* aParent, +uint32_t nsAppShellService::CalculateWindowZLevel(nsIXULWindow* aParent, uint32_t aChromeMask) { uint32_t zLevel; - zLevel = nsIAppWindow::normalZ; + zLevel = nsIXULWindow::normalZ; if (aChromeMask & nsIWebBrowserChrome::CHROME_WINDOW_RAISED) - zLevel = nsIAppWindow::raisedZ; + zLevel = nsIXULWindow::raisedZ; else if (aChromeMask & nsIWebBrowserChrome::CHROME_WINDOW_LOWERED) - zLevel = nsIAppWindow::loweredZ; + zLevel = nsIXULWindow::loweredZ; #ifdef XP_MACOSX /* Platforms on which modal windows are always application-modal, not @@ -528,7 +528,7 @@ static bool CheckForFullscreenWindow() { if (!wm) return false; nsCOMPtr windowList; - wm->GetAppWindowEnumerator(nullptr, getter_AddRefs(windowList)); + wm->GetXULWindowEnumerator(nullptr, getter_AddRefs(windowList)); if (!windowList) return false; for (;;) { @@ -555,17 +555,17 @@ static bool CheckForFullscreenWindow() { * Just do the window-making part of CreateTopLevelWindow */ nsresult nsAppShellService::JustCreateTopWindow( - nsIAppWindow* aParent, nsIURI* aUrl, uint32_t aChromeMask, + nsIXULWindow* aParent, nsIURI* aUrl, uint32_t aChromeMask, int32_t aInitialWidth, int32_t aInitialHeight, bool aIsHiddenWindow, nsIRemoteTab* aOpeningTab, mozIDOMWindowProxy* aOpenerWindow, - AppWindow** aResult) { + nsWebShellWindow** aResult) { *aResult = nullptr; NS_ENSURE_STATE(!mXPCOMWillShutDown); - nsCOMPtr parent; + nsCOMPtr parent; if (aChromeMask & nsIWebBrowserChrome::CHROME_DEPENDENT) parent = aParent; - RefPtr window = new AppWindow(aChromeMask); + RefPtr window = new nsWebShellWindow(aChromeMask); #ifdef XP_WIN // If the parent is currently fullscreen, tell the child to ignore persisted @@ -737,7 +737,7 @@ nsresult nsAppShellService::JustCreateTopWindow( } NS_IMETHODIMP -nsAppShellService::GetHiddenWindow(nsIAppWindow** aWindow) { +nsAppShellService::GetHiddenWindow(nsIXULWindow** aWindow) { NS_ENSURE_ARG_POINTER(aWindow); EnsureHiddenWindow(); @@ -784,7 +784,7 @@ nsAppShellService::GetApplicationProvidedHiddenWindow(bool* aAPHW) { * Register a new top level window (created elsewhere) */ NS_IMETHODIMP -nsAppShellService::RegisterTopLevelWindow(nsIAppWindow* aWindow) { +nsAppShellService::RegisterTopLevelWindow(nsIXULWindow* aWindow) { NS_ENSURE_ARG_POINTER(aWindow); nsCOMPtr docShell; @@ -816,15 +816,15 @@ nsAppShellService::RegisterTopLevelWindow(nsIAppWindow* aWindow) { if (obssvc) { obssvc->NotifyObservers(aWindow, "xul-window-registered", nullptr); - AppWindow* appWindow = static_cast(aWindow); - appWindow->WasRegistered(); + nsXULWindow* xulWindow = static_cast(aWindow); + xulWindow->WasRegistered(); } return NS_OK; } NS_IMETHODIMP -nsAppShellService::UnregisterTopLevelWindow(nsIAppWindow* aWindow) { +nsAppShellService::UnregisterTopLevelWindow(nsIXULWindow* aWindow) { if (mXPCOMShuttingDown) { /* return an error code in order to: - avoid doing anything with other member variables while we are in diff --git a/xpfe/appshell/nsAppShellService.h b/xpfe/appshell/nsAppShellService.h index bd3f70d6a212..4db031520393 100644 --- a/xpfe/appshell/nsAppShellService.h +++ b/xpfe/appshell/nsAppShellService.h @@ -10,7 +10,7 @@ #include "nsIObserver.h" // Interfaces Needed -#include "AppWindow.h" +#include "nsWebShellWindow.h" #include "nsStringFwd.h" #include "nsAutoPtr.h" #include "nsIRemoteTab.h" @@ -37,15 +37,15 @@ class nsAppShellService final : public nsIAppShellService, public nsIObserver { void EnsureHiddenWindow(); - nsresult JustCreateTopWindow(nsIAppWindow* aParent, nsIURI* aUrl, + nsresult JustCreateTopWindow(nsIXULWindow* aParent, nsIURI* aUrl, uint32_t aChromeMask, int32_t aInitialWidth, int32_t aInitialHeight, bool aIsHiddenWindow, nsIRemoteTab* aOpeningTab, mozIDOMWindowProxy* aOpenerWindow, - mozilla::AppWindow** aResult); - uint32_t CalculateWindowZLevel(nsIAppWindow* aParent, uint32_t aChromeMask); + nsWebShellWindow** aResult); + uint32_t CalculateWindowZLevel(nsIXULWindow* aParent, uint32_t aChromeMask); - RefPtr mHiddenWindow; + RefPtr mHiddenWindow; bool mXPCOMWillShutDown; bool mXPCOMShuttingDown; uint16_t mModalWindowCount; diff --git a/xpfe/appshell/nsAppShellWindowEnumerator.cpp b/xpfe/appshell/nsAppShellWindowEnumerator.cpp index f2333fd11c54..41d849ac1fb6 100644 --- a/xpfe/appshell/nsAppShellWindowEnumerator.cpp +++ b/xpfe/appshell/nsAppShellWindowEnumerator.cpp @@ -11,7 +11,7 @@ #include "nsIFactory.h" #include "nsIInterfaceRequestor.h" #include "nsIInterfaceRequestorUtils.h" -#include "nsIAppWindow.h" +#include "nsIXULWindow.h" #include "mozilla/dom/Element.h" #include "nsWindowMediator.h" @@ -23,9 +23,9 @@ using mozilla::dom::Element; // static helper functions // -static void GetAttribute(nsIAppWindow* inWindow, const nsAString& inAttribute, +static void GetAttribute(nsIXULWindow* inWindow, const nsAString& inAttribute, nsAString& outValue); -static void GetWindowType(nsIAppWindow* inWindow, nsString& outType); +static void GetWindowType(nsIXULWindow* inWindow, nsString& outType); static Element* GetElementFromDocShell(nsIDocShell* aShell) { nsCOMPtr cv; @@ -41,7 +41,7 @@ static Element* GetElementFromDocShell(nsIDocShell* aShell) { } // generic "retrieve the value of a XUL attribute" function -void GetAttribute(nsIAppWindow* inWindow, const nsAString& inAttribute, +void GetAttribute(nsIXULWindow* inWindow, const nsAString& inAttribute, nsAString& outValue) { nsCOMPtr shell; if (inWindow && NS_SUCCEEDED(inWindow->GetDocShell(getter_AddRefs(shell)))) { @@ -54,7 +54,7 @@ void GetAttribute(nsIAppWindow* inWindow, const nsAString& inAttribute, // retrieve the window type, stored as the value of a particular // attribute in its XUL window tag -void GetWindowType(nsIAppWindow* aWindow, nsString& outType) { +void GetWindowType(nsIXULWindow* aWindow, nsString& outType) { GetAttribute(aWindow, NS_LITERAL_STRING("windowtype"), outType); } @@ -62,10 +62,10 @@ void GetWindowType(nsIAppWindow* aWindow, nsString& outType) { // nsWindowInfo // -nsWindowInfo::nsWindowInfo(nsIAppWindow* inWindow, int32_t inTimeStamp) +nsWindowInfo::nsWindowInfo(nsIXULWindow* inWindow, int32_t inTimeStamp) : mWindow(inWindow), mTimeStamp(inTimeStamp), - mZLevel(nsIAppWindow::normalZ) { + mZLevel(nsIXULWindow::normalZ) { ReferenceSelf(true, true); } @@ -187,16 +187,16 @@ NS_IMETHODIMP nsASDOMWindowEnumerator::GetNext(nsISupports** retval) { } // -// nsASAppWindowEnumerator +// nsASXULWindowEnumerator // -nsASAppWindowEnumerator::nsASAppWindowEnumerator(const char16_t* aTypeString, +nsASXULWindowEnumerator::nsASXULWindowEnumerator(const char16_t* aTypeString, nsWindowMediator& aMediator) : nsAppShellWindowEnumerator(aTypeString, aMediator) {} -nsASAppWindowEnumerator::~nsASAppWindowEnumerator() {} +nsASXULWindowEnumerator::~nsASXULWindowEnumerator() {} -NS_IMETHODIMP nsASAppWindowEnumerator::GetNext(nsISupports** retval) { +NS_IMETHODIMP nsASXULWindowEnumerator::GetNext(nsISupports** retval) { if (!retval) return NS_ERROR_INVALID_ARG; *retval = nullptr; @@ -225,7 +225,7 @@ nsWindowInfo* nsASDOMWindowEarlyToLateEnumerator::FindNext() { nsWindowInfo *info, *listEnd; bool allWindows = mType.IsEmpty(); - // see AppWindowEarlyToLateEnumerator::FindNext + // see nsXULWindowEarlyToLateEnumerator::FindNext if (!mCurrentPosition) return nullptr; info = mCurrentPosition->mYounger; @@ -240,19 +240,19 @@ nsWindowInfo* nsASDOMWindowEarlyToLateEnumerator::FindNext() { } // -// nsASAppWindowEarlyToLateEnumerator +// nsASXULWindowEarlyToLateEnumerator // -nsASAppWindowEarlyToLateEnumerator::nsASAppWindowEarlyToLateEnumerator( +nsASXULWindowEarlyToLateEnumerator::nsASXULWindowEarlyToLateEnumerator( const char16_t* aTypeString, nsWindowMediator& aMediator) - : nsASAppWindowEnumerator(aTypeString, aMediator) { + : nsASXULWindowEnumerator(aTypeString, aMediator) { mCurrentPosition = aMediator.mOldestWindow; AdjustInitialPosition(); } -nsASAppWindowEarlyToLateEnumerator::~nsASAppWindowEarlyToLateEnumerator() {} +nsASXULWindowEarlyToLateEnumerator::~nsASXULWindowEarlyToLateEnumerator() {} -nsWindowInfo* nsASAppWindowEarlyToLateEnumerator::FindNext() { +nsWindowInfo* nsASXULWindowEarlyToLateEnumerator::FindNext() { nsWindowInfo *info, *listEnd; bool allWindows = mType.IsEmpty(); @@ -277,23 +277,23 @@ nsWindowInfo* nsASAppWindowEarlyToLateEnumerator::FindNext() { } // -// nsASAppWindowFrontToBackEnumerator +// nsASXULWindowFrontToBackEnumerator // -nsASAppWindowFrontToBackEnumerator::nsASAppWindowFrontToBackEnumerator( +nsASXULWindowFrontToBackEnumerator::nsASXULWindowFrontToBackEnumerator( const char16_t* aTypeString, nsWindowMediator& aMediator) - : nsASAppWindowEnumerator(aTypeString, aMediator) { + : nsASXULWindowEnumerator(aTypeString, aMediator) { mCurrentPosition = aMediator.mTopmostWindow; AdjustInitialPosition(); } -nsASAppWindowFrontToBackEnumerator::~nsASAppWindowFrontToBackEnumerator() {} +nsASXULWindowFrontToBackEnumerator::~nsASXULWindowFrontToBackEnumerator() {} -nsWindowInfo* nsASAppWindowFrontToBackEnumerator::FindNext() { +nsWindowInfo* nsASXULWindowFrontToBackEnumerator::FindNext() { nsWindowInfo *info, *listEnd; bool allWindows = mType.IsEmpty(); - // see AppWindowEarlyToLateEnumerator::FindNext + // see nsXULWindowEarlyToLateEnumerator::FindNext if (!mCurrentPosition) return nullptr; info = mCurrentPosition->mLower; @@ -308,24 +308,24 @@ nsWindowInfo* nsASAppWindowFrontToBackEnumerator::FindNext() { } // -// nsASAppWindowBackToFrontEnumerator +// nsASXULWindowBackToFrontEnumerator // -nsASAppWindowBackToFrontEnumerator::nsASAppWindowBackToFrontEnumerator( +nsASXULWindowBackToFrontEnumerator::nsASXULWindowBackToFrontEnumerator( const char16_t* aTypeString, nsWindowMediator& aMediator) - : nsASAppWindowEnumerator(aTypeString, aMediator) { + : nsASXULWindowEnumerator(aTypeString, aMediator) { mCurrentPosition = aMediator.mTopmostWindow ? aMediator.mTopmostWindow->mHigher : nullptr; AdjustInitialPosition(); } -nsASAppWindowBackToFrontEnumerator::~nsASAppWindowBackToFrontEnumerator() {} +nsASXULWindowBackToFrontEnumerator::~nsASXULWindowBackToFrontEnumerator() {} -nsWindowInfo* nsASAppWindowBackToFrontEnumerator::FindNext() { +nsWindowInfo* nsASXULWindowBackToFrontEnumerator::FindNext() { nsWindowInfo *info, *listEnd; bool allWindows = mType.IsEmpty(); - // see AppWindowEarlyToLateEnumerator::FindNext + // see nsXULWindowEarlyToLateEnumerator::FindNext if (!mCurrentPosition) return nullptr; info = mCurrentPosition->mHigher; diff --git a/xpfe/appshell/nsAppShellWindowEnumerator.h b/xpfe/appshell/nsAppShellWindowEnumerator.h index b5dc828dcfc1..e16b6011346b 100644 --- a/xpfe/appshell/nsAppShellWindowEnumerator.h +++ b/xpfe/appshell/nsAppShellWindowEnumerator.h @@ -10,7 +10,7 @@ #include "nsString.h" #include "nsSimpleEnumerator.h" -#include "nsIAppWindow.h" +#include "nsIXULWindow.h" class nsWindowMediator; @@ -19,10 +19,10 @@ class nsWindowMediator; // struct nsWindowInfo { - nsWindowInfo(nsIAppWindow* inWindow, int32_t inTimeStamp); + nsWindowInfo(nsIXULWindow* inWindow, int32_t inTimeStamp); ~nsWindowInfo(); - nsCOMPtr mWindow; + nsCOMPtr mWindow; int32_t mTimeStamp; uint32_t mZLevel; @@ -72,14 +72,14 @@ class nsASDOMWindowEnumerator : public nsAppShellWindowEnumerator { NS_IMETHOD GetNext(nsISupports** retval) override; }; -class nsASAppWindowEnumerator : public nsAppShellWindowEnumerator { +class nsASXULWindowEnumerator : public nsAppShellWindowEnumerator { public: - nsASAppWindowEnumerator(const char16_t* aTypeString, + nsASXULWindowEnumerator(const char16_t* aTypeString, nsWindowMediator& inMediator); - virtual ~nsASAppWindowEnumerator(); + virtual ~nsASXULWindowEnumerator(); NS_IMETHOD GetNext(nsISupports** retval) override; - const nsID& DefaultInterface() override { return NS_GET_IID(nsIAppWindow); } + const nsID& DefaultInterface() override { return NS_GET_IID(nsIXULWindow); } }; // @@ -97,34 +97,34 @@ class nsASDOMWindowEarlyToLateEnumerator : public nsASDOMWindowEnumerator { virtual nsWindowInfo* FindNext() override; }; -class nsASAppWindowEarlyToLateEnumerator : public nsASAppWindowEnumerator { +class nsASXULWindowEarlyToLateEnumerator : public nsASXULWindowEnumerator { public: - nsASAppWindowEarlyToLateEnumerator(const char16_t* aTypeString, + nsASXULWindowEarlyToLateEnumerator(const char16_t* aTypeString, nsWindowMediator& inMediator); - virtual ~nsASAppWindowEarlyToLateEnumerator(); + virtual ~nsASXULWindowEarlyToLateEnumerator(); protected: virtual nsWindowInfo* FindNext() override; }; -class nsASAppWindowFrontToBackEnumerator : public nsASAppWindowEnumerator { +class nsASXULWindowFrontToBackEnumerator : public nsASXULWindowEnumerator { public: - nsASAppWindowFrontToBackEnumerator(const char16_t* aTypeString, + nsASXULWindowFrontToBackEnumerator(const char16_t* aTypeString, nsWindowMediator& inMediator); - virtual ~nsASAppWindowFrontToBackEnumerator(); + virtual ~nsASXULWindowFrontToBackEnumerator(); protected: virtual nsWindowInfo* FindNext() override; }; -class nsASAppWindowBackToFrontEnumerator : public nsASAppWindowEnumerator { +class nsASXULWindowBackToFrontEnumerator : public nsASXULWindowEnumerator { public: - nsASAppWindowBackToFrontEnumerator(const char16_t* aTypeString, + nsASXULWindowBackToFrontEnumerator(const char16_t* aTypeString, nsWindowMediator& inMediator); - virtual ~nsASAppWindowBackToFrontEnumerator(); + virtual ~nsASXULWindowBackToFrontEnumerator(); protected: virtual nsWindowInfo* FindNext() override; diff --git a/xpfe/appshell/nsChromeTreeOwner.cpp b/xpfe/appshell/nsChromeTreeOwner.cpp index 315cf3d96f1f..adb4a20227b1 100644 --- a/xpfe/appshell/nsChromeTreeOwner.cpp +++ b/xpfe/appshell/nsChromeTreeOwner.cpp @@ -6,7 +6,7 @@ // Local Includes #include "nsChromeTreeOwner.h" -#include "AppWindow.h" +#include "nsXULWindow.h" // Helper Classes #include "nsString.h" @@ -43,7 +43,7 @@ const nsLiteralString kSpace(u" "); //*** nsChromeTreeOwner: Object Management //***************************************************************************** -nsChromeTreeOwner::nsChromeTreeOwner() : mAppWindow(nullptr) {} +nsChromeTreeOwner::nsChromeTreeOwner() : mXULWindow(nullptr) {} nsChromeTreeOwner::~nsChromeTreeOwner() {} @@ -71,24 +71,24 @@ NS_IMETHODIMP nsChromeTreeOwner::GetInterface(const nsIID& aIID, void** aSink) { NS_ENSURE_ARG_POINTER(aSink); if (aIID.Equals(NS_GET_IID(nsIPrompt))) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetInterface(aIID, aSink); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetInterface(aIID, aSink); } if (aIID.Equals(NS_GET_IID(nsIAuthPrompt))) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetInterface(aIID, aSink); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetInterface(aIID, aSink); } if (aIID.Equals(NS_GET_IID(nsIWebBrowserChrome))) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetInterface(aIID, aSink); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetInterface(aIID, aSink); } if (aIID.Equals(NS_GET_IID(nsIEmbeddingSiteWindow))) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetInterface(aIID, aSink); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetInterface(aIID, aSink); } - if (aIID.Equals(NS_GET_IID(nsIAppWindow))) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->QueryInterface(aIID, aSink); + if (aIID.Equals(NS_GET_IID(nsIXULWindow))) { + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->QueryInterface(aIID, aSink); } return QueryInterface(aIID, aSink); @@ -101,75 +101,75 @@ NS_IMETHODIMP nsChromeTreeOwner::GetInterface(const nsIID& aIID, void** aSink) { NS_IMETHODIMP nsChromeTreeOwner::ContentShellAdded(nsIDocShellTreeItem* aContentShell, bool aPrimary) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->ContentShellAdded(aContentShell, aPrimary); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->ContentShellAdded(aContentShell, aPrimary); } NS_IMETHODIMP nsChromeTreeOwner::ContentShellRemoved(nsIDocShellTreeItem* aContentShell) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->ContentShellRemoved(aContentShell); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->ContentShellRemoved(aContentShell); } NS_IMETHODIMP nsChromeTreeOwner::GetPrimaryContentShell( nsIDocShellTreeItem** aShell) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetPrimaryContentShell(aShell); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetPrimaryContentShell(aShell); } NS_IMETHODIMP nsChromeTreeOwner::RemoteTabAdded(nsIRemoteTab* aTab, bool aPrimary) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->RemoteTabAdded(aTab, aPrimary); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->RemoteTabAdded(aTab, aPrimary); } NS_IMETHODIMP nsChromeTreeOwner::RemoteTabRemoved(nsIRemoteTab* aTab) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->RemoteTabRemoved(aTab); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->RemoteTabRemoved(aTab); } NS_IMETHODIMP nsChromeTreeOwner::GetPrimaryRemoteTab(nsIRemoteTab** aTab) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetPrimaryRemoteTab(aTab); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetPrimaryRemoteTab(aTab); } NS_IMETHODIMP nsChromeTreeOwner::GetPrimaryContentSize(int32_t* aWidth, int32_t* aHeight) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetPrimaryContentSize(aWidth, aHeight); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetPrimaryContentSize(aWidth, aHeight); } NS_IMETHODIMP nsChromeTreeOwner::SetPrimaryContentSize(int32_t aWidth, int32_t aHeight) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->SetPrimaryContentSize(aWidth, aHeight); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->SetPrimaryContentSize(aWidth, aHeight); } NS_IMETHODIMP nsChromeTreeOwner::GetRootShellSize(int32_t* aWidth, int32_t* aHeight) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetRootShellSize(aWidth, aHeight); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetRootShellSize(aWidth, aHeight); } NS_IMETHODIMP nsChromeTreeOwner::SetRootShellSize(int32_t aWidth, int32_t aHeight) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->SetRootShellSize(aWidth, aHeight); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->SetRootShellSize(aWidth, aHeight); } NS_IMETHODIMP nsChromeTreeOwner::SizeShellTo(nsIDocShellTreeItem* aShellItem, int32_t aCX, int32_t aCY) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->SizeShellTo(aShellItem, aCX, aCY); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->SizeShellTo(aShellItem, aCX, aCY); } NS_IMETHODIMP nsChromeTreeOwner::SetPersistence(bool aPersistPosition, bool aPersistSize, bool aPersistSizeMode) { - NS_ENSURE_STATE(mAppWindow); - nsCOMPtr docShellElement = mAppWindow->GetWindowDOMElement(); + NS_ENSURE_STATE(mXULWindow); + nsCOMPtr docShellElement = mXULWindow->GetWindowDOMElement(); if (!docShellElement) return NS_ERROR_FAILURE; nsAutoString persistString; @@ -204,8 +204,8 @@ nsChromeTreeOwner::SetPersistence(bool aPersistPosition, bool aPersistSize, NS_IMETHODIMP nsChromeTreeOwner::GetPersistence(bool* aPersistPosition, bool* aPersistSize, bool* aPersistSizeMode) { - NS_ENSURE_STATE(mAppWindow); - nsCOMPtr docShellElement = mAppWindow->GetWindowDOMElement(); + NS_ENSURE_STATE(mXULWindow); + nsCOMPtr docShellElement = mXULWindow->GetWindowDOMElement(); if (!docShellElement) return NS_ERROR_FAILURE; nsAutoString persistString; @@ -227,8 +227,8 @@ nsChromeTreeOwner::GetPersistence(bool* aPersistPosition, bool* aPersistSize, NS_IMETHODIMP nsChromeTreeOwner::GetTabCount(uint32_t* aResult) { - if (mAppWindow) { - return mAppWindow->GetTabCount(aResult); + if (mXULWindow) { + return mXULWindow->GetTabCount(aResult); } *aResult = 0; @@ -237,8 +237,8 @@ nsChromeTreeOwner::GetTabCount(uint32_t* aResult) { NS_IMETHODIMP nsChromeTreeOwner::GetHasPrimaryContent(bool* aResult) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetHasPrimaryContent(aResult); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetHasPrimaryContent(aResult); } //***************************************************************************** @@ -261,69 +261,69 @@ NS_IMETHODIMP nsChromeTreeOwner::Create() { } NS_IMETHODIMP nsChromeTreeOwner::Destroy() { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->Destroy(); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->Destroy(); } NS_IMETHODIMP nsChromeTreeOwner::GetUnscaledDevicePixelsPerCSSPixel( double* aScale) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetUnscaledDevicePixelsPerCSSPixel(aScale); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetUnscaledDevicePixelsPerCSSPixel(aScale); } NS_IMETHODIMP nsChromeTreeOwner::GetDevicePixelsPerDesktopPixel( double* aScale) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetDevicePixelsPerDesktopPixel(aScale); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetDevicePixelsPerDesktopPixel(aScale); } NS_IMETHODIMP nsChromeTreeOwner::SetPositionDesktopPix(int32_t x, int32_t y) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->SetPositionDesktopPix(x, y); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->SetPositionDesktopPix(x, y); } NS_IMETHODIMP nsChromeTreeOwner::SetPosition(int32_t x, int32_t y) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->SetPosition(x, y); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->SetPosition(x, y); } NS_IMETHODIMP nsChromeTreeOwner::GetPosition(int32_t* x, int32_t* y) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetPosition(x, y); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetPosition(x, y); } NS_IMETHODIMP nsChromeTreeOwner::SetSize(int32_t cx, int32_t cy, bool fRepaint) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->SetSize(cx, cy, fRepaint); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->SetSize(cx, cy, fRepaint); } NS_IMETHODIMP nsChromeTreeOwner::GetSize(int32_t* cx, int32_t* cy) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetSize(cx, cy); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetSize(cx, cy); } NS_IMETHODIMP nsChromeTreeOwner::SetPositionAndSize(int32_t x, int32_t y, int32_t cx, int32_t cy, uint32_t aFlags) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->SetPositionAndSize(x, y, cx, cy, aFlags); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->SetPositionAndSize(x, y, cx, cy, aFlags); } NS_IMETHODIMP nsChromeTreeOwner::GetPositionAndSize(int32_t* x, int32_t* y, int32_t* cx, int32_t* cy) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetPositionAndSize(x, y, cx, cy); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetPositionAndSize(x, y, cx, cy); } NS_IMETHODIMP nsChromeTreeOwner::Repaint(bool aForce) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->Repaint(aForce); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->Repaint(aForce); } NS_IMETHODIMP nsChromeTreeOwner::GetParentWidget(nsIWidget** aParentWidget) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetParentWidget(aParentWidget); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetParentWidget(aParentWidget); } NS_IMETHODIMP nsChromeTreeOwner::SetParentWidget(nsIWidget* aParentWidget) { @@ -333,8 +333,8 @@ NS_IMETHODIMP nsChromeTreeOwner::SetParentWidget(nsIWidget* aParentWidget) { NS_IMETHODIMP nsChromeTreeOwner::GetParentNativeWindow( nativeWindow* aParentNativeWindow) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetParentNativeWindow(aParentNativeWindow); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetParentNativeWindow(aParentNativeWindow); } NS_IMETHODIMP nsChromeTreeOwner::SetParentNativeWindow( @@ -344,53 +344,53 @@ NS_IMETHODIMP nsChromeTreeOwner::SetParentNativeWindow( } NS_IMETHODIMP nsChromeTreeOwner::GetNativeHandle(nsAString& aNativeHandle) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetNativeHandle(aNativeHandle); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetNativeHandle(aNativeHandle); } NS_IMETHODIMP nsChromeTreeOwner::GetVisibility(bool* aVisibility) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetVisibility(aVisibility); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetVisibility(aVisibility); } NS_IMETHODIMP nsChromeTreeOwner::SetVisibility(bool aVisibility) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->SetVisibility(aVisibility); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->SetVisibility(aVisibility); } NS_IMETHODIMP nsChromeTreeOwner::GetEnabled(bool* aEnabled) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetEnabled(aEnabled); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetEnabled(aEnabled); } NS_IMETHODIMP nsChromeTreeOwner::SetEnabled(bool aEnable) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->SetEnabled(aEnable); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->SetEnabled(aEnable); } NS_IMETHODIMP nsChromeTreeOwner::GetMainWidget(nsIWidget** aMainWidget) { NS_ENSURE_ARG_POINTER(aMainWidget); - NS_ENSURE_STATE(mAppWindow); + NS_ENSURE_STATE(mXULWindow); - *aMainWidget = mAppWindow->mWindow; + *aMainWidget = mXULWindow->mWindow; NS_IF_ADDREF(*aMainWidget); return NS_OK; } NS_IMETHODIMP nsChromeTreeOwner::SetFocus() { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->SetFocus(); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->SetFocus(); } NS_IMETHODIMP nsChromeTreeOwner::GetTitle(nsAString& aTitle) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetTitle(aTitle); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetTitle(aTitle); } NS_IMETHODIMP nsChromeTreeOwner::SetTitle(const nsAString& aTitle) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->SetTitle(aTitle); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->SetTitle(aTitle); } //***************************************************************************** @@ -419,12 +419,12 @@ NS_IMETHODIMP nsChromeTreeOwner::OnLocationChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest, nsIURI* aLocation, uint32_t aFlags) { - NS_ENSURE_STATE(mAppWindow); + NS_ENSURE_STATE(mXULWindow); // If loading a new root .xul document, then redo chrome. if (aWebProgress) { nsCOMPtr docshell; - mAppWindow->GetDocShell(getter_AddRefs(docshell)); + mXULWindow->GetDocShell(getter_AddRefs(docshell)); nsCOMPtr webProgress(do_QueryInterface(docshell)); if (webProgress != aWebProgress) { @@ -432,7 +432,7 @@ nsChromeTreeOwner::OnLocationChange(nsIWebProgress* aWebProgress, } } - mAppWindow->mChromeLoaded = false; + mXULWindow->mChromeLoaded = false; return NS_OK; } @@ -464,10 +464,8 @@ nsChromeTreeOwner::OnContentBlockingEvent(nsIWebProgress* aWebProgress, // nsChromeTreeOwner: Accessors //***************************************************************************** -void nsChromeTreeOwner::AppWindow(mozilla::AppWindow* aAppWindow) { - mAppWindow = aAppWindow; +void nsChromeTreeOwner::XULWindow(nsXULWindow* aXULWindow) { + mXULWindow = aXULWindow; } -mozilla::AppWindow* nsChromeTreeOwner::AppWindow() { - return mAppWindow; -} +nsXULWindow* nsChromeTreeOwner::XULWindow() { return mXULWindow; } diff --git a/xpfe/appshell/nsChromeTreeOwner.h b/xpfe/appshell/nsChromeTreeOwner.h index 768fc446280e..199df2851011 100644 --- a/xpfe/appshell/nsChromeTreeOwner.h +++ b/xpfe/appshell/nsChromeTreeOwner.h @@ -18,16 +18,14 @@ #include "nsIWebProgressListener.h" #include "nsWeakReference.h" -namespace mozilla { -class AppWindow; -} +class nsXULWindow; class nsChromeTreeOwner : public nsIDocShellTreeOwner, public nsIBaseWindow, public nsIInterfaceRequestor, public nsIWebProgressListener, public nsSupportsWeakReference { - friend class mozilla::AppWindow; + friend class nsXULWindow; public: NS_DECL_ISUPPORTS @@ -41,11 +39,11 @@ class nsChromeTreeOwner : public nsIDocShellTreeOwner, nsChromeTreeOwner(); virtual ~nsChromeTreeOwner(); - void AppWindow(mozilla::AppWindow* aAppWindow); - mozilla::AppWindow* AppWindow(); + void XULWindow(nsXULWindow* aXULWindow); + nsXULWindow* XULWindow(); protected: - mozilla::AppWindow* mAppWindow; + nsXULWindow* mXULWindow; }; #endif /* nsChromeTreeOwner_h__ */ diff --git a/xpfe/appshell/nsContentTreeOwner.cpp b/xpfe/appshell/nsContentTreeOwner.cpp index b4f3636d8ef8..e967d57b2568 100644 --- a/xpfe/appshell/nsContentTreeOwner.cpp +++ b/xpfe/appshell/nsContentTreeOwner.cpp @@ -7,7 +7,7 @@ // Local Includes #include "nsContentTreeOwner.h" -#include "AppWindow.h" +#include "nsXULWindow.h" // Helper Classes #include "nsIServiceManager.h" @@ -78,7 +78,7 @@ class nsSiteWindow : public nsIEmbeddingSiteWindow { //***************************************************************************** nsContentTreeOwner::nsContentTreeOwner(bool fPrimary) - : mAppWindow(nullptr), mPrimary(fPrimary) { + : mXULWindow(nullptr), mPrimary(fPrimary) { // note if this fails, QI on nsIEmbeddingSiteWindow(2) will simply fail mSiteWindow = new nsSiteWindow(this); } @@ -122,26 +122,26 @@ NS_IMETHODIMP nsContentTreeOwner::GetInterface(const nsIID& aIID, *aSink = 0; if (aIID.Equals(NS_GET_IID(nsIPrompt))) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetInterface(aIID, aSink); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetInterface(aIID, aSink); } if (aIID.Equals(NS_GET_IID(nsIAuthPrompt))) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetInterface(aIID, aSink); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetInterface(aIID, aSink); } if (aIID.Equals(NS_GET_IID(nsIDocShellTreeItem))) { - NS_ENSURE_STATE(mAppWindow); + NS_ENSURE_STATE(mXULWindow); nsCOMPtr shell; - mAppWindow->GetDocShell(getter_AddRefs(shell)); + mXULWindow->GetDocShell(getter_AddRefs(shell)); if (shell) return shell->QueryInterface(aIID, aSink); return NS_ERROR_FAILURE; } if (aIID.Equals(NS_GET_IID(nsIDOMWindow)) || aIID.Equals(NS_GET_IID(nsPIDOMWindowOuter))) { - NS_ENSURE_STATE(mAppWindow); + NS_ENSURE_STATE(mXULWindow); nsCOMPtr shell; - mAppWindow->GetPrimaryContentShell(getter_AddRefs(shell)); + mXULWindow->GetPrimaryContentShell(getter_AddRefs(shell)); if (shell) { nsCOMPtr thing(do_QueryInterface(shell)); if (thing) return thing->GetInterface(aIID, aSink); @@ -149,9 +149,9 @@ NS_IMETHODIMP nsContentTreeOwner::GetInterface(const nsIID& aIID, return NS_ERROR_FAILURE; } - if (aIID.Equals(NS_GET_IID(nsIAppWindow))) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->QueryInterface(aIID, aSink); + if (aIID.Equals(NS_GET_IID(nsIXULWindow))) { + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->QueryInterface(aIID, aSink); } return QueryInterface(aIID, aSink); @@ -164,75 +164,75 @@ NS_IMETHODIMP nsContentTreeOwner::GetInterface(const nsIID& aIID, NS_IMETHODIMP nsContentTreeOwner::ContentShellAdded(nsIDocShellTreeItem* aContentShell, bool aPrimary) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->ContentShellAdded(aContentShell, aPrimary); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->ContentShellAdded(aContentShell, aPrimary); } NS_IMETHODIMP nsContentTreeOwner::ContentShellRemoved(nsIDocShellTreeItem* aContentShell) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->ContentShellRemoved(aContentShell); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->ContentShellRemoved(aContentShell); } NS_IMETHODIMP nsContentTreeOwner::GetPrimaryContentShell(nsIDocShellTreeItem** aShell) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetPrimaryContentShell(aShell); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetPrimaryContentShell(aShell); } NS_IMETHODIMP nsContentTreeOwner::RemoteTabAdded(nsIRemoteTab* aTab, bool aPrimary) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->RemoteTabAdded(aTab, aPrimary); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->RemoteTabAdded(aTab, aPrimary); } NS_IMETHODIMP nsContentTreeOwner::RemoteTabRemoved(nsIRemoteTab* aTab) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->RemoteTabRemoved(aTab); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->RemoteTabRemoved(aTab); } NS_IMETHODIMP nsContentTreeOwner::GetPrimaryRemoteTab(nsIRemoteTab** aTab) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetPrimaryRemoteTab(aTab); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetPrimaryRemoteTab(aTab); } NS_IMETHODIMP nsContentTreeOwner::GetPrimaryContentSize(int32_t* aWidth, int32_t* aHeight) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetPrimaryContentSize(aWidth, aHeight); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetPrimaryContentSize(aWidth, aHeight); } NS_IMETHODIMP nsContentTreeOwner::SetPrimaryContentSize(int32_t aWidth, int32_t aHeight) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->SetPrimaryContentSize(aWidth, aHeight); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->SetPrimaryContentSize(aWidth, aHeight); } NS_IMETHODIMP nsContentTreeOwner::GetRootShellSize(int32_t* aWidth, int32_t* aHeight) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetRootShellSize(aWidth, aHeight); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetRootShellSize(aWidth, aHeight); } NS_IMETHODIMP nsContentTreeOwner::SetRootShellSize(int32_t aWidth, int32_t aHeight) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->SetRootShellSize(aWidth, aHeight); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->SetRootShellSize(aWidth, aHeight); } NS_IMETHODIMP nsContentTreeOwner::SizeShellTo(nsIDocShellTreeItem* aShellItem, int32_t aCX, int32_t aCY) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->SizeShellTo(aShellItem, aCX, aCY); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->SizeShellTo(aShellItem, aCX, aCY); } NS_IMETHODIMP nsContentTreeOwner::SetPersistence(bool aPersistPosition, bool aPersistSize, bool aPersistSizeMode) { - NS_ENSURE_STATE(mAppWindow); - nsCOMPtr docShellElement = mAppWindow->GetWindowDOMElement(); + NS_ENSURE_STATE(mXULWindow); + nsCOMPtr docShellElement = mXULWindow->GetWindowDOMElement(); if (!docShellElement) return NS_ERROR_FAILURE; nsAutoString persistString; @@ -299,8 +299,8 @@ nsContentTreeOwner::SetPersistence(bool aPersistPosition, bool aPersistSize, NS_IMETHODIMP nsContentTreeOwner::GetPersistence(bool* aPersistPosition, bool* aPersistSize, bool* aPersistSizeMode) { - NS_ENSURE_STATE(mAppWindow); - nsCOMPtr docShellElement = mAppWindow->GetWindowDOMElement(); + NS_ENSURE_STATE(mXULWindow); + nsCOMPtr docShellElement = mXULWindow->GetWindowDOMElement(); if (!docShellElement) return NS_ERROR_FAILURE; nsAutoString persistString; @@ -326,8 +326,8 @@ nsContentTreeOwner::GetPersistence(bool* aPersistPosition, bool* aPersistSize, NS_IMETHODIMP nsContentTreeOwner::GetTabCount(uint32_t* aResult) { - if (mAppWindow) { - return mAppWindow->GetTabCount(aResult); + if (mXULWindow) { + return mXULWindow->GetTabCount(aResult); } *aResult = 0; @@ -336,8 +336,8 @@ nsContentTreeOwner::GetTabCount(uint32_t* aResult) { NS_IMETHODIMP nsContentTreeOwner::GetHasPrimaryContent(bool* aResult) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetHasPrimaryContent(aResult); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetHasPrimaryContent(aResult); } //***************************************************************************** @@ -347,10 +347,10 @@ nsContentTreeOwner::GetHasPrimaryContent(bool* aResult) { NS_IMETHODIMP nsContentTreeOwner::OnBeforeLinkTraversal( const nsAString& originalTarget, nsIURI* linkURI, nsINode* linkNode, bool isAppTab, nsAString& _retval) { - NS_ENSURE_STATE(mAppWindow); + NS_ENSURE_STATE(mXULWindow); nsCOMPtr xulBrowserWindow; - mAppWindow->GetXULBrowserWindow(getter_AddRefs(xulBrowserWindow)); + mXULWindow->GetXULBrowserWindow(getter_AddRefs(xulBrowserWindow)); if (xulBrowserWindow) return xulBrowserWindow->OnBeforeLinkTraversal(originalTarget, linkURI, @@ -364,10 +364,10 @@ NS_IMETHODIMP nsContentTreeOwner::ShouldLoadURI( nsIDocShell* aDocShell, nsIURI* aURI, nsIReferrerInfo* aReferrerInfo, bool aHasPostData, nsIPrincipal* aTriggeringPrincipal, nsIContentSecurityPolicy* aCsp, bool* _retval) { - NS_ENSURE_STATE(mAppWindow); + NS_ENSURE_STATE(mXULWindow); nsCOMPtr xulBrowserWindow; - mAppWindow->GetXULBrowserWindow(getter_AddRefs(xulBrowserWindow)); + mXULWindow->GetXULBrowserWindow(getter_AddRefs(xulBrowserWindow)); if (xulBrowserWindow) return xulBrowserWindow->ShouldLoadURI(aDocShell, aURI, aReferrerInfo, @@ -404,10 +404,10 @@ NS_IMETHODIMP nsContentTreeOwner::SetStatusWithContext( // We only allow the status to be set from the primary content shell if (!mPrimary && aStatusType != STATUS_LINK) return NS_OK; - NS_ENSURE_STATE(mAppWindow); + NS_ENSURE_STATE(mXULWindow); nsCOMPtr xulBrowserWindow; - mAppWindow->GetXULBrowserWindow(getter_AddRefs(xulBrowserWindow)); + mXULWindow->GetXULBrowserWindow(getter_AddRefs(xulBrowserWindow)); if (xulBrowserWindow) { switch (aStatusType) { @@ -436,23 +436,23 @@ NS_IMETHODIMP nsContentTreeOwner::SetStatus(uint32_t aStatusType, } NS_IMETHODIMP nsContentTreeOwner::SetChromeFlags(uint32_t aChromeFlags) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->SetChromeFlags(aChromeFlags); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->SetChromeFlags(aChromeFlags); } NS_IMETHODIMP nsContentTreeOwner::GetChromeFlags(uint32_t* aChromeFlags) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetChromeFlags(aChromeFlags); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetChromeFlags(aChromeFlags); } NS_IMETHODIMP nsContentTreeOwner::ShowAsModal() { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->ShowModal(); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->ShowModal(); } NS_IMETHODIMP nsContentTreeOwner::IsWindowModal(bool* _retval) { - NS_ENSURE_STATE(mAppWindow); - *_retval = mAppWindow->mContinueModalLoop; + NS_ENSURE_STATE(mXULWindow); + *_retval = mXULWindow->mContinueModalLoop; return NS_OK; } @@ -477,71 +477,71 @@ NS_IMETHODIMP nsContentTreeOwner::Create() { } NS_IMETHODIMP nsContentTreeOwner::Destroy() { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->Destroy(); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->Destroy(); } NS_IMETHODIMP nsContentTreeOwner::GetUnscaledDevicePixelsPerCSSPixel( double* aScale) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetUnscaledDevicePixelsPerCSSPixel(aScale); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetUnscaledDevicePixelsPerCSSPixel(aScale); } NS_IMETHODIMP nsContentTreeOwner::GetDevicePixelsPerDesktopPixel( double* aScale) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetDevicePixelsPerDesktopPixel(aScale); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetDevicePixelsPerDesktopPixel(aScale); } NS_IMETHODIMP nsContentTreeOwner::SetPositionDesktopPix(int32_t aX, int32_t aY) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->SetPositionDesktopPix(aX, aY); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->SetPositionDesktopPix(aX, aY); } NS_IMETHODIMP nsContentTreeOwner::SetPosition(int32_t aX, int32_t aY) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->SetPosition(aX, aY); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->SetPosition(aX, aY); } NS_IMETHODIMP nsContentTreeOwner::GetPosition(int32_t* aX, int32_t* aY) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetPosition(aX, aY); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetPosition(aX, aY); } NS_IMETHODIMP nsContentTreeOwner::SetSize(int32_t aCX, int32_t aCY, bool aRepaint) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->SetSize(aCX, aCY, aRepaint); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->SetSize(aCX, aCY, aRepaint); } NS_IMETHODIMP nsContentTreeOwner::GetSize(int32_t* aCX, int32_t* aCY) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetSize(aCX, aCY); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetSize(aCX, aCY); } NS_IMETHODIMP nsContentTreeOwner::SetPositionAndSize(int32_t aX, int32_t aY, int32_t aCX, int32_t aCY, uint32_t aFlags) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->SetPositionAndSize(aX, aY, aCX, aCY, aFlags); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->SetPositionAndSize(aX, aY, aCX, aCY, aFlags); } NS_IMETHODIMP nsContentTreeOwner::GetPositionAndSize(int32_t* aX, int32_t* aY, int32_t* aCX, int32_t* aCY) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetPositionAndSize(aX, aY, aCX, aCY); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetPositionAndSize(aX, aY, aCX, aCY); } NS_IMETHODIMP nsContentTreeOwner::Repaint(bool aForce) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->Repaint(aForce); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->Repaint(aForce); } NS_IMETHODIMP nsContentTreeOwner::GetParentWidget(nsIWidget** aParentWidget) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetParentWidget(aParentWidget); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetParentWidget(aParentWidget); } NS_IMETHODIMP nsContentTreeOwner::SetParentWidget(nsIWidget* aParentWidget) { @@ -551,8 +551,8 @@ NS_IMETHODIMP nsContentTreeOwner::SetParentWidget(nsIWidget* aParentWidget) { NS_IMETHODIMP nsContentTreeOwner::GetParentNativeWindow( nativeWindow* aParentNativeWindow) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetParentNativeWindow(aParentNativeWindow); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetParentNativeWindow(aParentNativeWindow); } NS_IMETHODIMP nsContentTreeOwner::SetParentNativeWindow( @@ -562,49 +562,49 @@ NS_IMETHODIMP nsContentTreeOwner::SetParentNativeWindow( } NS_IMETHODIMP nsContentTreeOwner::GetNativeHandle(nsAString& aNativeHandle) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetNativeHandle(aNativeHandle); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetNativeHandle(aNativeHandle); } NS_IMETHODIMP nsContentTreeOwner::GetVisibility(bool* aVisibility) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetVisibility(aVisibility); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetVisibility(aVisibility); } NS_IMETHODIMP nsContentTreeOwner::SetVisibility(bool aVisibility) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->SetVisibility(aVisibility); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->SetVisibility(aVisibility); } NS_IMETHODIMP nsContentTreeOwner::GetEnabled(bool* aEnabled) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->GetEnabled(aEnabled); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->GetEnabled(aEnabled); } NS_IMETHODIMP nsContentTreeOwner::SetEnabled(bool aEnable) { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->SetEnabled(aEnable); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->SetEnabled(aEnable); } NS_IMETHODIMP nsContentTreeOwner::GetMainWidget(nsIWidget** aMainWidget) { NS_ENSURE_ARG_POINTER(aMainWidget); - NS_ENSURE_STATE(mAppWindow); + NS_ENSURE_STATE(mXULWindow); - *aMainWidget = mAppWindow->mWindow; + *aMainWidget = mXULWindow->mWindow; NS_IF_ADDREF(*aMainWidget); return NS_OK; } NS_IMETHODIMP nsContentTreeOwner::SetFocus() { - NS_ENSURE_STATE(mAppWindow); - return mAppWindow->SetFocus(); + NS_ENSURE_STATE(mXULWindow); + return mXULWindow->SetFocus(); } NS_IMETHODIMP nsContentTreeOwner::GetTitle(nsAString& aTitle) { - NS_ENSURE_STATE(mAppWindow); + NS_ENSURE_STATE(mXULWindow); - return mAppWindow->GetTitle(aTitle); + return mXULWindow->GetTitle(aTitle); } NS_IMETHODIMP nsContentTreeOwner::SetTitle(const nsAString& aTitle) { @@ -629,7 +629,7 @@ nsContentTreeOwner::ProvideWindow( *aReturn = nullptr; - if (!mAppWindow) { + if (!mXULWindow) { // Nothing to do here return NS_OK; } @@ -690,11 +690,11 @@ nsContentTreeOwner::ProvideWindow( } nsCOMPtr domWin; - mAppWindow->GetWindowDOMWindow(getter_AddRefs(domWin)); + mXULWindow->GetWindowDOMWindow(getter_AddRefs(domWin)); nsCOMPtr chromeWin = do_QueryInterface(domWin); if (!chromeWin) { // Really odd... but whatever - NS_WARNING("AppWindow's DOMWindow is not a chrome window"); + NS_WARNING("nsXULWindow's DOMWindow is not a chrome window"); return NS_OK; } @@ -756,13 +756,11 @@ class nsContentTitleSettingEvent : public Runnable { }; #endif -void nsContentTreeOwner::AppWindow(mozilla::AppWindow* aAppWindow) { - mAppWindow = aAppWindow; +void nsContentTreeOwner::XULWindow(nsXULWindow* aXULWindow) { + mXULWindow = aXULWindow; } -mozilla::AppWindow* nsContentTreeOwner::AppWindow() { - return mAppWindow; -} +nsXULWindow* nsContentTreeOwner::XULWindow() { return mXULWindow; } //***************************************************************************** //*** nsSiteWindow implementation @@ -806,7 +804,7 @@ nsSiteWindow::SetFocus(void) { and it's better for our purposes to not pick a document and focus it, but allow nsGlobalWindow to carry on unhindered. */ - AppWindow *window = mAggregator->AppWindow(); + nsXULWindow *window = mAggregator->XULWindow(); if (window) { nsCOMPtr docshell; window->GetDocShell(getter_AddRefs(docshell)); @@ -827,15 +825,15 @@ nsSiteWindow::Blur(void) { NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID); nsCOMPtr windowEnumerator; - nsCOMPtr appWindow; + nsCOMPtr xulWindow; bool more, foundUs; - AppWindow* ourWindow = mAggregator->AppWindow(); + nsXULWindow* ourWindow = mAggregator->XULWindow(); { nsCOMPtr windowMediator( do_GetService(kWindowMediatorCID)); if (windowMediator) - windowMediator->GetZOrderAppWindowEnumerator( + windowMediator->GetZOrderXULWindowEnumerator( 0, true, getter_AddRefs(windowEnumerator)); } @@ -846,30 +844,30 @@ nsSiteWindow::Blur(void) { windowEnumerator->HasMoreElements(&more); while (more) { nsCOMPtr nextWindow; - nsCOMPtr nextAppWindow; + nsCOMPtr nextXULWindow; windowEnumerator->GetNext(getter_AddRefs(nextWindow)); - nextAppWindow = do_QueryInterface(nextWindow); + nextXULWindow = do_QueryInterface(nextWindow); // got it!(?) if (foundUs) { - appWindow = nextAppWindow; + xulWindow = nextXULWindow; break; } // remember the very first one, in case we have to wrap - if (!appWindow) appWindow = nextAppWindow; + if (!xulWindow) xulWindow = nextXULWindow; // look for us - if (nextAppWindow == ourWindow) foundUs = true; + if (nextXULWindow == ourWindow) foundUs = true; windowEnumerator->HasMoreElements(&more); } // change focus to the window we just found - if (appWindow) { + if (xulWindow) { nsCOMPtr docshell; - appWindow->GetDocShell(getter_AddRefs(docshell)); + xulWindow->GetDocShell(getter_AddRefs(docshell)); if (!docshell) { return NS_OK; } diff --git a/xpfe/appshell/nsContentTreeOwner.h b/xpfe/appshell/nsContentTreeOwner.h index 8d268bbf434e..fcbadf2a212b 100644 --- a/xpfe/appshell/nsContentTreeOwner.h +++ b/xpfe/appshell/nsContentTreeOwner.h @@ -19,9 +19,7 @@ #include "nsIWebBrowserChrome3.h" #include "nsIWindowProvider.h" -namespace mozilla { -class AppWindow; -} +class nsXULWindow; class nsSiteWindow; class nsContentTreeOwner final : public nsIDocShellTreeOwner, @@ -29,7 +27,7 @@ class nsContentTreeOwner final : public nsIDocShellTreeOwner, public nsIInterfaceRequestor, public nsIWebBrowserChrome3, public nsIWindowProvider { - friend class mozilla::AppWindow; + friend class nsXULWindow; friend class nsSiteWindow; public: @@ -47,11 +45,11 @@ class nsContentTreeOwner final : public nsIDocShellTreeOwner, explicit nsContentTreeOwner(bool fPrimary); virtual ~nsContentTreeOwner(); - void AppWindow(mozilla::AppWindow* aAppWindow); - mozilla::AppWindow* AppWindow(); + void XULWindow(nsXULWindow* aXULWindow); + nsXULWindow* XULWindow(); protected: - mozilla::AppWindow* mAppWindow; + nsXULWindow* mXULWindow; nsSiteWindow* mSiteWindow; bool mPrimary; }; diff --git a/xpfe/appshell/nsIAppShellService.idl b/xpfe/appshell/nsIAppShellService.idl index 4a3c0f0e4201..fca075ca17ec 100644 --- a/xpfe/appshell/nsIAppShellService.idl +++ b/xpfe/appshell/nsIAppShellService.idl @@ -5,7 +5,7 @@ #include "nsISupports.idl" -interface nsIAppWindow; +interface nsIXULWindow; interface nsIWindowlessBrowser; interface nsIURI; interface mozIDOMWindowProxy; @@ -42,7 +42,7 @@ interface nsIAppShellService : nsISupports * Can be left null. */ const long SIZE_TO_CONTENT = -1; - nsIAppWindow createTopLevelWindow(in nsIAppWindow aParent, + nsIXULWindow createTopLevelWindow(in nsIXULWindow aParent, in nsIURI aUrl, in uint32_t aChromeMask, in long aInitialWidth, @@ -79,7 +79,7 @@ interface nsIAppShellService : nsISupports * @param aResult the hidden window. Do not unhide hidden window. * Do not taunt hidden window. */ - readonly attribute nsIAppWindow hiddenWindow; + readonly attribute nsIXULWindow hiddenWindow; /** * Return the (singleton) application hidden window, automatically created @@ -104,7 +104,7 @@ interface nsIAppShellService : nsISupports * @note When this method is successful, it fires the global notification * "xul-window-registered" */ - void registerTopLevelWindow(in nsIAppWindow aWindow); + void registerTopLevelWindow(in nsIXULWindow aWindow); /** * Remove a window from the application's window registry. Note that @@ -112,7 +112,7 @@ interface nsIAppShellService : nsISupports * the last window is unregistered. For that, see Quit(). * @param aWindow you see the pattern */ - void unregisterTopLevelWindow(in nsIAppWindow aWindow); + void unregisterTopLevelWindow(in nsIXULWindow aWindow); /** * Whether the hidden window has been lazily created. diff --git a/xpfe/appshell/nsIWindowMediator.idl b/xpfe/appshell/nsIWindowMediator.idl index cdf5a0dd6492..2d29cfb41470 100644 --- a/xpfe/appshell/nsIWindowMediator.idl +++ b/xpfe/appshell/nsIWindowMediator.idl @@ -17,7 +17,7 @@ interface mozIDOMWindow; interface mozIDOMWindowProxy; -interface nsIAppWindow; +interface nsIXULWindow; interface nsIWidget; interface nsIWindowMediatorListener; @@ -37,9 +37,9 @@ interface nsIWindowMediator: nsISupports nsISimpleEnumerator getEnumerator(in wstring aWindowType); /** Identical to getEnumerator except: - * @return an enumerator of nsIAppWindows + * @return an enumerator of nsIXULWindows */ - nsISimpleEnumerator getAppWindowEnumerator(in wstring aWindowType); + nsISimpleEnumerator getXULWindowEnumerator(in wstring aWindowType); /** Return an enumerator which iterates over all windows of type aWindowType * in their z (front-to-back) order. Note this interface makes @@ -51,9 +51,9 @@ interface nsIWindowMediator: nsISupports * If null, all windows will be enumerated. * @param aFrontToBack if true, the enumerator enumerates windows in order * from front to back. back to front if false. - * @return an enumerator of nsIAppWindows + * @return an enumerator of nsIXULWindows */ - nsISimpleEnumerator getZOrderAppWindowEnumerator(in wstring aWindowType, + nsISimpleEnumerator getZOrderXULWindowEnumerator(in wstring aWindowType, in boolean aFrontToBack); /** This is a shortcut for simply fetching the first window in @@ -95,20 +95,20 @@ interface nsIWindowMediator: nsISupports * addListener) will be notified through their onOpenWindow method. * @param aWindow the window to add */ - [noscript] void registerWindow(in nsIAppWindow aWindow); + [noscript] void registerWindow(in nsIXULWindow aWindow); /** Remove the window from the list of known windows. Listeners (see * addListener) will be be notified through their onCloseWindow method. * @param aWindow the window to remove */ - [noscript] void unregisterWindow(in nsIAppWindow aWindow); + [noscript] void unregisterWindow(in nsIXULWindow aWindow); /** Call this method when a window gains focus. It's a primitive means of * determining the most recent window. It's no longer necessary and it * really should be removed. * @param aWindow the window which has gained focus */ - [noscript] void updateWindowTimeStamp(in nsIAppWindow aWindow); + [noscript] void updateWindowTimeStamp(in nsIXULWindow aWindow); /* z-ordering: */ @@ -120,8 +120,8 @@ interface nsIWindowMediator: nsISupports * it should be constrained. Note this method is advisory only: * it changes nothing either in WindowMediator's internal state * or with the window. - * Note it compares the nsIAppWindow to nsIWidgets. A pure interface - * would use all nsIAppWindows. But we expect this to be called from + * Note it compares the nsIXULWindow to nsIWidgets. A pure interface + * would use all nsIXULWindows. But we expect this to be called from * callbacks originating in native window code. They are expected to * hand us comparison values which are pulled from general storage * in the native widget, and may not correspond to an nsIWidget at all. @@ -146,7 +146,7 @@ interface nsIWindowMediator: nsISupports * the position given. */ - [noscript] boolean calculateZPosition(in nsIAppWindow inWindow, + [noscript] boolean calculateZPosition(in nsIXULWindow inWindow, in unsigned long inPosition, in nsIWidget inBelow, out unsigned long outPosition, @@ -161,24 +161,24 @@ interface nsIWindowMediator: nsISupports * for other values of inPosition.) * @param inBelow the window inWindow is behind, if zLevelBelow */ - [noscript] void setZPosition(in nsIAppWindow inWindow, + [noscript] void setZPosition(in nsIXULWindow inWindow, in unsigned long inPosition, - in nsIAppWindow inBelow); + in nsIXULWindow inBelow); - /** Return the window's Z level (as defined in nsIAppWindow). + /** Return the window's Z level (as defined in nsIXULWindow). * @param aWindow the window in question * @return aWindow's z level */ - [noscript] uint32_t getZLevel(in nsIAppWindow aWindow); + [noscript] uint32_t getZLevel(in nsIXULWindow aWindow); - /** Set the window's Z level (as defined in nsIAppWindow). The implementation + /** Set the window's Z level (as defined in nsIXULWindow). The implementation * will reposition the window as necessary to match its new Z level. * The implementation will assume a window's Z level to be - * nsIAppWindow::normalZ until it has been informed of a different level. + * nsIXULWindow::normalZ until it has been informed of a different level. * @param aWindow the window in question * @param aZLevel the window's new Z level */ - [noscript] void setZLevel(in nsIAppWindow aWindow, in uint32_t aZLevel); + [noscript] void setZLevel(in nsIXULWindow aWindow, in uint32_t aZLevel); /** Register a listener for window status changes. * keeps strong ref? (to be decided) diff --git a/xpfe/appshell/nsIWindowMediatorListener.idl b/xpfe/appshell/nsIWindowMediatorListener.idl index b30b66996b43..ae900718e635 100644 --- a/xpfe/appshell/nsIWindowMediatorListener.idl +++ b/xpfe/appshell/nsIWindowMediatorListener.idl @@ -5,12 +5,12 @@ #include "nsISupports.idl" -interface nsIAppWindow; +interface nsIXULWindow; [scriptable, uuid(2F276982-0D60-4377-A595-D350BA516395)] interface nsIWindowMediatorListener : nsISupports { - void onOpenWindow(in nsIAppWindow window); - void onCloseWindow(in nsIAppWindow window); + void onOpenWindow(in nsIXULWindow window); + void onCloseWindow(in nsIXULWindow window); }; diff --git a/xpfe/appshell/nsIAppWindow.idl b/xpfe/appshell/nsIXULWindow.idl similarity index 96% rename from xpfe/appshell/nsIAppWindow.idl rename to xpfe/appshell/nsIXULWindow.idl index 7c90a0d87d6b..efffc3d4fbbf 100644 --- a/xpfe/appshell/nsIAppWindow.idl +++ b/xpfe/appshell/nsIXULWindow.idl @@ -7,7 +7,7 @@ #include "nsISupports.idl" /** - * The nsIAppWindow + * The nsIXULWindow * * When the window is destroyed, it will fire a "xul-window-destroyed" * notification through the global observer service. @@ -27,7 +27,7 @@ interface mozIDOMWindowProxy; native LiveResizeListenerArray(nsTArray>); [builtinclass, scriptable, uuid(d6d7a014-e28d-4c9d-8727-1cf6d870619b)] -interface nsIAppWindow : nsISupports +interface nsIXULWindow : nsISupports { /** * The docshell owning the XUL for this window. @@ -64,7 +64,7 @@ interface nsIAppWindow : nsISupports * Tell this window that it has picked up a child XUL window * @param aChild the child window being added */ - void addChildWindow(in nsIAppWindow aChild); + void addChildWindow(in nsIXULWindow aChild); /** * Returns the difference between the inner window size (client size) and the @@ -77,7 +77,7 @@ interface nsIAppWindow : nsISupports * Tell this window that it has lost a child XUL window * @param aChild the child window being removed */ - void removeChildWindow(in nsIAppWindow aChild); + void removeChildWindow(in nsIXULWindow aChild); /** * Move the window to a centered position. @@ -93,7 +93,7 @@ interface nsIAppWindow : nsISupports * @param aAlert PR_TRUE to move the window to an alert position, * generally centered horizontally and 1/3 down from the top. */ - void center(in nsIAppWindow aRelative, in boolean aScreen, in boolean aAlert); + void center(in nsIXULWindow aRelative, in boolean aScreen, in boolean aAlert); /** * Shows the window as a modal window. That is, ensures that it is visible @@ -133,7 +133,7 @@ interface nsIAppWindow : nsISupports * 0 means there is no next remote tab actor to use. * @return the newly minted window */ - nsIAppWindow createNewWindow(in int32_t aChromeFlags, + nsIXULWindow createNewWindow(in int32_t aChromeFlags, in nsIRemoteTab aOpeningTab, in mozIDOMWindowProxy aOpener, in unsigned long long aNextRemoteTabId); diff --git a/xpfe/appshell/nsWebShellWindow.cpp b/xpfe/appshell/nsWebShellWindow.cpp new file mode 100644 index 000000000000..06d082b2980f --- /dev/null +++ b/xpfe/appshell/nsWebShellWindow.cpp @@ -0,0 +1,818 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "nsWebShellWindow.h" + +#include "nsLayoutCID.h" +#include "nsContentCID.h" +#include "nsContentList.h" +#include "nsIWeakReference.h" +#include "nsIContentViewer.h" +#include "nsIComponentManager.h" +#include "nsIServiceManager.h" +#include "nsIURL.h" +#include "nsIIOService.h" +#include "nsIURL.h" +#include "nsNetCID.h" +#include "nsIStringBundle.h" +#include "nsReadableUtils.h" + +#include "nsContentUtils.h" +#include "nsEscape.h" +#include "nsPIDOMWindow.h" +#include "nsIWebNavigation.h" +#include "nsIWindowWatcher.h" + +#include "nsWidgetInitData.h" +#include "nsWidgetsCID.h" +#include "nsIWidget.h" +#include "nsIWidgetListener.h" + +#include "nsINodeList.h" + +#include "nsITimer.h" +#include "nsXULPopupManager.h" + +#include "nsFocusManager.h" + +#include "nsIWebProgress.h" +#include "nsIWebProgressListener.h" + +#include "mozilla/dom/Document.h" +#include "nsIDocumentLoaderFactory.h" +#include "nsIObserverService.h" + +#include "nsIScreenManager.h" +#include "nsIScreen.h" + +#include "nsIContent.h" // for menus +#include "nsIScriptSecurityManager.h" + +// For calculating size +#include "nsPresContext.h" + +#include "nsIBaseWindow.h" +#include "nsIDocShellTreeItem.h" +#include "nsDocShell.h" + +#include "mozilla/Attributes.h" +#include "mozilla/DebugOnly.h" +#include "mozilla/EventDispatcher.h" +#include "mozilla/MouseEvents.h" +#include "mozilla/PresShell.h" + +#include "mozilla/dom/BrowsingContext.h" +#include "mozilla/dom/LoadURIOptionsBinding.h" + +#include "nsPIWindowRoot.h" + +#include "gfxPlatform.h" + +#ifdef XP_MACOSX +# include "nsINativeMenuService.h" +# define USE_NATIVE_MENUS +#endif + +using namespace mozilla; +using namespace mozilla::dom; + +#define SIZE_PERSISTENCE_TIMEOUT 500 // msec + +nsWebShellWindow::nsWebShellWindow(uint32_t aChromeFlags) + : nsXULWindow(aChromeFlags), + mSPTimerLock("nsWebShellWindow.mSPTimerLock"), + mWidgetListenerDelegate(this) {} + +nsWebShellWindow::~nsWebShellWindow() { + MutexAutoLock lock(mSPTimerLock); + if (mSPTimer) mSPTimer->Cancel(); +} + +NS_IMPL_ADDREF_INHERITED(nsWebShellWindow, nsXULWindow) +NS_IMPL_RELEASE_INHERITED(nsWebShellWindow, nsXULWindow) + +NS_INTERFACE_MAP_BEGIN(nsWebShellWindow) + NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener) +NS_INTERFACE_MAP_END_INHERITING(nsXULWindow) + +nsresult nsWebShellWindow::Initialize( + nsIXULWindow* aParent, nsIXULWindow* aOpener, nsIURI* aUrl, + int32_t aInitialWidth, int32_t aInitialHeight, bool aIsHiddenWindow, + nsIRemoteTab* aOpeningTab, mozIDOMWindowProxy* aOpenerWindow, + nsWidgetInitData& widgetInitData) { + nsresult rv; + nsCOMPtr parentWidget; + + mIsHiddenWindow = aIsHiddenWindow; + + int32_t initialX = 0, initialY = 0; + nsCOMPtr base(do_QueryInterface(aOpener)); + if (base) { + int32_t x, y, width, height; + rv = base->GetPositionAndSize(&x, &y, &width, &height); + if (NS_FAILED(rv)) { + mOpenerScreenRect.SetEmpty(); + } else { + double scale; + if (NS_SUCCEEDED(base->GetUnscaledDevicePixelsPerCSSPixel(&scale))) { + mOpenerScreenRect.SetRect( + NSToIntRound(x / scale), NSToIntRound(y / scale), + NSToIntRound(width / scale), NSToIntRound(height / scale)); + } else { + mOpenerScreenRect.SetRect(x, y, width, height); + } + initialX = mOpenerScreenRect.X(); + initialY = mOpenerScreenRect.Y(); + ConstrainToOpenerScreen(&initialX, &initialY); + } + } + + // XXX: need to get the default window size from prefs... + // Doesn't come from prefs... will come from CSS/XUL/RDF + DesktopIntRect deskRect(initialX, initialY, aInitialWidth, aInitialHeight); + + // Create top level window + if (gfxPlatform::IsHeadless()) { + mWindow = nsIWidget::CreateHeadlessWidget(); + } else { + mWindow = nsIWidget::CreateTopLevelWindow(); + } + if (!mWindow) { + return NS_ERROR_FAILURE; + } + + /* This next bit is troublesome. We carry two different versions of a pointer + to our parent window. One is the parent window's widget, which is passed + to our own widget. The other is a weak reference we keep here to our + parent WebShellWindow. The former is useful to the widget, and we can't + trust its treatment of the parent reference because they're platform- + specific. The latter is useful to this class. + A better implementation would be one in which the parent keeps strong + references to its children and closes them before it allows itself + to be closed. This would mimic the behaviour of OSes that support + top-level child windows in OSes that do not. Later. + */ + nsCOMPtr parentAsWin(do_QueryInterface(aParent)); + if (parentAsWin) { + parentAsWin->GetMainWidget(getter_AddRefs(parentWidget)); + mParentWindow = do_GetWeakReference(aParent); + } + + mWindow->SetWidgetListener(&mWidgetListenerDelegate); + rv = mWindow->Create((nsIWidget*)parentWidget, // Parent nsIWidget + nullptr, // Native parent widget + deskRect, // Widget dimensions + &widgetInitData); // Widget initialization data + NS_ENSURE_SUCCESS(rv, rv); + + LayoutDeviceIntRect r = mWindow->GetClientBounds(); + // Match the default background color of content. Important on windows + // since we no longer use content child widgets. + mWindow->SetBackgroundColor(NS_RGB(255, 255, 255)); + + // Create web shell + RefPtr openerContext = + aOpenerWindow + ? nsPIDOMWindowOuter::From(aOpenerWindow)->GetBrowsingContext() + : nullptr; + RefPtr browsingContext = + BrowsingContext::Create(/* aParent */ nullptr, openerContext, + EmptyString(), BrowsingContext::Type::Chrome); + mDocShell = nsDocShell::Create(browsingContext); + NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE); + + // XXX(nika): This is used to handle propagating opener across remote tab + // creation. We should come up with a better system for doing this (probably + // based on BrowsingContext). + mDocShell->SetOpener(aOpeningTab); + + // Make sure to set the item type on the docshell _before_ calling + // Create() so it knows what type it is. + nsCOMPtr docShellAsItem(mDocShell); + NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE); + NS_ENSURE_SUCCESS(EnsureChromeTreeOwner(), NS_ERROR_FAILURE); + + docShellAsItem->SetTreeOwner(mChromeTreeOwner); + + r.MoveTo(0, 0); + nsCOMPtr docShellAsWin(do_QueryInterface(mDocShell)); + NS_ENSURE_SUCCESS(docShellAsWin->InitWindow(nullptr, mWindow, r.X(), r.Y(), + r.Width(), r.Height()), + NS_ERROR_FAILURE); + NS_ENSURE_SUCCESS(docShellAsWin->Create(), NS_ERROR_FAILURE); + + // Attach a WebProgress listener.during initialization... + nsCOMPtr webProgress(do_GetInterface(mDocShell, &rv)); + if (webProgress) { + webProgress->AddProgressListener(this, + nsIWebProgress::NOTIFY_STATE_NETWORK); + } + +#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED + if (aOpenerWindow) { + BrowsingContext* bc = mDocShell->GetBrowsingContext(); + BrowsingContext* openerBC = + nsPIDOMWindowOuter::From(aOpenerWindow)->GetBrowsingContext(); + MOZ_DIAGNOSTIC_ASSERT(bc->GetOpenerId() == openerBC->Id()); + MOZ_DIAGNOSTIC_ASSERT(bc->HadOriginalOpener()); + } +#endif + + // Eagerly create an about:blank content viewer with the right principal here, + // rather than letting it happening in the upcoming call to + // SetInitialPrincipalToSubject. This avoids creating the about:blank document + // and then blowing it away with a second one, which can cause problems for + // the top-level chrome window case. See bug 789773. Note that we don't accept + // expanded principals here, similar to SetInitialPrincipalToSubject. + if (nsContentUtils::IsInitialized()) { // Sometimes this happens really early + // See bug 793370. + MOZ_ASSERT(mDocShell->ItemType() == nsIDocShellTreeItem::typeChrome); + nsCOMPtr principal = + nsContentUtils::SubjectPrincipalOrSystemIfNativeCaller(); + if (nsContentUtils::IsExpandedPrincipal(principal)) { + principal = nullptr; + } + // Use the subject (or system) principal as the storage principal too until + // the new window finishes navigating and gets a real storage principal. + rv = mDocShell->CreateAboutBlankContentViewer(principal, principal, + /* aCsp = */ nullptr); + NS_ENSURE_SUCCESS(rv, rv); + RefPtr doc = mDocShell->GetDocument(); + NS_ENSURE_TRUE(!!doc, NS_ERROR_FAILURE); + doc->SetIsInitialDocument(true); + } + + if (nullptr != aUrl) { + nsCString tmpStr; + + rv = aUrl->GetSpec(tmpStr); + if (NS_FAILED(rv)) return rv; + + NS_ConvertUTF8toUTF16 urlString(tmpStr); + nsCOMPtr webNav(do_QueryInterface(mDocShell)); + NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE); + + LoadURIOptions loadURIOptions; + loadURIOptions.mTriggeringPrincipal = nsContentUtils::GetSystemPrincipal(); + + rv = webNav->LoadURI(urlString, loadURIOptions); + NS_ENSURE_SUCCESS(rv, rv); + } + + return rv; +} + +PresShell* nsWebShellWindow::GetPresShell() { + if (!mDocShell) { + return nullptr; + } + return mDocShell->GetPresShell(); +} + +bool nsWebShellWindow::WindowMoved(nsIWidget* aWidget, int32_t x, int32_t y) { + nsXULPopupManager* pm = nsXULPopupManager::GetInstance(); + if (pm) { + nsCOMPtr window = + mDocShell ? mDocShell->GetWindow() : nullptr; + pm->AdjustPopupsOnWindowChange(window); + } + + // Notify all tabs that the widget moved. + if (mDocShell && mDocShell->GetWindow()) { + nsCOMPtr eventTarget = + mDocShell->GetWindow()->GetTopWindowRoot(); + nsContentUtils::DispatchChromeEvent(mDocShell->GetDocument(), eventTarget, + NS_LITERAL_STRING("MozUpdateWindowPos"), + CanBubble::eNo, Cancelable::eNo, + nullptr); + } + + // Persist position, but not immediately, in case this OS is firing + // repeated move events as the user drags the window + SetPersistenceTimer(PAD_POSITION); + return false; +} + +bool nsWebShellWindow::WindowResized(nsIWidget* aWidget, int32_t aWidth, + int32_t aHeight) { + nsCOMPtr shellAsWin(do_QueryInterface(mDocShell)); + if (shellAsWin) { + shellAsWin->SetPositionAndSize(0, 0, aWidth, aHeight, 0); + } + // Persist size, but not immediately, in case this OS is firing + // repeated size events as the user drags the sizing handle + if (!IsLocked()) SetPersistenceTimer(PAD_POSITION | PAD_SIZE | PAD_MISC); + return true; +} + +bool nsWebShellWindow::RequestWindowClose(nsIWidget* aWidget) { + // Maintain a reference to this as it is about to get destroyed. + nsCOMPtr xulWindow(this); + + nsCOMPtr window(mDocShell ? mDocShell->GetWindow() + : nullptr); + nsCOMPtr eventTarget = do_QueryInterface(window); + + RefPtr presShell = mDocShell->GetPresShell(); + if (!presShell) { + mozilla::DebugOnly dying; + MOZ_ASSERT(NS_SUCCEEDED(mDocShell->IsBeingDestroyed(&dying)) && dying, + "No presShell, but window is not being destroyed"); + } else if (eventTarget) { + RefPtr presContext = presShell->GetPresContext(); + + nsEventStatus status = nsEventStatus_eIgnore; + WidgetMouseEvent event(true, eClose, nullptr, WidgetMouseEvent::eReal); + if (NS_SUCCEEDED(EventDispatcher::Dispatch(eventTarget, presContext, &event, + nullptr, &status)) && + status == nsEventStatus_eConsumeNoDefault) + return false; + } + + Destroy(); + return false; +} + +void nsWebShellWindow::SizeModeChanged(nsSizeMode sizeMode) { + // An alwaysRaised (or higher) window will hide any newly opened normal + // browser windows, so here we just drop a raised window to the normal + // zlevel if it's maximized. We make no provision for automatically + // re-raising it when restored. + if (sizeMode == nsSizeMode_Maximized || sizeMode == nsSizeMode_Fullscreen) { + uint32_t zLevel; + GetZLevel(&zLevel); + if (zLevel > nsIXULWindow::normalZ) SetZLevel(nsIXULWindow::normalZ); + } + mWindow->SetSizeMode(sizeMode); + + // Persist mode, but not immediately, because in many (all?) + // cases this will merge with the similar call in NS_SIZE and + // write the attribute values only once. + SetPersistenceTimer(PAD_MISC); + nsCOMPtr ourWindow = + mDocShell ? mDocShell->GetWindow() : nullptr; + if (ourWindow) { + // Ensure that the fullscreen state is synchronized between + // the widget and the outer window object. + if (sizeMode == nsSizeMode_Fullscreen) { + ourWindow->SetFullScreen(true); + } else if (sizeMode != nsSizeMode_Minimized) { + if (ourWindow->GetFullScreen()) { + // The first SetFullscreenInternal call below ensures that we do + // not trigger any fullscreen transition even if the window was + // put in fullscreen only for the Fullscreen API. The second + // SetFullScreen call ensures that the window really exit from + // fullscreen even if it entered fullscreen for both Fullscreen + // Mode and Fullscreen API. + ourWindow->SetFullscreenInternal( + FullscreenReason::ForForceExitFullscreen, false); + ourWindow->SetFullScreen(false); + } + } + + // And always fire a user-defined sizemodechange event on the window + ourWindow->DispatchCustomEvent(NS_LITERAL_STRING("sizemodechange")); + } + + if (PresShell* presShell = GetPresShell()) { + presShell->GetPresContext()->SizeModeChanged(sizeMode); + } + + // Note the current implementation of SetSizeMode just stores + // the new state; it doesn't actually resize. So here we store + // the state and pass the event on to the OS. The day is coming + // when we'll handle the event here, and the return result will + // then need to be different. +} + +void nsWebShellWindow::UIResolutionChanged() { + nsCOMPtr ourWindow = + mDocShell ? mDocShell->GetWindow() : nullptr; + if (ourWindow) { + ourWindow->DispatchCustomEvent(NS_LITERAL_STRING("resolutionchange")); + } +} + +void nsWebShellWindow::FullscreenWillChange(bool aInFullscreen) { + if (mDocShell) { + if (nsCOMPtr ourWindow = mDocShell->GetWindow()) { + ourWindow->FullscreenWillChange(aInFullscreen); + } + } +} + +void nsWebShellWindow::FullscreenChanged(bool aInFullscreen) { + if (mDocShell) { + if (nsCOMPtr ourWindow = mDocShell->GetWindow()) { + ourWindow->FinishFullscreenChange(aInFullscreen); + } + } +} + +void nsWebShellWindow::OcclusionStateChanged(bool aIsFullyOccluded) { + nsCOMPtr ourWindow = + mDocShell ? mDocShell->GetWindow() : nullptr; + if (ourWindow) { + // And always fire a user-defined occlusionstatechange event on the window + ourWindow->DispatchCustomEvent(NS_LITERAL_STRING("occlusionstatechange")); + } +} + +void nsWebShellWindow::OSToolbarButtonPressed() { + // Keep a reference as setting the chrome flags can fire events. + nsCOMPtr xulWindow(this); + + // rjc: don't use "nsIWebBrowserChrome::CHROME_EXTRA" + // due to components with multiple sidebar components + // (such as Mail/News, Addressbook, etc)... and frankly, + // Mac IE, OmniWeb, and other Mac OS X apps all work this way + uint32_t chromeMask = (nsIWebBrowserChrome::CHROME_TOOLBAR | + nsIWebBrowserChrome::CHROME_LOCATIONBAR | + nsIWebBrowserChrome::CHROME_PERSONAL_TOOLBAR); + + nsCOMPtr wbc(do_GetInterface(xulWindow)); + if (!wbc) return; + + uint32_t chromeFlags, newChromeFlags = 0; + wbc->GetChromeFlags(&chromeFlags); + newChromeFlags = chromeFlags & chromeMask; + if (!newChromeFlags) + chromeFlags |= chromeMask; + else + chromeFlags &= (~newChromeFlags); + wbc->SetChromeFlags(chromeFlags); +} + +bool nsWebShellWindow::ZLevelChanged(bool aImmediate, nsWindowZ* aPlacement, + nsIWidget* aRequestBelow, + nsIWidget** aActualBelow) { + if (aActualBelow) *aActualBelow = nullptr; + + return ConstrainToZLevel(aImmediate, aPlacement, aRequestBelow, aActualBelow); +} + +void nsWebShellWindow::WindowActivated() { + nsCOMPtr xulWindow(this); + + // focusing the window could cause it to close, so keep a reference to it + nsCOMPtr window = + mDocShell ? mDocShell->GetWindow() : nullptr; + nsFocusManager* fm = nsFocusManager::GetFocusManager(); + if (fm && window) fm->WindowRaised(window); + + if (mChromeLoaded) { + PersistentAttributesDirty(PAD_POSITION | PAD_SIZE | PAD_MISC); + SavePersistentAttributes(); + } +} + +void nsWebShellWindow::WindowDeactivated() { + nsCOMPtr xulWindow(this); + + nsCOMPtr window = + mDocShell ? mDocShell->GetWindow() : nullptr; + nsFocusManager* fm = nsFocusManager::GetFocusManager(); + if (fm && window && !fm->IsTestMode()) fm->WindowLowered(window); +} + +#ifdef USE_NATIVE_MENUS +static void LoadNativeMenus(Document* aDoc, nsIWidget* aParentWindow) { + if (gfxPlatform::IsHeadless()) { + return; + } + nsCOMPtr nms = + do_GetService("@mozilla.org/widget/nativemenuservice;1"); + if (!nms) { + return; + } + + // Find the menubar tag (if there is more than one, we ignore all but + // the first). + nsCOMPtr menubarElements = aDoc->GetElementsByTagNameNS( + NS_LITERAL_STRING( + "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"), + NS_LITERAL_STRING("menubar")); + + nsCOMPtr menubarNode; + if (menubarElements) { + menubarNode = menubarElements->Item(0); + } + + if (menubarNode) { + nsCOMPtr menubarContent(do_QueryInterface(menubarNode)); + nms->CreateNativeMenuBar(aParentWindow, menubarContent); + } else { + nms->CreateNativeMenuBar(aParentWindow, nullptr); + } +} +#endif + +namespace mozilla { + +class WebShellWindowTimerCallback final : public nsITimerCallback, + public nsINamed { + public: + explicit WebShellWindowTimerCallback(nsWebShellWindow* aWindow) + : mWindow(aWindow) {} + + NS_DECL_THREADSAFE_ISUPPORTS + + NS_IMETHOD Notify(nsITimer* aTimer) override { + // Although this object participates in a refcount cycle (this -> mWindow + // -> mSPTimer -> this), mSPTimer is a one-shot timer and releases this + // after it fires. So we don't need to release mWindow here. + + mWindow->FirePersistenceTimer(); + return NS_OK; + } + + NS_IMETHOD GetName(nsACString& aName) override { + aName.AssignLiteral("WebShellWindowTimerCallback"); + return NS_OK; + } + + private: + ~WebShellWindowTimerCallback() {} + + RefPtr mWindow; +}; + +NS_IMPL_ISUPPORTS(WebShellWindowTimerCallback, nsITimerCallback, nsINamed) + +} // namespace mozilla + +void nsWebShellWindow::SetPersistenceTimer(uint32_t aDirtyFlags) { + MutexAutoLock lock(mSPTimerLock); + if (!mSPTimer) { + mSPTimer = NS_NewTimer(); + if (!mSPTimer) { + NS_WARNING("Couldn't create @mozilla.org/timer;1 instance?"); + return; + } + } + + RefPtr callback = + new WebShellWindowTimerCallback(this); + mSPTimer->InitWithCallback(callback, SIZE_PERSISTENCE_TIMEOUT, + nsITimer::TYPE_ONE_SHOT); + + PersistentAttributesDirty(aDirtyFlags); +} + +void nsWebShellWindow::FirePersistenceTimer() { + MutexAutoLock lock(mSPTimerLock); + SavePersistentAttributes(); +} + +//---------------------------------------- +// nsIWebProgessListener implementation +//---------------------------------------- +NS_IMETHODIMP +nsWebShellWindow::OnProgressChange(nsIWebProgress* aProgress, + nsIRequest* aRequest, + int32_t aCurSelfProgress, + int32_t aMaxSelfProgress, + int32_t aCurTotalProgress, + int32_t aMaxTotalProgress) { + MOZ_ASSERT_UNREACHABLE("notification excluded in AddProgressListener(...)"); + return NS_OK; +} + +NS_IMETHODIMP +nsWebShellWindow::OnStateChange(nsIWebProgress* aProgress, nsIRequest* aRequest, + uint32_t aStateFlags, nsresult aStatus) { + // If the notification is not about a document finishing, then just + // ignore it... + if (!(aStateFlags & nsIWebProgressListener::STATE_STOP) || + !(aStateFlags & nsIWebProgressListener::STATE_IS_NETWORK)) { + return NS_OK; + } + + if (mChromeLoaded) return NS_OK; + + // If this document notification is for a frame then ignore it... + nsCOMPtr eventWin; + aProgress->GetDOMWindow(getter_AddRefs(eventWin)); + auto* eventPWin = nsPIDOMWindowOuter::From(eventWin); + if (eventPWin) { + nsPIDOMWindowOuter* rootPWin = eventPWin->GetPrivateRoot(); + if (eventPWin != rootPWin) return NS_OK; + } + + mChromeLoaded = true; + mLockedUntilChromeLoad = false; + +#ifdef USE_NATIVE_MENUS + /////////////////////////////// + // Find the Menubar DOM and Load the menus, hooking them up to the loaded + // commands + /////////////////////////////// + nsCOMPtr cv; + mDocShell->GetContentViewer(getter_AddRefs(cv)); + if (cv) { + RefPtr menubarDoc = cv->GetDocument(); + if (menubarDoc) LoadNativeMenus(menubarDoc, mWindow); + } +#endif // USE_NATIVE_MENUS + + OnChromeLoaded(); + + return NS_OK; +} + +NS_IMETHODIMP +nsWebShellWindow::OnLocationChange(nsIWebProgress* aProgress, + nsIRequest* aRequest, nsIURI* aURI, + uint32_t aFlags) { + MOZ_ASSERT_UNREACHABLE("notification excluded in AddProgressListener(...)"); + return NS_OK; +} + +NS_IMETHODIMP +nsWebShellWindow::OnStatusChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, nsresult aStatus, + const char16_t* aMessage) { + MOZ_ASSERT_UNREACHABLE("notification excluded in AddProgressListener(...)"); + return NS_OK; +} + +NS_IMETHODIMP +nsWebShellWindow::OnSecurityChange(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, uint32_t aState) { + MOZ_ASSERT_UNREACHABLE("notification excluded in AddProgressListener(...)"); + return NS_OK; +} + +NS_IMETHODIMP +nsWebShellWindow::OnContentBlockingEvent(nsIWebProgress* aWebProgress, + nsIRequest* aRequest, + uint32_t aEvent) { + MOZ_ASSERT_UNREACHABLE("notification excluded in AddProgressListener(...)"); + return NS_OK; +} + +/** + * ExecuteCloseHandler - Run the close handler, if any. + * @return true iff we found a close handler to run. + */ +bool nsWebShellWindow::ExecuteCloseHandler() { + /* If the event handler closes this window -- a likely scenario -- + things get deleted out of order without this death grip. + (The problem may be the death grip in nsWindow::windowProc, + which forces this window's widget to remain alive longer + than it otherwise would.) */ + nsCOMPtr kungFuDeathGrip(this); + + nsCOMPtr eventTarget; + if (mDocShell) { + eventTarget = do_QueryInterface(mDocShell->GetWindow()); + } + + if (eventTarget) { + nsCOMPtr contentViewer; + mDocShell->GetContentViewer(getter_AddRefs(contentViewer)); + if (contentViewer) { + RefPtr presContext = contentViewer->GetPresContext(); + + nsEventStatus status = nsEventStatus_eIgnore; + WidgetMouseEvent event(true, eClose, nullptr, WidgetMouseEvent::eReal); + + nsresult rv = EventDispatcher::Dispatch(eventTarget, presContext, &event, + nullptr, &status); + if (NS_SUCCEEDED(rv) && status == nsEventStatus_eConsumeNoDefault) + return true; + // else fall through and return false + } + } + + return false; +} // ExecuteCloseHandler + +void nsWebShellWindow::ConstrainToOpenerScreen(int32_t* aX, int32_t* aY) { + if (mOpenerScreenRect.IsEmpty()) { + *aX = *aY = 0; + return; + } + + int32_t left, top, width, height; + // Constrain initial positions to the same screen as opener + nsCOMPtr screenmgr = + do_GetService("@mozilla.org/gfx/screenmanager;1"); + if (screenmgr) { + nsCOMPtr screen; + screenmgr->ScreenForRect( + mOpenerScreenRect.X(), mOpenerScreenRect.Y(), mOpenerScreenRect.Width(), + mOpenerScreenRect.Height(), getter_AddRefs(screen)); + if (screen) { + screen->GetAvailRectDisplayPix(&left, &top, &width, &height); + if (*aX < left || *aX > left + width) { + *aX = left; + } + if (*aY < top || *aY > top + height) { + *aY = top; + } + } + } +} + +// nsIBaseWindow +NS_IMETHODIMP nsWebShellWindow::Destroy() { + nsresult rv; + nsCOMPtr webProgress(do_GetInterface(mDocShell, &rv)); + if (webProgress) { + webProgress->RemoveProgressListener(this); + } + + nsCOMPtr kungFuDeathGrip(this); + { + MutexAutoLock lock(mSPTimerLock); + if (mSPTimer) { + mSPTimer->Cancel(); + SavePersistentAttributes(); + mSPTimer = nullptr; + } + } + return nsXULWindow::Destroy(); +} + +nsIXULWindow* nsWebShellWindow::WidgetListenerDelegate::GetXULWindow() { + return mWebShellWindow->GetXULWindow(); +} + +PresShell* nsWebShellWindow::WidgetListenerDelegate::GetPresShell() { + return mWebShellWindow->GetPresShell(); +} + +bool nsWebShellWindow::WidgetListenerDelegate::WindowMoved(nsIWidget* aWidget, + int32_t aX, + int32_t aY) { + RefPtr holder = mWebShellWindow; + return holder->WindowMoved(aWidget, aX, aY); +} + +bool nsWebShellWindow::WidgetListenerDelegate::WindowResized(nsIWidget* aWidget, + int32_t aWidth, + int32_t aHeight) { + RefPtr holder = mWebShellWindow; + return holder->WindowResized(aWidget, aWidth, aHeight); +} + +bool nsWebShellWindow::WidgetListenerDelegate::RequestWindowClose( + nsIWidget* aWidget) { + RefPtr holder = mWebShellWindow; + return holder->RequestWindowClose(aWidget); +} + +void nsWebShellWindow::WidgetListenerDelegate::SizeModeChanged( + nsSizeMode aSizeMode) { + RefPtr holder = mWebShellWindow; + holder->SizeModeChanged(aSizeMode); +} + +void nsWebShellWindow::WidgetListenerDelegate::UIResolutionChanged() { + RefPtr holder = mWebShellWindow; + holder->UIResolutionChanged(); +} + +void nsWebShellWindow::WidgetListenerDelegate::FullscreenWillChange( + bool aInFullscreen) { + RefPtr holder = mWebShellWindow; + holder->FullscreenWillChange(aInFullscreen); +} + +void nsWebShellWindow::WidgetListenerDelegate::FullscreenChanged( + bool aInFullscreen) { + RefPtr holder = mWebShellWindow; + holder->FullscreenChanged(aInFullscreen); +} + +void nsWebShellWindow::WidgetListenerDelegate::OcclusionStateChanged( + bool aIsFullyOccluded) { + RefPtr holder = mWebShellWindow; + holder->OcclusionStateChanged(aIsFullyOccluded); +} + +void nsWebShellWindow::WidgetListenerDelegate::OSToolbarButtonPressed() { + RefPtr holder = mWebShellWindow; + holder->OSToolbarButtonPressed(); +} + +bool nsWebShellWindow::WidgetListenerDelegate::ZLevelChanged( + bool aImmediate, nsWindowZ* aPlacement, nsIWidget* aRequestBelow, + nsIWidget** aActualBelow) { + RefPtr holder = mWebShellWindow; + return holder->ZLevelChanged(aImmediate, aPlacement, aRequestBelow, + aActualBelow); +} + +void nsWebShellWindow::WidgetListenerDelegate::WindowActivated() { + RefPtr holder = mWebShellWindow; + holder->WindowActivated(); +} + +void nsWebShellWindow::WidgetListenerDelegate::WindowDeactivated() { + RefPtr holder = mWebShellWindow; + holder->WindowDeactivated(); +} diff --git a/xpfe/appshell/nsWebShellWindow.h b/xpfe/appshell/nsWebShellWindow.h new file mode 100644 index 000000000000..ededd65c5b20 --- /dev/null +++ b/xpfe/appshell/nsWebShellWindow.h @@ -0,0 +1,133 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef nsWebShellWindow_h__ +#define nsWebShellWindow_h__ + +#include "mozilla/Mutex.h" +#include "nsIWebProgressListener.h" +#include "nsITimer.h" +#include "nsCOMPtr.h" +#include "nsXULWindow.h" +#include "nsIWidgetListener.h" +#include "nsIRemoteTab.h" + +/* Forward declarations.... */ +class nsIURI; + +struct nsWidgetInitData; + +namespace mozilla { +class PresShell; +class WebShellWindowTimerCallback; +} // namespace mozilla + +class nsWebShellWindow final : public nsXULWindow, + public nsIWebProgressListener { + public: + // The implementation of non-refcounted nsIWidgetListener, which would hold a + // strong reference on stack before calling nsWebShellWindow's + // MOZ_CAN_RUN_SCRIPT methods. + class WidgetListenerDelegate : public nsIWidgetListener { + public: + explicit WidgetListenerDelegate(nsWebShellWindow* aWebShellWindow) + : mWebShellWindow(aWebShellWindow) {} + + MOZ_CAN_RUN_SCRIPT_BOUNDARY + virtual nsIXULWindow* GetXULWindow() override; + MOZ_CAN_RUN_SCRIPT_BOUNDARY + virtual mozilla::PresShell* GetPresShell() override; + MOZ_CAN_RUN_SCRIPT_BOUNDARY + virtual bool WindowMoved(nsIWidget* aWidget, int32_t x, int32_t y) override; + MOZ_CAN_RUN_SCRIPT_BOUNDARY + virtual bool WindowResized(nsIWidget* aWidget, int32_t aWidth, + int32_t aHeight) override; + MOZ_CAN_RUN_SCRIPT_BOUNDARY + virtual bool RequestWindowClose(nsIWidget* aWidget) override; + MOZ_CAN_RUN_SCRIPT_BOUNDARY + virtual void SizeModeChanged(nsSizeMode sizeMode) override; + MOZ_CAN_RUN_SCRIPT_BOUNDARY + virtual void UIResolutionChanged() override; + MOZ_CAN_RUN_SCRIPT_BOUNDARY + virtual void FullscreenWillChange(bool aInFullscreen) override; + MOZ_CAN_RUN_SCRIPT_BOUNDARY + virtual void FullscreenChanged(bool aInFullscreen) override; + MOZ_CAN_RUN_SCRIPT_BOUNDARY + virtual void OcclusionStateChanged(bool aIsFullyOccluded) override; + MOZ_CAN_RUN_SCRIPT_BOUNDARY + virtual void OSToolbarButtonPressed() override; + MOZ_CAN_RUN_SCRIPT_BOUNDARY + virtual bool ZLevelChanged(bool aImmediate, nsWindowZ* aPlacement, + nsIWidget* aRequestBelow, + nsIWidget** aActualBelow) override; + MOZ_CAN_RUN_SCRIPT_BOUNDARY + virtual void WindowActivated() override; + MOZ_CAN_RUN_SCRIPT_BOUNDARY + virtual void WindowDeactivated() override; + + private: + // The lifetime of WidgetListenerDelegate is bound to nsWebShellWindow so + // we just use a raw pointer here. + nsWebShellWindow* mWebShellWindow; + }; + + explicit nsWebShellWindow(uint32_t aChromeFlags); + + // nsISupports interface... + NS_DECL_ISUPPORTS_INHERITED + + // nsWebShellWindow methods... + nsresult Initialize(nsIXULWindow* aParent, nsIXULWindow* aOpener, + nsIURI* aUrl, int32_t aInitialWidth, + int32_t aInitialHeight, bool aIsHiddenWindow, + nsIRemoteTab* aOpeningTab, + mozIDOMWindowProxy* aOpenerWIndow, + nsWidgetInitData& widgetInitData); + + nsresult Toolbar(); + + // nsIWebProgressListener + NS_DECL_NSIWEBPROGRESSLISTENER + + // nsIBaseWindow + NS_IMETHOD Destroy() override; + + // nsIWidgetListener methods for WidgetListenerDelegate. + nsIXULWindow* GetXULWindow() { return this; } + mozilla::PresShell* GetPresShell(); + MOZ_CAN_RUN_SCRIPT + bool WindowMoved(nsIWidget* aWidget, int32_t aX, int32_t aY); + MOZ_CAN_RUN_SCRIPT + bool WindowResized(nsIWidget* aWidget, int32_t aWidth, int32_t aHeight); + MOZ_CAN_RUN_SCRIPT bool RequestWindowClose(nsIWidget* aWidget); + MOZ_CAN_RUN_SCRIPT void SizeModeChanged(nsSizeMode aSizeMode); + MOZ_CAN_RUN_SCRIPT void UIResolutionChanged(); + MOZ_CAN_RUN_SCRIPT void FullscreenWillChange(bool aInFullscreen); + MOZ_CAN_RUN_SCRIPT void FullscreenChanged(bool aInFullscreen); + MOZ_CAN_RUN_SCRIPT void OcclusionStateChanged(bool aIsFullyOccluded); + MOZ_CAN_RUN_SCRIPT void OSToolbarButtonPressed(); + MOZ_CAN_RUN_SCRIPT + bool ZLevelChanged(bool aImmediate, nsWindowZ* aPlacement, + nsIWidget* aRequestBelow, nsIWidget** aActualBelow); + MOZ_CAN_RUN_SCRIPT void WindowActivated(); + MOZ_CAN_RUN_SCRIPT void WindowDeactivated(); + + protected: + friend class mozilla::WebShellWindowTimerCallback; + + virtual ~nsWebShellWindow(); + + bool ExecuteCloseHandler(); + void ConstrainToOpenerScreen(int32_t* aX, int32_t* aY); + + nsCOMPtr mSPTimer; + mozilla::Mutex mSPTimerLock; + WidgetListenerDelegate mWidgetListenerDelegate; + + void SetPersistenceTimer(uint32_t aDirtyFlags); + void FirePersistenceTimer(); +}; + +#endif /* nsWebShellWindow_h__ */ diff --git a/xpfe/appshell/nsWindowMediator.cpp b/xpfe/appshell/nsWindowMediator.cpp index b580bd02c268..d90f8bacf7a2 100644 --- a/xpfe/appshell/nsWindowMediator.cpp +++ b/xpfe/appshell/nsWindowMediator.cpp @@ -21,12 +21,12 @@ #include "nsIDocShell.h" #include "nsIInterfaceRequestor.h" #include "nsIInterfaceRequestorUtils.h" -#include "nsIAppWindow.h" +#include "nsIXULWindow.h" using namespace mozilla; nsresult nsWindowMediator::GetDOMWindow( - nsIAppWindow* inWindow, nsCOMPtr& outDOMWindow) { + nsIXULWindow* inWindow, nsCOMPtr& outDOMWindow) { nsCOMPtr docShell; outDOMWindow = nullptr; @@ -61,7 +61,7 @@ nsresult nsWindowMediator::Init() { return NS_OK; } -NS_IMETHODIMP nsWindowMediator::RegisterWindow(nsIAppWindow* inWindow) { +NS_IMETHODIMP nsWindowMediator::RegisterWindow(nsIXULWindow* inWindow) { MOZ_RELEASE_ASSERT(NS_IsMainThread()); NS_ENSURE_STATE(mReady); @@ -89,7 +89,7 @@ NS_IMETHODIMP nsWindowMediator::RegisterWindow(nsIAppWindow* inWindow) { } NS_IMETHODIMP -nsWindowMediator::UnregisterWindow(nsIAppWindow* inWindow) { +nsWindowMediator::UnregisterWindow(nsIXULWindow* inWindow) { MOZ_RELEASE_ASSERT(NS_IsMainThread()); NS_ENSURE_STATE(mReady); nsWindowInfo* info = GetInfoFor(inWindow); @@ -105,7 +105,7 @@ nsresult nsWindowMediator::UnregisterWindow(nsWindowInfo* inInfo) { index++; } - nsIAppWindow* window = inInfo->mWindow.get(); + nsIXULWindow* window = inInfo->mWindow.get(); ListenerArray::ForwardIterator iter(mListeners); while (iter.HasMore()) { iter.GetNext()->OnCloseWindow(window); @@ -122,7 +122,7 @@ nsresult nsWindowMediator::UnregisterWindow(nsWindowInfo* inInfo) { return NS_OK; } -nsWindowInfo* nsWindowMediator::GetInfoFor(nsIAppWindow* aWindow) { +nsWindowInfo* nsWindowMediator::GetInfoFor(nsIXULWindow* aWindow) { nsWindowInfo *info, *listEnd; if (!aWindow) return nullptr; @@ -170,20 +170,20 @@ nsWindowMediator::GetEnumerator(const char16_t* inType, } NS_IMETHODIMP -nsWindowMediator::GetAppWindowEnumerator(const char16_t* inType, +nsWindowMediator::GetXULWindowEnumerator(const char16_t* inType, nsISimpleEnumerator** outEnumerator) { MOZ_RELEASE_ASSERT(NS_IsMainThread()); NS_ENSURE_ARG_POINTER(outEnumerator); NS_ENSURE_STATE(mReady); RefPtr enumerator = - new nsASAppWindowEarlyToLateEnumerator(inType, *this); + new nsASXULWindowEarlyToLateEnumerator(inType, *this); enumerator.forget(outEnumerator); return NS_OK; } NS_IMETHODIMP -nsWindowMediator::GetZOrderAppWindowEnumerator(const char16_t* aWindowType, +nsWindowMediator::GetZOrderXULWindowEnumerator(const char16_t* aWindowType, bool aFrontToBack, nsISimpleEnumerator** _retval) { MOZ_RELEASE_ASSERT(NS_IsMainThread()); @@ -192,9 +192,9 @@ nsWindowMediator::GetZOrderAppWindowEnumerator(const char16_t* aWindowType, RefPtr enumerator; if (aFrontToBack) - enumerator = new nsASAppWindowFrontToBackEnumerator(aWindowType, *this); + enumerator = new nsASXULWindowFrontToBackEnumerator(aWindowType, *this); else - enumerator = new nsASAppWindowBackToFrontEnumerator(aWindowType, *this); + enumerator = new nsASXULWindowBackToFrontEnumerator(aWindowType, *this); enumerator.forget(_retval); return NS_OK; @@ -344,7 +344,7 @@ nsWindowMediator::GetCurrentInnerWindowWithId(uint64_t aWindowID, } NS_IMETHODIMP -nsWindowMediator::UpdateWindowTimeStamp(nsIAppWindow* inWindow) { +nsWindowMediator::UpdateWindowTimeStamp(nsIXULWindow* inWindow) { MOZ_RELEASE_ASSERT(NS_IsMainThread()); NS_ENSURE_STATE(mReady); nsWindowInfo* info = GetInfoFor(inWindow); @@ -363,7 +363,7 @@ nsWindowMediator::UpdateWindowTimeStamp(nsIAppWindow* inWindow) { calculate a change as seldom as possible. */ NS_IMETHODIMP -nsWindowMediator::CalculateZPosition(nsIAppWindow* inWindow, +nsWindowMediator::CalculateZPosition(nsIXULWindow* inWindow, uint32_t inPosition, nsIWidget* inBelow, uint32_t* outPosition, nsIWidget** outBelow, bool* outAltered) { @@ -381,7 +381,7 @@ nsWindowMediator::CalculateZPosition(nsIAppWindow* inWindow, return NS_ERROR_INVALID_ARG; nsWindowInfo* info = mTopmostWindow; - nsIAppWindow* belowWindow = nullptr; + nsIXULWindow* belowWindow = nullptr; bool found = false; nsresult result = NS_OK; @@ -486,8 +486,8 @@ nsWindowMediator::CalculateZPosition(nsIAppWindow* inWindow, } NS_IMETHODIMP -nsWindowMediator::SetZPosition(nsIAppWindow* inWindow, uint32_t inPosition, - nsIAppWindow* inBelow) { +nsWindowMediator::SetZPosition(nsIXULWindow* inWindow, uint32_t inPosition, + nsIXULWindow* inBelow) { MOZ_RELEASE_ASSERT(NS_IsMainThread()); nsWindowInfo *inInfo, *belowInfo; @@ -539,9 +539,9 @@ nsWindowMediator::SetZPosition(nsIAppWindow* inWindow, uint32_t inPosition, } NS_IMETHODIMP -nsWindowMediator::GetZLevel(nsIAppWindow* aWindow, uint32_t* _retval) { +nsWindowMediator::GetZLevel(nsIXULWindow* aWindow, uint32_t* _retval) { NS_ENSURE_ARG_POINTER(_retval); - *_retval = nsIAppWindow::normalZ; + *_retval = nsIXULWindow::normalZ; // This can fail during window destruction. nsWindowInfo* info = GetInfoFor(aWindow); if (info) { @@ -551,7 +551,7 @@ nsWindowMediator::GetZLevel(nsIAppWindow* aWindow, uint32_t* _retval) { } NS_IMETHODIMP -nsWindowMediator::SetZLevel(nsIAppWindow* aWindow, uint32_t aZLevel) { +nsWindowMediator::SetZLevel(nsIXULWindow* aWindow, uint32_t aZLevel) { MOZ_RELEASE_ASSERT(NS_IsMainThread()); NS_ENSURE_STATE(mReady); diff --git a/xpfe/appshell/nsWindowMediator.h b/xpfe/appshell/nsWindowMediator.h index 32ea5f9be638..e7d29a4f92ab 100644 --- a/xpfe/appshell/nsWindowMediator.h +++ b/xpfe/appshell/nsWindowMediator.h @@ -15,10 +15,10 @@ #include "nsTObserverArray.h" class nsAppShellWindowEnumerator; -class nsASAppWindowEarlyToLateEnumerator; +class nsASXULWindowEarlyToLateEnumerator; class nsASDOMWindowEarlyToLateEnumerator; -class nsASAppWindowFrontToBackEnumerator; -class nsASAppWindowBackToFrontEnumerator; +class nsASXULWindowFrontToBackEnumerator; +class nsASXULWindowBackToFrontEnumerator; class nsIWindowMediatorListener; struct nsWindowInfo; @@ -26,10 +26,10 @@ class nsWindowMediator : public nsIWindowMediator, public nsIObserver, public nsSupportsWeakReference { friend class nsAppShellWindowEnumerator; - friend class nsASAppWindowEarlyToLateEnumerator; + friend class nsASXULWindowEarlyToLateEnumerator; friend class nsASDOMWindowEarlyToLateEnumerator; - friend class nsASAppWindowFrontToBackEnumerator; - friend class nsASAppWindowBackToFrontEnumerator; + friend class nsASXULWindowFrontToBackEnumerator; + friend class nsASXULWindowBackToFrontEnumerator; protected: virtual ~nsWindowMediator(); @@ -43,7 +43,7 @@ class nsWindowMediator : public nsIWindowMediator, NS_DECL_NSIWINDOWMEDIATOR NS_DECL_NSIOBSERVER - static nsresult GetDOMWindow(nsIAppWindow* inWindow, + static nsresult GetDOMWindow(nsIXULWindow* inWindow, nsCOMPtr& outDOMWindow); private: @@ -53,7 +53,7 @@ class nsWindowMediator : public nsIWindowMediator, bool aSkipPrivateBrowsingOrClosed = false); nsresult UnregisterWindow(nsWindowInfo* inInfo); - nsWindowInfo* GetInfoFor(nsIAppWindow* aWindow); + nsWindowInfo* GetInfoFor(nsIXULWindow* aWindow); nsWindowInfo* GetInfoFor(nsIWidget* aWindow); void SortZOrderFrontToBack(); void SortZOrderBackToFront(); diff --git a/xpfe/appshell/AppWindow.cpp b/xpfe/appshell/nsXULWindow.cpp similarity index 66% rename from xpfe/appshell/AppWindow.cpp rename to xpfe/appshell/nsXULWindow.cpp index ef73f78410bc..dde80f40e26a 100644 --- a/xpfe/appshell/AppWindow.cpp +++ b/xpfe/appshell/nsXULWindow.cpp @@ -7,7 +7,7 @@ #include "mozilla/MathAlgorithms.h" // Local includes -#include "AppWindow.h" +#include "nsXULWindow.h" #include // Helper classes @@ -46,11 +46,9 @@ #include "nsStyleConsts.h" #include "nsPresContext.h" #include "nsContentUtils.h" +#include "nsWebShellWindow.h" // get rid of this one, too... #include "nsGlobalWindow.h" #include "nsXULTooltipListener.h" -#include "nsXULPopupManager.h" -#include "nsFocusManager.h" -#include "nsContentList.h" #include "prenv.h" #include "mozilla/AutoRestore.h" @@ -62,17 +60,13 @@ #include "mozilla/dom/ScriptSettings.h" #include "mozilla/dom/BrowserHost.h" #include "mozilla/dom/BrowserParent.h" -#include "mozilla/dom/LoadURIOptionsBinding.h" -#include "mozilla/EventDispatcher.h" #ifdef MOZ_NEW_XULSTORE # include "mozilla/XULStore.h" #endif -#ifdef XP_MACOSX -# include "nsINativeMenuService.h" -# define USE_NATIVE_MENUS -#endif +using namespace mozilla; +using dom::AutoNoJSAPI; #define SIZEMODE_NORMAL NS_LITERAL_STRING("normal") #define SIZEMODE_MAXIMIZED NS_LITERAL_STRING("maximized") @@ -90,22 +84,11 @@ #define TILED_ATTRIBUTE NS_LITERAL_STRING("gtktiledwindow") #define ZLEVEL_ATTRIBUTE NS_LITERAL_STRING("zlevel") -#define SIZE_PERSISTENCE_TIMEOUT 500 // msec - //***************************************************************************** -//*** AppWindow: Object Management +//*** nsXULWindow: Object Management //***************************************************************************** -namespace mozilla { - -using dom::AutoNoJSAPI; -using dom::BrowserHost; -using dom::BrowsingContext; -using dom::Document; -using dom::EventTarget; -using dom::LoadURIOptions; - -AppWindow::AppWindow(uint32_t aChromeFlags) +nsXULWindow::nsXULWindow(uint32_t aChromeFlags) : mChromeTreeOwner(nullptr), mContentTreeOwner(nullptr), mPrimaryContentTreeOwner(nullptr), @@ -128,208 +111,31 @@ AppWindow::AppWindow(uint32_t aChromeFlags) mPersistentAttributesDirty(0), mPersistentAttributesMask(0), mChromeFlags(aChromeFlags), - mNextRemoteTabId(0), - mSPTimerLock("AppWindow.mSPTimerLock"), - mWidgetListenerDelegate(this) {} + mNextRemoteTabId(0) {} -AppWindow::~AppWindow() { - { - MutexAutoLock lock(mSPTimerLock); - if (mSPTimer) mSPTimer->Cancel(); - } - Destroy(); -} +nsXULWindow::~nsXULWindow() { Destroy(); } //***************************************************************************** -// AppWindow::nsISupports +// nsXULWindow::nsISupports //***************************************************************************** -NS_IMPL_ADDREF(AppWindow) -NS_IMPL_RELEASE(AppWindow) +NS_IMPL_ADDREF(nsXULWindow) +NS_IMPL_RELEASE(nsXULWindow) -NS_INTERFACE_MAP_BEGIN(AppWindow) - NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIAppWindow) - NS_INTERFACE_MAP_ENTRY(nsIAppWindow) +NS_INTERFACE_MAP_BEGIN(nsXULWindow) + NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIXULWindow) + NS_INTERFACE_MAP_ENTRY(nsIXULWindow) NS_INTERFACE_MAP_ENTRY(nsIBaseWindow) NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor) NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference) - NS_INTERFACE_MAP_ENTRY(nsIWebProgressListener) - NS_INTERFACE_MAP_ENTRY_CONCRETE(AppWindow) + NS_INTERFACE_MAP_ENTRY_CONCRETE(nsXULWindow) NS_INTERFACE_MAP_END -nsresult AppWindow::Initialize(nsIAppWindow* aParent, nsIAppWindow* aOpener, - nsIURI* aUrl, int32_t aInitialWidth, - int32_t aInitialHeight, bool aIsHiddenWindow, - nsIRemoteTab* aOpeningTab, - mozIDOMWindowProxy* aOpenerWindow, - nsWidgetInitData& widgetInitData) { - nsresult rv; - nsCOMPtr parentWidget; - - mIsHiddenWindow = aIsHiddenWindow; - - int32_t initialX = 0, initialY = 0; - nsCOMPtr base(do_QueryInterface(aOpener)); - if (base) { - int32_t x, y, width, height; - rv = base->GetPositionAndSize(&x, &y, &width, &height); - if (NS_FAILED(rv)) { - mOpenerScreenRect.SetEmpty(); - } else { - double scale; - if (NS_SUCCEEDED(base->GetUnscaledDevicePixelsPerCSSPixel(&scale))) { - mOpenerScreenRect.SetRect( - NSToIntRound(x / scale), NSToIntRound(y / scale), - NSToIntRound(width / scale), NSToIntRound(height / scale)); - } else { - mOpenerScreenRect.SetRect(x, y, width, height); - } - initialX = mOpenerScreenRect.X(); - initialY = mOpenerScreenRect.Y(); - ConstrainToOpenerScreen(&initialX, &initialY); - } - } - - // XXX: need to get the default window size from prefs... - // Doesn't come from prefs... will come from CSS/XUL/RDF - DesktopIntRect deskRect(initialX, initialY, aInitialWidth, aInitialHeight); - - // Create top level window - if (gfxPlatform::IsHeadless()) { - mWindow = nsIWidget::CreateHeadlessWidget(); - } else { - mWindow = nsIWidget::CreateTopLevelWindow(); - } - if (!mWindow) { - return NS_ERROR_FAILURE; - } - - /* This next bit is troublesome. We carry two different versions of a pointer - to our parent window. One is the parent window's widget, which is passed - to our own widget. The other is a weak reference we keep here to our - parent AppWindow. The former is useful to the widget, and we can't - trust its treatment of the parent reference because they're platform- - specific. The latter is useful to this class. - A better implementation would be one in which the parent keeps strong - references to its children and closes them before it allows itself - to be closed. This would mimic the behaviour of OSes that support - top-level child windows in OSes that do not. Later. - */ - nsCOMPtr parentAsWin(do_QueryInterface(aParent)); - if (parentAsWin) { - parentAsWin->GetMainWidget(getter_AddRefs(parentWidget)); - mParentWindow = do_GetWeakReference(aParent); - } - - mWindow->SetWidgetListener(&mWidgetListenerDelegate); - rv = mWindow->Create((nsIWidget*)parentWidget, // Parent nsIWidget - nullptr, // Native parent widget - deskRect, // Widget dimensions - &widgetInitData); // Widget initialization data - NS_ENSURE_SUCCESS(rv, rv); - - LayoutDeviceIntRect r = mWindow->GetClientBounds(); - // Match the default background color of content. Important on windows - // since we no longer use content child widgets. - mWindow->SetBackgroundColor(NS_RGB(255, 255, 255)); - - // Create web shell - RefPtr openerContext = - aOpenerWindow - ? nsPIDOMWindowOuter::From(aOpenerWindow)->GetBrowsingContext() - : nullptr; - RefPtr browsingContext = - BrowsingContext::Create(/* aParent */ nullptr, openerContext, - EmptyString(), BrowsingContext::Type::Chrome); - mDocShell = nsDocShell::Create(browsingContext); - NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE); - - // XXX(nika): This is used to handle propagating opener across remote tab - // creation. We should come up with a better system for doing this (probably - // based on BrowsingContext). - mDocShell->SetOpener(aOpeningTab); - - // Make sure to set the item type on the docshell _before_ calling - // Create() so it knows what type it is. - nsCOMPtr docShellAsItem(mDocShell); - NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE); - NS_ENSURE_SUCCESS(EnsureChromeTreeOwner(), NS_ERROR_FAILURE); - - docShellAsItem->SetTreeOwner(mChromeTreeOwner); - - r.MoveTo(0, 0); - nsCOMPtr docShellAsWin(do_QueryInterface(mDocShell)); - NS_ENSURE_SUCCESS(docShellAsWin->InitWindow(nullptr, mWindow, r.X(), r.Y(), - r.Width(), r.Height()), - NS_ERROR_FAILURE); - NS_ENSURE_SUCCESS(docShellAsWin->Create(), NS_ERROR_FAILURE); - - // Attach a WebProgress listener.during initialization... - nsCOMPtr webProgress(do_GetInterface(mDocShell, &rv)); - if (webProgress) { - webProgress->AddProgressListener(this, - nsIWebProgress::NOTIFY_STATE_NETWORK); - } - -#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED - if (aOpenerWindow) { - BrowsingContext* bc = mDocShell->GetBrowsingContext(); - BrowsingContext* openerBC = - nsPIDOMWindowOuter::From(aOpenerWindow)->GetBrowsingContext(); - MOZ_DIAGNOSTIC_ASSERT(bc->GetOpenerId() == openerBC->Id()); - MOZ_DIAGNOSTIC_ASSERT(bc->HadOriginalOpener()); - } -#endif - - // Eagerly create an about:blank content viewer with the right principal here, - // rather than letting it happening in the upcoming call to - // SetInitialPrincipalToSubject. This avoids creating the about:blank document - // and then blowing it away with a second one, which can cause problems for - // the top-level chrome window case. See bug 789773. Note that we don't accept - // expanded principals here, similar to SetInitialPrincipalToSubject. - if (nsContentUtils::IsInitialized()) { // Sometimes this happens really early - // See bug 793370. - MOZ_ASSERT(mDocShell->ItemType() == nsIDocShellTreeItem::typeChrome); - nsCOMPtr principal = - nsContentUtils::SubjectPrincipalOrSystemIfNativeCaller(); - if (nsContentUtils::IsExpandedPrincipal(principal)) { - principal = nullptr; - } - // Use the subject (or system) principal as the storage principal too until - // the new window finishes navigating and gets a real storage principal. - rv = mDocShell->CreateAboutBlankContentViewer(principal, principal, - /* aCsp = */ nullptr); - NS_ENSURE_SUCCESS(rv, rv); - RefPtr doc = mDocShell->GetDocument(); - NS_ENSURE_TRUE(!!doc, NS_ERROR_FAILURE); - doc->SetIsInitialDocument(true); - } - - if (nullptr != aUrl) { - nsCString tmpStr; - - rv = aUrl->GetSpec(tmpStr); - if (NS_FAILED(rv)) return rv; - - NS_ConvertUTF8toUTF16 urlString(tmpStr); - nsCOMPtr webNav(do_QueryInterface(mDocShell)); - NS_ENSURE_TRUE(webNav, NS_ERROR_FAILURE); - - LoadURIOptions loadURIOptions; - loadURIOptions.mTriggeringPrincipal = nsContentUtils::GetSystemPrincipal(); - - rv = webNav->LoadURI(urlString, loadURIOptions); - NS_ENSURE_SUCCESS(rv, rv); - } - - return rv; -} - //***************************************************************************** -// AppWindow::nsIIntefaceRequestor +// nsXULWindow::nsIIntefaceRequestor //***************************************************************************** -NS_IMETHODIMP AppWindow::GetInterface(const nsIID& aIID, void** aSink) { +NS_IMETHODIMP nsXULWindow::GetInterface(const nsIID& aIID, void** aSink) { nsresult rv; NS_ENSURE_ARG_POINTER(aSink); @@ -368,10 +174,10 @@ NS_IMETHODIMP AppWindow::GetInterface(const nsIID& aIID, void** aSink) { } //***************************************************************************** -// AppWindow::nsIAppWindow +// nsXULWindow::nsIXULWindow //***************************************************************************** -NS_IMETHODIMP AppWindow::GetDocShell(nsIDocShell** aDocShell) { +NS_IMETHODIMP nsXULWindow::GetDocShell(nsIDocShell** aDocShell) { NS_ENSURE_ARG_POINTER(aDocShell); *aDocShell = mDocShell; @@ -379,7 +185,7 @@ NS_IMETHODIMP AppWindow::GetDocShell(nsIDocShell** aDocShell) { return NS_OK; } -NS_IMETHODIMP AppWindow::GetZLevel(uint32_t* outLevel) { +NS_IMETHODIMP nsXULWindow::GetZLevel(uint32_t* outLevel) { nsCOMPtr mediator( do_GetService(NS_WINDOWMEDIATOR_CONTRACTID)); if (mediator) @@ -389,7 +195,7 @@ NS_IMETHODIMP AppWindow::GetZLevel(uint32_t* outLevel) { return NS_OK; } -NS_IMETHODIMP AppWindow::SetZLevel(uint32_t aLevel) { +NS_IMETHODIMP nsXULWindow::SetZLevel(uint32_t aLevel) { nsCOMPtr mediator( do_GetService(NS_WINDOWMEDIATOR_CONTRACTID)); if (!mediator) return NS_ERROR_FAILURE; @@ -400,7 +206,7 @@ NS_IMETHODIMP AppWindow::SetZLevel(uint32_t aLevel) { /* refuse to raise a maximized window above the normal browser level, for fear it could hide newly opened browser windows */ - if (aLevel > nsIAppWindow::normalZ && mWindow) { + if (aLevel > nsIXULWindow::normalZ && mWindow) { nsSizeMode sizeMode = mWindow->SizeMode(); if (sizeMode == nsSizeMode_Maximized || sizeMode == nsSizeMode_Fullscreen) { return NS_ERROR_FAILURE; @@ -432,7 +238,7 @@ NS_IMETHODIMP AppWindow::SetZLevel(uint32_t aLevel) { return NS_OK; } -NS_IMETHODIMP AppWindow::GetChromeFlags(uint32_t* aChromeFlags) { +NS_IMETHODIMP nsXULWindow::GetChromeFlags(uint32_t* aChromeFlags) { NS_ENSURE_ARG_POINTER(aChromeFlags); *aChromeFlags = mChromeFlags; /* mChromeFlags is kept up to date, except for scrollbar visibility. @@ -451,7 +257,7 @@ NS_IMETHODIMP AppWindow::GetChromeFlags(uint32_t* aChromeFlags) { return NS_OK; } -NS_IMETHODIMP AppWindow::SetChromeFlags(uint32_t aChromeFlags) { +NS_IMETHODIMP nsXULWindow::SetChromeFlags(uint32_t aChromeFlags) { NS_ASSERTION(!mChromeFlagsFrozen, "SetChromeFlags() after AssumeChromeFlagsAreFrozen()!"); @@ -462,24 +268,24 @@ NS_IMETHODIMP AppWindow::SetChromeFlags(uint32_t aChromeFlags) { return NS_OK; } -NS_IMETHODIMP AppWindow::AssumeChromeFlagsAreFrozen() { +NS_IMETHODIMP nsXULWindow::AssumeChromeFlagsAreFrozen() { mChromeFlagsFrozen = true; return NS_OK; } -NS_IMETHODIMP AppWindow::SetIntrinsicallySized(bool aIntrinsicallySized) { +NS_IMETHODIMP nsXULWindow::SetIntrinsicallySized(bool aIntrinsicallySized) { mIntrinsicallySized = aIntrinsicallySized; return NS_OK; } -NS_IMETHODIMP AppWindow::GetIntrinsicallySized(bool* aIntrinsicallySized) { +NS_IMETHODIMP nsXULWindow::GetIntrinsicallySized(bool* aIntrinsicallySized) { NS_ENSURE_ARG_POINTER(aIntrinsicallySized); *aIntrinsicallySized = mIntrinsicallySized; return NS_OK; } -NS_IMETHODIMP AppWindow::GetPrimaryContentShell( +NS_IMETHODIMP nsXULWindow::GetPrimaryContentShell( nsIDocShellTreeItem** aDocShellTreeItem) { NS_ENSURE_ARG_POINTER(aDocShellTreeItem); NS_IF_ADDREF(*aDocShellTreeItem = mPrimaryContentShell); @@ -487,7 +293,7 @@ NS_IMETHODIMP AppWindow::GetPrimaryContentShell( } NS_IMETHODIMP -AppWindow::RemoteTabAdded(nsIRemoteTab* aTab, bool aPrimary) { +nsXULWindow::RemoteTabAdded(nsIRemoteTab* aTab, bool aPrimary) { if (aPrimary) { mPrimaryBrowserParent = aTab; mPrimaryContentShell = nullptr; @@ -499,7 +305,7 @@ AppWindow::RemoteTabAdded(nsIRemoteTab* aTab, bool aPrimary) { } NS_IMETHODIMP -AppWindow::RemoteTabRemoved(nsIRemoteTab* aTab) { +nsXULWindow::RemoteTabRemoved(nsIRemoteTab* aTab) { if (aTab == mPrimaryBrowserParent) { mPrimaryBrowserParent = nullptr; } @@ -508,7 +314,7 @@ AppWindow::RemoteTabRemoved(nsIRemoteTab* aTab) { } NS_IMETHODIMP -AppWindow::GetPrimaryRemoteTab(nsIRemoteTab** aTab) { +nsXULWindow::GetPrimaryRemoteTab(nsIRemoteTab** aTab) { nsCOMPtr tab = mPrimaryBrowserParent; tab.forget(aTab); return NS_OK; @@ -532,19 +338,19 @@ static CSSIntSize GetOuterToInnerSizeDifferenceInCSSPixels(nsIWidget* aWindow) { } NS_IMETHODIMP -AppWindow::GetOuterToInnerHeightDifferenceInCSSPixels(uint32_t* aResult) { +nsXULWindow::GetOuterToInnerHeightDifferenceInCSSPixels(uint32_t* aResult) { *aResult = GetOuterToInnerSizeDifferenceInCSSPixels(mWindow).height; return NS_OK; } NS_IMETHODIMP -AppWindow::GetOuterToInnerWidthDifferenceInCSSPixels(uint32_t* aResult) { +nsXULWindow::GetOuterToInnerWidthDifferenceInCSSPixels(uint32_t* aResult) { *aResult = GetOuterToInnerSizeDifferenceInCSSPixels(mWindow).width; return NS_OK; } nsTArray> -AppWindow::GetLiveResizeListeners() { +nsXULWindow::GetLiveResizeListeners() { nsTArray> listeners; if (mPrimaryBrowserParent) { BrowserHost* host = BrowserHost::GetFrom(mPrimaryBrowserParent.get()); @@ -553,22 +359,22 @@ AppWindow::GetLiveResizeListeners() { return listeners; } -NS_IMETHODIMP AppWindow::AddChildWindow(nsIAppWindow* aChild) { +NS_IMETHODIMP nsXULWindow::AddChildWindow(nsIXULWindow* aChild) { // we're not really keeping track of this right now return NS_OK; } -NS_IMETHODIMP AppWindow::RemoveChildWindow(nsIAppWindow* aChild) { +NS_IMETHODIMP nsXULWindow::RemoveChildWindow(nsIXULWindow* aChild) { // we're not really keeping track of this right now return NS_OK; } -NS_IMETHODIMP AppWindow::ShowModal() { - AUTO_PROFILER_LABEL("AppWindow::ShowModal", OTHER); +NS_IMETHODIMP nsXULWindow::ShowModal() { + AUTO_PROFILER_LABEL("nsXULWindow::ShowModal", OTHER); // Store locally so it doesn't die on us nsCOMPtr window = mWindow; - nsCOMPtr tempRef = this; + nsCOMPtr tempRef = this; window->SetModal(true); mContinueModalLoop = true; @@ -597,40 +403,24 @@ NS_IMETHODIMP AppWindow::ShowModal() { } //***************************************************************************** -// AppWindow::nsIBaseWindow +// nsXULWindow::nsIBaseWindow //***************************************************************************** -NS_IMETHODIMP AppWindow::InitWindow(nativeWindow aParentNativeWindow, - nsIWidget* parentWidget, int32_t x, - int32_t y, int32_t cx, int32_t cy) { +NS_IMETHODIMP nsXULWindow::InitWindow(nativeWindow aParentNativeWindow, + nsIWidget* parentWidget, int32_t x, + int32_t y, int32_t cx, int32_t cy) { // XXX First Check In NS_ASSERTION(false, "Not Yet Implemented"); return NS_OK; } -NS_IMETHODIMP AppWindow::Create() { +NS_IMETHODIMP nsXULWindow::Create() { // XXX First Check In NS_ASSERTION(false, "Not Yet Implemented"); return NS_OK; } -NS_IMETHODIMP AppWindow::Destroy() { - nsresult rv; - nsCOMPtr webProgress(do_GetInterface(mDocShell, &rv)); - if (webProgress) { - webProgress->RemoveProgressListener(this); - } - - nsCOMPtr kungFuDeathGrip(this); - { - MutexAutoLock lock(mSPTimerLock); - if (mSPTimer) { - mSPTimer->Cancel(); - SavePersistentAttributes(); - mSPTimer = nullptr; - } - } - +NS_IMETHODIMP nsXULWindow::Destroy() { if (!mWindow) return NS_OK; // Ensure we don't reenter this code @@ -643,20 +433,20 @@ NS_IMETHODIMP AppWindow::Destroy() { do_GetService(NS_APPSHELLSERVICE_CONTRACTID)); NS_ASSERTION(appShell, "Couldn't get appShell... xpcom shutdown?"); if (appShell) - appShell->UnregisterTopLevelWindow(static_cast(this)); + appShell->UnregisterTopLevelWindow(static_cast(this)); - nsCOMPtr parentWindow(do_QueryReferent(mParentWindow)); + nsCOMPtr parentWindow(do_QueryReferent(mParentWindow)); if (parentWindow) parentWindow->RemoveChildWindow(this); // let's make sure the window doesn't get deleted out from under us // while we are trying to close....this can happen if the docshell - // we close ends up being the last owning reference to this AppWindow + // we close ends up being the last owning reference to this xulwindow // XXXTAB This shouldn't be an issue anymore because the ownership model // only goes in one direction. When webshell container is fully removed // try removing this... - nsCOMPtr placeHolder = this; + nsCOMPtr placeHolder = this; // Remove modality (if any) and hide while destroying. More than // a convenience, the hide prevents user interaction with the partially @@ -686,7 +476,7 @@ NS_IMETHODIMP AppWindow::Destroy() { appShell->GetHasHiddenWindow(&hasHiddenWindow); if (hasHiddenWindow) { nsCOMPtr baseHiddenWindow; - nsCOMPtr hiddenWindow; + nsCOMPtr hiddenWindow; appShell->GetHiddenWindow(getter_AddRefs(hiddenWindow)); if (hiddenWindow) { baseHiddenWindow = do_GetInterface(hiddenWindow); @@ -716,15 +506,15 @@ NS_IMETHODIMP AppWindow::Destroy() { mPrimaryContentShell = nullptr; if (mContentTreeOwner) { - mContentTreeOwner->AppWindow(nullptr); + mContentTreeOwner->XULWindow(nullptr); NS_RELEASE(mContentTreeOwner); } if (mPrimaryContentTreeOwner) { - mPrimaryContentTreeOwner->AppWindow(nullptr); + mPrimaryContentTreeOwner->XULWindow(nullptr); NS_RELEASE(mPrimaryContentTreeOwner); } if (mChromeTreeOwner) { - mChromeTreeOwner->AppWindow(nullptr); + mChromeTreeOwner->XULWindow(nullptr); NS_RELEASE(mChromeTreeOwner); } if (mWindow) { @@ -749,17 +539,17 @@ NS_IMETHODIMP AppWindow::Destroy() { return NS_OK; } -NS_IMETHODIMP AppWindow::GetDevicePixelsPerDesktopPixel(double* aScale) { +NS_IMETHODIMP nsXULWindow::GetDevicePixelsPerDesktopPixel(double* aScale) { *aScale = mWindow ? mWindow->GetDesktopToDeviceScale().scale : 1.0; return NS_OK; } -NS_IMETHODIMP AppWindow::GetUnscaledDevicePixelsPerCSSPixel(double* aScale) { +NS_IMETHODIMP nsXULWindow::GetUnscaledDevicePixelsPerCSSPixel(double* aScale) { *aScale = mWindow ? mWindow->GetDefaultScale().scale : 1.0; return NS_OK; } -NS_IMETHODIMP AppWindow::SetPositionDesktopPix(int32_t aX, int32_t aY) { +NS_IMETHODIMP nsXULWindow::SetPositionDesktopPix(int32_t aX, int32_t aY) { mWindow->Move(aX, aY); if (mSizingShellFromXUL) { // If we're invoked for sizing from XUL, we want to neither ignore anything @@ -779,7 +569,7 @@ NS_IMETHODIMP AppWindow::SetPositionDesktopPix(int32_t aX, int32_t aY) { // The parameters here are device pixels; do the best we can to convert to // desktop px, using the window's current scale factor (if available). -NS_IMETHODIMP AppWindow::SetPosition(int32_t aX, int32_t aY) { +NS_IMETHODIMP nsXULWindow::SetPosition(int32_t aX, int32_t aY) { // Don't reset the window's size mode here - platforms that don't want to move // maximized windows should reset it in their respective Move implementation. DesktopToLayoutDeviceScale currScale = mWindow->GetDesktopToDeviceScale(); @@ -787,11 +577,11 @@ NS_IMETHODIMP AppWindow::SetPosition(int32_t aX, int32_t aY) { return SetPositionDesktopPix(pos.x, pos.y); } -NS_IMETHODIMP AppWindow::GetPosition(int32_t* aX, int32_t* aY) { +NS_IMETHODIMP nsXULWindow::GetPosition(int32_t* aX, int32_t* aY) { return GetPositionAndSize(aX, aY, nullptr, nullptr); } -NS_IMETHODIMP AppWindow::SetSize(int32_t aCX, int32_t aCY, bool aRepaint) { +NS_IMETHODIMP nsXULWindow::SetSize(int32_t aCX, int32_t aCY, bool aRepaint) { /* any attempt to set the window's size or position overrides the window's zoom state. this is important when these two states are competing while the window is being opened. but it should probably just always be so. */ @@ -821,12 +611,13 @@ NS_IMETHODIMP AppWindow::SetSize(int32_t aCX, int32_t aCY, bool aRepaint) { return NS_OK; } -NS_IMETHODIMP AppWindow::GetSize(int32_t* aCX, int32_t* aCY) { +NS_IMETHODIMP nsXULWindow::GetSize(int32_t* aCX, int32_t* aCY) { return GetPositionAndSize(nullptr, nullptr, aCX, aCY); } -NS_IMETHODIMP AppWindow::SetPositionAndSize(int32_t aX, int32_t aY, int32_t aCX, - int32_t aCY, uint32_t aFlags) { +NS_IMETHODIMP nsXULWindow::SetPositionAndSize(int32_t aX, int32_t aY, + int32_t aCX, int32_t aCY, + uint32_t aFlags) { /* any attempt to set the window's size or position overrides the window's zoom state. this is important when these two states are competing while the window is being opened. but it should probably just always be so. */ @@ -856,8 +647,8 @@ NS_IMETHODIMP AppWindow::SetPositionAndSize(int32_t aX, int32_t aY, int32_t aCX, return NS_OK; } -NS_IMETHODIMP AppWindow::GetPositionAndSize(int32_t* x, int32_t* y, int32_t* cx, - int32_t* cy) { +NS_IMETHODIMP nsXULWindow::GetPositionAndSize(int32_t* x, int32_t* y, + int32_t* cx, int32_t* cy) { if (!mWindow) return NS_ERROR_FAILURE; LayoutDeviceIntRect rect = mWindow->GetScreenBounds(); @@ -870,8 +661,8 @@ NS_IMETHODIMP AppWindow::GetPositionAndSize(int32_t* x, int32_t* y, int32_t* cx, return NS_OK; } -NS_IMETHODIMP AppWindow::Center(nsIAppWindow* aRelative, bool aScreen, - bool aAlert) { +NS_IMETHODIMP nsXULWindow::Center(nsIXULWindow* aRelative, bool aScreen, + bool aAlert) { int32_t left, top, width, height, ourWidth, ourHeight; bool screenCoordinates = false, windowCoordinates = false; nsresult result; @@ -961,13 +752,13 @@ NS_IMETHODIMP AppWindow::Center(nsIAppWindow* aRelative, bool aScreen, return NS_ERROR_FAILURE; } -NS_IMETHODIMP AppWindow::Repaint(bool aForce) { +NS_IMETHODIMP nsXULWindow::Repaint(bool aForce) { // XXX First Check In NS_ASSERTION(false, "Not Yet Implemented"); return NS_OK; } -NS_IMETHODIMP AppWindow::GetParentWidget(nsIWidget** aParentWidget) { +NS_IMETHODIMP nsXULWindow::GetParentWidget(nsIWidget** aParentWidget) { NS_ENSURE_ARG_POINTER(aParentWidget); NS_ENSURE_STATE(mWindow); @@ -975,13 +766,13 @@ NS_IMETHODIMP AppWindow::GetParentWidget(nsIWidget** aParentWidget) { return NS_OK; } -NS_IMETHODIMP AppWindow::SetParentWidget(nsIWidget* aParentWidget) { +NS_IMETHODIMP nsXULWindow::SetParentWidget(nsIWidget* aParentWidget) { // XXX First Check In NS_ASSERTION(false, "Not Yet Implemented"); return NS_OK; } -NS_IMETHODIMP AppWindow::GetParentNativeWindow( +NS_IMETHODIMP nsXULWindow::GetParentNativeWindow( nativeWindow* aParentNativeWindow) { NS_ENSURE_ARG_POINTER(aParentNativeWindow); @@ -996,14 +787,14 @@ NS_IMETHODIMP AppWindow::GetParentNativeWindow( return NS_OK; } -NS_IMETHODIMP AppWindow::SetParentNativeWindow( +NS_IMETHODIMP nsXULWindow::SetParentNativeWindow( nativeWindow aParentNativeWindow) { // XXX First Check In NS_ASSERTION(false, "Not Yet Implemented"); return NS_OK; } -NS_IMETHODIMP AppWindow::GetNativeHandle(nsAString& aNativeHandle) { +NS_IMETHODIMP nsXULWindow::GetNativeHandle(nsAString& aNativeHandle) { nsCOMPtr mainWidget; NS_ENSURE_SUCCESS(GetMainWidget(getter_AddRefs(mainWidget)), NS_ERROR_FAILURE); @@ -1020,7 +811,7 @@ NS_IMETHODIMP AppWindow::GetNativeHandle(nsAString& aNativeHandle) { return NS_OK; } -NS_IMETHODIMP AppWindow::GetVisibility(bool* aVisibility) { +NS_IMETHODIMP nsXULWindow::GetVisibility(bool* aVisibility) { NS_ENSURE_ARG_POINTER(aVisibility); // Always claim to be visible for now. See bug @@ -1031,7 +822,7 @@ NS_IMETHODIMP AppWindow::GetVisibility(bool* aVisibility) { return NS_OK; } -NS_IMETHODIMP AppWindow::SetVisibility(bool aVisibility) { +NS_IMETHODIMP nsXULWindow::SetVisibility(bool aVisibility) { if (!mChromeLoaded) { mShowAfterLoad = aVisibility; return NS_OK; @@ -1047,7 +838,7 @@ NS_IMETHODIMP AppWindow::SetVisibility(bool aVisibility) { nsCOMPtr shellAsWin(do_QueryInterface(mDocShell)); shellAsWin->SetVisibility(aVisibility); // Store locally so it doesn't die on us. 'Show' can result in the window - // being closed with AppWindow::Destroy being called. That would set + // being closed with nsXULWindow::Destroy being called. That would set // mWindow to null and posibly destroy the nsIWidget while its Show method // is on the stack. We need to keep it alive until Show finishes. nsCOMPtr window = mWindow; @@ -1056,13 +847,13 @@ NS_IMETHODIMP AppWindow::SetVisibility(bool aVisibility) { nsCOMPtr windowMediator( do_GetService(NS_WINDOWMEDIATOR_CONTRACTID)); if (windowMediator) - windowMediator->UpdateWindowTimeStamp(static_cast(this)); + windowMediator->UpdateWindowTimeStamp(static_cast(this)); // notify observers so that we can hide the splash screen if possible nsCOMPtr obssvc = services::GetObserverService(); NS_ASSERTION(obssvc, "Couldn't get observer service."); if (obssvc) { - obssvc->NotifyObservers(static_cast(this), + obssvc->NotifyObservers(static_cast(this), "xul-window-visible", nullptr); } @@ -1070,7 +861,7 @@ NS_IMETHODIMP AppWindow::SetVisibility(bool aVisibility) { return NS_OK; } -NS_IMETHODIMP AppWindow::GetEnabled(bool* aEnabled) { +NS_IMETHODIMP nsXULWindow::GetEnabled(bool* aEnabled) { NS_ENSURE_ARG_POINTER(aEnabled); if (mWindow) { @@ -1082,7 +873,7 @@ NS_IMETHODIMP AppWindow::GetEnabled(bool* aEnabled) { return NS_ERROR_FAILURE; } -NS_IMETHODIMP AppWindow::SetEnabled(bool aEnable) { +NS_IMETHODIMP nsXULWindow::SetEnabled(bool aEnable) { if (mWindow) { mWindow->Enable(aEnable); return NS_OK; @@ -1090,7 +881,7 @@ NS_IMETHODIMP AppWindow::SetEnabled(bool aEnable) { return NS_ERROR_FAILURE; } -NS_IMETHODIMP AppWindow::GetMainWidget(nsIWidget** aMainWidget) { +NS_IMETHODIMP nsXULWindow::GetMainWidget(nsIWidget** aMainWidget) { NS_ENSURE_ARG_POINTER(aMainWidget); *aMainWidget = mWindow; @@ -1098,18 +889,18 @@ NS_IMETHODIMP AppWindow::GetMainWidget(nsIWidget** aMainWidget) { return NS_OK; } -NS_IMETHODIMP AppWindow::SetFocus() { +NS_IMETHODIMP nsXULWindow::SetFocus() { // XXX First Check In NS_ASSERTION(false, "Not Yet Implemented"); return NS_OK; } -NS_IMETHODIMP AppWindow::GetTitle(nsAString& aTitle) { +NS_IMETHODIMP nsXULWindow::GetTitle(nsAString& aTitle) { aTitle = mTitle; return NS_OK; } -NS_IMETHODIMP AppWindow::SetTitle(const nsAString& aTitle) { +NS_IMETHODIMP nsXULWindow::SetTitle(const nsAString& aTitle) { NS_ENSURE_STATE(mWindow); mTitle.Assign(aTitle); mTitle.StripCRLF(); @@ -1118,40 +909,40 @@ NS_IMETHODIMP AppWindow::SetTitle(const nsAString& aTitle) { } //***************************************************************************** -// AppWindow: Helpers +// nsXULWindow: Helpers //***************************************************************************** -NS_IMETHODIMP AppWindow::EnsureChromeTreeOwner() { +NS_IMETHODIMP nsXULWindow::EnsureChromeTreeOwner() { if (mChromeTreeOwner) return NS_OK; mChromeTreeOwner = new nsChromeTreeOwner(); NS_ADDREF(mChromeTreeOwner); - mChromeTreeOwner->AppWindow(this); + mChromeTreeOwner->XULWindow(this); return NS_OK; } -NS_IMETHODIMP AppWindow::EnsureContentTreeOwner() { +NS_IMETHODIMP nsXULWindow::EnsureContentTreeOwner() { if (mContentTreeOwner) return NS_OK; mContentTreeOwner = new nsContentTreeOwner(false); NS_ADDREF(mContentTreeOwner); - mContentTreeOwner->AppWindow(this); + mContentTreeOwner->XULWindow(this); return NS_OK; } -NS_IMETHODIMP AppWindow::EnsurePrimaryContentTreeOwner() { +NS_IMETHODIMP nsXULWindow::EnsurePrimaryContentTreeOwner() { if (mPrimaryContentTreeOwner) return NS_OK; mPrimaryContentTreeOwner = new nsContentTreeOwner(true); NS_ADDREF(mPrimaryContentTreeOwner); - mPrimaryContentTreeOwner->AppWindow(this); + mPrimaryContentTreeOwner->XULWindow(this); return NS_OK; } -NS_IMETHODIMP AppWindow::EnsurePrompter() { +NS_IMETHODIMP nsXULWindow::EnsurePrompter() { if (mPrompter) return NS_OK; nsCOMPtr ourWindow; @@ -1164,7 +955,7 @@ NS_IMETHODIMP AppWindow::EnsurePrompter() { return mPrompter ? NS_OK : NS_ERROR_FAILURE; } -NS_IMETHODIMP AppWindow::EnsureAuthPrompter() { +NS_IMETHODIMP nsXULWindow::EnsureAuthPrompter() { if (mAuthPrompter) return NS_OK; nsCOMPtr ourWindow; @@ -1178,8 +969,8 @@ NS_IMETHODIMP AppWindow::EnsureAuthPrompter() { return mAuthPrompter ? NS_OK : NS_ERROR_FAILURE; } -NS_IMETHODIMP AppWindow::GetAvailScreenSize(int32_t* aAvailWidth, - int32_t* aAvailHeight) { +NS_IMETHODIMP nsXULWindow::GetAvailScreenSize(int32_t* aAvailWidth, + int32_t* aAvailHeight) { nsCOMPtr domWindow; GetWindowDOMWindow(getter_AddRefs(domWindow)); NS_ENSURE_STATE(domWindow); @@ -1205,7 +996,7 @@ NS_IMETHODIMP AppWindow::GetAvailScreenSize(int32_t* aAvailWidth, // Rounds window size to 1000x1000, or, if there isn't enough available // screen space, to a multiple of 200x100. -NS_IMETHODIMP AppWindow::ForceRoundedDimensions() { +NS_IMETHODIMP nsXULWindow::ForceRoundedDimensions() { if (mIsHiddenWindow) { return NS_OK; } @@ -1258,7 +1049,7 @@ NS_IMETHODIMP AppWindow::ForceRoundedDimensions() { return NS_OK; } -void AppWindow::OnChromeLoaded() { +void nsXULWindow::OnChromeLoaded() { nsresult rv = EnsureContentTreeOwner(); if (NS_SUCCEEDED(rv)) { @@ -1273,13 +1064,13 @@ void AppWindow::OnChromeLoaded() { AddTooltipSupport(); } // At this point the window may have been closed already during Show() or - // SyncAttributesToWidget(), so AppWindow::Destroy may already have been + // SyncAttributesToWidget(), so nsXULWindow::Destroy may already have been // called. Take care! } mPersistentAttributesMask |= PAD_POSITION | PAD_SIZE | PAD_MISC; } -bool AppWindow::NeedsTooltipListener() { +bool nsXULWindow::NeedsTooltipListener() { nsCOMPtr docShellElement = GetWindowDOMElement(); if (!docShellElement || docShellElement->IsXULElement()) { // Tooltips in XUL are handled by each element. @@ -1289,7 +1080,7 @@ bool AppWindow::NeedsTooltipListener() { return true; } -void AppWindow::AddTooltipSupport() { +void nsXULWindow::AddTooltipSupport() { if (!NeedsTooltipListener()) { return; } @@ -1303,7 +1094,7 @@ void AppWindow::AddTooltipSupport() { listener->AddTooltipSupport(docShellElement); } -void AppWindow::RemoveTooltipSupport() { +void nsXULWindow::RemoveTooltipSupport() { if (!NeedsTooltipListener()) { return; } @@ -1320,7 +1111,7 @@ void AppWindow::RemoveTooltipSupport() { // If aSpecWidth and/or aSpecHeight are > 0, we will use these CSS px sizes // to fit to the screen when staggering windows; if they're negative, // we use the window's current size instead. -bool AppWindow::LoadPositionFromXUL(int32_t aSpecWidth, int32_t aSpecHeight) { +bool nsXULWindow::LoadPositionFromXUL(int32_t aSpecWidth, int32_t aSpecHeight) { bool gotPosition = false; // if we're the hidden window, don't try to validate our size/position. We're @@ -1422,7 +1213,7 @@ static Maybe ReadSize(const Element& aElement, nsAtom* aAttr, return Some(std::min(max, std::max(*attr, min))); } -bool AppWindow::LoadSizeFromXUL(int32_t& aSpecWidth, int32_t& aSpecHeight) { +bool nsXULWindow::LoadSizeFromXUL(int32_t& aSpecWidth, int32_t& aSpecHeight) { bool gotSize = false; // if we're the hidden window, don't try to validate our size/position. We're @@ -1453,7 +1244,7 @@ bool AppWindow::LoadSizeFromXUL(int32_t& aSpecWidth, int32_t& aSpecHeight) { return gotSize; } -void AppWindow::SetSpecifiedSize(int32_t aSpecWidth, int32_t aSpecHeight) { +void nsXULWindow::SetSpecifiedSize(int32_t aSpecWidth, int32_t aSpecHeight) { // constrain to screen size int32_t screenWidth; int32_t screenHeight; @@ -1487,7 +1278,7 @@ void AppWindow::SetSpecifiedSize(int32_t aSpecWidth, int32_t aSpecHeight) { |persist| attribute, other than size and position. Those are special because it's important to load those before one of the misc attributes (sizemode) and they require extra processing. */ -bool AppWindow::UpdateWindowStateFromMiscXULAttributes() { +bool nsXULWindow::UpdateWindowStateFromMiscXULAttributes() { bool gotState = false; /* There are no misc attributes of interest to the hidden window. @@ -1562,8 +1353,8 @@ bool AppWindow::UpdateWindowStateFromMiscXULAttributes() { The aRequested{X,Y} parameters here are in desktop pixels; the aSpec{Width,Height} parameters are CSS pixel dimensions. */ -void AppWindow::StaggerPosition(int32_t& aRequestedX, int32_t& aRequestedY, - int32_t aSpecWidth, int32_t aSpecHeight) { +void nsXULWindow::StaggerPosition(int32_t& aRequestedX, int32_t& aRequestedY, + int32_t aSpecWidth, int32_t aSpecHeight) { // These "constants" will be converted from CSS to desktop pixels // for the appropriate screen, assuming we find a screen to use... // hence they're not actually declared const here. @@ -1581,7 +1372,7 @@ void AppWindow::StaggerPosition(int32_t& aRequestedX, int32_t& aRequestedY, nsCOMPtr windowElement = GetWindowDOMElement(); if (!windowElement) return; - nsCOMPtr ourAppWindow(this); + nsCOMPtr ourXULWindow(this); nsAutoString windowType; windowElement->GetAttribute(WINDOWTYPE_ATTRIBUTE, windowType); @@ -1626,7 +1417,7 @@ void AppWindow::StaggerPosition(int32_t& aRequestedX, int32_t& aRequestedY, do { keepTrying = false; nsCOMPtr windowList; - wm->GetAppWindowEnumerator(windowType.get(), getter_AddRefs(windowList)); + wm->GetXULWindowEnumerator(windowType.get(), getter_AddRefs(windowList)); if (!windowList) break; @@ -1640,8 +1431,8 @@ void AppWindow::StaggerPosition(int32_t& aRequestedX, int32_t& aRequestedY, nsCOMPtr supportsWindow; windowList->GetNext(getter_AddRefs(supportsWindow)); - nsCOMPtr listAppWindow(do_QueryInterface(supportsWindow)); - if (listAppWindow != ourAppWindow) { + nsCOMPtr listXULWindow(do_QueryInterface(supportsWindow)); + if (listXULWindow != ourXULWindow) { int32_t listX, listY; nsCOMPtr listBaseWindow( do_QueryInterface(supportsWindow)); @@ -1694,7 +1485,7 @@ void AppWindow::StaggerPosition(int32_t& aRequestedX, int32_t& aRequestedY, } while (keepTrying); } -void AppWindow::SyncAttributesToWidget() { +void nsXULWindow::SyncAttributesToWidget() { nsCOMPtr windowElement = GetWindowDOMElement(); if (!windowElement) return; @@ -1767,7 +1558,7 @@ enum class ConversionDirection { OuterToInner, }; -static void ConvertWindowSize(nsIAppWindow* aWin, const nsAtom* aAttr, +static void ConvertWindowSize(nsIXULWindow* aWin, const nsAtom* aAttr, ConversionDirection aDirection, nsAString& aInOutString) { MOZ_ASSERT(aWin); @@ -1793,7 +1584,8 @@ static void ConvertWindowSize(nsIAppWindow* aWin, const nsAtom* aAttr, aInOutString); } -nsresult AppWindow::GetPersistentValue(const nsAtom* aAttr, nsAString& aValue) { +nsresult nsXULWindow::GetPersistentValue(const nsAtom* aAttr, + nsAString& aValue) { nsCOMPtr docShellElement = GetWindowDOMElement(); if (!docShellElement) { return NS_ERROR_FAILURE; @@ -1843,8 +1635,8 @@ nsresult AppWindow::GetPersistentValue(const nsAtom* aAttr, nsAString& aValue) { return NS_OK; } -nsresult AppWindow::SetPersistentValue(const nsAtom* aAttr, - const nsAString& aValue) { +nsresult nsXULWindow::SetPersistentValue(const nsAtom* aAttr, + const nsAString& aValue) { nsCOMPtr docShellElement = GetWindowDOMElement(); if (!docShellElement) { return NS_ERROR_FAILURE; @@ -1896,7 +1688,7 @@ nsresult AppWindow::SetPersistentValue(const nsAtom* aAttr, #endif } -NS_IMETHODIMP AppWindow::SavePersistentAttributes() { +NS_IMETHODIMP nsXULWindow::SavePersistentAttributes() { // can happen when the persistence timer fires at an inopportune time // during window shutdown if (!mDocShell) return NS_ERROR_FAILURE; @@ -2019,7 +1811,7 @@ NS_IMETHODIMP AppWindow::SavePersistentAttributes() { return NS_OK; } -NS_IMETHODIMP AppWindow::GetWindowDOMWindow(mozIDOMWindowProxy** aDOMWindow) { +NS_IMETHODIMP nsXULWindow::GetWindowDOMWindow(mozIDOMWindowProxy** aDOMWindow) { NS_ENSURE_STATE(mDocShell); if (!mDOMWindow) mDOMWindow = mDocShell->GetWindow(); @@ -2030,7 +1822,7 @@ NS_IMETHODIMP AppWindow::GetWindowDOMWindow(mozIDOMWindowProxy** aDOMWindow) { return NS_OK; } -dom::Element* AppWindow::GetWindowDOMElement() const { +dom::Element* nsXULWindow::GetWindowDOMElement() const { NS_ENSURE_TRUE(mDocShell, nullptr); nsCOMPtr cv; @@ -2043,8 +1835,8 @@ dom::Element* AppWindow::GetWindowDOMElement() const { return document->GetRootElement(); } -nsresult AppWindow::ContentShellAdded(nsIDocShellTreeItem* aContentShell, - bool aPrimary) { +nsresult nsXULWindow::ContentShellAdded(nsIDocShellTreeItem* aContentShell, + bool aPrimary) { // Set the default content tree owner if (aPrimary) { NS_ENSURE_SUCCESS(EnsurePrimaryContentTreeOwner(), NS_ERROR_FAILURE); @@ -2060,7 +1852,7 @@ nsresult AppWindow::ContentShellAdded(nsIDocShellTreeItem* aContentShell, return NS_OK; } -nsresult AppWindow::ContentShellRemoved(nsIDocShellTreeItem* aContentShell) { +nsresult nsXULWindow::ContentShellRemoved(nsIDocShellTreeItem* aContentShell) { if (mPrimaryContentShell == aContentShell) { mPrimaryContentShell = nullptr; } @@ -2068,7 +1860,7 @@ nsresult AppWindow::ContentShellRemoved(nsIDocShellTreeItem* aContentShell) { } NS_IMETHODIMP -AppWindow::GetPrimaryContentSize(int32_t* aWidth, int32_t* aHeight) { +nsXULWindow::GetPrimaryContentSize(int32_t* aWidth, int32_t* aHeight) { if (mPrimaryBrowserParent) { return GetPrimaryRemoteTabSize(aWidth, aHeight); } else if (mPrimaryContentShell) { @@ -2077,7 +1869,8 @@ AppWindow::GetPrimaryContentSize(int32_t* aWidth, int32_t* aHeight) { return NS_ERROR_UNEXPECTED; } -nsresult AppWindow::GetPrimaryRemoteTabSize(int32_t* aWidth, int32_t* aHeight) { +nsresult nsXULWindow::GetPrimaryRemoteTabSize(int32_t* aWidth, + int32_t* aHeight) { BrowserHost* host = BrowserHost::GetFrom(mPrimaryBrowserParent.get()); // Need strong ref, since Client* can run script. nsCOMPtr element = host->GetOwnerElement(); @@ -2088,8 +1881,8 @@ nsresult AppWindow::GetPrimaryRemoteTabSize(int32_t* aWidth, int32_t* aHeight) { return NS_OK; } -nsresult AppWindow::GetPrimaryContentShellSize(int32_t* aWidth, - int32_t* aHeight) { +nsresult nsXULWindow::GetPrimaryContentShellSize(int32_t* aWidth, + int32_t* aHeight) { NS_ENSURE_STATE(mPrimaryContentShell); nsCOMPtr shellWindow(do_QueryInterface(mPrimaryContentShell)); @@ -2109,7 +1902,7 @@ nsresult AppWindow::GetPrimaryContentShellSize(int32_t* aWidth, } NS_IMETHODIMP -AppWindow::SetPrimaryContentSize(int32_t aWidth, int32_t aHeight) { +nsXULWindow::SetPrimaryContentSize(int32_t aWidth, int32_t aHeight) { if (mPrimaryBrowserParent) { return SetPrimaryRemoteTabSize(aWidth, aHeight); } else if (mPrimaryContentShell) { @@ -2118,7 +1911,7 @@ AppWindow::SetPrimaryContentSize(int32_t aWidth, int32_t aHeight) { return NS_ERROR_UNEXPECTED; } -nsresult AppWindow::SetPrimaryRemoteTabSize(int32_t aWidth, int32_t aHeight) { +nsresult nsXULWindow::SetPrimaryRemoteTabSize(int32_t aWidth, int32_t aHeight) { int32_t shellWidth, shellHeight; GetPrimaryRemoteTabSize(&shellWidth, &shellHeight); @@ -2130,19 +1923,19 @@ nsresult AppWindow::SetPrimaryRemoteTabSize(int32_t aWidth, int32_t aHeight) { return NS_OK; } -nsresult AppWindow::GetRootShellSize(int32_t* aWidth, int32_t* aHeight) { +nsresult nsXULWindow::GetRootShellSize(int32_t* aWidth, int32_t* aHeight) { nsCOMPtr shellAsWin = do_QueryInterface(mDocShell); NS_ENSURE_TRUE(shellAsWin, NS_ERROR_FAILURE); return shellAsWin->GetSize(aWidth, aHeight); } -nsresult AppWindow::SetRootShellSize(int32_t aWidth, int32_t aHeight) { +nsresult nsXULWindow::SetRootShellSize(int32_t aWidth, int32_t aHeight) { nsCOMPtr docShellAsItem = mDocShell; return SizeShellTo(docShellAsItem, aWidth, aHeight); } -NS_IMETHODIMP AppWindow::SizeShellTo(nsIDocShellTreeItem* aShellItem, - int32_t aCX, int32_t aCY) { +NS_IMETHODIMP nsXULWindow::SizeShellTo(nsIDocShellTreeItem* aShellItem, + int32_t aCX, int32_t aCY) { // XXXTAB This is wrong, we should actually reflow based on the passed in // shell. For now we are hacking and doing delta sizing. This is bad // because it assumes all size we add will go to the shell which probably @@ -2160,7 +1953,7 @@ NS_IMETHODIMP AppWindow::SizeShellTo(nsIDocShellTreeItem* aShellItem, return NS_OK; } -NS_IMETHODIMP AppWindow::ExitModalLoop(nsresult aStatus) { +NS_IMETHODIMP nsXULWindow::ExitModalLoop(nsresult aStatus) { if (mContinueModalLoop) EnableParent(true); mContinueModalLoop = false; mModalStatus = aStatus; @@ -2168,11 +1961,11 @@ NS_IMETHODIMP AppWindow::ExitModalLoop(nsresult aStatus) { } // top-level function to create a new window -NS_IMETHODIMP AppWindow::CreateNewWindow(int32_t aChromeFlags, - nsIRemoteTab* aOpeningTab, - mozIDOMWindowProxy* aOpener, - uint64_t aNextRemoteTabId, - nsIAppWindow** _retval) { +NS_IMETHODIMP nsXULWindow::CreateNewWindow(int32_t aChromeFlags, + nsIRemoteTab* aOpeningTab, + mozIDOMWindowProxy* aOpener, + uint64_t aNextRemoteTabId, + nsIXULWindow** _retval) { NS_ENSURE_ARG_POINTER(_retval); if (aChromeFlags & nsIWebBrowserChrome::CHROME_OPENAS_CHROME) { @@ -2186,16 +1979,16 @@ NS_IMETHODIMP AppWindow::CreateNewWindow(int32_t aChromeFlags, aNextRemoteTabId, _retval); } -NS_IMETHODIMP AppWindow::CreateNewChromeWindow(int32_t aChromeFlags, - nsIRemoteTab* aOpeningTab, - mozIDOMWindowProxy* aOpener, - nsIAppWindow** _retval) { +NS_IMETHODIMP nsXULWindow::CreateNewChromeWindow(int32_t aChromeFlags, + nsIRemoteTab* aOpeningTab, + mozIDOMWindowProxy* aOpener, + nsIXULWindow** _retval) { nsCOMPtr appShell( do_GetService(NS_APPSHELLSERVICE_CONTRACTID)); NS_ENSURE_TRUE(appShell, NS_ERROR_FAILURE); // Just do a normal create of a window and return. - nsCOMPtr newWindow; + nsCOMPtr newWindow; appShell->CreateTopLevelWindow( this, nullptr, aChromeFlags, nsIAppShellService::SIZE_TO_CONTENT, nsIAppShellService::SIZE_TO_CONTENT, aOpeningTab, aOpener, @@ -2209,11 +2002,11 @@ NS_IMETHODIMP AppWindow::CreateNewChromeWindow(int32_t aChromeFlags, return NS_OK; } -NS_IMETHODIMP AppWindow::CreateNewContentWindow(int32_t aChromeFlags, - nsIRemoteTab* aOpeningTab, - mozIDOMWindowProxy* aOpener, - uint64_t aNextRemoteTabId, - nsIAppWindow** _retval) { +NS_IMETHODIMP nsXULWindow::CreateNewContentWindow(int32_t aChromeFlags, + nsIRemoteTab* aOpeningTab, + mozIDOMWindowProxy* aOpener, + uint64_t aNextRemoteTabId, + nsIXULWindow** _retval) { nsCOMPtr appShell( do_GetService(NS_APPSHELLSERVICE_CONTRACTID)); NS_ENSURE_TRUE(appShell, NS_ERROR_FAILURE); @@ -2237,7 +2030,7 @@ NS_IMETHODIMP AppWindow::CreateNewContentWindow(int32_t aChromeFlags, // to pass back. The subject principal needs to be system while we're creating // it to make things work right, so force a system caller. See bug 799348 // comment 13 for a description of what happens when we don't. - nsCOMPtr newWindow; + nsCOMPtr newWindow; { AutoNoJSAPI nojsapi; // We actually want this toplevel window which we are creating to have a @@ -2251,16 +2044,16 @@ NS_IMETHODIMP AppWindow::CreateNewContentWindow(int32_t aChromeFlags, // Specify that we want the window to remain locked until the chrome has // loaded. - AppWindow* appWin = - static_cast(static_cast(newWindow)); + nsXULWindow* xulWin = + static_cast(static_cast(newWindow)); if (aNextRemoteTabId) { - appWin->mNextRemoteTabId = aNextRemoteTabId; + xulWin->mNextRemoteTabId = aNextRemoteTabId; } if (aOpener) { nsCOMPtr docShell; - appWin->GetDocShell(getter_AddRefs(docShell)); + xulWin->GetDocShell(getter_AddRefs(docShell)); MOZ_ASSERT(docShell); nsCOMPtr window = docShell->GetWindow(); MOZ_ASSERT(window); @@ -2268,16 +2061,16 @@ NS_IMETHODIMP AppWindow::CreateNewContentWindow(int32_t aChromeFlags, nsPIDOMWindowOuter::From(aOpener)->GetBrowsingContext()); } - appWin->LockUntilChromeLoad(); + xulWin->LockUntilChromeLoad(); { AutoNoJSAPI nojsapi; - SpinEventLoopUntil([&]() { return !appWin->IsLocked(); }); + SpinEventLoopUntil([&]() { return !xulWin->IsLocked(); }); } - NS_ENSURE_STATE(appWin->mPrimaryContentShell || - appWin->mPrimaryBrowserParent); - MOZ_ASSERT_IF(appWin->mPrimaryContentShell, aNextRemoteTabId == 0); + NS_ENSURE_STATE(xulWin->mPrimaryContentShell || + xulWin->mPrimaryBrowserParent); + MOZ_ASSERT_IF(xulWin->mPrimaryContentShell, aNextRemoteTabId == 0); *_retval = newWindow; NS_ADDREF(*_retval); @@ -2285,12 +2078,12 @@ NS_IMETHODIMP AppWindow::CreateNewContentWindow(int32_t aChromeFlags, return NS_OK; } -NS_IMETHODIMP AppWindow::GetHasPrimaryContent(bool* aResult) { +NS_IMETHODIMP nsXULWindow::GetHasPrimaryContent(bool* aResult) { *aResult = mPrimaryBrowserParent || mPrimaryContentShell; return NS_OK; } -void AppWindow::EnableParent(bool aEnable) { +void nsXULWindow::EnableParent(bool aEnable) { nsCOMPtr parentWindow; nsCOMPtr parentWidget; @@ -2300,9 +2093,9 @@ void AppWindow::EnableParent(bool aEnable) { } // Constrain the window to its proper z-level -bool AppWindow::ConstrainToZLevel(bool aImmediate, nsWindowZ* aPlacement, - nsIWidget* aReqBelow, - nsIWidget** aActualBelow) { +bool nsXULWindow::ConstrainToZLevel(bool aImmediate, nsWindowZ* aPlacement, + nsIWidget* aReqBelow, + nsIWidget** aActualBelow) { #if 0 /* Do we have a parent window? This means our z-order is already constrained, since we're a dependent window. Our window list isn't hierarchical, @@ -2319,14 +2112,14 @@ bool AppWindow::ConstrainToZLevel(bool aImmediate, nsWindowZ* aPlacement, bool altered; uint32_t position, newPosition, zLevel; - nsIAppWindow* us = this; + nsIXULWindow* us = this; altered = false; mediator->GetZLevel(this, &zLevel); // translate from WidgetGUIEvent to nsIWindowMediator constants position = nsIWindowMediator::zLevelTop; - if (*aPlacement == nsWindowZBottom || zLevel == nsIAppWindow::lowestZ) + if (*aPlacement == nsWindowZBottom || zLevel == nsIXULWindow::lowestZ) position = nsIWindowMediator::zLevelBottom; else if (*aPlacement == nsWindowZRelative) position = nsIWindowMediator::zLevelBelow; @@ -2341,7 +2134,7 @@ bool AppWindow::ConstrainToZLevel(bool aImmediate, nsWindowZ* aPlacement, if (altered && (position == nsIWindowMediator::zLevelTop || (position == nsIWindowMediator::zLevelBelow && aReqBelow == 0))) - PlaceWindowLayersBehind(zLevel + 1, nsIAppWindow::highestZ, 0); + PlaceWindowLayersBehind(zLevel + 1, nsIXULWindow::highestZ, 0); if (*aPlacement != nsWindowZBottom && position == nsIWindowMediator::zLevelBottom) @@ -2371,9 +2164,9 @@ bool AppWindow::ConstrainToZLevel(bool aImmediate, nsWindowZ* aPlacement, not to change something it doesn't recognize. A request to verify being below an unrecognized window, then, is treated as a request to come to the top (below null) */ - nsCOMPtr windowAbove; + nsCOMPtr windowAbove; if (newPosition == nsIWindowMediator::zLevelBelow && *aActualBelow) { - windowAbove = (*aActualBelow)->GetWidgetListener()->GetAppWindow(); + windowAbove = (*aActualBelow)->GetWidgetListener()->GetXULWindow(); } mediator->SetZPosition(us, newPosition, windowAbove); @@ -2390,8 +2183,9 @@ bool AppWindow::ConstrainToZLevel(bool aImmediate, nsWindowZ* aPlacement, a range of layers of our own windows relative to windows belonging to external applications. */ -void AppWindow::PlaceWindowLayersBehind(uint32_t aLowLevel, uint32_t aHighLevel, - nsIAppWindow* aBehind) { +void nsXULWindow::PlaceWindowLayersBehind(uint32_t aLowLevel, + uint32_t aHighLevel, + nsIXULWindow* aBehind) { // step through windows in z-order from top to bottommost window nsCOMPtr mediator( @@ -2399,7 +2193,7 @@ void AppWindow::PlaceWindowLayersBehind(uint32_t aLowLevel, uint32_t aHighLevel, if (!mediator) return; nsCOMPtr windowEnumerator; - mediator->GetZOrderAppWindowEnumerator(0, true, + mediator->GetZOrderXULWindowEnumerator(0, true, getter_AddRefs(windowEnumerator)); if (!windowEnumerator) return; @@ -2417,13 +2211,13 @@ void AppWindow::PlaceWindowLayersBehind(uint32_t aLowLevel, uint32_t aHighLevel, uint32_t nextZ; // z-level of nextWindow nsCOMPtr nextWindow; windowEnumerator->GetNext(getter_AddRefs(nextWindow)); - nsCOMPtr nextAppWindow(do_QueryInterface(nextWindow)); - nextAppWindow->GetZLevel(&nextZ); + nsCOMPtr nextXULWindow(do_QueryInterface(nextWindow)); + nextXULWindow->GetZLevel(&nextZ); if (nextZ < aLowLevel) break; // we've processed all windows through aLowLevel // move it just below its next higher window - nsCOMPtr nextBase(do_QueryInterface(nextAppWindow)); + nsCOMPtr nextBase(do_QueryInterface(nextXULWindow)); if (nextBase) { nsCOMPtr nextWidget; nextBase->GetMainWidget(getter_AddRefs(nextWidget)); @@ -2434,7 +2228,7 @@ void AppWindow::PlaceWindowLayersBehind(uint32_t aLowLevel, uint32_t aHighLevel, } } -void AppWindow::SetContentScrollbarVisibility(bool aVisible) { +void nsXULWindow::SetContentScrollbarVisibility(bool aVisible) { nsCOMPtr contentWin( do_GetInterface(mPrimaryContentShell)); if (!contentWin) { @@ -2444,7 +2238,7 @@ void AppWindow::SetContentScrollbarVisibility(bool aVisible) { nsContentUtils::SetScrollbarsVisibility(contentWin->GetDocShell(), aVisible); } -bool AppWindow::GetContentScrollbarVisibility() { +bool nsXULWindow::GetContentScrollbarVisibility() { // This code already exists in dom/src/base/nsBarProp.cpp, but we // can't safely get to that from here as this function is called // while the DOM window is being set up, and we need the DOM window @@ -2466,11 +2260,11 @@ bool AppWindow::GetContentScrollbarVisibility() { } // during spinup, attributes that haven't been loaded yet can't be dirty -void AppWindow::PersistentAttributesDirty(uint32_t aDirtyFlags) { +void nsXULWindow::PersistentAttributesDirty(uint32_t aDirtyFlags) { mPersistentAttributesDirty |= aDirtyFlags & mPersistentAttributesMask; } -void AppWindow::ApplyChromeFlags() { +void nsXULWindow::ApplyChromeFlags() { nsCOMPtr window = GetWindowDOMElement(); if (!window) { return; @@ -2517,7 +2311,7 @@ void AppWindow::ApplyChromeFlags() { } NS_IMETHODIMP -AppWindow::BeforeStartLayout() { +nsXULWindow::BeforeStartLayout() { ApplyChromeFlags(); LoadPersistentWindowState(); SyncAttributesToWidget(); @@ -2528,12 +2322,12 @@ AppWindow::BeforeStartLayout() { } NS_IMETHODIMP -AppWindow::LockAspectRatio(bool aShouldLock) { +nsXULWindow::LockAspectRatio(bool aShouldLock) { mWindow->LockAspectRatio(aShouldLock); return NS_OK; } -void AppWindow::LoadPersistentWindowState() { +void nsXULWindow::LoadPersistentWindowState() { nsCOMPtr docShellElement = GetWindowDOMElement(); if (!docShellElement) { return; @@ -2566,7 +2360,7 @@ void AppWindow::LoadPersistentWindowState() { loadValue(nsGkAtoms::sizemode); } -void AppWindow::SizeShell() { +void nsXULWindow::SizeShell() { AutoRestore sizingShellFromXUL(mSizingShellFromXUL); mSizingShellFromXUL = true; @@ -2599,7 +2393,7 @@ void AppWindow::SizeShell() { } bool positionSet = !mIgnoreXULPosition; - nsCOMPtr parentWindow(do_QueryReferent(mParentWindow)); + nsCOMPtr parentWindow(do_QueryReferent(mParentWindow)); #if defined(XP_UNIX) && !defined(XP_MACOSX) // don't override WM placement on unix for independent, top-level windows // (however, we think the benefits of intelligent dependent window placement @@ -2654,22 +2448,22 @@ void AppWindow::SizeShell() { } } -NS_IMETHODIMP AppWindow::GetXULBrowserWindow( +NS_IMETHODIMP nsXULWindow::GetXULBrowserWindow( nsIXULBrowserWindow** aXULBrowserWindow) { NS_IF_ADDREF(*aXULBrowserWindow = mXULBrowserWindow); return NS_OK; } -NS_IMETHODIMP AppWindow::SetXULBrowserWindow( +NS_IMETHODIMP nsXULWindow::SetXULBrowserWindow( nsIXULBrowserWindow* aXULBrowserWindow) { mXULBrowserWindow = aXULBrowserWindow; return NS_OK; } -void AppWindow::SizeShellToWithLimit(int32_t aDesiredWidth, - int32_t aDesiredHeight, - int32_t shellItemWidth, - int32_t shellItemHeight) { +void nsXULWindow::SizeShellToWithLimit(int32_t aDesiredWidth, + int32_t aDesiredHeight, + int32_t shellItemWidth, + int32_t shellItemHeight) { int32_t widthDelta = aDesiredWidth - shellItemWidth; int32_t heightDelta = aDesiredHeight - shellItemHeight; @@ -2688,7 +2482,7 @@ void AppWindow::SizeShellToWithLimit(int32_t aDesiredWidth, } } -nsresult AppWindow::GetTabCount(uint32_t* aResult) { +nsresult nsXULWindow::GetTabCount(uint32_t* aResult) { if (mXULBrowserWindow) { return mXULBrowserWindow->GetTabCount(aResult); } @@ -2697,527 +2491,8 @@ nsresult AppWindow::GetTabCount(uint32_t* aResult) { return NS_OK; } -nsresult AppWindow::GetNextRemoteTabId(uint64_t* aNextRemoteTabId) { +nsresult nsXULWindow::GetNextRemoteTabId(uint64_t* aNextRemoteTabId) { NS_ENSURE_ARG_POINTER(aNextRemoteTabId); *aNextRemoteTabId = mNextRemoteTabId; return NS_OK; } - -PresShell* AppWindow::GetPresShell() { - if (!mDocShell) { - return nullptr; - } - return mDocShell->GetPresShell(); -} - -bool AppWindow::WindowMoved(nsIWidget* aWidget, int32_t x, int32_t y) { - nsXULPopupManager* pm = nsXULPopupManager::GetInstance(); - if (pm) { - nsCOMPtr window = - mDocShell ? mDocShell->GetWindow() : nullptr; - pm->AdjustPopupsOnWindowChange(window); - } - - // Notify all tabs that the widget moved. - if (mDocShell && mDocShell->GetWindow()) { - nsCOMPtr eventTarget = - mDocShell->GetWindow()->GetTopWindowRoot(); - nsContentUtils::DispatchChromeEvent(mDocShell->GetDocument(), eventTarget, - NS_LITERAL_STRING("MozUpdateWindowPos"), - CanBubble::eNo, Cancelable::eNo, - nullptr); - } - - // Persist position, but not immediately, in case this OS is firing - // repeated move events as the user drags the window - SetPersistenceTimer(PAD_POSITION); - return false; -} - -bool AppWindow::WindowResized(nsIWidget* aWidget, int32_t aWidth, - int32_t aHeight) { - nsCOMPtr shellAsWin(do_QueryInterface(mDocShell)); - if (shellAsWin) { - shellAsWin->SetPositionAndSize(0, 0, aWidth, aHeight, 0); - } - // Persist size, but not immediately, in case this OS is firing - // repeated size events as the user drags the sizing handle - if (!IsLocked()) SetPersistenceTimer(PAD_POSITION | PAD_SIZE | PAD_MISC); - return true; -} - -bool AppWindow::RequestWindowClose(nsIWidget* aWidget) { - // Maintain a reference to this as it is about to get destroyed. - nsCOMPtr appWindow(this); - - nsCOMPtr window(mDocShell ? mDocShell->GetWindow() - : nullptr); - nsCOMPtr eventTarget = do_QueryInterface(window); - - RefPtr presShell = mDocShell->GetPresShell(); - if (!presShell) { - mozilla::DebugOnly dying; - MOZ_ASSERT(NS_SUCCEEDED(mDocShell->IsBeingDestroyed(&dying)) && dying, - "No presShell, but window is not being destroyed"); - } else if (eventTarget) { - RefPtr presContext = presShell->GetPresContext(); - - nsEventStatus status = nsEventStatus_eIgnore; - WidgetMouseEvent event(true, eClose, nullptr, WidgetMouseEvent::eReal); - if (NS_SUCCEEDED(EventDispatcher::Dispatch(eventTarget, presContext, &event, - nullptr, &status)) && - status == nsEventStatus_eConsumeNoDefault) - return false; - } - - Destroy(); - return false; -} - -void AppWindow::SizeModeChanged(nsSizeMode sizeMode) { - // An alwaysRaised (or higher) window will hide any newly opened normal - // browser windows, so here we just drop a raised window to the normal - // zlevel if it's maximized. We make no provision for automatically - // re-raising it when restored. - if (sizeMode == nsSizeMode_Maximized || sizeMode == nsSizeMode_Fullscreen) { - uint32_t zLevel; - GetZLevel(&zLevel); - if (zLevel > nsIAppWindow::normalZ) SetZLevel(nsIAppWindow::normalZ); - } - mWindow->SetSizeMode(sizeMode); - - // Persist mode, but not immediately, because in many (all?) - // cases this will merge with the similar call in NS_SIZE and - // write the attribute values only once. - SetPersistenceTimer(PAD_MISC); - nsCOMPtr ourWindow = - mDocShell ? mDocShell->GetWindow() : nullptr; - if (ourWindow) { - // Ensure that the fullscreen state is synchronized between - // the widget and the outer window object. - if (sizeMode == nsSizeMode_Fullscreen) { - ourWindow->SetFullScreen(true); - } else if (sizeMode != nsSizeMode_Minimized) { - if (ourWindow->GetFullScreen()) { - // The first SetFullscreenInternal call below ensures that we do - // not trigger any fullscreen transition even if the window was - // put in fullscreen only for the Fullscreen API. The second - // SetFullScreen call ensures that the window really exit from - // fullscreen even if it entered fullscreen for both Fullscreen - // Mode and Fullscreen API. - ourWindow->SetFullscreenInternal( - FullscreenReason::ForForceExitFullscreen, false); - ourWindow->SetFullScreen(false); - } - } - - // And always fire a user-defined sizemodechange event on the window - ourWindow->DispatchCustomEvent(NS_LITERAL_STRING("sizemodechange")); - } - - if (PresShell* presShell = GetPresShell()) { - presShell->GetPresContext()->SizeModeChanged(sizeMode); - } - - // Note the current implementation of SetSizeMode just stores - // the new state; it doesn't actually resize. So here we store - // the state and pass the event on to the OS. The day is coming - // when we'll handle the event here, and the return result will - // then need to be different. -} - -void AppWindow::UIResolutionChanged() { - nsCOMPtr ourWindow = - mDocShell ? mDocShell->GetWindow() : nullptr; - if (ourWindow) { - ourWindow->DispatchCustomEvent(NS_LITERAL_STRING("resolutionchange")); - } -} - -void AppWindow::FullscreenWillChange(bool aInFullscreen) { - if (mDocShell) { - if (nsCOMPtr ourWindow = mDocShell->GetWindow()) { - ourWindow->FullscreenWillChange(aInFullscreen); - } - } -} - -void AppWindow::FullscreenChanged(bool aInFullscreen) { - if (mDocShell) { - if (nsCOMPtr ourWindow = mDocShell->GetWindow()) { - ourWindow->FinishFullscreenChange(aInFullscreen); - } - } -} - -void AppWindow::OcclusionStateChanged(bool aIsFullyOccluded) { - nsCOMPtr ourWindow = - mDocShell ? mDocShell->GetWindow() : nullptr; - if (ourWindow) { - // And always fire a user-defined occlusionstatechange event on the window - ourWindow->DispatchCustomEvent(NS_LITERAL_STRING("occlusionstatechange")); - } -} - -void AppWindow::OSToolbarButtonPressed() { - // Keep a reference as setting the chrome flags can fire events. - nsCOMPtr appWindow(this); - - // rjc: don't use "nsIWebBrowserChrome::CHROME_EXTRA" - // due to components with multiple sidebar components - // (such as Mail/News, Addressbook, etc)... and frankly, - // Mac IE, OmniWeb, and other Mac OS X apps all work this way - uint32_t chromeMask = (nsIWebBrowserChrome::CHROME_TOOLBAR | - nsIWebBrowserChrome::CHROME_LOCATIONBAR | - nsIWebBrowserChrome::CHROME_PERSONAL_TOOLBAR); - - nsCOMPtr wbc(do_GetInterface(appWindow)); - if (!wbc) return; - - uint32_t chromeFlags, newChromeFlags = 0; - wbc->GetChromeFlags(&chromeFlags); - newChromeFlags = chromeFlags & chromeMask; - if (!newChromeFlags) - chromeFlags |= chromeMask; - else - chromeFlags &= (~newChromeFlags); - wbc->SetChromeFlags(chromeFlags); -} - -bool AppWindow::ZLevelChanged(bool aImmediate, nsWindowZ* aPlacement, - nsIWidget* aRequestBelow, - nsIWidget** aActualBelow) { - if (aActualBelow) *aActualBelow = nullptr; - - return ConstrainToZLevel(aImmediate, aPlacement, aRequestBelow, aActualBelow); -} - -void AppWindow::WindowActivated() { - nsCOMPtr appWindow(this); - - // focusing the window could cause it to close, so keep a reference to it - nsCOMPtr window = - mDocShell ? mDocShell->GetWindow() : nullptr; - nsFocusManager* fm = nsFocusManager::GetFocusManager(); - if (fm && window) fm->WindowRaised(window); - - if (mChromeLoaded) { - PersistentAttributesDirty(PAD_POSITION | PAD_SIZE | PAD_MISC); - SavePersistentAttributes(); - } -} - -void AppWindow::WindowDeactivated() { - nsCOMPtr appWindow(this); - - nsCOMPtr window = - mDocShell ? mDocShell->GetWindow() : nullptr; - nsFocusManager* fm = nsFocusManager::GetFocusManager(); - if (fm && window && !fm->IsTestMode()) fm->WindowLowered(window); -} - -#ifdef USE_NATIVE_MENUS -static void LoadNativeMenus(Document* aDoc, nsIWidget* aParentWindow) { - if (gfxPlatform::IsHeadless()) { - return; - } - nsCOMPtr nms = - do_GetService("@mozilla.org/widget/nativemenuservice;1"); - if (!nms) { - return; - } - - // Find the menubar tag (if there is more than one, we ignore all but - // the first). - nsCOMPtr menubarElements = aDoc->GetElementsByTagNameNS( - NS_LITERAL_STRING( - "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"), - NS_LITERAL_STRING("menubar")); - - nsCOMPtr menubarNode; - if (menubarElements) { - menubarNode = menubarElements->Item(0); - } - - if (menubarNode) { - nsCOMPtr menubarContent(do_QueryInterface(menubarNode)); - nms->CreateNativeMenuBar(aParentWindow, menubarContent); - } else { - nms->CreateNativeMenuBar(aParentWindow, nullptr); - } -} -#endif - -class AppWindowTimerCallback final : public nsITimerCallback, public nsINamed { - public: - explicit AppWindowTimerCallback(AppWindow* aWindow) : mWindow(aWindow) {} - - NS_DECL_THREADSAFE_ISUPPORTS - - NS_IMETHOD Notify(nsITimer* aTimer) override { - // Although this object participates in a refcount cycle (this -> mWindow - // -> mSPTimer -> this), mSPTimer is a one-shot timer and releases this - // after it fires. So we don't need to release mWindow here. - - mWindow->FirePersistenceTimer(); - return NS_OK; - } - - NS_IMETHOD GetName(nsACString& aName) override { - aName.AssignLiteral("AppWindowTimerCallback"); - return NS_OK; - } - - private: - ~AppWindowTimerCallback() {} - - RefPtr mWindow; -}; - -NS_IMPL_ISUPPORTS(AppWindowTimerCallback, nsITimerCallback, nsINamed) - -void AppWindow::SetPersistenceTimer(uint32_t aDirtyFlags) { - MutexAutoLock lock(mSPTimerLock); - if (!mSPTimer) { - mSPTimer = NS_NewTimer(); - if (!mSPTimer) { - NS_WARNING("Couldn't create @mozilla.org/timer;1 instance?"); - return; - } - } - - RefPtr callback = new AppWindowTimerCallback(this); - mSPTimer->InitWithCallback(callback, SIZE_PERSISTENCE_TIMEOUT, - nsITimer::TYPE_ONE_SHOT); - - PersistentAttributesDirty(aDirtyFlags); -} - -void AppWindow::FirePersistenceTimer() { - MutexAutoLock lock(mSPTimerLock); - SavePersistentAttributes(); -} - -//---------------------------------------- -// nsIWebProgessListener implementation -//---------------------------------------- -NS_IMETHODIMP -AppWindow::OnProgressChange(nsIWebProgress* aProgress, nsIRequest* aRequest, - int32_t aCurSelfProgress, int32_t aMaxSelfProgress, - int32_t aCurTotalProgress, - int32_t aMaxTotalProgress) { - MOZ_ASSERT_UNREACHABLE("notification excluded in AddProgressListener(...)"); - return NS_OK; -} - -NS_IMETHODIMP -AppWindow::OnStateChange(nsIWebProgress* aProgress, nsIRequest* aRequest, - uint32_t aStateFlags, nsresult aStatus) { - // If the notification is not about a document finishing, then just - // ignore it... - if (!(aStateFlags & nsIWebProgressListener::STATE_STOP) || - !(aStateFlags & nsIWebProgressListener::STATE_IS_NETWORK)) { - return NS_OK; - } - - if (mChromeLoaded) return NS_OK; - - // If this document notification is for a frame then ignore it... - nsCOMPtr eventWin; - aProgress->GetDOMWindow(getter_AddRefs(eventWin)); - auto* eventPWin = nsPIDOMWindowOuter::From(eventWin); - if (eventPWin) { - nsPIDOMWindowOuter* rootPWin = eventPWin->GetPrivateRoot(); - if (eventPWin != rootPWin) return NS_OK; - } - - mChromeLoaded = true; - mLockedUntilChromeLoad = false; - -#ifdef USE_NATIVE_MENUS - /////////////////////////////// - // Find the Menubar DOM and Load the menus, hooking them up to the loaded - // commands - /////////////////////////////// - nsCOMPtr cv; - mDocShell->GetContentViewer(getter_AddRefs(cv)); - if (cv) { - RefPtr menubarDoc = cv->GetDocument(); - if (menubarDoc) LoadNativeMenus(menubarDoc, mWindow); - } -#endif // USE_NATIVE_MENUS - - OnChromeLoaded(); - - return NS_OK; -} - -NS_IMETHODIMP -AppWindow::OnLocationChange(nsIWebProgress* aProgress, nsIRequest* aRequest, - nsIURI* aURI, uint32_t aFlags) { - MOZ_ASSERT_UNREACHABLE("notification excluded in AddProgressListener(...)"); - return NS_OK; -} - -NS_IMETHODIMP -AppWindow::OnStatusChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest, - nsresult aStatus, const char16_t* aMessage) { - MOZ_ASSERT_UNREACHABLE("notification excluded in AddProgressListener(...)"); - return NS_OK; -} - -NS_IMETHODIMP -AppWindow::OnSecurityChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest, - uint32_t aState) { - MOZ_ASSERT_UNREACHABLE("notification excluded in AddProgressListener(...)"); - return NS_OK; -} - -NS_IMETHODIMP -AppWindow::OnContentBlockingEvent(nsIWebProgress* aWebProgress, - nsIRequest* aRequest, uint32_t aEvent) { - MOZ_ASSERT_UNREACHABLE("notification excluded in AddProgressListener(...)"); - return NS_OK; -} - -/** - * ExecuteCloseHandler - Run the close handler, if any. - * @return true iff we found a close handler to run. - */ -bool AppWindow::ExecuteCloseHandler() { - /* If the event handler closes this window -- a likely scenario -- - things get deleted out of order without this death grip. - (The problem may be the death grip in nsWindow::windowProc, - which forces this window's widget to remain alive longer - than it otherwise would.) */ - nsCOMPtr kungFuDeathGrip(this); - - nsCOMPtr eventTarget; - if (mDocShell) { - eventTarget = do_QueryInterface(mDocShell->GetWindow()); - } - - if (eventTarget) { - nsCOMPtr contentViewer; - mDocShell->GetContentViewer(getter_AddRefs(contentViewer)); - if (contentViewer) { - RefPtr presContext = contentViewer->GetPresContext(); - - nsEventStatus status = nsEventStatus_eIgnore; - WidgetMouseEvent event(true, eClose, nullptr, WidgetMouseEvent::eReal); - - nsresult rv = EventDispatcher::Dispatch(eventTarget, presContext, &event, - nullptr, &status); - if (NS_SUCCEEDED(rv) && status == nsEventStatus_eConsumeNoDefault) - return true; - // else fall through and return false - } - } - - return false; -} // ExecuteCloseHandler - -void AppWindow::ConstrainToOpenerScreen(int32_t* aX, int32_t* aY) { - if (mOpenerScreenRect.IsEmpty()) { - *aX = *aY = 0; - return; - } - - int32_t left, top, width, height; - // Constrain initial positions to the same screen as opener - nsCOMPtr screenmgr = - do_GetService("@mozilla.org/gfx/screenmanager;1"); - if (screenmgr) { - nsCOMPtr screen; - screenmgr->ScreenForRect( - mOpenerScreenRect.X(), mOpenerScreenRect.Y(), mOpenerScreenRect.Width(), - mOpenerScreenRect.Height(), getter_AddRefs(screen)); - if (screen) { - screen->GetAvailRectDisplayPix(&left, &top, &width, &height); - if (*aX < left || *aX > left + width) { - *aX = left; - } - if (*aY < top || *aY > top + height) { - *aY = top; - } - } - } -} - -nsIAppWindow* AppWindow::WidgetListenerDelegate::GetAppWindow() { - return mAppWindow->GetAppWindow(); -} - -PresShell* AppWindow::WidgetListenerDelegate::GetPresShell() { - return mAppWindow->GetPresShell(); -} - -bool AppWindow::WidgetListenerDelegate::WindowMoved(nsIWidget* aWidget, - int32_t aX, int32_t aY) { - RefPtr holder = mAppWindow; - return holder->WindowMoved(aWidget, aX, aY); -} - -bool AppWindow::WidgetListenerDelegate::WindowResized(nsIWidget* aWidget, - int32_t aWidth, - int32_t aHeight) { - RefPtr holder = mAppWindow; - return holder->WindowResized(aWidget, aWidth, aHeight); -} - -bool AppWindow::WidgetListenerDelegate::RequestWindowClose(nsIWidget* aWidget) { - RefPtr holder = mAppWindow; - return holder->RequestWindowClose(aWidget); -} - -void AppWindow::WidgetListenerDelegate::SizeModeChanged(nsSizeMode aSizeMode) { - RefPtr holder = mAppWindow; - holder->SizeModeChanged(aSizeMode); -} - -void AppWindow::WidgetListenerDelegate::UIResolutionChanged() { - RefPtr holder = mAppWindow; - holder->UIResolutionChanged(); -} - -void AppWindow::WidgetListenerDelegate::FullscreenWillChange( - bool aInFullscreen) { - RefPtr holder = mAppWindow; - holder->FullscreenWillChange(aInFullscreen); -} - -void AppWindow::WidgetListenerDelegate::FullscreenChanged(bool aInFullscreen) { - RefPtr holder = mAppWindow; - holder->FullscreenChanged(aInFullscreen); -} - -void AppWindow::WidgetListenerDelegate::OcclusionStateChanged( - bool aIsFullyOccluded) { - RefPtr holder = mAppWindow; - holder->OcclusionStateChanged(aIsFullyOccluded); -} - -void AppWindow::WidgetListenerDelegate::OSToolbarButtonPressed() { - RefPtr holder = mAppWindow; - holder->OSToolbarButtonPressed(); -} - -bool AppWindow::WidgetListenerDelegate::ZLevelChanged( - bool aImmediate, nsWindowZ* aPlacement, nsIWidget* aRequestBelow, - nsIWidget** aActualBelow) { - RefPtr holder = mAppWindow; - return holder->ZLevelChanged(aImmediate, aPlacement, aRequestBelow, - aActualBelow); -} - -void AppWindow::WidgetListenerDelegate::WindowActivated() { - RefPtr holder = mAppWindow; - holder->WindowActivated(); -} - -void AppWindow::WidgetListenerDelegate::WindowDeactivated() { - RefPtr holder = mAppWindow; - holder->WindowDeactivated(); -} - -} // namespace mozilla diff --git a/xpfe/appshell/AppWindow.h b/xpfe/appshell/nsXULWindow.h similarity index 56% rename from xpfe/appshell/AppWindow.h rename to xpfe/appshell/nsXULWindow.h index d202a3129727..43004dcc80ef 100644 --- a/xpfe/appshell/AppWindow.h +++ b/xpfe/appshell/nsXULWindow.h @@ -4,8 +4,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef mozilla_AppWindow_h__ -#define mozilla_AppWindow_h__ +#ifndef nsXULWindow_h__ +#define nsXULWindow_h__ // Local Includes #include "nsChromeTreeOwner.h" @@ -19,7 +19,6 @@ #include "nsCOMArray.h" #include "nsRect.h" #include "Units.h" -#include "mozilla/Mutex.h" // Interfaces needed #include "nsIBaseWindow.h" @@ -27,14 +26,12 @@ #include "nsIDocShellTreeItem.h" #include "nsIInterfaceRequestor.h" #include "nsIInterfaceRequestorUtils.h" -#include "nsIAppWindow.h" +#include "nsIXULWindow.h" #include "nsIPrompt.h" #include "nsIAuthPrompt.h" #include "nsIXULBrowserWindow.h" #include "nsIWidgetListener.h" #include "nsIRemoteTab.h" -#include "nsIWebProgressListener.h" -#include "nsITimer.h" #ifndef MOZ_NEW_XULSTORE # include "nsIXULStore.h" @@ -48,16 +45,10 @@ class Element; class nsAtom; class nsXULTooltipListener; -struct nsWidgetInitData; -namespace mozilla { -class PresShell; -class AppWindowTimerCallback; -} // namespace mozilla +// nsXULWindow -// AppWindow - -#define NS_APPWINDOW_IMPL_CID \ +#define NS_XULWINDOW_IMPL_CID \ { /* 8eaec2f3-ed02-4be2-8e0f-342798477298 */ \ 0x8eaec2f3, 0xed02, 0x4be2, { \ 0x8e, 0x0f, 0x34, 0x27, 0x98, 0x47, 0x72, 0x98 \ @@ -66,111 +57,27 @@ class AppWindowTimerCallback; class nsContentShellInfo; -namespace mozilla { - -class AppWindow final : public nsIBaseWindow, - public nsIInterfaceRequestor, - public nsIAppWindow, - public nsSupportsWeakReference, - public nsIWebProgressListener { - friend class ::nsChromeTreeOwner; - friend class ::nsContentTreeOwner; +class nsXULWindow : public nsIBaseWindow, + public nsIInterfaceRequestor, + public nsIXULWindow, + public nsSupportsWeakReference { + friend class nsChromeTreeOwner; + friend class nsContentTreeOwner; public: - // The implementation of non-refcounted nsIWidgetListener, which would hold a - // strong reference on stack before calling AppWindow's - // MOZ_CAN_RUN_SCRIPT methods. - class WidgetListenerDelegate : public nsIWidgetListener { - public: - explicit WidgetListenerDelegate(AppWindow* aAppWindow) - : mAppWindow(aAppWindow) {} - - MOZ_CAN_RUN_SCRIPT_BOUNDARY - virtual nsIAppWindow* GetAppWindow() override; - MOZ_CAN_RUN_SCRIPT_BOUNDARY - virtual mozilla::PresShell* GetPresShell() override; - MOZ_CAN_RUN_SCRIPT_BOUNDARY - virtual bool WindowMoved(nsIWidget* aWidget, int32_t x, int32_t y) override; - MOZ_CAN_RUN_SCRIPT_BOUNDARY - virtual bool WindowResized(nsIWidget* aWidget, int32_t aWidth, - int32_t aHeight) override; - MOZ_CAN_RUN_SCRIPT_BOUNDARY - virtual bool RequestWindowClose(nsIWidget* aWidget) override; - MOZ_CAN_RUN_SCRIPT_BOUNDARY - virtual void SizeModeChanged(nsSizeMode sizeMode) override; - MOZ_CAN_RUN_SCRIPT_BOUNDARY - virtual void UIResolutionChanged() override; - MOZ_CAN_RUN_SCRIPT_BOUNDARY - virtual void FullscreenWillChange(bool aInFullscreen) override; - MOZ_CAN_RUN_SCRIPT_BOUNDARY - virtual void FullscreenChanged(bool aInFullscreen) override; - MOZ_CAN_RUN_SCRIPT_BOUNDARY - virtual void OcclusionStateChanged(bool aIsFullyOccluded) override; - MOZ_CAN_RUN_SCRIPT_BOUNDARY - virtual void OSToolbarButtonPressed() override; - MOZ_CAN_RUN_SCRIPT_BOUNDARY - virtual bool ZLevelChanged(bool aImmediate, nsWindowZ* aPlacement, - nsIWidget* aRequestBelow, - nsIWidget** aActualBelow) override; - MOZ_CAN_RUN_SCRIPT_BOUNDARY - virtual void WindowActivated() override; - MOZ_CAN_RUN_SCRIPT_BOUNDARY - virtual void WindowDeactivated() override; - - private: - // The lifetime of WidgetListenerDelegate is bound to AppWindow so - // we just use a raw pointer here. - AppWindow* mAppWindow; - }; - NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_NSIINTERFACEREQUESTOR - NS_DECL_NSIAPPWINDOW + NS_DECL_NSIXULWINDOW NS_DECL_NSIBASEWINDOW - NS_DECLARE_STATIC_IID_ACCESSOR(NS_APPWINDOW_IMPL_CID) + NS_DECLARE_STATIC_IID_ACCESSOR(NS_XULWINDOW_IMPL_CID) void LockUntilChromeLoad() { mLockedUntilChromeLoad = true; } bool IsLocked() const { return mLockedUntilChromeLoad; } void IgnoreXULSizeMode(bool aEnable) { mIgnoreXULSizeMode = aEnable; } void WasRegistered() { mRegistered = true; } - // AppWindow methods... - nsresult Initialize(nsIAppWindow* aParent, nsIAppWindow* aOpener, - nsIURI* aUrl, int32_t aInitialWidth, - int32_t aInitialHeight, bool aIsHiddenWindow, - nsIRemoteTab* aOpeningTab, - mozIDOMWindowProxy* aOpenerWIndow, - nsWidgetInitData& widgetInitData); - - nsresult Toolbar(); - - // nsIWebProgressListener - NS_DECL_NSIWEBPROGRESSLISTENER - - // nsIWidgetListener methods for WidgetListenerDelegate. - nsIAppWindow* GetAppWindow() { return this; } - mozilla::PresShell* GetPresShell(); - MOZ_CAN_RUN_SCRIPT - bool WindowMoved(nsIWidget* aWidget, int32_t aX, int32_t aY); - MOZ_CAN_RUN_SCRIPT - bool WindowResized(nsIWidget* aWidget, int32_t aWidth, int32_t aHeight); - MOZ_CAN_RUN_SCRIPT bool RequestWindowClose(nsIWidget* aWidget); - MOZ_CAN_RUN_SCRIPT void SizeModeChanged(nsSizeMode aSizeMode); - MOZ_CAN_RUN_SCRIPT void UIResolutionChanged(); - MOZ_CAN_RUN_SCRIPT void FullscreenWillChange(bool aInFullscreen); - MOZ_CAN_RUN_SCRIPT void FullscreenChanged(bool aInFullscreen); - MOZ_CAN_RUN_SCRIPT void OcclusionStateChanged(bool aIsFullyOccluded); - MOZ_CAN_RUN_SCRIPT void OSToolbarButtonPressed(); - MOZ_CAN_RUN_SCRIPT - bool ZLevelChanged(bool aImmediate, nsWindowZ* aPlacement, - nsIWidget* aRequestBelow, nsIWidget** aActualBelow); - MOZ_CAN_RUN_SCRIPT void WindowActivated(); - MOZ_CAN_RUN_SCRIPT void WindowDeactivated(); - - explicit AppWindow(uint32_t aChromeFlags); - protected: enum persistentAttributes { PAD_MISC = 0x1, @@ -178,15 +85,8 @@ class AppWindow final : public nsIBaseWindow, PAD_SIZE = 0x4 }; - virtual ~AppWindow(); - - friend class mozilla::AppWindowTimerCallback; - - bool ExecuteCloseHandler(); - void ConstrainToOpenerScreen(int32_t* aX, int32_t* aY); - - void SetPersistenceTimer(uint32_t aDirtyFlags); - void FirePersistenceTimer(); + explicit nsXULWindow(uint32_t aChromeFlags); + virtual ~nsXULWindow(); NS_IMETHOD EnsureChromeTreeOwner(); NS_IMETHOD EnsureContentTreeOwner(); @@ -229,19 +129,19 @@ class AppWindow final : public nsIBaseWindow, NS_IMETHOD CreateNewChromeWindow(int32_t aChromeFlags, nsIRemoteTab* aOpeningTab, mozIDOMWindowProxy* aOpenerWindow, - nsIAppWindow** _retval); + nsIXULWindow** _retval); NS_IMETHOD CreateNewContentWindow(int32_t aChromeFlags, nsIRemoteTab* aOpeningTab, mozIDOMWindowProxy* aOpenerWindow, uint64_t aNextRemoteTabId, - nsIAppWindow** _retval); + nsIXULWindow** _retval); NS_IMETHOD GetHasPrimaryContent(bool* aResult); void EnableParent(bool aEnable); bool ConstrainToZLevel(bool aImmediate, nsWindowZ* aPlacement, nsIWidget* aReqBelow, nsIWidget** aActualBelow); void PlaceWindowLayersBehind(uint32_t aLowLevel, uint32_t aHighLevel, - nsIAppWindow* aBehind); + nsIXULWindow* aBehind); void SetContentScrollbarVisibility(bool aVisible); bool GetContentScrollbarVisibility(); void PersistentAttributesDirty(uint32_t aDirtyFlags); @@ -289,10 +189,6 @@ class AppWindow final : public nsIBaseWindow, nsCOMPtr mPrimaryBrowserParent; - nsCOMPtr mSPTimer; - mozilla::Mutex mSPTimerLock; - WidgetListenerDelegate mWidgetListenerDelegate; - private: // GetPrimaryBrowserParentSize is called from xpidl methods and we don't have // a good way to annotate those with MOZ_CAN_RUN_SCRIPT yet. It takes no @@ -306,8 +202,5 @@ class AppWindow final : public nsIBaseWindow, #endif }; -NS_DEFINE_STATIC_IID_ACCESSOR(AppWindow, NS_APPWINDOW_IMPL_CID) - -} // namespace mozilla - -#endif /* mozilla_AppWindow_h__ */ +NS_DEFINE_STATIC_IID_ACCESSOR(nsXULWindow, NS_XULWINDOW_IMPL_CID) +#endif /* nsXULWindow_h__ */