Bug 445461 - restore MRU tab order when restoring a session. r=ttaubert

This commit is contained in:
Dão Gottwald 2014-02-07 22:48:49 +01:00
parent 4e6998a884
commit acbbcb8605
2 changed files with 16 additions and 1 deletions

View File

@ -223,7 +223,7 @@ var ctrlTab = {
if (!this._recentlyUsedTabs) {
tabPreviews.init();
this._recentlyUsedTabs = [gBrowser.selectedTab];
this._initRecentlyUsedTabs();
this._init(true);
}
},
@ -495,6 +495,9 @@ var ctrlTab = {
handleEvent: function ctrlTab_handleEvent(event) {
switch (event.type) {
case "SSWindowStateReady":
this._initRecentlyUsedTabs();
break;
case "TabAttrModified":
// tab attribute modified (e.g. label, crop, busy, image, selected)
for (let i = this.previews.length - 1; i >= 0; i--) {
@ -530,9 +533,17 @@ var ctrlTab = {
}
},
_initRecentlyUsedTabs: function () {
this._recentlyUsedTabs =
Array.filter(gBrowser.tabs, tab => !tab.closing)
.sort((tab1, tab2) => tab2.lastAccessed - tab1.lastAccessed);
},
_init: function ctrlTab__init(enable) {
var toggleEventListener = enable ? "addEventListener" : "removeEventListener";
window[toggleEventListener]("SSWindowStateReady", this, false);
var tabContainer = gBrowser.tabContainer;
tabContainer[toggleEventListener]("TabOpen", this, false);
tabContainer[toggleEventListener]("TabAttrModified", this, false);

View File

@ -2521,6 +2521,10 @@ let SessionStoreInternal = {
else
tabbrowser.showTab(tab);
if (tabData.lastAccessed) {
tab.lastAccessed = tabData.lastAccessed;
}
if ("attributes" in tabData) {
// Ensure that we persist tab attributes restored from previous sessions.
Object.keys(tabData.attributes).forEach(a => TabAttributes.persist(a));