Bug 653681 - TabMatcher._getTabsForOtherWindows() must not use nsIWindowMediator.getMostRecentWindow(); r=dao
authorTim Taubert <tim.taubert@gmx.de>
Fri, 29 Apr 2011 15:05:19 +0200
changeset 69402 af5c044d29aca671b29703a585536047009b31d6
parent 69401 508c54f638245a6baa2a422ea7c006d4e6d6beaa
child 69443 6e68a1d9538beb26ff3f7f543751fb30f60d9f19
push id76
push userbzbarsky@mozilla.com
push dateTue, 05 Jul 2011 17:00:57 +0000
treeherdermozilla-beta@d3a2732c35f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdao
bugs653681
milestone6.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 653681 - TabMatcher._getTabsForOtherWindows() must not use nsIWindowMediator.getMostRecentWindow(); r=dao
browser/base/content/tabview/search.js
--- a/browser/base/content/tabview/search.js
+++ b/browser/base/content/tabview/search.js
@@ -213,53 +213,49 @@ TabMatcher.prototype = {
       var name = tab.$tabTitle[0].innerHTML;
       let url = TabUtils.URLOf(tab);
       return !name.match(self.term, "i") && !url.match(self.term, "i");
     });
   },
   
   // ---------
   // Function: _getTabsForOtherWindows
-  // Returns an array of <TabItem>s and <xul:tabs>s representing that
-  // tabs from all windows but the currently focused window. <TabItem>s
-  // will be returned for windows in which Panorama has been activated at
-  // least once, while <xul:tab>s will be return for windows in which
-  // Panorama has never been activated.
-  _getTabsForOtherWindows: function TabMatcher__getTabsForOtherWindows(){
-    var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
-                       .getService(Components.interfaces.nsIWindowMediator);
-    var enumerator = wm.getEnumerator("navigator:browser");    
-    var currentWindow = wm.getMostRecentWindow("navigator:browser");
-    
-    var allTabs = [];    
+  // Returns an array of <TabItem>s and <xul:tabs>s representing tabs
+  // from all windows but the current window. <TabItem>s will be returned
+  // for windows in which Panorama has been activated at least once, while
+  // <xul:tab>s will be returned for windows in which Panorama has never
+  // been activated.
+  _getTabsForOtherWindows: function TabMatcher__getTabsForOtherWindows() {
+    var enumerator = Services.wm.getEnumerator("navigator:browser");
+    var allTabs = [];
+
     while (enumerator.hasMoreElements()) {
       var win = enumerator.getNext();
-      // This function gets tabs from other windows: not the one you currently
-      // have focused.
-      if (win != currentWindow) {
+      // This function gets tabs from other windows, not from the current window
+      if (win != gWindow) {
         // If TabView is around iterate over all tabs, else get the currently
         // shown tabs...
-        
         let tvWindow = win.TabView.getContentWindow();
         if (tvWindow)
-          allTabs = allTabs.concat( tvWindow.TabItems.getItems() );
+          allTabs = allTabs.concat(tvWindow.TabItems.getItems());
         else
           // win.gBrowser.tabs isn't a proper array, so we can't use concat
-          for (var i=0; i<win.gBrowser.tabs.length; i++) allTabs.push( win.gBrowser.tabs[i] );
-      } 
+          for (let i = 0; i < win.gBrowser.tabs.length; i++)
+            allTabs.push(win.gBrowser.tabs[i]);
+      }
     }
-    return allTabs;    
+    return allTabs;
   },
   
   // ----------
   // Function: matchedTabsFromOtherWindows
   // Returns an array of <TabItem>s and <xul:tab>s that match the search term
-  // from all windows but the currently focused window. <TabItem>s will be
-  // returned for windows in which Panorama has been activated at least once,
-  // while <xul:tab>s will be return for windows in which Panorama has never
+  // from all windows but the current window. <TabItem>s will be returned for
+  // windows in which Panorama has been activated at least once, while
+  // <xul:tab>s will be returned for windows in which Panorama has never
   // been activated.
   // (new TabMatcher("app")).matchedTabsFromOtherWindows();
   matchedTabsFromOtherWindows: function TabMatcher_matchedTabsFromOtherWindows(){
     if (this.term.length < 2)
       return [];
     
     var tabs = this._getTabsForOtherWindows();
     tabs = this._filterAndSortForMatches(tabs);