Bug 1602915 - Remove nsIBrowserDOMWindow.isTabContentWindow. r=mossop,marionette-reviewers,whimboo

This only works for non-e10s and it also seems superseded by the
mPendingClose as per the comment.

Differential Revision: https://phabricator.services.mozilla.com/D92003
This commit is contained in:
Emilio Cobos Álvarez
2020-10-13 16:58:37 +00:00
parent 1f795c78eb
commit aa39e68d1f
6 changed files with 5 additions and 64 deletions

View File

@@ -6359,10 +6359,6 @@ nsBrowserAccess.prototype = {
);
},
isTabContentWindow(aWindow) {
return gBrowser.browsers.some(browser => browser.contentWindow == aWindow);
},
canClose() {
return CanCloseWindow();
},

View File

@@ -245,11 +245,6 @@ class BrowserDOMWindow {
);
}
isTabContentWindow(window) {
// This method is probably not needed anymore: bug 1602915
return gSSBBrowser.contentWindow == window;
}
canClose() {
/* globals docShell */
for (let i = 0; i < docShell.childCount; i++) {

View File

@@ -6386,44 +6386,12 @@ void nsGlobalWindowOuter::ReallyCloseWindow() {
mHavePendingClose = true;
nsCOMPtr<nsIBaseWindow> treeOwnerAsWin = GetTreeOwnerWindow();
// If there's no treeOwnerAsWin, this window must already be closed.
if (treeOwnerAsWin) {
// but if we're a browser window we could be in some nasty
// self-destroying cascade that we should mostly ignore
if (mDocShell) {
nsCOMPtr<nsIBrowserDOMWindow> bwin;
nsCOMPtr<nsIDocShellTreeItem> rootItem;
mDocShell->GetInProcessRootTreeItem(getter_AddRefs(rootItem));
nsCOMPtr<nsPIDOMWindowOuter> rootWin =
rootItem ? rootItem->GetWindow() : nullptr;
nsCOMPtr<nsIDOMChromeWindow> chromeWin(do_QueryInterface(rootWin));
if (chromeWin) chromeWin->GetBrowserDOMWindow(getter_AddRefs(bwin));
if (rootWin) {
/* Normally we destroy the entire window, but not if
this DOM window belongs to a tabbed browser and doesn't
correspond to a tab. This allows a well-behaved tab
to destroy the container as it should but is a final measure
to prevent an errant tab from doing so when it shouldn't.
This works because we reach this code when we shouldn't only
in the particular circumstance that we belong to a tab
that has just been closed (and is therefore already missing
from the list of browsers) (and has an unload handler
that closes the window). */
// XXXbz now that we have mHavePendingClose, is this needed?
bool isTab;
if (rootWin == this || !bwin ||
(NS_SUCCEEDED(bwin->IsTabContentWindow(this, &isTab)) && isTab)) {
treeOwnerAsWin->Destroy();
}
}
}
CleanUp();
if (!treeOwnerAsWin) {
return;
}
treeOwnerAsWin->Destroy();
CleanUp();
}
void nsGlobalWindowOuter::EnterModalState() {

View File

@@ -175,13 +175,6 @@ interface nsIBrowserDOMWindow : nsISupports
in short aWhere, in long aFlags,
in AString aName);
/**
* @param aWindow the window to test.
* @return whether the window is the main content window for any
* currently open tab in this toplevel browser window.
*/
boolean isTabContentWindow(in nsIDOMWindow aWindow);
/**
* This function is responsible for calling
* nsIContentViewer::PermitUnload on each frame in the window. It

View File

@@ -534,11 +534,6 @@ class GeckoViewNavigation extends GeckoViewModule {
return browser;
}
// nsIBrowserDOMWindow.
isTabContentWindow(aWindow) {
return this.browser.contentWindow === aWindow;
}
// nsIBrowserDOMWindow.
canClose() {
debug`canClose`;

View File

@@ -62,12 +62,6 @@ BrowserDOMWindow.prototype = {
get tabCount() {
return 1;
},
isTabContentWindow(win) {
// This method is probably not needed anymore: bug 1602915
// In any case this gives us the default behavior.
return false;
},
};
window.browserDOMWindow = new BrowserDOMWindow();