Bug 1492950 - Get tabbrowser.js and browser.js off of _getTabForContentWindow. r=NeilDeakin
authorMike Conley <mconley@mozilla.com>
Tue, 02 Oct 2018 17:53:47 +0000
changeset 494957 1940595cb776790de40008a4b90d54356f5e5753
parent 494956 a1b2eb69cd3c3c99091518ef41dee7f9efd06373
child 494958 48be1c7d47ef2dbc664d350dbe7f1837d1d39ce7
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersNeilDeakin
bugs1492950
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1492950 - Get tabbrowser.js and browser.js off of _getTabForContentWindow. r=NeilDeakin Depends on D6715 Differential Revision: https://phabricator.services.mozilla.com/D6716
browser/base/content/browser.js
browser/base/content/tabbrowser.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -7200,18 +7200,18 @@ function BrowserOpenAddonsMgr(aView) {
     Services.obs.addObserver(receivePong, "EM-pong");
     Services.obs.notifyObservers(null, "EM-ping");
     Services.obs.removeObserver(receivePong, "EM-pong");
 
     if (emWindow) {
       if (aView) {
         emWindow.loadView(aView);
       }
-      browserWindow.gBrowser.selectedTab =
-        browserWindow.gBrowser._getTabForContentWindow(emWindow);
+      let tab = browserWindow.gBrowser.getTabForBrowser(emWindow.docShell.chromeEventHandler);
+      browserWindow.gBrowser.selectedTab = tab;
       emWindow.focus();
       resolve(emWindow);
       return;
     }
 
     // This must be a new load, else the ping/pong would have
     // found the window above.
     let whereToOpen = (window.gBrowser && isTabEmpty(gBrowser.selectedTab)) ?
--- a/browser/base/content/tabbrowser.js
+++ b/browser/base/content/tabbrowser.js
@@ -4439,17 +4439,18 @@ window._gBrowser = {
       if (this.tabs.length == 1) {
         // We already did PermitUnload in nsGlobalWindow::Close
         // for this tab. There are no other tabs we need to do
         // PermitUnload for.
         window.skipNextCanClose = true;
         return;
       }
 
-      var tab = this._getTabForContentWindow(event.target);
+      let browser = event.target.docShell.chromeEventHandler;
+      let tab = this.getTabForBrowser(browser);
       if (tab) {
         // Skip running PermitUnload since it already happened.
         this.removeTab(tab, { skipPermitUnload: true });
         event.preventDefault();
       }
     }, true);
 
     this.addEventListener("DOMWillOpenModalDialog", (event) => {
@@ -4459,17 +4460,17 @@ window._gBrowser = {
       let targetIsWindow = event.target instanceof Window;
 
       // We're about to open a modal dialog, so figure out for which tab:
       // If this is a same-process modal dialog, then we're given its DOM
       // window as the event's target. For remote dialogs, we're given the
       // browser, but that's in the originalTarget and not the target,
       // because it's across the tabbrowser's XBL boundary.
       let tabForEvent = targetIsWindow ?
-        this._getTabForContentWindow(event.target.top) :
+        this.getTabForBrowser(event.target.docShell.chromeEventHandler) :
         this.getTabForBrowser(event.originalTarget);
 
       // Focus window for beforeunload dialog so it is seen but don't
       // steal focus from other applications.
       if (event.detail &&
           event.detail.tabPrompt &&
           event.detail.inPermitUnload &&
           Services.focus.activeWindow)
@@ -4522,17 +4523,18 @@ window._gBrowser = {
     this.addEventListener("DOMTitleChanged", (event) => {
       if (!event.isTrusted)
         return;
 
       var contentWin = event.target.defaultView;
       if (contentWin != contentWin.top)
         return;
 
-      var tab = this._getTabForContentWindow(contentWin);
+      let browser = contentWin.docShell.chromeEventHandler;
+      var tab = this.getTabForBrowser(browser);
       if (!tab || tab.hasAttribute("pending"))
         return;
 
       var titleChanged = this.setTabTitle(tab);
       if (titleChanged && !tab.selected && !tab.hasAttribute("busy"))
         tab.setAttribute("titlechanged", "true");
     });