From 7e22e0548a327f165e256c9fe73ef4e6903e0bc6 Mon Sep 17 00:00:00 2001 From: piro Date: Fri, 26 Oct 2007 10:25:59 +0000 Subject: [PATCH] =?UTF-8?q?=E3=82=BB=E3=83=83=E3=82=B7=E3=83=A7=E3=83=B3?= =?UTF-8?q?=E4=BF=9D=E5=AD=98API=E3=82=92=E7=94=A8=E3=81=84=E3=81=9F?= =?UTF-8?q?=E3=82=BB=E3=83=83=E3=82=B7=E3=83=A7=E3=83=B3=E3=81=AE=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E6=99=82=E3=81=AB=E3=82=BF=E3=83=96=E3=81=AE=E3=83=84?= =?UTF-8?q?=E3=83=AA=E3=83=BC=E3=81=AE=E7=8A=B6=E6=85=8B=E3=81=8C=E5=AE=8C?= =?UTF-8?q?=E5=85=A8=E3=81=AB=E3=81=AF=20=E4=BF=9D=E5=AD=98=E3=81=95?= =?UTF-8?q?=E3=82=8C=E3=81=A6=E3=81=84=E3=81=AA=E3=81=8B=E3=81=A3=E3=81=9F?= =?UTF-8?q?=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= 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@1343 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/treestyletab.js | 51 ++++++++++++++-------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/content/treestyletab/treestyletab.js b/content/treestyletab/treestyletab.js index 3ac891bd..20221063 100644 --- a/content/treestyletab/treestyletab.js +++ b/content/treestyletab/treestyletab.js @@ -229,11 +229,11 @@ var TreeStyleTabService = { if (aTab.__treestyletab__linkedTabBrowser) return aTab.__treestyletab__linkedTabBrowser; - var target = aTab; - while (target.localName != 'tabbrowser' && target.parentNode) - target = target.parentNode; - - return (target.localName == 'tabbrowser') ? target : null ; + return this.evaluateXPath( + 'ancestor-or-self::xul:tabbrowser', + aTab, + XPathResult.FIRST_ORDERED_NODE_TYPE + ).singleNodeValue; }, getTabBrowserFromFrame : function(aFrame) @@ -923,15 +923,6 @@ catch(e) { aTabBrowser.__treestyletab__observer.destroy(); delete aTabBrowser.__treestyletab__observer; - var tabs = aTabBrowser.mTabContainer.childNodes; - var parent; - for (var i = 0, maxi = tabs.length; i < maxi; i++) - { - parent = this.getParentTab(tabs[i]); - if (parent) - this.setTabValue(tabs[i], this.kPARENT, parent.getAttribute(this.kID)); - } - aTabBrowser.mTabContainer.removeEventListener('TreeStyleTab:TabOpen', this, true); aTabBrowser.mTabContainer.removeEventListener('TabClose', this, true); aTabBrowser.mTabContainer.removeEventListener('TabMove', this, true); @@ -1067,12 +1058,9 @@ catch(e) { var parentTab = this.getParentTab(tab); var nextFocusedTab = null; - if (parentTab) { - this.setTabValue(tab, this.kPARENT, parentTab.getAttribute(this.kID)); - var next = this.getNextSiblingTab(tab); - if (next) - this.setTabValue(tab, this.kINSERT_BEFORE, next.getAttribute(this.kID)); - } + var next = this.getNextSiblingTab(tab); + if (next) + this.setTabValue(tab, this.kINSERT_BEFORE, next.getAttribute(this.kID)); if (firstChild) { var backupChildren = this.getTabValue(tab, this.kCHILDREN); @@ -1169,17 +1157,29 @@ catch(e) { var parent = this.getTabValue(tab, this.kPARENT); var before = this.getTabValue(tab, this.kINSERT_BEFORE); - if (parent && (parent = this.getTabById(parent, b))) { - this.attachTabTo(tab, parent, { dontExpand : true, insertBefore : (before ? this.getTabById(before, b) : null ), dontUpdateIndent : true }); - this.deleteTabValue(tab, this.kPARENT); - this.updateTabsIndent([tab]); - this.checkTabsIndentOverflow(b); + if (parent) { + parent = this.getTabById(parent, b); + if (parent) { + this.attachTabTo(tab, parent, { dontExpand : true, insertBefore : (before ? this.getTabById(before, b) : null ), dontUpdateIndent : true }); + this.updateTabsIndent([tab]); + this.checkTabsIndentOverflow(b); + } + else { + this.deleteTabValue(tab, this.kPARENT); + } } else if (children) { this.updateTabsIndent(tabs); this.checkTabsIndentOverflow(b); } + if (!parent && (before = this.getTabById(before, b))) { + var index = before._tPos; + if (index > tab._tPos) index--; + b.moveTabTo(tab, index); + } + this.deleteTabValue(tab, this.kINSERT_BEFORE); + if (isSubTreeCollapsed) { this.collapseExpandTabSubTree(tab, isSubTreeCollapsed); } @@ -1778,6 +1778,7 @@ catch(e) { } this.setTabValue(aParent, this.kCHILDREN, children); + this.setTabValue(aChild, this.kPARENT, aParent.getAttribute(this.kID)); this.updateTabsCount(aParent); if (newIndex > aChild._tPos) newIndex--;