From f362343c48958b897ab5e477a18f59010bd07b52 Mon Sep 17 00:00:00 2001 From: piro Date: Mon, 26 Jan 2009 06:37:29 +0000 Subject: [PATCH] getLastTab() git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@3538 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/treestyletab.js | 47 ++++++++++++--------- content/treestyletab/treestyletabbrowser.js | 9 ++-- 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/content/treestyletab/treestyletab.js b/content/treestyletab/treestyletab.js index 14dd9f41..0d793456 100644 --- a/content/treestyletab/treestyletab.js +++ b/content/treestyletab/treestyletab.js @@ -509,25 +509,6 @@ var TreeStyleTabService = { return frame; }, - getTabs : function(aTabBrowser) - { - return this.evaluateXPath( - 'descendant::xul:tab', - aTabBrowser.mTabContainer - ); - }, - - getTabsArray : function(aTabBrowser) - { - var tabs = this.getTabs(aTabBrowser); - var array = []; - for (var i = 0, maxi = tabs.snapshotLength; i < maxi; i++) - { - array.push(tabs.snapshotItem(i)); - } - return array; - }, - makeNewId : function() { return 'tab-<'+Date.now()+'-'+parseInt(Math.random() * 65000)+'>'; @@ -592,6 +573,34 @@ var TreeStyleTabService = { ).singleNodeValue; }, + getTabs : function(aTabBrowser) + { + return this.evaluateXPath( + 'descendant::xul:tab', + aTabBrowser.mTabContainer + ); + }, + + getTabsArray : function(aTabBrowser) + { + var tabs = this.getTabs(aTabBrowser); + var array = []; + for (var i = 0, maxi = tabs.snapshotLength; i < maxi; i++) + { + array.push(tabs.snapshotItem(i)); + } + return array; + }, + + getLastTab : function(aTabBrowser) + { + return this.evaluateXPath( + 'descendant::xul:tab[last()]', + aTabBrowser.mTabContainer, + XPathResult.FIRST_ORDERED_NODE_TYPE + ).singleNodeValue; + }, + getNextTab : function(aTab) { return this.evaluateXPath( diff --git a/content/treestyletab/treestyletabbrowser.js b/content/treestyletab/treestyletabbrowser.js index 4a40dbfe..d2405484 100644 --- a/content/treestyletab/treestyletabbrowser.js +++ b/content/treestyletab/treestyletabbrowser.js @@ -133,8 +133,7 @@ TreeStyleTabBrowser.prototype = { '{', .toString() )); @@ -1339,8 +1338,7 @@ TreeStyleTabBrowser.prototype = { var attach = this.getTreePref('attachChildrenToGrandParentOnRemoveTab'); var processTab = !attach ? function(aTab) { self.partTab(aTab, true); - var tabs = self.getTabs(b); - self.moveTabSubTreeTo(aTab, tabs.snapshotItem(tabs.snapshotLength-1)._tPos); + self.moveTabSubTreeTo(aTab, self.getLastTab(b)._tPos); } : parentTab ? function(aTab) { self.attachTabTo(aTab, parentTab, { @@ -2738,8 +2736,7 @@ TreeStyleTabBrowser.prototype = { b.moveTabTo(b.mCurrentTab, nextTab._tPos - 1); } else { - var tabs = this.getTabs(b); - b.moveTabTo(b.mCurrentTab, tabs.snapshotItem(tabs.snapshotLength-1)._tPos); + b.moveTabTo(b.mCurrentTab, this.getLastTab(b)._tPos); } this.internallyTabMoving = false; b.mCurrentTab.focus();