From ca0b1fe073cadba2e99002eac8836a832434d1aa Mon Sep 17 00:00:00 2001 From: SHIMODA Hiroshi Date: Wed, 7 Dec 2011 10:18:05 +0900 Subject: [PATCH] partTab() => detachTab() (API is renamed) --- modules/browser.js | 52 +++++++++++++---------- modules/tabbarDNDObserver.js | 10 ++--- modules/utils.js | 2 +- modules/window.js | 2 +- tests/unit/treestyletab_treeUtils.test.js | 2 +- 5 files changed, 38 insertions(+), 30 deletions(-) diff --git a/modules/browser.js b/modules/browser.js index d95fb598..1c1b1271 100644 --- a/modules/browser.js +++ b/modules/browser.js @@ -2770,7 +2770,7 @@ TreeStyleTabBrowser.prototype = { [children[0]] : children ); - this.partAllChildren(tab, { + this.detachAllChildren(tab, { behavior : closeParentBehavior, dontUpdateIndent : true }); @@ -2808,7 +2808,7 @@ TreeStyleTabBrowser.prototype = { if (shouldCloseParentTab && nextFocusedTab == parentTab) nextFocusedTab = this.getNextFocusedTab(parentTab); - this.partTab(tab, { dontUpdateIndent : true }); + this.detachTab(tab, { dontUpdateIndent : true }); if (shouldCloseParentTab) { this.Deferred.next(function() { @@ -3071,7 +3071,7 @@ TreeStyleTabBrowser.prototype = { this.attachTabTo(aTab, newParent, { insertBefore : nextTab }); } else { - this.partTab(aTab); + this.detachTab(aTab); } } }, @@ -3169,7 +3169,7 @@ TreeStyleTabBrowser.prototype = { } if (!attached) { this.collapseExpandTab(tab, false, true); - this.partTab(tab); + this.detachTab(tab); } } @@ -3214,7 +3214,7 @@ TreeStyleTabBrowser.prototype = { let b = this.mTabBrowser; let lastCount = this.getAllTabs(b).snapshotLength - 1; w.setTimeout(function(aSelf) { - aSelf.partTab(aParent); + aSelf.detachTab(aParent); b.moveTabTo(aParent, lastCount); let descendantTabs = aSelf.getDescendantTabs(aParent); descendantTabs.forEach(function(aTab) { @@ -3290,7 +3290,7 @@ TreeStyleTabBrowser.prototype = { ) ) { // for safety - this.partAllChildren(aTab, { + this.detachAllChildren(aTab, { dontUpdateIndent : true, dontAnimate : this.windowService.restoringTree }); @@ -3692,13 +3692,13 @@ TreeStyleTabBrowser.prototype = { this.internallyTabMovingCount--; } - this.partAllChildren(aTab, { + this.detachAllChildren(aTab, { behavior : this.getCloseParentBehaviorForTab( aTab, this.kCLOSE_PARENT_BEHAVIOR_PROMOTE_FIRST_CHILD ) }); - this.partTab(aTab); + this.detachTab(aTab); this.collapseExpandTab(aTab, false); if (this.isVertical) this.positionPinnedTabsWithDelay(); @@ -4274,12 +4274,12 @@ TreeStyleTabBrowser.prototype = { resetTab : function TSTBrowser_resetTab(aTab, aPartChildren) { if (aPartChildren) - this.partAllChildren(aTab, { + this.detachAllChildren(aTab, { dontUpdateIndent : true, dontAnimate : true }); - this.partTab(aTab, { + this.detachTab(aTab, { dontUpdateIndent : true, dontAnimate : true }); @@ -4405,7 +4405,7 @@ TreeStyleTabBrowser.prototype = { var id = aChild.getAttribute(this.kID); - this.partTab(aChild, { + this.detachTab(aChild, { dontUpdateIndent : true }); @@ -4525,7 +4525,7 @@ TreeStyleTabBrowser.prototype = { this.isSubtreeCollapsed(aTab); }, - partTab : function TSTBrowser_partTab(aChild, aInfo) /* PUBLIC API */ + detachTab : function TSTBrowser_detachTab(aChild, aInfo) /* PUBLIC API */ { if (!aChild) return; if (!aInfo) aInfo = {}; @@ -4575,12 +4575,12 @@ TreeStyleTabBrowser.prototype = { }, 0, this.getTabBrowserFromChild(parentTab)); } }, - detachTab : function TSTBrowser_detachTab(aChild, aInfo) // alias (unstable API!) + partTab : function TSTBrowser_partTab(aChild, aInfo) /* PUBLIC API, for backward compatibility */ { - return this.partTab(aChild, aInfo); + return this.detachTab(aChild, aInfo); }, - partAllChildren : function TSTBrowser_partAllChildren(aTab, aInfo) + detachAllChildren : function TSTBrowser_detachAllChildren(aTab, aInfo) { aInfo = aInfo || {}; if (!('behavior' in aInfo)) @@ -4610,12 +4610,12 @@ TreeStyleTabBrowser.prototype = { children.forEach(( aInfo.behavior == this.kCLOSE_PARENT_BEHAVIOR_DETACH_ALL_CHILDREN ? function(aTab) { - this.partTab(aTab, aInfo); + this.detachTab(aTab, aInfo); this.moveTabSubtreeTo(aTab, insertBefore ? insertBefore._tPos - 1 : this.getLastTab(b)._tPos ); } : aInfo.behavior == this.kCLOSE_PARENT_BEHAVIOR_PROMOTE_FIRST_CHILD ? function(aTab, aIndex) { - this.partTab(aTab, aInfo); + this.detachTab(aTab, aInfo); if (aIndex == 0) { if (parentTab) { this.attachTabTo(aTab, parentTab, { @@ -4645,19 +4645,23 @@ TreeStyleTabBrowser.prototype = { } : // aInfo.behavior == this.kCLOSE_PARENT_BEHAVIOR_SIMPLY_DETACH_ALL_CHILDREN ? function(aTab) { - this.partTab(aTab, aInfo); + this.detachTab(aTab, aInfo); } ), this); }, + partAllChildren : function TSTBrowser_partAllChildren(aTab, aInfo) /* for backward compatibility */ + { + return this.detachAllChildren(aTab, aInfo); + }, - partTabs : function TSTBrowser_partTabs(aTabs) + detachTabs : function TSTBrowser_detachTabs(aTabs) { var aTabs = Array.slice(aTabs); for each (let tab in aTabs) { if (aTabs.indexOf(this.getParentTab(tab)) > -1) continue; - this.partAllChildren(tab, { + this.detachAllChildren(tab, { behavior : this.getCloseParentBehaviorForTab( tab, this.kCLOSE_PARENT_BEHAVIOR_PROMOTE_FIRST_CHILD @@ -4665,6 +4669,10 @@ TreeStyleTabBrowser.prototype = { }); } }, + partTabs : function TSTBrowser_partTabs(aTabs) /* for backward compatibility */ + { + return this.detachTabs(aTabs); + }, getCloseParentBehaviorForTab : function TSTBrowser_getCloseParentBehaviorForTab(aTab, aDefaultBehavior) { @@ -4950,7 +4958,7 @@ TreeStyleTabBrowser.prototype = { var parent = this.getParentTab(aTab); var newParent = this.getParentTab(parent); if (this.maxTreeLevel == 0 || !newParent) { - this.partTab(aTab); + this.detachTab(aTab); } else { let nextSibling = this.getNextTab(aTab); @@ -5011,7 +5019,7 @@ TreeStyleTabBrowser.prototype = { } else { let nextTab = this.getNextSiblingTab(parentTab); - this.partTab(b.mCurrentTab); + this.detachTab(b.mCurrentTab); this.internallyTabMovingCount++; if (nextTab) { b.moveTabTo(b.mCurrentTab, nextTab._tPos - 1); diff --git a/modules/tabbarDNDObserver.js b/modules/tabbarDNDObserver.js index ad9e3003..4b891b9a 100644 --- a/modules/tabbarDNDObserver.js +++ b/modules/tabbarDNDObserver.js @@ -431,7 +431,7 @@ catch(e) { selectedTabs.length) { draggedTabs = draggedRoots = selectedTabs; if (aInfo.action & sv.kACTIONS_FOR_SOURCE) - sourceService.partTabs(selectedTabs); + sourceService.detachTabs(selectedTabs); } while (aInfo.insertBefore && draggedWholeTree.indexOf(aInfo.insertBefore) > -1) @@ -441,7 +441,7 @@ catch(e) { if (aInfo.action & sv.kACTIONS_FOR_SOURCE) { if (aInfo.action & sv.kACTION_PART) { - this.partTabsOnDrop(draggedRoots); + this.detachTabsOnDrop(draggedRoots); } else if (aInfo.action & sv.kACTION_ATTACH) { this.attachTabsOnDrop(draggedRoots, aInfo.parent); @@ -520,13 +520,13 @@ catch(e) { if (aParent) sv.attachTabTo(aTab, aParent); else - sv.partTab(aTab); + sv.detachTab(aTab); sv.collapseExpandTab(aTab, false); }, sv); b.movingSelectedTabs = false; // Multiple Tab Handler }, - partTabsOnDrop : function TabbarDND_partTabsOnDrop(aTabs) + detachTabsOnDrop : function TabbarDND_detachTabsOnDrop(aTabs) { var b = aTabs[0].ownerDocument.defaultView.TreeStyleTabService.getTabBrowserFromChild(aTabs[0]); var sv = b.treeStyleTab; @@ -534,7 +534,7 @@ catch(e) { b.movingSelectedTabs = true; // Multiple Tab Handler aTabs.forEach(function(aTab) { if (!aTab.parentNode) return; // ignore removed tabs - sv.partTab(aTab); + sv.detachTab(aTab); sv.collapseExpandTab(aTab, false); }, sv); b.movingSelectedTabs = false; // Multiple Tab Handler diff --git a/modules/utils.js b/modules/utils.js index e33415d1..19ce2a20 100644 --- a/modules/utils.js +++ b/modules/utils.js @@ -2301,7 +2301,7 @@ var TreeStyleTabUtils = { var parentTab = null; aTabs.forEach(function(aTab, aIndex) { if (sv.isCollapsed(aTab)) sv.collapseExpandTab(aTab, false, true); - sv.partTab(aTab); + sv.detachTab(aTab); var parentIndexInTree = aTreeStructure[aIndex]; if (parentIndexInTree < 0) // there is no parent, so this is a new parent! diff --git a/modules/window.js b/modules/window.js index b0e37748..7848613c 100644 --- a/modules/window.js +++ b/modules/window.js @@ -1456,7 +1456,7 @@ TreeStyleTabWindow.prototype = { }); } else { - sv.partTab(aTab); + sv.detachTab(aTab); let index = nextSibling ? nextSibling._tPos : b.mTabContainer.childNodes.length ; if (index > aTab._tPos) index--; b.moveTabTo(aTab, index); diff --git a/tests/unit/treestyletab_treeUtils.test.js b/tests/unit/treestyletab_treeUtils.test.js index fe3f0805..226611b9 100644 --- a/tests/unit/treestyletab_treeUtils.test.js +++ b/tests/unit/treestyletab_treeUtils.test.js @@ -20,7 +20,7 @@ sv.collapseExpandAllSubtree(collapse) sv.changeTabbarPosition() sv.currentTabbarPosition -sv.partAllChildren() +sv.detachAllChildren() sv.resetTab() sv.resetAllTabs()