From e54774051e494ca1a0fd87c704f2a97eb1d6e69f Mon Sep 17 00:00:00 2001 From: Tim Taubert Date: Sun, 9 Nov 2014 12:28:56 +0100 Subject: [PATCH] Bug 1096013 - [e10s] Improve perceived session restore duration by prioritizing selected tabs when restoring session history and by setting tab labels and icons as soon as possible to indicate a restored session r=smacleod --- .../components/sessionstore/SessionStore.jsm | 51 +++++++++++++------ 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/browser/components/sessionstore/SessionStore.jsm b/browser/components/sessionstore/SessionStore.jsm index 25242386a21a..f9b31bfa89e5 100644 --- a/browser/components/sessionstore/SessionStore.jsm +++ b/browser/components/sessionstore/SessionStore.jsm @@ -635,21 +635,8 @@ let SessionStoreInternal = { let uri = activePageData ? activePageData.url || null : null; browser.userTypedValue = uri; - // If the page has a title, set it. - if (activePageData) { - if (activePageData.title) { - tab.label = activePageData.title; - tab.crop = "end"; - } else if (activePageData.url != "about:blank") { - tab.label = activePageData.url; - tab.crop = "center"; - } - } - - // Restore the tab icon. - if ("image" in tabData) { - win.gBrowser.setIcon(tab, tabData.image); - } + // Update tab label and icon again after the tab history was updated. + this.updateTabLabelAndIcon(tab, tabData); let event = win.document.createEvent("Events"); event.initEvent("SSTabRestoring", true, false); @@ -1860,6 +1847,26 @@ let SessionStoreInternal = { } }, + updateTabLabelAndIcon(tab, tabData) { + let activePageData = tabData.entries[tabData.index - 1] || null; + + // If the page has a title, set it. + if (activePageData) { + if (activePageData.title) { + tab.label = activePageData.title; + tab.crop = "end"; + } else if (activePageData.url != "about:blank") { + tab.label = activePageData.url; + tab.crop = "center"; + } + } + + // Restore the tab icon. + if ("image" in tabData) { + tab.ownerDocument.defaultView.gBrowser.setIcon(tab, tabData.image); + } + }, + /** * Restores the session state stored in LastSession. This will attempt * to merge data into the current session. If a window was opened at startup @@ -2532,9 +2539,17 @@ let SessionStoreInternal = { this._windows[aWindow.__SSi].selected = aSelectTab; } + // If we restore the selected tab, make sure it goes first. + let selectedIndex = aTabs.indexOf(tabbrowser.selectedTab); + if (selectedIndex > -1) { + this.restoreTab(tabbrowser.selectedTab, aTabData[selectedIndex]); + } + // Restore all tabs. for (let t = 0; t < aTabs.length; t++) { - this.restoreTab(aTabs[t], aTabData[t]); + if (t != selectedIndex) { + this.restoreTab(aTabs[t], aTabData[t]); + } } }, @@ -2640,6 +2655,10 @@ let SessionStoreInternal = { browser.messageManager.sendAsyncMessage("SessionStore:restoreHistory", {tabData: tabData, epoch: epoch}); + // Update tab label and icon to show something + // while we wait for the messages to be processed. + this.updateTabLabelAndIcon(tab, tabData); + // Restore tab attributes. if ("attributes" in tabData) { TabAttributes.set(tab, tabData.attributes);