From ec8cf6915363c70df3e1b3dbdf795b73d9dd569a Mon Sep 17 00:00:00 2001 From: piro Date: Mon, 26 Oct 2009 02:36:42 +0000 Subject: [PATCH] =?UTF-8?q?=E3=82=B5=E3=83=96=E3=83=84=E3=83=AA=E3=83=BC?= =?UTF-8?q?=E3=82=92=E6=8A=98=E3=82=8A=E3=81=9F=E3=81=9F=E3=82=81=E3=81=AA?= =?UTF-8?q?=E3=81=84=E8=A8=AD=E5=AE=9A=E3=81=AE=E6=99=82=E3=81=AB=E3=81=BE?= =?UTF-8?q?=E3=81=A7=E3=80=81=E3=82=BF=E3=83=96=E3=81=8C=E5=86=85=E9=83=A8?= =?UTF-8?q?=E7=9A=84=E3=81=AB=E6=8A=98=E3=82=8A=E3=81=9F=E3=81=9F=E3=81=BE?= =?UTF-8?q?=E3=82=8C=E3=81=9F=E7=8A=B6=E6=85=8B=E3=81=A8=E3=81=97=E3=81=A6?= =?UTF-8?q?=E6=89=B1=E3=82=8F=E3=82=8C=E3=81=A6=E3=81=97=E3=81=BE=E3=81=A3?= =?UTF-8?q?=E3=81=A6=E3=81=84=E3=81=9F=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@5265 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/treestyletab.js | 82 +++++++++++++++++++-- content/treestyletab/treestyletabbrowser.js | 32 ++++---- 2 files changed, 93 insertions(+), 21 deletions(-) diff --git a/content/treestyletab/treestyletab.js b/content/treestyletab/treestyletab.js index 6e3800b7..47b89862 100644 --- a/content/treestyletab/treestyletab.js +++ b/content/treestyletab/treestyletab.js @@ -807,9 +807,24 @@ var TreeStyleTabService = { ).singleNodeValue; }, + getTabIndex : function(aTab) + { + if (!aTab) return -1; + return this.evaluateXPath( + 'count(preceding-sibling::xul:tab)', + aTab, + XPathResult.NUMBER_TYPE + ).numberValue; + }, + getNextVisibleTab : function(aTab) { if (!aTab) return null; + + var b = this.getTabBrowserFromChild(aTab) || this.browser; + if (b.getAttribute(this.kALLOW_COLLAPSE) != 'true') + return this.getNextTab(aTab); + return this.evaluateXPath( 'following-sibling::xul:tab[not(@'+this.kCOLLAPSED+'="true")][1]', aTab, @@ -820,6 +835,11 @@ var TreeStyleTabService = { getPreviousVisibleTab : function(aTab) { if (!aTab) return null; + + var b = this.getTabBrowserFromChild(aTab) || this.browser; + if (b.getAttribute(this.kALLOW_COLLAPSE) != 'true') + return this.getPreviousTab(aTab); + return this.evaluateXPath( 'preceding-sibling::xul:tab[not(@'+this.kCOLLAPSED+'="true")][1]', aTab, @@ -830,6 +850,11 @@ var TreeStyleTabService = { getLastVisibleTab : function(aTab) { if (!aTab) return null; + + var b = this.getTabBrowserFromChild(aTab) || this.browser; + if (b.getAttribute(this.kALLOW_COLLAPSE) != 'true') + return this.getLastTab(aTab); + return this.evaluateXPath( 'child::xul:tab[not(@'+this.kCOLLAPSED+'="true")][last()]', aTab.parentNode, @@ -839,6 +864,10 @@ var TreeStyleTabService = { getVisibleTabs : function(aTab) { + var b = this.getTabBrowserFromChild(aTab) || this.browser; + if (b.getAttribute(this.kALLOW_COLLAPSE) != 'true') + return this.getTabs(b); + var xpathResult = this.evaluateXPath( 'child::xul:tab[not(@'+this.kCOLLAPSED+'="true")]', aTab.parentNode @@ -848,8 +877,15 @@ var TreeStyleTabService = { getVisibleIndex : function(aTab) { - if (!aTab || aTab.getAttribute(this.kCOLLAPSED) == 'true') return -1; - return this.evaluateXPath( + if (!aTab) return -1; + + var b = this.getTabBrowserFromChild(aTab) || this.browser; + if (b.getAttribute(this.kALLOW_COLLAPSE) != 'true') + return this.getTabIndex(aTab); + + return aTab.getAttribute(this.kCOLLAPSED) == 'true' ? + -1 : + this.evaluateXPath( 'count(preceding-sibling::xul:tab[not(@'+this.kCOLLAPSED+'="true")])', aTab, XPathResult.NUMBER_TYPE @@ -868,6 +904,28 @@ var TreeStyleTabService = { ); }, + isCollapsed : function(aTab) /* PUBLIC API */ + { + if (!aTab) return false; + + var b = this.getTabBrowserFromChild(aTab) || this.browser; + if (b.getAttribute(this.kALLOW_COLLAPSE) == 'true') + return false; + + return aTab.getAttribute(this.kCOLLAPSED) == 'true'; + }, + + isSubtreeCollapsed : function(aTab) /* PUBLIC API */ + { + if (!aTab) return false; + + var b = this.getTabBrowserFromChild(aTab) || this.browser; + if (b.getAttribute(this.kALLOW_COLLAPSE) == 'true') + return false; + + return aTab.getAttribute(this.kSUBTREE_COLLAPSED) == 'true'; + }, + getParentTab : function(aTab) /* PUBLIC API */ { if (!aTab) return null; @@ -1064,16 +1122,26 @@ 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")]'; + return this.evaluateXPath( - 'sum((self::* | preceding-sibling::xul:tab[not(@'+this.kCOLLAPSED+'="true")])/attribute::'+this.kX_OFFSET+')', + 'sum((self::* | preceding-sibling::xul:tab'+extraCondition+')/attribute::'+this.kX_OFFSET+')', aTab, XPathResult.NUMBER_TYPE ).numberValue; }, getYOffsetOfTab : function(aTab) { + var extraCondition = ''; + var b = this.getTabBrowserFromChild(aTab) || this.browser; + if (b.getAttribute(this.kALLOW_COLLAPSE) == 'true') + extraCondition = '[not(@'+this.kCOLLAPSED+'="true")]'; + return this.evaluateXPath( - 'sum((self::* | preceding-sibling::xul:tab[not(@'+this.kCOLLAPSED+'="true")])/attribute::'+this.kY_OFFSET+')', + 'sum((self::* | preceding-sibling::xul:tab'+extraCondition+')/attribute::'+this.kY_OFFSET+')', aTab, XPathResult.NUMBER_TYPE ).numberValue; @@ -1517,7 +1585,7 @@ try{ return true; tab = TSTTabBrowser.treeStyleTab.getTabFromEvent(aEvent); - if (tab && tab.getAttribute(TreeStyleTabService.kCOLLAPSED) == 'true') + if (TreeStyleTabService.isCollapsed(tab)) return false; var info = TSTTabBrowser.treeStyleTab.getDropAction(aEvent, TST_DRAGSESSION); @@ -2208,7 +2276,7 @@ catch(e) { if (this._tabShouldBeExpandedAfterKeyReleased) { let tab = this._tabShouldBeExpandedAfterKeyReleased; if (this.hasChildTabs(tab) && - (tab.getAttribute(this.kSUBTREE_COLLAPSED) == 'true')) { + this.isSubtreeCollapsed(tab)) { this.getTabBrowserFromChild(tab) .treeStyleTab .collapseExpandTreesIntelligentlyFor(tab); @@ -2310,7 +2378,7 @@ catch(e) { handleTooltip : function(aEvent, aTab) { var label; - var collapsed = aTab.getAttribute(this.kSUBTREE_COLLAPSED) == 'true'; + var collapsed = this.isSubtreeCollapsed(aTab); var base = parseInt(aTab.getAttribute(this.kNEST) || 0); var descendant = this.getDescendantTabs(aTab); diff --git a/content/treestyletab/treestyletabbrowser.js b/content/treestyletab/treestyletabbrowser.js index 314a6e47..eb917b5b 100644 --- a/content/treestyletab/treestyletabbrowser.js +++ b/content/treestyletab/treestyletabbrowser.js @@ -223,7 +223,8 @@ TreeStyleTabBrowser.prototype = { -1; i--) { - if (descendant[i].getAttribute(this.kCOLLAPSED) == 'true') continue; + if (this.isCollapsed(descendant[i])) continue; lastVisible = descendant[i]; break; }