getTabByIdの最適化を再導入

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@6338 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2010-03-04 02:43:12 +00:00
parent 0a46d3bc4b
commit 8e9a74581d

View File

@ -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;
// getParentTab : function TSTBrowser_getParentTab(aTab) /* PUBLIC API */
// {
// if (!aTab) return null;
// var b = this.getTabBrowserFromChild(aTab);
// return b.treeStyleTab.getTabById(aTab.getAttribute(this.kPARENT));
// },
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 */
// {
@ -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);