From a57bd32d1cfcb6b37104d58013371efc625c4515 Mon Sep 17 00:00:00 2001 From: SHIMODA Hiroshi Date: Wed, 15 Jun 2011 13:32:39 +0900 Subject: [PATCH] split methods and define new utility API "collectRootTabs()" --- modules/tabbarDNDObserver.js | 21 +-------------------- modules/utils.js | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/modules/tabbarDNDObserver.js b/modules/tabbarDNDObserver.js index 7f7b6b07..1e67342b 100644 --- a/modules/tabbarDNDObserver.js +++ b/modules/tabbarDNDObserver.js @@ -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 }; }, diff --git a/modules/utils.js b/modules/utils.js index aa4b2fe3..d1b2e573 100644 --- a/modules/utils.js +++ b/modules/utils.js @@ -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