partTab() => detachTab() (API is renamed)

This commit is contained in:
SHIMODA Hiroshi 2011-12-07 10:18:05 +09:00
parent 87352e22e6
commit ca0b1fe073
5 changed files with 38 additions and 30 deletions

View File

@ -2770,7 +2770,7 @@ TreeStyleTabBrowser.prototype = {
[children[0]] : [children[0]] :
children children
); );
this.partAllChildren(tab, { this.detachAllChildren(tab, {
behavior : closeParentBehavior, behavior : closeParentBehavior,
dontUpdateIndent : true dontUpdateIndent : true
}); });
@ -2808,7 +2808,7 @@ TreeStyleTabBrowser.prototype = {
if (shouldCloseParentTab && nextFocusedTab == parentTab) if (shouldCloseParentTab && nextFocusedTab == parentTab)
nextFocusedTab = this.getNextFocusedTab(parentTab); nextFocusedTab = this.getNextFocusedTab(parentTab);
this.partTab(tab, { dontUpdateIndent : true }); this.detachTab(tab, { dontUpdateIndent : true });
if (shouldCloseParentTab) { if (shouldCloseParentTab) {
this.Deferred.next(function() { this.Deferred.next(function() {
@ -3071,7 +3071,7 @@ TreeStyleTabBrowser.prototype = {
this.attachTabTo(aTab, newParent, { insertBefore : nextTab }); this.attachTabTo(aTab, newParent, { insertBefore : nextTab });
} }
else { else {
this.partTab(aTab); this.detachTab(aTab);
} }
} }
}, },
@ -3169,7 +3169,7 @@ TreeStyleTabBrowser.prototype = {
} }
if (!attached) { if (!attached) {
this.collapseExpandTab(tab, false, true); this.collapseExpandTab(tab, false, true);
this.partTab(tab); this.detachTab(tab);
} }
} }
@ -3214,7 +3214,7 @@ TreeStyleTabBrowser.prototype = {
let b = this.mTabBrowser; let b = this.mTabBrowser;
let lastCount = this.getAllTabs(b).snapshotLength - 1; let lastCount = this.getAllTabs(b).snapshotLength - 1;
w.setTimeout(function(aSelf) { w.setTimeout(function(aSelf) {
aSelf.partTab(aParent); aSelf.detachTab(aParent);
b.moveTabTo(aParent, lastCount); b.moveTabTo(aParent, lastCount);
let descendantTabs = aSelf.getDescendantTabs(aParent); let descendantTabs = aSelf.getDescendantTabs(aParent);
descendantTabs.forEach(function(aTab) { descendantTabs.forEach(function(aTab) {
@ -3290,7 +3290,7 @@ TreeStyleTabBrowser.prototype = {
) )
) { ) {
// for safety // for safety
this.partAllChildren(aTab, { this.detachAllChildren(aTab, {
dontUpdateIndent : true, dontUpdateIndent : true,
dontAnimate : this.windowService.restoringTree dontAnimate : this.windowService.restoringTree
}); });
@ -3692,13 +3692,13 @@ TreeStyleTabBrowser.prototype = {
this.internallyTabMovingCount--; this.internallyTabMovingCount--;
} }
this.partAllChildren(aTab, { this.detachAllChildren(aTab, {
behavior : this.getCloseParentBehaviorForTab( behavior : this.getCloseParentBehaviorForTab(
aTab, aTab,
this.kCLOSE_PARENT_BEHAVIOR_PROMOTE_FIRST_CHILD this.kCLOSE_PARENT_BEHAVIOR_PROMOTE_FIRST_CHILD
) )
}); });
this.partTab(aTab); this.detachTab(aTab);
this.collapseExpandTab(aTab, false); this.collapseExpandTab(aTab, false);
if (this.isVertical) this.positionPinnedTabsWithDelay(); if (this.isVertical) this.positionPinnedTabsWithDelay();
@ -4274,12 +4274,12 @@ TreeStyleTabBrowser.prototype = {
resetTab : function TSTBrowser_resetTab(aTab, aPartChildren) resetTab : function TSTBrowser_resetTab(aTab, aPartChildren)
{ {
if (aPartChildren) if (aPartChildren)
this.partAllChildren(aTab, { this.detachAllChildren(aTab, {
dontUpdateIndent : true, dontUpdateIndent : true,
dontAnimate : true dontAnimate : true
}); });
this.partTab(aTab, { this.detachTab(aTab, {
dontUpdateIndent : true, dontUpdateIndent : true,
dontAnimate : true dontAnimate : true
}); });
@ -4405,7 +4405,7 @@ TreeStyleTabBrowser.prototype = {
var id = aChild.getAttribute(this.kID); var id = aChild.getAttribute(this.kID);
this.partTab(aChild, { this.detachTab(aChild, {
dontUpdateIndent : true dontUpdateIndent : true
}); });
@ -4525,7 +4525,7 @@ TreeStyleTabBrowser.prototype = {
this.isSubtreeCollapsed(aTab); this.isSubtreeCollapsed(aTab);
}, },
partTab : function TSTBrowser_partTab(aChild, aInfo) /* PUBLIC API */ detachTab : function TSTBrowser_detachTab(aChild, aInfo) /* PUBLIC API */
{ {
if (!aChild) return; if (!aChild) return;
if (!aInfo) aInfo = {}; if (!aInfo) aInfo = {};
@ -4575,12 +4575,12 @@ TreeStyleTabBrowser.prototype = {
}, 0, this.getTabBrowserFromChild(parentTab)); }, 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 || {}; aInfo = aInfo || {};
if (!('behavior' in aInfo)) if (!('behavior' in aInfo))
@ -4610,12 +4610,12 @@ TreeStyleTabBrowser.prototype = {
children.forEach(( children.forEach((
aInfo.behavior == this.kCLOSE_PARENT_BEHAVIOR_DETACH_ALL_CHILDREN ? aInfo.behavior == this.kCLOSE_PARENT_BEHAVIOR_DETACH_ALL_CHILDREN ?
function(aTab) { function(aTab) {
this.partTab(aTab, aInfo); this.detachTab(aTab, aInfo);
this.moveTabSubtreeTo(aTab, insertBefore ? insertBefore._tPos - 1 : this.getLastTab(b)._tPos ); this.moveTabSubtreeTo(aTab, insertBefore ? insertBefore._tPos - 1 : this.getLastTab(b)._tPos );
} : } :
aInfo.behavior == this.kCLOSE_PARENT_BEHAVIOR_PROMOTE_FIRST_CHILD ? aInfo.behavior == this.kCLOSE_PARENT_BEHAVIOR_PROMOTE_FIRST_CHILD ?
function(aTab, aIndex) { function(aTab, aIndex) {
this.partTab(aTab, aInfo); this.detachTab(aTab, aInfo);
if (aIndex == 0) { if (aIndex == 0) {
if (parentTab) { if (parentTab) {
this.attachTabTo(aTab, parentTab, { this.attachTabTo(aTab, parentTab, {
@ -4645,19 +4645,23 @@ TreeStyleTabBrowser.prototype = {
} : } :
// aInfo.behavior == this.kCLOSE_PARENT_BEHAVIOR_SIMPLY_DETACH_ALL_CHILDREN ? // aInfo.behavior == this.kCLOSE_PARENT_BEHAVIOR_SIMPLY_DETACH_ALL_CHILDREN ?
function(aTab) { function(aTab) {
this.partTab(aTab, aInfo); this.detachTab(aTab, aInfo);
} }
), this); ), 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); var aTabs = Array.slice(aTabs);
for each (let tab in aTabs) for each (let tab in aTabs)
{ {
if (aTabs.indexOf(this.getParentTab(tab)) > -1) if (aTabs.indexOf(this.getParentTab(tab)) > -1)
continue; continue;
this.partAllChildren(tab, { this.detachAllChildren(tab, {
behavior : this.getCloseParentBehaviorForTab( behavior : this.getCloseParentBehaviorForTab(
tab, tab,
this.kCLOSE_PARENT_BEHAVIOR_PROMOTE_FIRST_CHILD 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) getCloseParentBehaviorForTab : function TSTBrowser_getCloseParentBehaviorForTab(aTab, aDefaultBehavior)
{ {
@ -4950,7 +4958,7 @@ TreeStyleTabBrowser.prototype = {
var parent = this.getParentTab(aTab); var parent = this.getParentTab(aTab);
var newParent = this.getParentTab(parent); var newParent = this.getParentTab(parent);
if (this.maxTreeLevel == 0 || !newParent) { if (this.maxTreeLevel == 0 || !newParent) {
this.partTab(aTab); this.detachTab(aTab);
} }
else { else {
let nextSibling = this.getNextTab(aTab); let nextSibling = this.getNextTab(aTab);
@ -5011,7 +5019,7 @@ TreeStyleTabBrowser.prototype = {
} }
else { else {
let nextTab = this.getNextSiblingTab(parentTab); let nextTab = this.getNextSiblingTab(parentTab);
this.partTab(b.mCurrentTab); this.detachTab(b.mCurrentTab);
this.internallyTabMovingCount++; this.internallyTabMovingCount++;
if (nextTab) { if (nextTab) {
b.moveTabTo(b.mCurrentTab, nextTab._tPos - 1); b.moveTabTo(b.mCurrentTab, nextTab._tPos - 1);

View File

@ -431,7 +431,7 @@ catch(e) {
selectedTabs.length) { selectedTabs.length) {
draggedTabs = draggedRoots = selectedTabs; draggedTabs = draggedRoots = selectedTabs;
if (aInfo.action & sv.kACTIONS_FOR_SOURCE) if (aInfo.action & sv.kACTIONS_FOR_SOURCE)
sourceService.partTabs(selectedTabs); sourceService.detachTabs(selectedTabs);
} }
while (aInfo.insertBefore && draggedWholeTree.indexOf(aInfo.insertBefore) > -1) 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.kACTIONS_FOR_SOURCE) {
if (aInfo.action & sv.kACTION_PART) { if (aInfo.action & sv.kACTION_PART) {
this.partTabsOnDrop(draggedRoots); this.detachTabsOnDrop(draggedRoots);
} }
else if (aInfo.action & sv.kACTION_ATTACH) { else if (aInfo.action & sv.kACTION_ATTACH) {
this.attachTabsOnDrop(draggedRoots, aInfo.parent); this.attachTabsOnDrop(draggedRoots, aInfo.parent);
@ -520,13 +520,13 @@ catch(e) {
if (aParent) if (aParent)
sv.attachTabTo(aTab, aParent); sv.attachTabTo(aTab, aParent);
else else
sv.partTab(aTab); sv.detachTab(aTab);
sv.collapseExpandTab(aTab, false); sv.collapseExpandTab(aTab, false);
}, sv); }, sv);
b.movingSelectedTabs = false; // Multiple Tab Handler 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 b = aTabs[0].ownerDocument.defaultView.TreeStyleTabService.getTabBrowserFromChild(aTabs[0]);
var sv = b.treeStyleTab; var sv = b.treeStyleTab;
@ -534,7 +534,7 @@ catch(e) {
b.movingSelectedTabs = true; // Multiple Tab Handler b.movingSelectedTabs = true; // Multiple Tab Handler
aTabs.forEach(function(aTab) { aTabs.forEach(function(aTab) {
if (!aTab.parentNode) return; // ignore removed tabs if (!aTab.parentNode) return; // ignore removed tabs
sv.partTab(aTab); sv.detachTab(aTab);
sv.collapseExpandTab(aTab, false); sv.collapseExpandTab(aTab, false);
}, sv); }, sv);
b.movingSelectedTabs = false; // Multiple Tab Handler b.movingSelectedTabs = false; // Multiple Tab Handler

View File

@ -2301,7 +2301,7 @@ var TreeStyleTabUtils = {
var parentTab = null; var parentTab = null;
aTabs.forEach(function(aTab, aIndex) { aTabs.forEach(function(aTab, aIndex) {
if (sv.isCollapsed(aTab)) sv.collapseExpandTab(aTab, false, true); if (sv.isCollapsed(aTab)) sv.collapseExpandTab(aTab, false, true);
sv.partTab(aTab); sv.detachTab(aTab);
var parentIndexInTree = aTreeStructure[aIndex]; var parentIndexInTree = aTreeStructure[aIndex];
if (parentIndexInTree < 0) // there is no parent, so this is a new parent! if (parentIndexInTree < 0) // there is no parent, so this is a new parent!

View File

@ -1456,7 +1456,7 @@ TreeStyleTabWindow.prototype = {
}); });
} }
else { else {
sv.partTab(aTab); sv.detachTab(aTab);
let index = nextSibling ? nextSibling._tPos : b.mTabContainer.childNodes.length ; let index = nextSibling ? nextSibling._tPos : b.mTabContainer.childNodes.length ;
if (index > aTab._tPos) index--; if (index > aTab._tPos) index--;
b.moveTabTo(aTab, index); b.moveTabTo(aTab, index);

View File

@ -20,7 +20,7 @@ sv.collapseExpandAllSubtree(collapse)
sv.changeTabbarPosition() sv.changeTabbarPosition()
sv.currentTabbarPosition sv.currentTabbarPosition
sv.partAllChildren() sv.detachAllChildren()
sv.resetTab() sv.resetTab()
sv.resetAllTabs() sv.resetAllTabs()