From c5d0a231573a32f4b69fe1ea2fe3cc1f50b50b6b Mon Sep 17 00:00:00 2001 From: piro Date: Tue, 29 Sep 2009 06:36:11 +0000 Subject: [PATCH] =?UTF-8?q?=E5=AE=9F=E9=9A=9B=E3=81=AE=E7=8A=B6=E6=85=8B?= =?UTF-8?q?=E3=81=A8=E4=BF=9D=E5=AD=98=E3=81=95=E3=82=8C=E3=81=9F=E3=82=BB?= =?UTF-8?q?=E3=83=83=E3=82=B7=E3=83=A7=E3=83=B3=E6=83=85=E5=A0=B1=E3=81=A8?= =?UTF-8?q?=E3=81=AE=E9=96=93=E3=81=AB=E4=B8=8D=E6=95=B4=E5=90=88=E3=81=8C?= =?UTF-8?q?=E7=99=BA=E7=94=9F=E3=81=99=E3=82=8B=E5=A0=B4=E5=90=88=E3=81=8C?= =?UTF-8?q?=E3=81=82=E3=81=A3=E3=81=9F=EF=BC=88=E3=82=BB=E3=83=83=E3=82=B7?= =?UTF-8?q?=E3=83=A7=E3=83=B3=E5=BE=A9=E5=85=83=E6=99=82=E3=81=AB=E3=83=84?= =?UTF-8?q?=E3=83=AA=E3=83=BC=E6=A7=8B=E9=80=A0=E3=81=8C=E5=A3=8A=E3=82=8C?= =?UTF-8?q?=E3=82=8B=E3=81=93=E3=81=A8=E3=81=8C=E3=81=82=E3=81=A3=E3=81=9F?= =?UTF-8?q?=EF=BC=89=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@5142 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/treestyletab.js | 16 ++++++++++++++-- content/treestyletab/treestyletabbrowser.js | 4 +++- tests/unit/treestyletab_tabUtils.test.js | 1 + 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/content/treestyletab/treestyletab.js b/content/treestyletab/treestyletab.js index 79e0dbd8..b87a86ec 100644 --- a/content/treestyletab/treestyletab.js +++ b/content/treestyletab/treestyletab.js @@ -727,8 +727,7 @@ var TreeStyleTabService = { getTabById : function(aId, aTabBrowserChildren) { if (!aId) return null; - var b = aTabBrowserChildren ? this.getTabBrowserFromChild(aTabBrowserChildren) : null ; - if (!b) b = this.browser; + var b = this.getTabBrowserFromChild(aTabBrowserChildren) || this.browser; return this.evaluateXPath( 'descendant::xul:tab[@'+this.kID+' = "'+aId+'"]', b.mTabContainer, @@ -736,6 +735,18 @@ var TreeStyleTabService = { ).singleNodeValue; }, + isTabDuplicated : function(aTab) + { + if (!aTab) return false; + var id = this.getTabValue(aTab, this.kID); + var b = this.getTabBrowserFromChild(aTab) || this.browser; + return this.evaluateXPath( + 'count(descendant::xul:tab[@'+this.kID+' = "'+id+'" or @'+this.kID+'-temp = "'+id+'"]) > 1', + b.mTabContainer, + XPathResult.BOOLEAN_TYPE + ).booleanValue; + }, + getTabs : function(aTabBrowser) { return this.evaluateXPath( @@ -1113,6 +1124,7 @@ var TreeStyleTabService = { { aTab.removeAttribute(aKey); try { + this.SessionStore.setTabValue(aTab, ''); this.SessionStore.deleteTabValue(aTab, aKey); } catch(e) { diff --git a/content/treestyletab/treestyletabbrowser.js b/content/treestyletab/treestyletabbrowser.js index 354d0c10..62080ad2 100644 --- a/content/treestyletab/treestyletabbrowser.js +++ b/content/treestyletab/treestyletabbrowser.js @@ -1744,10 +1744,12 @@ TreeStyleTabBrowser.prototype = { var id = this.getTabValue(tab, this.kID); - if (this.getTabById(id)) { // this is a duplicated tab! + tab.setAttribute(this.kID+'-temp', id); + if (this.isTabDuplicated(tab)) { // this is a duplicated tab! maybeDuplicated = true; id = this.redirectId(id); } + tab.removeAttribute(this.kID+'-temp'); if (!maybeDuplicated) { /* If it has a parent, it is wrongly attacched by tab moving diff --git a/tests/unit/treestyletab_tabUtils.test.js b/tests/unit/treestyletab_tabUtils.test.js index 520d20b1..25286cb5 100644 --- a/tests/unit/treestyletab_tabUtils.test.js +++ b/tests/unit/treestyletab_tabUtils.test.js @@ -196,6 +196,7 @@ test_setAndGetTabValue.setUp = function() { test_setAndGetTabValue.tearDown = function() { tabs.forEach(function(aTab) { try { + SessionStore.setTabValue(aTab, randomKey, ''); SessionStore.deleteTabValue(aTab, randomKey); } catch(e) {