From 8e9a74581d674e02167be8cd67b6bb6b8e2f4ca7 Mon Sep 17 00:00:00 2001 From: piro Date: Thu, 4 Mar 2010 02:43:12 +0000 Subject: [PATCH] =?UTF-8?q?getTabById=E3=81=AE=E6=9C=80=E9=81=A9=E5=8C=96?= =?UTF-8?q?=E3=82=92=E5=86=8D=E5=B0=8E=E5=85=A5?= 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@6338 599a83e7-65a4-db11-8015-0010dcdd6dc2 --- content/treestyletab/treestyletabbrowser.js | 55 +++++++++++---------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/content/treestyletab/treestyletabbrowser.js b/content/treestyletab/treestyletabbrowser.js index 31ec8932..2f3f0f54 100644 --- a/content/treestyletab/treestyletabbrowser.js +++ b/content/treestyletab/treestyletabbrowser.js @@ -128,23 +128,28 @@ TreeStyleTabBrowser.prototype = { return false; }, -// getTabById : function TSTBrowser_getTabById(aId, aTabBrowserChildren) -// { -// if (!aId) return null; -// -// if (!aTabBrowserChildren) -// return aId in this._tabsCache ? this._tabsCache[aId] : null ; -// -// var b = this.getTabBrowserFromChild(aTabBrowserChildren); -// return b ? b.treeStyleTab.getTabById(aId) : null ; -// }, + getTabById : function TSTBrowser_getTabById(aId, aTabBrowserChildren) /* PUBLIC API */ + { + if (aTabBrowserChildren && !(aTabBrowserChildren instanceof Ci.nsIDOMNode)) + aTabBrowserChildren = null; + + if (aTabBrowserChildren) { + var b = this.getTabBrowserFromChild(aTabBrowserChildren); + if (!b) + return null; + if (b != this.mTabBrowser) + return b.treeStyleTab.getTabById(aId); + } + + return this._tabsCache[aId] || null; + }, -// getParentTab : function TSTBrowser_getParentTab(aTab) /* PUBLIC API */ -// { -// if (!aTab) return null; -// var b = this.getTabBrowserFromChild(aTab); -// return b.treeStyleTab.getTabById(aTab.getAttribute(this.kPARENT)); -// }, + getParentTab : function TSTBrowser_getParentTab(aTab) /* PUBLIC API */ + { + if (!aTab) return null; + var b = this.getTabBrowserFromChild(aTab); + return b.treeStyleTab.getTabById(aTab.getAttribute(this.kPARENT)); + }, // getParentTab : function TSTBrowser_getParentTab(aTab) /* PUBLIC API */ // { @@ -181,7 +186,7 @@ TreeStyleTabBrowser.prototype = { var b = this.mTabBrowser; -// this._tabsCache = {}; + this._tabsCache = {}; this.internallyTabMovingCount = 0; this.subTreeMovingCount = 0; @@ -684,12 +689,12 @@ TreeStyleTabBrowser.prototype = { window.setTimeout(function(aSelf) { if (!aSelf.getTabValue(aTab, aSelf.kID)) { aSelf.setTabValue(aTab, aSelf.kID, id); -// if (!(id in aSelf._tabsCache)) -// aSelf._tabsCache[id] = aTab; + if (!(id in aSelf._tabsCache)) + aSelf._tabsCache[id] = aTab; } }, 0, this); -// if (!(id in this._tabsCache)) -// this._tabsCache[id] = aTab; + if (!(id in this._tabsCache)) + this._tabsCache[id] = aTab; } aTab.__treestyletab__linkedTabBrowser = this.mTabBrowser; @@ -1254,9 +1259,9 @@ TreeStyleTabBrowser.prototype = { destroyTab : function TSTBrowser_destroyTab(aTab) { -// var id = aTab.getAttribute(this.kID); -// if (id in this._tabsCache) -// delete this._tabsCache[id]; + var id = aTab.getAttribute(this.kID); + if (id in this._tabsCache) + delete this._tabsCache[id]; // delete aTab.__treestyletab__parentTab; // delete aTab.__treestyletab__childTabs; @@ -2126,7 +2131,7 @@ TreeStyleTabBrowser.prototype = { this.deleteTabValue(tab, this.kCLOSED_SET_ID); this.setTabValue(tab, this.kID, id); -// this._tabsCache[id] = tab; + this._tabsCache[id] = tab; if (closeSetId) this.restoreClosedSet(closeSetId, tab);