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
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -630,31 +630,18 @@ let SessionStoreInternal = {
let tabData = browser.__SS_data;
// wall-paper fix for bug 439675: make sure that the URL to be loaded
// is always visible in the address bar
let activePageData = tabData.entries[tabData.index - 1] || null;
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);
tab.dispatchEvent(event);
}
break;
case "SessionStore:restoreTabContentStarted":
if (this.isCurrentEpoch(browser, aMessage.data.epoch)) {
@@ -1855,16 +1842,36 @@ let SessionStoreInternal = {
},
persistTabAttribute: function ssi_persistTabAttribute(aName) {
if (TabAttributes.persist(aName)) {
this.saveStateDelayed();
}
},
+ 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
* with pinned tab(s), then the remaining data from the previous session for
* that window will be opened into that winddow. Otherwise new windows will
* be opened.
*/
restoreLastSession: function ssi_restoreLastSession() {
@@ -2527,19 +2534,27 @@ let SessionStoreInternal = {
// If provided, set the selected tab.
if (aSelectTab > 0 && aSelectTab <= aTabs.length) {
tabbrowser.selectedTab = aTabs[aSelectTab - 1];
// Update the window state in case we shut down without being notified.
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]);
+ }
}
},
// Restores the given tab state for a given tab.
restoreTab(tab, tabData, options = {}) {
let restoreImmediately = options.restoreImmediately;
let loadArguments = options.loadArguments;
let browser = tab.linkedBrowser;
@@ -2635,16 +2650,20 @@ let SessionStoreInternal = {
formdata: tabData.formdata || null,
disallow: tabData.disallow || null,
pageStyle: tabData.pageStyle || null
});
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);
}
// This could cause us to ignore MAX_CONCURRENT_TAB_RESTORES a bit, but
// it ensures each window will have its selected tab loaded.
if (restoreImmediately || tabbrowser.selectedBrowser == browser || loadArguments) {