split methods and define new utility API "collectRootTabs()"

This commit is contained in:
SHIMODA Hiroshi 2011-06-15 13:32:39 +09:00
parent 75dc1da17d
commit a57bd32d1c
2 changed files with 20 additions and 20 deletions

View File

@ -403,7 +403,7 @@ catch(e) {
aDraggedTab = tabsInfo.draggedTab;
var draggedTabs = tabsInfo.draggedTabs;
var draggedRoots = tabsInfo.draggedRoots;
var draggedRoots = sv.collectRootTabs(tabsInfo.draggedTabs);
var targetBrowser = b;
@ -593,7 +593,6 @@ catch(e) {
return {
draggedTab : null,
draggedTabs : [],
draggedRoots : [],
isMultipleMove : false
};
@ -604,27 +603,10 @@ catch(e) {
var sourceBrowser = sv.getTabBrowserFromChild(aTab);
var draggedTabs = w['piro.sakura.ne.jp'].tabsDragUtils.getSelectedTabs(aTab || sourceBrowser || aInfo.event);
var draggedRoots = [aTab];
var isMultipleMove = false;
if (draggedTabs.length > 1) {
isMultipleMove = true;
if (!(aInfo.action & sv.kACTIONS_FOR_DESTINATION)) {
draggedRoots = [];
draggedTabs.forEach(function(aTab) {
var parent = aTab,
current;
do {
current = parent;
parent = sourceBrowser.treeStyleTab.getParentTab(parent)
if (parent && draggedTabs.indexOf(parent) > -1) continue;
if (draggedRoots.indexOf(current) < 0)
draggedRoots.push(current);
return;
}
while (parent);
}, this);
}
}
else if (aInfo.action & sv.kACTIONS_FOR_DESTINATION) {
draggedTabs = [aTab].concat(sourceBrowser.treeStyleTab.getDescendantTabs(aTab));
@ -633,7 +615,6 @@ catch(e) {
return {
draggedTab : aTab,
draggedTabs : draggedTabs,
draggedRoots : draggedRoots,
isMultipleMove : isMultipleMove
};
},

View File

@ -2079,6 +2079,25 @@ var TreeStyleTabUtils = {
).singleNodeValue;
},
collectRootTabs : function TSTUtils_collectRootTabs(aTabs) /* PUBLIC API */
{
var roots = [];
aTabs.forEach(function(aTab) {
var parent = aTab,
current;
do {
current = parent;
parent = this.getParentTab(parent)
if (parent && aTabs.indexOf(parent) > -1) continue;
if (aTabs.indexOf(current) < 0)
aTabs.push(current);
return;
}
while (parent);
}, this);
return roots;
},
getChildIndex : function TSTUtils_getChildIndex(aTab, aParent) /* PUBLIC API */
{
if (this.tabsHash) { // XPath-less implementation