From 47826d20299a929f216433ae2a27686066184a72 Mon Sep 17 00:00:00 2001 From: piro Date: Sun, 27 Dec 2009 11:22:44 +0000 Subject: [PATCH] =?UTF-8?q?=E3=83=84=E3=83=AA=E3=83=BC=E3=81=AE=E5=AD=90?= =?UTF-8?q?=E3=81=A0=E3=81=91=E3=82=92=E9=96=89=E3=81=98=E3=82=8B=E6=A9=9F?= =?UTF-8?q?=E8=83=BD=E3=81=8C=E5=83=8D=E3=81=8B=E3=81=AA=E3=81=8F=E3=81=AA?= =?UTF-8?q?=E3=81=A3=E3=81=A6=E3=81=84=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@5680 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/treestyletab.js | 31 ++++++++-------------------- modules/utils.js | 26 ++++++++++++++++++----- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/content/treestyletab/treestyletab.js b/content/treestyletab/treestyletab.js index 5e18ec47..c836b506 100644 --- a/content/treestyletab/treestyletab.js +++ b/content/treestyletab/treestyletab.js @@ -1279,43 +1279,30 @@ catch(e) { removeTabSubtree : function TSTService_removeTabSubtree(aTabOrTabs, aOnlyChildren) { - var tabs = this.gatherSubtreeMemberTabs(aTabOrTabs, aOnlyChildren); + var tabs = this.gatherSubtreeMemberTabs(aTabOrTabs); if (!this.warnAboutClosingTabs(tabs.length)) return; this.splitTabsToSubtrees(tabs).forEach(function(aTabs) { if (!this.fireTabSubtreeClosingEvent(aTabs[0], aTabs)) return; - this.markAsClosedSet(aTabs); var b = this.getTabBrowserFromChild(aTabs[0]); - for (var i = tabs.length-1; i > -1; i--) + if (aOnlyChildren) + aTabs = aTabs.slice(1); + if (!aTabs.length) + return; + this.stopRendering(); + this.markAsClosedSet(aTabs); + for (var i = aTabs.length-1; i > -1; i--) { b.removeTab(aTabs[i]); } + this.startRendering(); this.fireTabSubtreeClosedEvent(b, aTabs[0], aTabs) }, this); }, removeTabSubTree : function() { return this.removeTabSubtree.apply(this, arguments); }, // obsolete, for backward compatibility - splitTabsToSubtrees : function TSTService_splitTabsToSubtrees(aTabs) /* PUBLIC API */ - { - var groups = []; - var group = []; - this.cleanUpTabsArray(aTabs) - .forEach(function(aTab) { - var parent = this.getParentTab(aTab); - if (group.indexOf(parent) < 0) { - groups.push(group); - group = [aTab]; - } - else { - group.push(aTab); - } - }, this); - groups.push(group); - return groups; - }, - fireTabSubtreeClosingEvent : function TSTService_fireTabSubtreeClosingEvent(aParentTab, aClosedTabs) { /* PUBLIC API */ diff --git a/modules/utils.js b/modules/utils.js index d74f58f6..76e909e8 100644 --- a/modules/utils.js +++ b/modules/utils.js @@ -726,7 +726,7 @@ var TreeStyleTabUtils = { return aA._tPos - aB._tPos; }, - gatherSubtreeMemberTabs : function TSTUtils_gatherSubtreeMemberTabs(aTabOrTabs, aOnlyChildren) + gatherSubtreeMemberTabs : function TSTUtils_gatherSubtreeMemberTabs(aTabOrTabs) { var tabs = aTabOrTabs; if (!(tabs instanceof Array)) { @@ -740,13 +740,29 @@ var TreeStyleTabUtils = { descendant = descendant.concat(b.treeStyleTab.getDescendantTabs(tabs[i])); } - if (aOnlyChildren) - tabs = this.cleanUpTabsArray(descendant); - else - tabs = this.cleanUpTabsArray(tabs.concat(descendant)); + tabs = this.cleanUpTabsArray(tabs.concat(descendant)); return tabs; }, + + splitTabsToSubtrees : function TSTUtils_splitTabsToSubtrees(aTabs) /* PUBLIC API */ + { + var groups = []; + var group = []; + this.cleanUpTabsArray(aTabs) + .forEach(function(aTab) { + var parent = this.getParentTab(aTab); + if (!parent || group.indexOf(parent) < 0) { + if (group.length) groups.push(group); + group = [aTab]; + } + else { + group.push(aTab); + } + }, this); + if (group.length) groups.push(group); + return groups; + }, // tabbrowser