Bug 746837 - In undoCloseTab, focus the browser instead of the content window and do it immediately rather than after a timeout. r=zpao a=desktop-only
authorDão Gottwald <dao@mozilla.com>
Sat, 21 Apr 2012 14:45:51 +0200
changeset 92058 d1ac8e24872c
parent 92057 021f95903ded
child 92059 97170e7a5f84
push id22500
push userdgottwald@mozilla.com
push date2012-04-21 12:46 +0000
Treeherderresults
reviewerszpao, desktop-only
bugs746837
milestone14.0a1
Bug 746837 - In undoCloseTab, focus the browser instead of the content window and do it immediately rather than after a timeout. r=zpao a=desktop-only
browser/components/sessionstore/src/nsSessionStore.js
--- a/browser/components/sessionstore/src/nsSessionStore.js
+++ b/browser/components/sessionstore/src/nsSessionStore.js
@@ -1445,43 +1445,42 @@ SessionStoreService.prototype = {
     if (!aWindow.__SSi)
       return this._toJSONString(aWindow.__SS_dyingCache._closedTabs);
     return this._toJSONString(this._windows[aWindow.__SSi]._closedTabs);
   },
 
   undoCloseTab: function sss_undoCloseTab(aWindow, aIndex) {
     if (!aWindow.__SSi)
       throw (Components.returnCode = Cr.NS_ERROR_INVALID_ARG);
-    
+
     var closedTabs = this._windows[aWindow.__SSi]._closedTabs;
 
     // default to the most-recently closed tab
     aIndex = aIndex || 0;
     if (!(aIndex in closedTabs))
       throw (Components.returnCode = Cr.NS_ERROR_INVALID_ARG);
-    
+
     // fetch the data of closed tab, while removing it from the array
     let closedTab = closedTabs.splice(aIndex, 1).shift();
     let closedTabState = closedTab.state;
 
     this._setWindowStateBusy(aWindow);
     // create a new tab
-    let browser = aWindow.gBrowser;
-    let tab = browser.addTab();
+    let tabbrowser = aWindow.gBrowser;
+    let tab = tabbrowser.addTab();
 
     // restore tab content
     this.restoreHistoryPrecursor(aWindow, [tab], [closedTabState], 1, 0, 0);
-      
+
     // restore the tab's position
-    browser.moveTabTo(tab, closedTab.pos);
-
-    // focus the tab's content area
-    let content = browser.getBrowserForTab(tab).contentWindow;
-    aWindow.setTimeout(function() { content.focus(); }, 0);
-    
+    tabbrowser.moveTabTo(tab, closedTab.pos);
+
+    // focus the tab's content area (bug 342432)
+    tab.linkedBrowser.focus();
+
     return tab;
   },
 
   forgetClosedTab: function sss_forgetClosedTab(aWindow, aIndex) {
     if (!aWindow.__SSi)
       throw (Components.returnCode = Cr.NS_ERROR_INVALID_ARG);
     
     var closedTabs = this._windows[aWindow.__SSi]._closedTabs;