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
This commit is contained in:
Dorel Luca 2019-11-04 19:18:56 +02:00
Родитель b1b874a300
Коммит 0207ce5451
71 изменённых файлов: 1673 добавлений и 1557 удалений

Просмотреть файл

@ -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<nsIDocShell> docShell = nsCoreUtils::GetDocShellFor(mDocumentNode);
NS_ENSURE_TRUE(docShell, 0);
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
docShell->GetTreeOwner(getter_AddRefs(treeOwner));
NS_ENSURE_TRUE(treeOwner, 0);
nsCOMPtr<nsIAppWindow> appWin(do_GetInterface(treeOwner));
if (!appWin) {
nsCOMPtr<nsIXULWindow> xulWin(do_GetInterface(treeOwner));
if (!xulWin) {
return 0;
}
uint32_t chromeFlags;
appWin->GetChromeFlags(&chromeFlags);
xulWin->GetChromeFlags(&chromeFlags);
return chromeFlags;
}
#endif

Просмотреть файл

@ -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;
},
};

Просмотреть файл

@ -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 {

Просмотреть файл

@ -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

Просмотреть файл

@ -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() {

Просмотреть файл

@ -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],

Просмотреть файл

@ -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(

Просмотреть файл

@ -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") !=

Просмотреть файл

@ -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;
}
}

Просмотреть файл

@ -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);

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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<nsIBaseWindow> 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;
}

Просмотреть файл

@ -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;

Просмотреть файл

