tree structure was not restored correctly

This commit is contained in:
SHIMODA Hiroshi 2011-12-07 12:06:05 +09:00
parent ff5a299316
commit 9b5c3c594d
2 changed files with 25 additions and 20 deletions

View File

@ -799,7 +799,7 @@ TreeStyleTabBrowser.prototype = {
this.initTabContents(aTab); this.initTabContents(aTab);
if (!aTab.hasAttribute(this.kNEST)) if (!aTab.hasAttribute(this.kNEST))
this.setTabValue(aTab, this.kNEST, 0); aTab.setAttribute(this.kNEST, 0);
}, },
isTabInitialized : function TSTBrowser_isTabInitialized(aTab) isTabInitialized : function TSTBrowser_isTabInitialized(aTab)
{ {
@ -2368,7 +2368,7 @@ TreeStyleTabBrowser.prototype = {
.split('\n') .split('\n')
.filter(function(aId) { return aId; }) .filter(function(aId) { return aId; })
.length; .length;
tabs = tabs.slice(preTabs, preTabs + treeStructure.tree.length-1); tabs = tabs.slice(preTabs, preTabs + treeStructure.tree.length);
var relations = tabs.map(function(aTab) { var relations = tabs.map(function(aTab) {
return { return {
@ -2379,9 +2379,8 @@ TreeStyleTabBrowser.prototype = {
insertAfter : this.getTabValue(aTab, this.kINSERT_AFTER) insertAfter : this.getTabValue(aTab, this.kINSERT_AFTER)
}; };
}, this); }, this);
this.applyTreeStructureToTabs(tabs, treeStructure.tree);
this.updateAllTabsIndent(true); this.applyTreeStructureToTabs(tabs, treeStructure.tree, true);
tabs.forEach(function(aTab, aIndex) { tabs.forEach(function(aTab, aIndex) {
var relation = relations[aIndex]; var relation = relations[aIndex];
@ -2392,7 +2391,7 @@ TreeStyleTabBrowser.prototype = {
var state = treeStructure.state[aIndex]; var state = treeStructure.state[aIndex];
this.setTabValue(aTab, this.kSUBTREE_COLLAPSED, state.subTreeCollapsed || null); this.setTabValue(aTab, this.kSUBTREE_COLLAPSED, state.subTreeCollapsed || null);
this.collapseExpandTab(aTab, state.collapsed || false); this.collapseExpandTab(aTab, state.collapsed || false, true);
this.setTabValue(aTab, this.kID, relation.id); this.setTabValue(aTab, this.kID, relation.id);
this.setTabValue(aTab, this.kPARENT, relation.parent); this.setTabValue(aTab, this.kPARENT, relation.parent);
@ -2402,8 +2401,6 @@ TreeStyleTabBrowser.prototype = {
aTab.__treestyletab__structureRestored = true; aTab.__treestyletab__structureRestored = true;
}, this); }, this);
this.updateAllTabsCount();
}, },
/* DOM Event Handling */ /* DOM Event Handling */
@ -2685,6 +2682,8 @@ TreeStyleTabBrowser.prototype = {
*/ */
b._lastRelatedTab = lastRelatedTab; b._lastRelatedTab = lastRelatedTab;
this.saveTreeStructureWithDelay();
return true; return true;
}, },
_addedCountInThisLoop : 0, _addedCountInThisLoop : 0,
@ -2870,6 +2869,8 @@ TreeStyleTabBrowser.prototype = {
if (collapsed) if (collapsed)
this.startRendering(); this.startRendering();
this.saveTreeStructureWithDelay();
}, },
_reserveCloseNeedlessGroupTabSibling : function TSTBrowser_reserveCloseNeedlessGroupTabSibling(aTab) _reserveCloseNeedlessGroupTabSibling : function TSTBrowser_reserveCloseNeedlessGroupTabSibling(aTab)
{ {
@ -2995,6 +2996,8 @@ TreeStyleTabBrowser.prototype = {
if (this.canStackTabs) if (this.canStackTabs)
this.updateTabsZIndex(true); this.updateTabsZIndex(true);
this.saveTreeStructureWithDelay();
if ( if (
this.subTreeMovingCount || this.subTreeMovingCount ||
this.internallyTabMovingCount || this.internallyTabMovingCount ||
@ -3038,8 +3041,8 @@ TreeStyleTabBrowser.prototype = {
var prevParent = this.getParentTab(prevTab); var prevParent = this.getParentTab(prevTab);
var nextParent = this.getParentTab(nextTab); var nextParent = this.getParentTab(nextTab);
var prevLevel = prevTab ? Number(this.getTabValue(prevTab, this.kNEST)) : -1 ; var prevLevel = prevTab ? Number(prevTab.getAttribute(this.kNEST)) : -1 ;
var nextLevel = nextTab ? Number(this.getTabValue(nextTab, this.kNEST)) : -1 ; var nextLevel = nextTab ? Number(nextTab.getAttribute(this.kNEST)) : -1 ;
var newParent; var newParent;
@ -3303,7 +3306,6 @@ TreeStyleTabBrowser.prototype = {
if (structureRestored) { if (structureRestored) {
[ [
this.kNEST,
this.kPARENT, this.kPARENT,
this.kCHILDREN, this.kCHILDREN,
this.kINSERT_BEFORE, this.kINSERT_BEFORE,
@ -4364,7 +4366,7 @@ TreeStyleTabBrowser.prototype = {
aInfo = aInfo || {}; aInfo = aInfo || {};
if (aParent && this.maxTreeLevelPhisical && this.maxTreeLevel > -1) { if (aParent && this.maxTreeLevelPhisical && this.maxTreeLevel > -1) {
let level = parseInt(this.getTabValue(aParent, this.kNEST) || 0) + 1; let level = parseInt(aParent.getAttribute(this.kNEST) || 0) + 1;
while (aParent && level > this.maxTreeLevel) while (aParent && level > this.maxTreeLevel)
{ {
level--; level--;
@ -4395,7 +4397,7 @@ TreeStyleTabBrowser.prototype = {
shouldInheritIndent = ( shouldInheritIndent = (
!currentParent || !currentParent ||
(this.getTabValue(currentParent, this.kNEST) == this.getTabValue(aParent, this.kNEST)) (currentParent.getAttribute(this.kNEST) == aParent.getAttribute(this.kNEST))
); );
this.ensureTabInitialized(aChild); this.ensureTabInitialized(aChild);
@ -4464,7 +4466,10 @@ TreeStyleTabBrowser.prototype = {
this.moveTabSubtreeTo(aChild, newIndex); this.moveTabSubtreeTo(aChild, newIndex);
} }
if (!aInfo.dontExpand) { if (aInfo.forceExpand) {
this.collapseExpandSubtree(aParent, false, aInfo.dontAnimate);
}
else if (!aInfo.dontExpand) {
if (this.getTreePref('autoCollapseExpandSubtreeOnSelect')) { if (this.getTreePref('autoCollapseExpandSubtreeOnSelect')) {
if (this.shouldTabAutoExpanded(aParent)) if (this.shouldTabAutoExpanded(aParent))
this.collapseExpandTreesIntelligentlyFor(aParent); this.collapseExpandTreesIntelligentlyFor(aParent);
@ -4713,7 +4718,7 @@ TreeStyleTabBrowser.prototype = {
Array.slice(aTabs).forEach(function(aTab) { Array.slice(aTabs).forEach(function(aTab) {
if (!aTab.parentNode) return; // ignore removed tabs if (!aTab.parentNode) return; // ignore removed tabs
this.updateTabIndent(aTab, indent, aJustNow); this.updateTabIndent(aTab, indent, aJustNow);
this.setTabValue(aTab, this.kNEST, aLevel); aTab.setAttribute(this.kNEST, aLevel);
this.updateCanCollapseSubtree(aTab, aLevel); this.updateCanCollapseSubtree(aTab, aLevel);
this.updateTabsIndent(this.getChildTabs(aTab), aLevel+1, aJustNow); this.updateTabsIndent(this.getChildTabs(aTab), aLevel+1, aJustNow);
}, this); }, this);
@ -4871,8 +4876,8 @@ TreeStyleTabBrowser.prototype = {
if (!tabs.length) return; if (!tabs.length) return;
var self = this; var self = this;
tabs.sort(function(aA, aB) { return Number(self.getTabValue(aA, self.kNEST)) - Number(self.getTabValue(aB, self.kNEST)); }); tabs.sort(function(aA, aB) { return Number(aA.getAttribute(self.kNEST)) - Number(aB.setAttribute(self.kNEST)); });
var nest = this.getTabValue(tabs[tabs.length-1], this.kNEST); var nest = tabs[tabs.length-1].getAttribute(this.kNEST);
if (this.maxTreeLevel > -1) if (this.maxTreeLevel > -1)
nest = Math.min(nest, this.maxTreeLevel); nest = Math.min(nest, this.maxTreeLevel);
if (!nest) if (!nest)
@ -4951,7 +4956,7 @@ TreeStyleTabBrowser.prototype = {
var tabs = aParent ? this.getDescendantTabs(aParent) : this.getAllTabsArray(this.mTabBrowser) ; var tabs = aParent ? this.getDescendantTabs(aParent) : this.getAllTabsArray(this.mTabBrowser) ;
tabs.forEach(function(aTab) { tabs.forEach(function(aTab) {
var level = parseInt(this.getTabValue(aTab, this.kNEST) || 0); var level = parseInt(aTab.getAttribute(this.kNEST) || 0);
if (level <= this.maxTreeLevel) if (level <= this.maxTreeLevel)
return; return;

View File

@ -2314,15 +2314,15 @@ var TreeStyleTabUtils = {
} }
if (parent) { if (parent) {
sv.attachTabTo(aTab, parent, { sv.attachTabTo(aTab, parent, {
dontExpand : true, forceExpand : true,
dontMove : true dontMove : true
}); });
} }
}); });
for (let i = aTabs.length-1; i > -1; i--) for (let i = aTabs.length-1; i > -1; i--)
{ {
sv.collapseExpandSubtree(aTabs[i], !aExpandStates[i], true); sv.collapseExpandSubtree(aTabs[i], !sv.hasChildTabs(aTabs[i]) || !aExpandStates[i], true);
} }
}, },