From 665355599d57daa4e171f5b5cf4901f950b02e19 Mon Sep 17 00:00:00 2001 From: SHIMODA Hiroshi Date: Thu, 20 Jan 2011 12:08:25 +0900 Subject: [PATCH] don't save tree structure if the fast restoring is disabled --- content/treestyletab/treestyletabbrowser.js | 83 +++++++++++---------- 1 file changed, 44 insertions(+), 39 deletions(-) diff --git a/content/treestyletab/treestyletabbrowser.js b/content/treestyletab/treestyletabbrowser.js index a0f88742..4513e8d9 100644 --- a/content/treestyletab/treestyletabbrowser.js +++ b/content/treestyletab/treestyletabbrowser.js @@ -1894,11 +1894,51 @@ TreeStyleTabBrowser.prototype = { onWindowStateRestored : function TSTBrowser_onWindowStateRestored() { - if ( - !window.__SS_tabsToRestore || - !this.getTreePref('restoreTreeOnStartup') - ) + if (!window.__SS_tabsToRestore) return; + }, + + saveTreeStructureWithDelay : function TSTBrowser_saveTreeStructureWithDelay() + { + if (this.restoringTree || this.saveTreeStructureWithDelayTimer) + return; + + this.saveTreeStructureWithDelayTimer = window.setTimeout(function(aSelf) { + aSelf.saveTreeStructureWithDelayTimer = null; + aSelf.saveTreeStructure(); + }, this.getPref('browser.sessionstore.interval'), this); + }, + saveTreeStructureWithDelayTimer : null, + saveTreeStructure : function TSTBrowser_saveTreeStructure() + { + if (!this.getTreePref('restoreTreeOnStartup')) + return; + + var treeStructures = JSON.parse(this.SessionStore.getWindowValue(window, this.kSTRUCTURE) || '{}'); + var id = this.mTabBrowser.getAttribute('id'); + var tabs = this.getAllTabsArray(this.mTabBrowser); + treeStructures[id] = { + tree : this.getTreeStructureFromTabs(tabs), + collapsed : tabs.filter(function(aTab) { + return this.isCollapsed(aTab); + }, this).map(function(aTab) { + return aTab._tPos; + }), + treeCollapsed : tabs.filter(function(aTab) { + return this.isSubtreeCollapsed(aTab); + }, this).map(function(aTab) { + return aTab._tPos; + }) + }; + this.SessionStore.setWindowValue(window, this.kSTRUCTURE, JSON.stringify(treeStructures)) + }, + + restoreTreeStructure : function TSTBrowser_restoreTreeStructure() + { + if (!this.getTreePref('restoreTreeOnStartup')) + return; + + this.restoreTreeStructure(); var treeStructures = JSON.parse(this.SessionStore.getWindowValue(window, this.kSTRUCTURE) || '{}'); var id = this.mTabBrowser.getAttribute('id'); @@ -1927,41 +1967,6 @@ TreeStyleTabBrowser.prototype = { aTab.removeAttribute(this.kCHILDREN); }, this); }, - - saveTreeStructureWithDelay : function TSTBrowser_saveTreeStructureWithDelay() - { - if (this.restoringTree) - return; - - if (this.saveTreeStructureWithDelayTimer) - window.clearTimeout(this.saveTreeStructureWithDelayTimer); - - this.saveTreeStructureWithDelayTimer = window.setTimeout(function(aSelf) { - aSelf.saveTreeStructureWithDelayTimer = null; - aSelf.saveTreeStructure(); - }, this.getPref('browser.sessionstore.interval'), this); - }, - saveTreeStructureWithDelayTimer : null, - saveTreeStructure : function TSTBrowser_saveTreeStructure() - { - var treeStructures = JSON.parse(this.SessionStore.getWindowValue(window, this.kSTRUCTURE) || '{}'); - var id = this.mTabBrowser.getAttribute('id'); - var tabs = this.getAllTabsArray(this.mTabBrowser); - treeStructures[id] = { - tree : this.getTreeStructureFromTabs(tabs), - collapsed : tabs.filter(function(aTab) { - return this.isCollapsed(aTab); - }, this).map(function(aTab) { - return aTab._tPos; - }), - treeCollapsed : tabs.filter(function(aTab) { - return this.isSubtreeCollapsed(aTab); - }, this).map(function(aTab) { - return aTab._tPos; - }) - }; - this.SessionStore.setWindowValue(window, this.kSTRUCTURE, JSON.stringify(treeStructures)) - }, /* DOM Event Handling */