@ -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<nsIAppWindow> win = GetAppWindowIfToplevelChrome()) {
if (nsCOMPtr<nsIXULWindow> win = GetXULWindowIfToplevelChrome()) {
// We're the chrome document!
win->BeforeStartLayout();
}
@ -14275,23 +14275,23 @@ already_AddRefed<XPathResult> Document::Evaluate(
aType, aResult, rv);
}
already_AddRefed<nsIAppWindow> Document::GetAppWindowIfToplevelChrome() const {
already_AddRefed<nsIXULWindow> Document::GetXULWindowIfToplevelChrome() const {
nsCOMPtr<nsIDocShellTreeItem> item = GetDocShell();
if (!item) {
return nullptr;
}
nsCOMPtr<nsIDocShellTreeOwner> owner;
item->GetTreeOwner(getter_AddRefs(owner));
nsCOMPtr<nsIAppWindow> appWin = do_GetInterface(owner);
if (!appWin) {
nsCOMPtr<nsIXULWindow> xulWin = do_GetInterface(owner);
if (!xulWin) {
return nullptr;
}
nsCOMPtr<nsIDocShell> appWinShell;
appWin->GetDocShell(getter_AddRefs(appWinShell));
if (!SameCOMIdentity(appWinShell, item)) {
nsCOMPtr<nsIDocShell> xulWinShell;
xulWin->GetDocShell(getter_AddRefs(xulWinShell));
if (!SameCOMIdentity(xulWinShell, item)) {
return nullptr;
}
return appWin.forget();
return xulWin.forget();
}
Document* Document::GetTopLevelContentDocument() {

Просмотреть файл

@ -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<nsIAppWindow> GetAppWindowIfToplevelChrome() const;
already_AddRefed<nsIXULWindow> GetXULWindowIfToplevelChrome() const;
already_AddRefed<Element> CreateElement(
const nsAString& aTagName, const ElementCreationOptionsOrString& aOptions,

Просмотреть файл

@ -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<nsIAppWindow> hw;
nsCOMPtr<nsIXULWindow> hw;
appShell->GetHiddenWindow(getter_AddRefs(hw));
nsCOMPtr<nsIDocShell> shell;
hw->GetDocShell(getter_AddRefs(shell));

Просмотреть файл

@ -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<nsIAppWindow> appWin(do_GetInterface(baseWindow));
Focus(currentWindow, currentFocus, 0, true, false, appWin != nullptr, true);
nsCOMPtr<nsIXULWindow> xulWin(do_GetInterface(baseWindow));
Focus(currentWindow, currentFocus, 0, true, false, xulWin != nullptr, true);
return NS_OK;
}

Просмотреть файл

@ -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<nsIAppWindow> window(do_GetInterface(parentOwner));
nsCOMPtr<nsIXULWindow> window(do_GetInterface(parentOwner));
if (window && NS_FAILED(window->GetChromeFlags(&chromeFlags))) {
return false;
}

Просмотреть файл

@ -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

Просмотреть файл

@ -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<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
nsCOMPtr<nsIAppWindow> appWin(do_GetInterface(treeOwnerAsWin));
if (aFullscreen && appWin) {
appWin->SetIntrinsicallySized(false);
nsCOMPtr<nsIXULWindow> 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<nsPIDOMWindowOuter> topLevelWindow;
// widgetListener should be an AppWindow
// widgetListener should be a nsXULWindow
nsIWidgetListener* listener = topLevelWidget->GetWidgetListener();
if (listener) {
nsCOMPtr<nsIAppWindow> window = listener->GetAppWindow();
nsCOMPtr<nsIXULWindow> window = listener->GetXULWindow();
nsCOMPtr<nsIInterfaceRequestor> req(do_QueryInterface(window));
topLevelWindow = do_GetInterface(req);
}

Просмотреть файл

@ -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<nsIAppWindow> window = do_GetInterface(treeOwner);
nsCOMPtr<nsIXULWindow> window = do_GetInterface(treeOwner);
if (!window) {
return nullptr;
}
@ -798,9 +798,9 @@ mozilla::ipc::IPCResult BrowserParent::RecvSizeShellTo(
height = mDimensions.height;
}
nsCOMPtr<nsIAppWindow> appWin(do_GetInterface(treeOwner));
NS_ENSURE_TRUE(appWin, IPC_OK());
appWin->SizeShellToWithLimit(width, height, aShellItemWidth,
nsCOMPtr<nsIXULWindow> xulWin(do_GetInterface(treeOwner));
NS_ENSURE_TRUE(xulWin, IPC_OK());
xulWin->SizeShellToWithLimit(width, height, aShellItemWidth,
aShellItemHeight);
return IPC_OK();

Просмотреть файл

@ -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"

Просмотреть файл

@ -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<nsIAppWindow> win =
mDocument->GetAppWindowIfToplevelChrome()) {
if (nsCOMPtr<nsIXULWindow> 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<nsIAppWindow> win =
mDocument->GetAppWindowIfToplevelChrome()) {
if (nsCOMPtr<nsIXULWindow> win =
mDocument->GetXULWindowIfToplevelChrome()) {
continue;
}
}

Просмотреть файл

@ -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);

Просмотреть файл

@ -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();

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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;
}
}

Просмотреть файл

@ -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";

Просмотреть файл

@ -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<nsIDocShellTreeOwner> owner;
docShell->GetTreeOwner(getter_AddRefs(owner));
nsCOMPtr<nsIAppWindow> ownerAppWindow = do_GetInterface(owner);
nsCOMPtr<mozIDOMWindowProxy> ownerWindow = do_GetInterface(ownerAppWindow);
nsCOMPtr<nsIXULWindow> ownerXULWindow = do_GetInterface(owner);
nsCOMPtr<mozIDOMWindowProxy> ownerWindow = do_GetInterface(ownerXULWindow);
NS_ENSURE_STATE(ownerWindow);
nsCOMPtr<nsPIDOMWindowOuter> piOwnerWindow =

Просмотреть файл

@ -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 =

Просмотреть файл

@ -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<nsIAppWindow> window(do_GetInterface(treeOwner));
nsCOMPtr<nsIXULWindow> window(do_GetInterface(treeOwner));
if (!window) {
return false;
}

Просмотреть файл

@ -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<nsIAppWindow> hiddenWindow;
nsCOMPtr<nsIXULWindow> 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<nsIAppWindow> newWindow;
nsCOMPtr<nsIXULWindow> newWindow;
if (aParent) {
nsCOMPtr<nsIAppWindow> appParent(do_GetInterface(aParent));
NS_ASSERTION(appParent,
"window created using non-app parent. that's unexpected, but "
nsCOMPtr<nsIXULWindow> 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).

Просмотреть файл

@ -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<nsIAppWindow> appWin = do_GetInterface(newChrome);
if (appWin) {
nsCOMPtr<nsIXULWindow> xulWin = do_GetInterface(newChrome);
if (xulWin) {
nsCOMPtr<nsIXULBrowserWindow> 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<nsPIDOMWindowOuter> newWindow(do_GetInterface(newChrome));
@ -2372,9 +2372,9 @@ void nsWindowWatcher::SizeOpenedWindow(nsIDocShellTreeOwner* aTreeOwner,
}
if (aIsCallerChrome) {
nsCOMPtr<nsIAppWindow> appWin = do_GetInterface(treeOwnerAsWin);
if (appWin && aSizeSpec.mLockAspectRatio) {
appWin->LockAspectRatio(true);
nsCOMPtr<nsIXULWindow> xulWin = do_GetInterface(treeOwnerAsWin);
if (xulWin && aSizeSpec.mLockAspectRatio) {
xulWin->LockAspectRatio(true);
}
}

Просмотреть файл

@ -152,7 +152,7 @@ registerCleanupFunction(() => {
function getParentChromeFlags(win) {
return win.docShell.treeOwner
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIAppWindow).chromeFlags;
.getInterface(Ci.nsIXULWindow).chromeFlags;
}
/**

Просмотреть файл

@ -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"

Просмотреть файл

@ -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.");

Просмотреть файл

@ -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");

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -66,7 +66,7 @@
window.docShell
.treeOwner
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIAppWindow)
.getInterface(Ci.nsIXULWindow)
.XULBrowserWindow = gXULBrowserWindow;
gFindBar = document.getElementById("FindToolbar");

Просмотреть файл

@ -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;

Просмотреть файл

@ -44,6 +44,8 @@
* "soft" shutdown, passwords are flushed.
*/
interface nsIXULWindow;
[scriptable, uuid(5fdf8480-1f98-11d4-8077-00600811a9c3)]
interface nsINativeAppSupport : nsISupports {
// Startup/shutdown.

Просмотреть файл

@ -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<nsIAppWindow> appWindow(window->mWidgetListener->GetAppWindow());
if (appWindow) {
// Our window is not intrinsically sized, so tell AppWindow to
nsCOMPtr<nsIXULWindow> 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);
}
}
}

Просмотреть файл

@ -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<nsIAppWindow> hiddenWindow;
nsCOMPtr<nsIXULWindow> 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<nsIBaseWindow> 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;
}

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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<nsIAppWindow> window = mWidgetListener->GetAppWindow();
nsCOMPtr<nsIBaseWindow> appWindow(do_QueryInterface(window));
if (appWindow) {
appWindow->Destroy();
nsCOMPtr<nsIXULWindow> window = mWidgetListener->GetXULWindow();
nsCOMPtr<nsIBaseWindow> xulWindow(do_QueryInterface(window));
if (xulWindow) {
xulWindow->Destroy();
}
}
@ -2028,11 +2028,11 @@ void nsBaseWidget::NotifyLiveResizeStarted() {
if (!mWidgetListener) {
return;
}
nsCOMPtr<nsIAppWindow> appWindow = mWidgetListener->GetAppWindow();
if (!appWindow) {
nsCOMPtr<nsIXULWindow> xulWindow = mWidgetListener->GetXULWindow();
if (!xulWindow) {
return;
}
mLiveResizeListeners = appWindow->GetLiveResizeListeners();
mLiveResizeListeners = xulWindow->GetLiveResizeListeners();
for (uint32_t i = 0; i < mLiveResizeListeners.Length(); i++) {
mLiveResizeListeners[i]->LiveResizeStarted();
}

Просмотреть файл

@ -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; }

Просмотреть файл

@ -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.

Просмотреть файл

@ -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<nsIAppWindow> appWindow;
nsCOMPtr<nsIXULWindow> 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<nsIDOMWindow> window = do_GetInterface(appWindow);
nsCOMPtr<nsIDOMWindow> window = do_GetInterface(xulWindow);
if (!window) {
fail("Can't get dom window!");
return false;

Просмотреть файл

@ -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<nsIAppShellService> appShell(
do_GetService(NS_APPSHELLSERVICE_CONTRACTID));
nsCOMPtr<nsIAppWindow> hiddenWindow;
nsCOMPtr<nsIXULWindow> hiddenWindow;
nsresult rv = appShell->GetHiddenWindow(getter_AddRefs(hiddenWindow));
if (NS_FAILED(rv)) {

Просмотреть файл

@ -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"

Просмотреть файл

@ -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 += [

Просмотреть файл

@ -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<AppWindow> newWindow;
RefPtr<nsWebShellWindow> 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<AppWindow> newWindow;
RefPtr<nsWebShellWindow> 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<nsIAppWindow> parent;
nsCOMPtr<nsIXULWindow> 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<nsISimpleEnumerator> 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<nsIAppWindow> parent;
nsCOMPtr<nsIXULWindow> parent;
if (aChromeMask & nsIWebBrowserChrome::CHROME_DEPENDENT) parent = aParent;
RefPtr<AppWindow> window = new AppWindow(aChromeMask);
RefPtr<nsWebShellWindow> 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<nsIDocShell> docShell;
@ -816,15 +816,15 @@ nsAppShellService::RegisterTopLevelWindow(nsIAppWindow* aWindow) {
if (obssvc) {
obssvc->NotifyObservers(aWindow, "xul-window-registered", nullptr);
AppWindow* appWindow = static_cast<AppWindow*>(aWindow);
appWindow->WasRegistered();
nsXULWindow* xulWindow = static_cast<nsXULWindow*>(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

Просмотреть файл

@ -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<mozilla::AppWindow> mHiddenWindow;
RefPtr<nsWebShellWindow> mHiddenWindow;
bool mXPCOMWillShutDown;
bool mXPCOMShuttingDown;
uint16_t mModalWindowCount;

Просмотреть файл

@ -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<nsIContentViewer> 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<nsIDocShell> 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;

Просмотреть файл

@ -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<nsIAppWindow> mWindow;
nsCOMPtr<nsIXULWindow> 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;

Просмотреть файл

@ -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<dom::Element> docShellElement = mAppWindow->GetWindowDOMElement();
NS_ENSURE_STATE(mXULWindow);
nsCOMPtr<dom::Element> 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<dom::Element> docShellElement = mAppWindow->GetWindowDOMElement();
NS_ENSURE_STATE(mXULWindow);
nsCOMPtr<dom::Element> 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<nsIDocShell> docshell;
mAppWindow->GetDocShell(getter_AddRefs(docshell));
mXULWindow->GetDocShell(getter_AddRefs(docshell));
nsCOMPtr<nsIWebProgress> 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; }

Просмотреть файл

@ -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__ */

Просмотреть файл

@ -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<nsIDocShell> 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<nsIDocShellTreeItem> shell;
mAppWindow->GetPrimaryContentShell(getter_AddRefs(shell));
mXULWindow->GetPrimaryContentShell(getter_AddRefs(shell));
if (shell) {
nsCOMPtr<nsIInterfaceRequestor> 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<dom::Element> docShellElement = mAppWindow->GetWindowDOMElement();
NS_ENSURE_STATE(mXULWindow);
nsCOMPtr<dom::Element> 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<dom::Element> docShellElement = mAppWindow->GetWindowDOMElement();
NS_ENSURE_STATE(mXULWindow);
nsCOMPtr<dom::Element> 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<nsIXULBrowserWindow> 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<nsIXULBrowserWindow> 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<nsIXULBrowserWindow> 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<mozIDOMWindowProxy> domWin;
mAppWindow->GetWindowDOMWindow(getter_AddRefs(domWin));
mXULWindow->GetWindowDOMWindow(getter_AddRefs(domWin));
nsCOMPtr<nsIDOMChromeWindow> 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<nsIDocShell> docshell;
window->GetDocShell(getter_AddRefs(docshell));
@ -827,15 +825,15 @@ nsSiteWindow::Blur(void) {
NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID);
nsCOMPtr<nsISimpleEnumerator> windowEnumerator;
nsCOMPtr<nsIAppWindow> appWindow;
nsCOMPtr<nsIXULWindow> xulWindow;
bool more, foundUs;
AppWindow* ourWindow = mAggregator->AppWindow();
nsXULWindow* ourWindow = mAggregator->XULWindow();
{
nsCOMPtr<nsIWindowMediator> 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<nsISupports> nextWindow;
nsCOMPtr<nsIAppWindow> nextAppWindow;
nsCOMPtr<nsIXULWindow> 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<nsIDocShell> docshell;
appWindow->GetDocShell(getter_AddRefs(docshell));
xulWindow->GetDocShell(getter_AddRefs(docshell));
if (!docshell) {
return NS_OK;
}

Просмотреть файл

@ -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;
};

Просмотреть файл

@ -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.

Просмотреть файл

@ -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)

Просмотреть файл

@ -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);
};

Просмотреть файл

@ -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<RefPtr<mozilla::LiveResizeListener>>);
[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);

Просмотреть файл

@ -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<nsIWidget> parentWidget;
mIsHiddenWindow = aIsHiddenWindow;
int32_t initialX = 0, initialY = 0;
nsCOMPtr<nsIBaseWindow> 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<nsIBaseWindow> 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<BrowsingContext> openerContext =
aOpenerWindow
? nsPIDOMWindowOuter::From(aOpenerWindow)->GetBrowsingContext()
: nullptr;
RefPtr<BrowsingContext> 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<nsIDocShellTreeItem> docShellAsItem(mDocShell);
NS_ENSURE_TRUE(docShellAsItem, NS_ERROR_FAILURE);
NS_ENSURE_SUCCESS(EnsureChromeTreeOwner(), NS_ERROR_FAILURE);
docShellAsItem->SetTreeOwner(mChromeTreeOwner);
r.MoveTo(0, 0);
nsCOMPtr<nsIBaseWindow> 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<nsIWebProgress> 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<nsIPrincipal> 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<Document> 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<nsIWebNavigation> 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<nsPIDOMWindowOuter> window =
mDocShell ? mDocShell->GetWindow() : nullptr;
pm->AdjustPopupsOnWindowChange(window);
}
// Notify all tabs that the widget moved.
if (mDocShell && mDocShell->GetWindow()) {
nsCOMPtr<EventTarget> 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<nsIBaseWindow> 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<nsIXULWindow> xulWindow(this);
nsCOMPtr<nsPIDOMWindowOuter> window(mDocShell ? mDocShell->GetWindow()
: nullptr);
nsCOMPtr<EventTarget> eventTarget = do_QueryInterface(window);
RefPtr<PresShell> presShell = mDocShell->GetPresShell();
if (!presShell) {
mozilla::DebugOnly<bool> dying;
MOZ_ASSERT(NS_SUCCEEDED(mDocShell->IsBeingDestroyed(&dying)) && dying,
"No presShell, but window is not being destroyed");
} else if (eventTarget) {
RefPtr<nsPresContext> 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<nsPIDOMWindowOuter> 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<nsPIDOMWindowOuter> ourWindow =
mDocShell ? mDocShell->GetWindow() : nullptr;
if (ourWindow) {
ourWindow->DispatchCustomEvent(NS_LITERAL_STRING("resolutionchange"));
}
}
void nsWebShellWindow::FullscreenWillChange(bool aInFullscreen) {
if (mDocShell) {
if (nsCOMPtr<nsPIDOMWindowOuter> ourWindow = mDocShell->GetWindow()) {
ourWindow->FullscreenWillChange(aInFullscreen);
}
}
}
void nsWebShellWindow::FullscreenChanged(bool aInFullscreen) {
if (mDocShell) {
if (nsCOMPtr<nsPIDOMWindowOuter> ourWindow = mDocShell->GetWindow()) {
ourWindow->FinishFullscreenChange(aInFullscreen);
}
}
}
void nsWebShellWindow::OcclusionStateChanged(bool aIsFullyOccluded) {
nsCOMPtr<nsPIDOMWindowOuter> 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<nsIXULWindow> 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<nsIWebBrowserChrome> 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<nsIXULWindow> xulWindow(this);
// focusing the window could cause it to close, so keep a reference to it
nsCOMPtr<nsPIDOMWindowOuter> 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<nsIXULWindow> xulWindow(this);
nsCOMPtr<nsPIDOMWindowOuter> 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<nsINativeMenuService> 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<nsINodeList> menubarElements = aDoc->GetElementsByTagNameNS(
NS_LITERAL_STRING(
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"),
NS_LITERAL_STRING("menubar"));
nsCOMPtr<nsINode> menubarNode;
if (menubarElements) {
menubarNode = menubarElements->Item(0);
}
if (menubarNode) {
nsCOMPtr<Element> 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<nsWebShellWindow> 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<WebShellWindowTimerCallback> 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<mozIDOMWindowProxy> 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<nsIContentViewer> cv;
mDocShell->GetContentViewer(getter_AddRefs(cv));
if (cv) {
RefPtr<Document> 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<nsIXULWindow> kungFuDeathGrip(this);
nsCOMPtr<EventTarget> eventTarget;
if (mDocShell) {
eventTarget = do_QueryInterface(mDocShell->GetWindow());
}
if (eventTarget) {
nsCOMPtr<nsIContentViewer> contentViewer;
mDocShell->GetContentViewer(getter_AddRefs(contentViewer));
if (contentViewer) {
RefPtr<nsPresContext> 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<nsIScreenManager> screenmgr =
do_GetService("@mozilla.org/gfx/screenmanager;1");
if (screenmgr) {
nsCOMPtr<nsIScreen> 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<nsIWebProgress> webProgress(do_GetInterface(mDocShell, &rv));
if (webProgress) {
webProgress->RemoveProgressListener(this);
}
nsCOMPtr<nsIXULWindow> 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<nsWebShellWindow> holder = mWebShellWindow;
return holder->WindowMoved(aWidget, aX, aY);
}
bool nsWebShellWindow::WidgetListenerDelegate::WindowResized(nsIWidget* aWidget,
int32_t aWidth,
int32_t aHeight) {
RefPtr<nsWebShellWindow> holder = mWebShellWindow;
return holder->WindowResized(aWidget, aWidth, aHeight);
}
bool nsWebShellWindow::WidgetListenerDelegate::RequestWindowClose(
nsIWidget* aWidget) {
RefPtr<nsWebShellWindow> holder = mWebShellWindow;
return holder->RequestWindowClose(aWidget);
}
void nsWebShellWindow::WidgetListenerDelegate::SizeModeChanged(
nsSizeMode aSizeMode) {
RefPtr<nsWebShellWindow> holder = mWebShellWindow;
holder->SizeModeChanged(aSizeMode);
}
void nsWebShellWindow::WidgetListenerDelegate::UIResolutionChanged() {
RefPtr<nsWebShellWindow> holder = mWebShellWindow;
holder->UIResolutionChanged();
}
void nsWebShellWindow::WidgetListenerDelegate::FullscreenWillChange(
bool aInFullscreen) {
RefPtr<nsWebShellWindow> holder = mWebShellWindow;
holder->FullscreenWillChange(aInFullscreen);
}
void nsWebShellWindow::WidgetListenerDelegate::FullscreenChanged(
bool aInFullscreen) {
RefPtr<nsWebShellWindow> holder = mWebShellWindow;
holder->FullscreenChanged(aInFullscreen);
}
void nsWebShellWindow::WidgetListenerDelegate::OcclusionStateChanged(
bool aIsFullyOccluded) {
RefPtr<nsWebShellWindow> holder = mWebShellWindow;
holder->OcclusionStateChanged(aIsFullyOccluded);
}
void nsWebShellWindow::WidgetListenerDelegate::OSToolbarButtonPressed() {
RefPtr<nsWebShellWindow> holder = mWebShellWindow;
holder->OSToolbarButtonPressed();
}
bool nsWebShellWindow::WidgetListenerDelegate::ZLevelChanged(
bool aImmediate, nsWindowZ* aPlacement, nsIWidget* aRequestBelow,
nsIWidget** aActualBelow) {
RefPtr<nsWebShellWindow> holder = mWebShellWindow;
return holder->ZLevelChanged(aImmediate, aPlacement, aRequestBelow,
aActualBelow);
}
void nsWebShellWindow::WidgetListenerDelegate::WindowActivated() {
RefPtr<nsWebShellWindow> holder = mWebShellWindow;
holder->WindowActivated();
}
void nsWebShellWindow::WidgetListenerDelegate::WindowDeactivated() {
RefPtr<nsWebShellWindow> holder = mWebShellWindow;
holder->WindowDeactivated();
}

Просмотреть файл

@ -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<nsITimer> mSPTimer;
mozilla::Mutex mSPTimerLock;
WidgetListenerDelegate mWidgetListenerDelegate;
void SetPersistenceTimer(uint32_t aDirtyFlags);
void FirePersistenceTimer();
};
#endif /* nsWebShellWindow_h__ */

Просмотреть файл

@ -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<nsPIDOMWindowOuter>& outDOMWindow) {
nsIXULWindow* inWindow, nsCOMPtr<nsPIDOMWindowOuter>& outDOMWindow) {
nsCOMPtr<nsIDocShell> 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<nsAppShellWindowEnumerator> 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<nsAppShellWindowEnumerator> 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);

Просмотреть файл

@ -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<nsPIDOMWindowOuter>& 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();

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -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<nsIRemoteTab> mPrimaryBrowserParent;
nsCOMPtr<nsITimer> 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__ */