From 2a65b99cab7191d8b1ac692d7b4e8b99a6f61c8d Mon Sep 17 00:00:00 2001 From: piro Date: Mon, 26 Oct 2009 02:47:38 +0000 Subject: [PATCH] =?UTF-8?q?=E6=8A=98=E3=82=8A=E3=81=9F=E3=81=9F=E3=81=BF?= =?UTF-8?q?=E5=8F=AF=E8=83=BD=E3=81=8B=E3=81=A9=E3=81=86=E3=81=8B=E3=81=AE?= =?UTF-8?q?=E5=88=A4=E5=AE=9A=E3=81=8C=E3=81=8A=E3=81=8B=E3=81=97=E3=81=8F?= =?UTF-8?q?=E3=81=AA=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@5266 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/treestyletab.js | 45 +++++++++------------ content/treestyletab/treestyletabbrowser.js | 16 ++++---- 2 files changed, 27 insertions(+), 34 deletions(-) diff --git a/content/treestyletab/treestyletab.js b/content/treestyletab/treestyletab.js index 47b89862..ae3f30a8 100644 --- a/content/treestyletab/treestyletab.js +++ b/content/treestyletab/treestyletab.js @@ -821,8 +821,7 @@ var TreeStyleTabService = { { if (!aTab) return null; - var b = this.getTabBrowserFromChild(aTab) || this.browser; - if (b.getAttribute(this.kALLOW_COLLAPSE) != 'true') + if (!this.canCollapseSubtree(aTab)) return this.getNextTab(aTab); return this.evaluateXPath( @@ -836,8 +835,7 @@ var TreeStyleTabService = { { if (!aTab) return null; - var b = this.getTabBrowserFromChild(aTab) || this.browser; - if (b.getAttribute(this.kALLOW_COLLAPSE) != 'true') + if (!this.canCollapseSubtree(aTab)) return this.getPreviousTab(aTab); return this.evaluateXPath( @@ -851,8 +849,7 @@ var TreeStyleTabService = { { if (!aTab) return null; - var b = this.getTabBrowserFromChild(aTab) || this.browser; - if (b.getAttribute(this.kALLOW_COLLAPSE) != 'true') + if (!this.canCollapseSubtree(aTab)) return this.getLastTab(aTab); return this.evaluateXPath( @@ -864,8 +861,7 @@ var TreeStyleTabService = { getVisibleTabs : function(aTab) { - var b = this.getTabBrowserFromChild(aTab) || this.browser; - if (b.getAttribute(this.kALLOW_COLLAPSE) != 'true') + if (!this.canCollapseSubtree(aTab)) return this.getTabs(b); var xpathResult = this.evaluateXPath( @@ -879,8 +875,7 @@ var TreeStyleTabService = { { if (!aTab) return -1; - var b = this.getTabBrowserFromChild(aTab) || this.browser; - if (b.getAttribute(this.kALLOW_COLLAPSE) != 'true') + if (!this.canCollapseSubtree(aTab)) return this.getTabIndex(aTab); return aTab.getAttribute(this.kCOLLAPSED) == 'true' ? @@ -904,12 +899,15 @@ var TreeStyleTabService = { ); }, + canCollapseSubtree : function(aTabBrowser) /* PUBLIC API */ + { + var b = this.getTabBrowserFromChild(aTabBrowser) || this.browser; + return b.getAttribute(this.kALLOW_COLLAPSE) == 'true'; + }, + isCollapsed : function(aTab) /* PUBLIC API */ { - if (!aTab) return false; - - var b = this.getTabBrowserFromChild(aTab) || this.browser; - if (b.getAttribute(this.kALLOW_COLLAPSE) == 'true') + if (!aTab || !this.canCollapseSubtree(aTab)) return false; return aTab.getAttribute(this.kCOLLAPSED) == 'true'; @@ -917,10 +915,7 @@ var TreeStyleTabService = { isSubtreeCollapsed : function(aTab) /* PUBLIC API */ { - if (!aTab) return false; - - var b = this.getTabBrowserFromChild(aTab) || this.browser; - if (b.getAttribute(this.kALLOW_COLLAPSE) == 'true') + if (!aTab || !this.canCollapseSubtree(aTab)) return false; return aTab.getAttribute(this.kSUBTREE_COLLAPSED) == 'true'; @@ -1122,10 +1117,9 @@ var TreeStyleTabService = { getXOffsetOfTab : function(aTab) { - var extraCondition = ''; - var b = this.getTabBrowserFromChild(aTab) || this.browser; - if (b.getAttribute(this.kALLOW_COLLAPSE) == 'true') - extraCondition = '[not(@'+this.kCOLLAPSED+'="true")]'; + var extraCondition = this.canCollapseSubtree(aTab) ? + '[not(@'+this.kCOLLAPSED+'="true")]' : + '' ; return this.evaluateXPath( 'sum((self::* | preceding-sibling::xul:tab'+extraCondition+')/attribute::'+this.kX_OFFSET+')', @@ -1135,10 +1129,9 @@ var TreeStyleTabService = { }, getYOffsetOfTab : function(aTab) { - var extraCondition = ''; - var b = this.getTabBrowserFromChild(aTab) || this.browser; - if (b.getAttribute(this.kALLOW_COLLAPSE) == 'true') - extraCondition = '[not(@'+this.kCOLLAPSED+'="true")]'; + var extraCondition = this.canCollapseSubtree(aTab) ? + '[not(@'+this.kCOLLAPSED+'="true")]' : + ''; return this.evaluateXPath( 'sum((self::* | preceding-sibling::xul:tab'+extraCondition+')/attribute::'+this.kY_OFFSET+')', diff --git a/content/treestyletab/treestyletabbrowser.js b/content/treestyletab/treestyletabbrowser.js index eb917b5b..0f8df083 100644 --- a/content/treestyletab/treestyletabbrowser.js +++ b/content/treestyletab/treestyletabbrowser.js @@ -223,7 +223,7 @@ TreeStyleTabBrowser.prototype = {