optimize: reduce use of Iterator

This commit is contained in:
Piro / SHIMODA Hiroshi 2012-02-05 06:31:03 +09:00
parent f9daab2ae0
commit 16f6cd7dd9
11 changed files with 336 additions and 205 deletions

View File

@ -52,16 +52,18 @@ var TreeStyleTabBookmarksService = {
return; return;
} }
for (let [, item] in Iterator(aBookarmks)) for (let i = 0, maxi = aBookarmks.length; i < maxi; i++)
{ {
let item = aBookarmks[i];
item.position = this.BookmarksService.getItemIndex(item.id); item.position = this.BookmarksService.getItemIndex(item.id);
} }
aBookarmks.sort(function(aA, aB) { aBookarmks.sort(function(aA, aB) {
return aA.position - aB.position; return aA.position - aB.position;
}); });
for (let [i, item] in Iterator(aBookarmks)) for (let i = 0, maxi = aBookarmks.length; i < maxi; i++)
{ {
let item = aBookarmks[i];
if (this.BookmarksService.getItemType(item.id) != this.BookmarksService.TYPE_BOOKMARK) if (this.BookmarksService.getItemType(item.id) != this.BookmarksService.TYPE_BOOKMARK)
continue; continue;
@ -104,8 +106,9 @@ var TreeStyleTabBookmarksService = {
var b = this.getTabBrowserFromChild(tabs[0]); var b = this.getTabBrowserFromChild(tabs[0]);
var bookmarkedTabs = []; var bookmarkedTabs = [];
for (let [i, tab] in Iterator(tabs)) for (let i = 0, maxi = tabs.length; i < maxi; i++)
{ {
let tab = tabs[i];
if (!this.isGroupTab(tab, i == 0)) bookmarkedTabs.push(tab); if (!this.isGroupTab(tab, i == 0)) bookmarkedTabs.push(tab);
bookmarkedTabs = bookmarkedTabs.concat(b.treeStyleTab.getDescendantTabs(tab)); bookmarkedTabs = bookmarkedTabs.concat(b.treeStyleTab.getDescendantTabs(tab));
} }
@ -360,8 +363,10 @@ var TreeStyleTabBookmarksService = {
TreeStyleTabBookmarksService.beginAddBookmarksFromTabs((function() { TreeStyleTabBookmarksService.beginAddBookmarksFromTabs((function() {
var tabs = []; var tabs = [];
var seen = {}; var seen = {};
for (let [, tab] in Iterator(getBrowser().mTabContainer.childNodes)) var allTabs = getBrowser().mTabContainer.childNodes;
for (let i = 0, maxi = allTabs.length; i < maxi; i++)
{ {
let tab = allTabs[i];
let uri = tab.linkedBrowser.currentURI.spec; let uri = tab.linkedBrowser.currentURI.spec;
if (uri in seen) continue; if (uri in seen) continue;
seen[uri] = true; seen[uri] = true;

View File

@ -185,13 +185,15 @@ function onSyncGroupBookmarkUIToPref()
if (gGroupBookmarkUnderParent.checked) behavior |= 256; if (gGroupBookmarkUnderParent.checked) behavior |= 256;
if (gGroupBookmarkType.value == 'true') behavior |= 512; if (gGroupBookmarkType.value == 'true') behavior |= 512;
for (let [, node] in Iterator([ var nodes = [
gGroupBookmarkUnderParent, gGroupBookmarkUnderParent,
gGroupBookmarkType, gGroupBookmarkType,
gGroupBookmarkType.previousSibling, gGroupBookmarkType.previousSibling,
gGroupBookmarkType.nextSibling gGroupBookmarkType.nextSibling
])) ];
for (let i = 0, maxi = nodes.length; i < maxi; i++)
{ {
let node = nodes[i];
if (behavior & 1) if (behavior & 1)
node.removeAttribute('disabled'); node.removeAttribute('disabled');
else else

View File

@ -201,15 +201,17 @@ var TreeStyleTabWindowHelper = {
); );
} }
for (let [, func] in Iterator(this._splitFunctionNames(<![CDATA[ let (functions = this._splitFunctionNames(<![CDATA[
window.duplicateTab.handleLinkClick window.duplicateTab.handleLinkClick
window.duplicatethistab.handleLinkClick window.duplicatethistab.handleLinkClick
window.__treestyletab__highlander__origHandleLinkClick window.__treestyletab__highlander__origHandleLinkClick
window.__splitbrowser__handleLinkClick window.__splitbrowser__handleLinkClick
window.__ctxextensions__handleLinkClick window.__ctxextensions__handleLinkClick
window.handleLinkClick window.handleLinkClick
]]>))) ]]>)) {
for (let i = 0, maxi = functions.length; i < maxi; i++)
{ {
let func = functions[i];
let source = this._getFunctionSource(func); let source = this._getFunctionSource(func);
if (!source || !/^\(?function handleLinkClick/.test(source)) if (!source || !/^\(?function handleLinkClick/.test(source))
continue; continue;
@ -219,6 +221,7 @@ var TreeStyleTabWindowHelper = {
)); ));
break; break;
} }
}
if ('openLinkIn' in window) { if ('openLinkIn' in window) {
eval('window.openLinkIn = '+ eval('window.openLinkIn = '+
@ -233,13 +236,15 @@ var TreeStyleTabWindowHelper = {
); );
} }
for (let [, func] in Iterator(this._splitFunctionNames(<![CDATA[ let (functions = this._splitFunctionNames(<![CDATA[
window.permaTabs.utils.wrappedFunctions["window.contentAreaClick"] window.permaTabs.utils.wrappedFunctions["window.contentAreaClick"]
window.__contentAreaClick window.__contentAreaClick
window.__ctxextensions__contentAreaClick window.__ctxextensions__contentAreaClick
window.contentAreaClick window.contentAreaClick
]]>))) ]]>)) {
for (let i = 0, maxi = functions.length; i < maxi; i++)
{ {
let func = functions[i];
let source = this._getFunctionSource(func); let source = this._getFunctionSource(func);
if (!source || !/^\(?function contentAreaClick/.test(source)) if (!source || !/^\(?function contentAreaClick/.test(source))
continue; continue;
@ -252,8 +257,9 @@ var TreeStyleTabWindowHelper = {
$1]]> $1]]>
)); ));
} }
}
for (let [, func] in Iterator(this._splitFunctionNames(<![CDATA[ let (functions = this._splitFunctionNames(<![CDATA[
window.duplicateTab.gotoHistoryIndex window.duplicateTab.gotoHistoryIndex
window.duplicateTab.BrowserBack window.duplicateTab.BrowserBack
window.duplicateTab.BrowserForward window.duplicateTab.BrowserForward
@ -265,8 +271,10 @@ var TreeStyleTabWindowHelper = {
window.gotoHistoryIndex window.gotoHistoryIndex
window.BrowserForward window.BrowserForward
window.BrowserBack window.BrowserBack
]]>))) ]]>)) {
for (let i = 0, maxi = functions.length; i < maxi; i++)
{ {
let func = functions[i];
let source = this._getFunctionSource(func); let source = this._getFunctionSource(func);
if (!source || !/^\(?function (gotoHistoryIndex|BrowserForward|BrowserBack)/.test(source)) if (!source || !/^\(?function (gotoHistoryIndex|BrowserForward|BrowserBack)/.test(source))
continue; continue;
@ -278,11 +286,14 @@ var TreeStyleTabWindowHelper = {
$1]]> $1]]>
)); ));
} }
}
for (let [, func] in Iterator(this._splitFunctionNames(<![CDATA[ let (functions = this._splitFunctionNames(<![CDATA[
window.BrowserReloadOrDuplicate window.BrowserReloadOrDuplicate
]]>))) ]]>)) {
for (let i = 0, maxi = functions.length; i < maxi; i++)
{ {
let func = functions[i];
let source = this._getFunctionSource(func); let source = this._getFunctionSource(func);
if (!source || !/^\(?function (BrowserReloadOrDuplicate)/.test(source)) if (!source || !/^\(?function (BrowserReloadOrDuplicate)/.test(source))
continue; continue;
@ -294,13 +305,16 @@ var TreeStyleTabWindowHelper = {
$&]]> $&]]>
)); ));
} }
}
for (let [, func] in Iterator(this._splitFunctionNames(<![CDATA[ let (functions = this._splitFunctionNames(<![CDATA[
permaTabs.utils.wrappedFunctions["window.BrowserHomeClick"] permaTabs.utils.wrappedFunctions["window.BrowserHomeClick"]
window.BrowserHomeClick window.BrowserHomeClick
window.BrowserGoHome window.BrowserGoHome
]]>))) ]]>)) {
for (let i = 0, maxi = functions.length; i < maxi; i++)
{ {
let func = functions[i];
let source = this._getFunctionSource(func); let source = this._getFunctionSource(func);
if (!source || !/^\(?function (BrowserHomeClick|BrowserGoHome)/.test(source)) if (!source || !/^\(?function (BrowserHomeClick|BrowserGoHome)/.test(source))
continue; continue;
@ -311,6 +325,7 @@ var TreeStyleTabWindowHelper = {
$&]]> $&]]>
)); ));
} }
}
eval('FeedHandler.loadFeed = '+ eval('FeedHandler.loadFeed = '+
FeedHandler.loadFeed.toSource().replace( FeedHandler.loadFeed.toSource().replace(

View File

@ -86,13 +86,16 @@ TreeStyleTabWindowHelper.overrideExtensionsPreInit = function TSTWH_overrideExte
(function() { (function() {
var tabsInfo = {}; var tabsInfo = {};
var TST = TreeStyleTabService; var TST = TreeStyleTabService;
for (let [, tab] in Iterator(getBrowser().mTabContainer.childNodes)) var allTabs = getBrowser().mTabContainer.childNodes;
for (let i = 0, maxi = allTabs.length; i < maxi; i++)
{ {
let tab = allTabs[i];
let index = this.getPermaTabLocalIndex(tab); let index = this.getPermaTabLocalIndex(tab);
if (index < 0) continue; if (index < 0) continue;
let info = {}; let info = {};
for (let [, property] in Iterator(TST.extraProperties)) for (let i = 0, maxi = TST.extraProperties.length; i < maxi; i++)
{ {
let property = TST.extraProperties[i];
info[property] = TST.getTabValue(tab, property); info[property] = TST.getTabValue(tab, property);
} }
tabsInfo[this.permaTabs[index].id] = info; tabsInfo[this.permaTabs[index].id] = info;
@ -125,8 +128,9 @@ TreeStyleTabWindowHelper.overrideExtensionsPreInit = function TSTWH_overrideExte
sessionData.getTabProperties.toSource().replace( sessionData.getTabProperties.toSource().replace(
'return tabProperties;', 'return tabProperties;',
<![CDATA[ <![CDATA[
for (let [, property] in Iterator(this.tabTSTProperties)) for (let i = 0, maxi = this.tabTSTProperties.length; i < maxi; i++)
{ {
let tabProperties = this.tabTSTProperties[i];
tabProperties += '|' + property + '=' + encodeURIComponent(aTab.getAttribute(property)); tabProperties += '|' + property + '=' + encodeURIComponent(aTab.getAttribute(property));
} }
$&]]> $&]]>
@ -138,8 +142,9 @@ TreeStyleTabWindowHelper.overrideExtensionsPreInit = function TSTWH_overrideExte
<![CDATA[$& <![CDATA[$&
var TSTProps = tabProperties.split('|'); var TSTProps = tabProperties.split('|');
tabProperties = TSTProps.shift(); tabProperties = TSTProps.shift();
for (let [, property] in Iterator(TSTProps)) for (let i = 0, maxi = TSTProps.length; i < maxi; i++)
{ {
let property = TSTProps[i];
let index = property.indexOf('='); let index = property.indexOf('=');
let name = property.substring(0, index); let name = property.substring(0, index);
let value = decodeURIComponent(property.substring(index+1)); let value = decodeURIComponent(property.substring(index+1));
@ -200,10 +205,13 @@ TreeStyleTabWindowHelper.overrideExtensionsPreInit = function TSTWH_overrideExte
'var tabcount = ', 'var tabcount = ',
<![CDATA[ <![CDATA[
gBrowser.treeStyleTab.collapseExpandAllSubtree(false, true); gBrowser.treeStyleTab.collapseExpandAllSubtree(false, true);
for (let [, tab] in Iterator(gBrowser.treeStyleTab.getTabsArray(gBrowser).slice(1).reverse())) let (tabs = gBrowser.treeStyleTab.getTabsArray(gBrowser).slice(1).reverse()) {
for (let i = 0, maxi = tabs.length; i < maxi; i++)
{ {
let tab = tabs[i];
gBrowser.removeTab(tab); gBrowser.removeTab(tab);
} }
}
TreeStyleTabService.restoringTree = true; TreeStyleTabService.restoringTree = true;
$&]]> $&]]>
)); ));
@ -214,8 +222,10 @@ TreeStyleTabWindowHelper.overrideExtensionsPreInit = function TSTWH_overrideExte
// https://addons.mozilla.org/firefox/addon/4650 // https://addons.mozilla.org/firefox/addon/4650
if ('FS_onFullerScreen' in window && if ('FS_onFullerScreen' in window &&
sv.getTreePref('compatibility.FullerScreen')) { sv.getTreePref('compatibility.FullerScreen')) {
for (let [, func] in Iterator('CheckIfFullScreen,FS_onFullerScreen,FS_onMouseMove'.split(','))) let (functions = 'CheckIfFullScreen,FS_onFullerScreen,FS_onMouseMove'.split(',')) {
for (let i = 0, maxi = functions.length; i < maxi; i++)
{ {
let func = functions[i];
if (!(func in window)) continue; if (!(func in window)) continue;
eval('window.'+func+' = '+window[func].toSource().replace( eval('window.'+func+' = '+window[func].toSource().replace(
/FS_data.mTabs.(removeAttribute\("moz-collapsed"\)|setAttribute\("moz-collapsed", "true"\));/g, /FS_data.mTabs.(removeAttribute\("moz-collapsed"\)|setAttribute\("moz-collapsed", "true"\));/g,
@ -223,6 +233,7 @@ TreeStyleTabWindowHelper.overrideExtensionsPreInit = function TSTWH_overrideExte
)); ));
} }
} }
}
// TooManyTabs // TooManyTabs
// https://addons.mozilla.org/firefox/addon/9429 // https://addons.mozilla.org/firefox/addon/9429
@ -817,8 +828,10 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
if ('LinkyContext' in window && if ('LinkyContext' in window &&
'prototype' in LinkyContext && 'prototype' in LinkyContext &&
sv.getTreePref('compatibility.Linky')) { sv.getTreePref('compatibility.Linky')) {
for (let [, method] in Iterator('doSelected,doSelectedText,doImages,doAll,doAllPics,doValidateAll,doValidateSelected'.split(','))) let (methods = 'doSelected,doSelectedText,doImages,doAll,doAllPics,doValidateAll,doValidateSelected'.split(',')) {
for (let i = 0, maxi = methods.length; i < maxi; i++)
{ {
let method = methods[i];
if (!(method in LinkyContext.prototype)) continue; if (!(method in LinkyContext.prototype)) continue;
eval('LinkyContext.prototype.'+method+' = '+ eval('LinkyContext.prototype.'+method+' = '+
LinkyContext.prototype[method].toSource().replace( LinkyContext.prototype[method].toSource().replace(
@ -831,6 +844,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
); );
} }
} }
}
// QuickDrag // QuickDrag
// https://addons.mozilla.org/firefox/addon/6912 // https://addons.mozilla.org/firefox/addon/6912
@ -1324,15 +1338,16 @@ TreeStyleTabWindowHelper.overrideExtensionsDelayed = function TSTWH_overrideExte
break; break;
case sv.kEVENT_TYPE_BEFORE_TOOLBAR_CUSTOMIZATION: case sv.kEVENT_TYPE_BEFORE_TOOLBAR_CUSTOMIZATION:
for (let [, toolbox] in Iterator(tabbarToolboxes)) for (let i = 0, maxi = tabbarToolboxes.length; i < maxi; i++)
{ {
toolbox.removeAttribute('collapsed'); tabbarToolboxes[i].removeAttribute('collapsed');
} }
break; break;
case sv.kEVENT_TYPE_AFTER_TOOLBAR_CUSTOMIZATION: case sv.kEVENT_TYPE_AFTER_TOOLBAR_CUSTOMIZATION:
for (let [, toolbox] in Iterator(tabbarToolboxes)) for (let i = 0, maxi = tabbarToolboxes.length; i < maxi; i++)
{ {
let toolbox = tabbarToolboxes[i];
if (!toolbox.firstChild.hasChildNodes()) if (!toolbox.firstChild.hasChildNodes())
toolbox.setAttribute('collapsed', true); toolbox.setAttribute('collapsed', true);
} }
@ -1352,8 +1367,9 @@ TreeStyleTabWindowHelper.overrideExtensionsDelayed = function TSTWH_overrideExte
document.addEventListener(sv.kEVENT_TYPE_BEFORE_TOOLBAR_CUSTOMIZATION, listener, false); document.addEventListener(sv.kEVENT_TYPE_BEFORE_TOOLBAR_CUSTOMIZATION, listener, false);
document.addEventListener(sv.kEVENT_TYPE_AFTER_TOOLBAR_CUSTOMIZATION, listener, false); document.addEventListener(sv.kEVENT_TYPE_AFTER_TOOLBAR_CUSTOMIZATION, listener, false);
document.addEventListener('unload', listener, false); document.addEventListener('unload', listener, false);
for (let [, toolbox] in Iterator(tabbarToolboxes)) for (let i = 0, maxi = tabbarToolboxes.length; i < maxi; i++)
{ {
let toolbox = tabbarToolboxes[i];
if (!toolbox.firstChild.hasChildNodes()) if (!toolbox.firstChild.hasChildNodes())
toolbox.setAttribute('collapsed', true); toolbox.setAttribute('collapsed', true);
} }

View File

@ -523,8 +523,9 @@ TreeStyleTabBrowser.prototype = {
{ {
var tabs = this.getTabsArray(this.mTabBrowser); var tabs = this.getTabsArray(this.mTabBrowser);
var count = tabs.length; var count = tabs.length;
for (let [i, tab] in Iterator(tabs)) for (let i = 0; i < count; i++)
{ {
let tab = tabs[i];
if (aStacked) if (aStacked)
tab.style.zIndex = count * 1000 - index; tab.style.zIndex = count * 1000 - index;
else else
@ -721,7 +722,7 @@ TreeStyleTabBrowser.prototype = {
if (!('MultipleTabService' in w)) { if (!('MultipleTabService' in w)) {
w.setTimeout(function(aSelf, aTabBrowser, aPopup) { w.setTimeout(function(aSelf, aTabBrowser, aPopup) {
let suffix = '-tabbrowser-'+(aTabBrowser.id || 'instance-'+parseInt(Math.random() * 65000)); let suffix = '-tabbrowser-'+(aTabBrowser.id || 'instance-'+parseInt(Math.random() * 65000));
for (let [, id] in Iterator([ let ids = [
aSelf.kMENUITEM_RELOADSUBTREE, aSelf.kMENUITEM_RELOADSUBTREE,
aSelf.kMENUITEM_RELOADCHILDREN, aSelf.kMENUITEM_RELOADCHILDREN,
aSelf.kMENUITEM_REMOVESUBTREE, aSelf.kMENUITEM_REMOVESUBTREE,
@ -734,8 +735,10 @@ TreeStyleTabBrowser.prototype = {
aSelf.kMENUITEM_AUTOHIDE, aSelf.kMENUITEM_AUTOHIDE,
aSelf.kMENUITEM_FIXED, aSelf.kMENUITEM_FIXED,
aSelf.kMENUITEM_BOOKMARKSUBTREE aSelf.kMENUITEM_BOOKMARKSUBTREE
])) ];
for (let i = 0, maxi = ids.length; i < maxi; i++)
{ {
let id = ids[i];
let item = d.getElementById(id).cloneNode(true); let item = d.getElementById(id).cloneNode(true);
item.setAttribute('id', item.getAttribute('id')+suffix); item.setAttribute('id', item.getAttribute('id')+suffix);
@ -973,13 +976,15 @@ TreeStyleTabBrowser.prototype = {
namedNodes.counterAnchor = namedNodes.label; namedNodes.counterAnchor = namedNodes.label;
var foundContainers = []; var foundContainers = [];
for (let [, container] in Iterator([ var containers = [
namedNodes.twistyAnchor.parentNode, namedNodes.twistyAnchor.parentNode,
namedNodes.label.parentNode, namedNodes.label.parentNode,
namedNodes.counter.parentNode, namedNodes.counter.parentNode,
namedNodes.closeAnchor.parentNode namedNodes.closeAnchor.parentNode
])) ];
for (let i = 0, maxi = containers.length; i < maxi; i++)
{ {
let container = containers[i];
if (foundContainers.indexOf(container) > -1) if (foundContainers.indexOf(container) > -1)
continue; continue;
this.initTabContentsOrderInternal(container, namedNodes, aForce); this.initTabContentsOrderInternal(container, namedNodes, aForce);
@ -994,8 +999,9 @@ TreeStyleTabBrowser.prototype = {
var nodes = Array.slice(this.document.getAnonymousNodes(aContainer) || aContainer.childNodes); var nodes = Array.slice(this.document.getAnonymousNodes(aContainer) || aContainer.childNodes);
// reset order at first! // reset order at first!
for (let [i, node] in Iterator(nodes)) for (let i = 0, maxi = nodes.length; i < maxi; i++)
{ {
let node = nodes[i];
if (node.getAttribute('class') == 'informationaltab-thumbnail-container') if (node.getAttribute('class') == 'informationaltab-thumbnail-container')
continue; continue;
node.setAttribute('ordinal', i); node.setAttribute('ordinal', i);
@ -1030,8 +1036,9 @@ TreeStyleTabBrowser.prototype = {
var count = nodes.length; var count = nodes.length;
nodes.reverse(); nodes.reverse();
for (let [i, node] in Iterator(nodes)) for (let i = 0, maxi = nodes.length; i < maxi; i++)
{ {
let node = nodes[i];
if (node.getAttribute('class') == 'informationaltab-thumbnail-container') if (node.getAttribute('class') == 'informationaltab-thumbnail-container')
continue; continue;
node.setAttribute('ordinal', (count - i + 1) * 100); node.setAttribute('ordinal', (count - i + 1) * 100);
@ -1043,14 +1050,16 @@ TreeStyleTabBrowser.prototype = {
* Gecko doesn't re-render them in the new order. * Gecko doesn't re-render them in the new order.
* Changing of "display" or "position" can fix this problem. * Changing of "display" or "position" can fix this problem.
*/ */
for (let [, node] in Iterator(nodes)) for (let i = 0, maxi = nodes.length; i < maxi; i++)
{ {
let node = nodes[i];
node.style.visibility = 'hidden'; // we should hide temporary state! node.style.visibility = 'hidden'; // we should hide temporary state!
node.style.position = 'fixed'; node.style.position = 'fixed';
} }
this.Deferred.wait(0.1).next(function() { this.Deferred.wait(0.1).next(function() {
for (let [, node] in Iterator(nodes)) for (let i = 0, maxi = nodes.length; i < maxi; i++)
{ {
let node = nodes[i];
node.style.position = ''; node.style.position = '';
node.style.visibility = ''; node.style.visibility = '';
} }
@ -1070,9 +1079,9 @@ TreeStyleTabBrowser.prototype = {
(typeof aTarget == 'object' && 'length' in aTarget) ? (typeof aTarget == 'object' && 'length' in aTarget) ?
Array.slice(aTarget) : Array.slice(aTarget) :
self.getAllTabsArray(b); self.getAllTabsArray(b);
for (let [, tab] in Iterator(tabs)) for (let i = 0, maxi = tabs.length; i < maxi; i++)
{ {
this.initTabContentsOrder(tab); this.initTabContentsOrder(tabs[i]);
} }
}); });
}, },
@ -1187,8 +1196,10 @@ TreeStyleTabBrowser.prototype = {
b.mPanelContainer.removeAttribute('height'); b.mPanelContainer.removeAttribute('height');
if (strip.localName == 'toolbar') { if (strip.localName == 'toolbar') {
for (let [, node] in Iterator(strip.childNodes)) let nodes = strip.childNodes;
for (let i = 0, maxi = nodes.length; i < maxi; i++)
{ {
let node = nodes[i];
if (node.localName == 'tabs') if (node.localName == 'tabs')
continue; continue;
if (node.hasAttribute('flex')) if (node.hasAttribute('flex'))
@ -1267,8 +1278,10 @@ TreeStyleTabBrowser.prototype = {
this.removeTabbrowserAttribute(this.kTAB_INVERTED); this.removeTabbrowserAttribute(this.kTAB_INVERTED);
if (strip.localName == 'toolbar') { if (strip.localName == 'toolbar') {
for (let [, node] in Iterator(strip.childNodes)) let nodes = strip.childNodes;
for (let i = 0, maxi = nodes.length; i < maxi; i++)
{ {
let node = nodes[i];
if (node.localName == 'tabs') if (node.localName == 'tabs')
continue; continue;
let flex = node.hasAttribute('treestyletab-backup-flex'); let flex = node.hasAttribute('treestyletab-backup-flex');
@ -1302,8 +1315,9 @@ TreeStyleTabBrowser.prototype = {
} }
var tabs = this.getAllTabsArray(b); var tabs = this.getAllTabsArray(b);
for (let [, tab] in Iterator(tabs)) for (let i = 0, maxi = tabs.length; i < maxi; i++)
{ {
let tab = tabs[i];
tab.style.removeProperty(this.indentCSSProp); tab.style.removeProperty(this.indentCSSProp);
tab.style.removeProperty(this.collapseCSSProp); tab.style.removeProperty(this.collapseCSSProp);
} }
@ -1312,8 +1326,9 @@ TreeStyleTabBrowser.prototype = {
this.indentCSSProp = this.indentProp+'-'+this.indentTarget; this.indentCSSProp = this.indentProp+'-'+this.indentTarget;
this.collapseCSSProp = 'margin-'+this.collapseTarget; this.collapseCSSProp = 'margin-'+this.collapseTarget;
for (let [i, tab] in Iterator(tabs)) for (let i = 0, maxi = tabs.length; i < maxi; i++)
{ {
let tab = tabs[i];
this.updateTabCollapsed(tab, tab.getAttribute(this.kCOLLAPSED) == 'true', true); this.updateTabCollapsed(tab, tab.getAttribute(this.kCOLLAPSED) == 'true', true);
} }
@ -1805,8 +1820,10 @@ TreeStyleTabBrowser.prototype = {
reinitAllTabs : function TSTBrowser_reinitAllTabs(aSouldUpdateCount) reinitAllTabs : function TSTBrowser_reinitAllTabs(aSouldUpdateCount)
{ {
for (let [, tab] in Iterator(this.getAllTabsArray(this.mTabBrowser))) var tabs = this.getAllTabsArray(this.mTabBrowser);
for (let i = 0, maxi = tabs.length; i < maxi; i++)
{ {
let tab = tabs[i];
this.initTabAttributes(tab); this.initTabAttributes(tab);
this.initTabContents(tab); this.initTabContents(tab);
if (aSouldUpdateCount) if (aSouldUpdateCount)
@ -1837,8 +1854,10 @@ TreeStyleTabBrowser.prototype = {
var b = this.mTabBrowser; var b = this.mTabBrowser;
delete b.tabContainer.treeStyleTab; delete b.tabContainer.treeStyleTab;
for (let [, tab] in Iterator(this.getAllTabsArray(b))) var tabs = this.getAllTabsArray(b);
for (let i = 0, maxi = tabs.length; i < maxi; i++)
{ {
let tab = tabs[i];
this.stopTabIndentAnimation(tab); this.stopTabIndentAnimation(tab);
this.stopTabCollapseAnimation(tab); this.stopTabCollapseAnimation(tab);
this.destroyTab(tab); this.destroyTab(tab);
@ -2150,24 +2169,24 @@ TreeStyleTabBrowser.prototype = {
case 'extensions.treestyletab.tabbar.multirow': case 'extensions.treestyletab.tabbar.multirow':
this.initTabbar(); this.initTabbar();
this.updateAllTabsIndent(); this.updateAllTabsIndent();
for (let [, tab] in Iterator(tabs)) for (let i = 0, maxi = tabs.length; i < maxi; i++)
{ {
this.initTabContents(tab); this.initTabContents(tabs[i]);
} }
return; return;
case 'extensions.treestyletab.tabbar.invertTabContents': case 'extensions.treestyletab.tabbar.invertTabContents':
this.setTabbrowserAttribute(this.kTAB_CONTENTS_INVERTED, value); this.setTabbrowserAttribute(this.kTAB_CONTENTS_INVERTED, value);
for (let [, tab] in Iterator(tabs)) for (let i = 0, maxi = tabs.length; i < maxi; i++)
{ {
this.initTabContents(tab); this.initTabContents(tabs[i]);
} }
return; return;
case 'extensions.treestyletab.tabbar.invertClosebox': case 'extensions.treestyletab.tabbar.invertClosebox':
this.setTabbrowserAttribute(this.kCLOSEBOX_INVERTED, value); this.setTabbrowserAttribute(this.kCLOSEBOX_INVERTED, value);
for (let [, tab] in Iterator(tabs)) for (let i = 0, maxi = tabs.length; i < maxi; i++)
{ {
this.initTabContents(tab); this.initTabContents(tabs[i]);
} }
return; return;
@ -2714,9 +2733,10 @@ TreeStyleTabBrowser.prototype = {
this.markAsClosedSet([tab].concat(tabs)); this.markAsClosedSet([tab].concat(tabs));
for (let [, tab] in Iterator(tabs.reverse())) tabs.reverse();
for (let i = 0, maxi = tabs.length; i < maxi; i++)
{ {
b.removeTab(tab, { animate : true }); b.removeTab(tabs[i], { animate : true });
} }
this.fireTabSubtreeClosedEvent(b, tab, tabs); this.fireTabSubtreeClosedEvent(b, tab, tabs);
@ -2903,8 +2923,9 @@ TreeStyleTabBrowser.prototype = {
var self = this; var self = this;
this.Deferred.next(function() { this.Deferred.next(function() {
for (let [, tabs] in Iterator(trees)) for (let i = 0, maxi = trees.length; i < maxi; i++)
{ {
let tabs = trees[i];
self.fireTabSubtreeClosedEvent(b, tabs[0], tabs); self.fireTabSubtreeClosedEvent(b, tabs[0], tabs);
} }
}); });
@ -3129,8 +3150,9 @@ TreeStyleTabBrowser.prototype = {
return aB._tPos - aA._tPos; return aB._tPos - aA._tPos;
}) })
.filter(aSelf.restoreOneTab, aSelf); .filter(aSelf.restoreOneTab, aSelf);
for (let [, tab] in Iterator(restoreTabs)) for (let i = 0, maxi = restoreTabs.length; i < maxi; i++)
{ {
let tab = restoreTabs[i];
aSelf.updateInsertionPositionInfo(tab); aSelf.updateInsertionPositionInfo(tab);
delete tab.__treestyletab__restoreState; delete tab.__treestyletab__restoreState;
} }
@ -3189,8 +3211,9 @@ TreeStyleTabBrowser.prototype = {
var lastIndex = allTabs.length - 1; var lastIndex = allTabs.length - 1;
var lastMovedTab; var lastMovedTab;
normalTabs = normalTabs.slice(0).reverse(); normalTabs = normalTabs.slice(0).reverse();
for (let [, tab] in Iterator(normalTabs)) for (let i = 0, maxi = normalTabs.length; i < maxi; i++)
{ {
let tab = normalTabs[i];
let parent = this.getParentTab(tab); let parent = this.getParentTab(tab);
let attached = false; let attached = false;
if (parent && (tab.hidden != parent.hidden)) { if (parent && (tab.hidden != parent.hidden)) {
@ -3257,8 +3280,9 @@ TreeStyleTabBrowser.prototype = {
this.detachTab(aParent); this.detachTab(aParent);
b.moveTabTo(aParent, lastCount); b.moveTabTo(aParent, lastCount);
var descendantTabs = this.getDescendantTabs(aParent); var descendantTabs = this.getDescendantTabs(aParent);
for (let [, tab] in Iterator(descendantTabs)) for (let i = 0, maxi = descendantTabs.length; i < maxi; i++)
{ {
let tab = descendantTabs[i];
w.TabView.moveTabTo(tab, id); w.TabView.moveTabTo(tab, id);
b.moveTabTo(tab, lastCount); b.moveTabTo(tab, lastCount);
} }
@ -3453,14 +3477,16 @@ TreeStyleTabBrowser.prototype = {
* For failsafe, we must override actual attributes by stored * For failsafe, we must override actual attributes by stored
* values. * values.
*/ */
for (let [, key] in Iterator([ var keys = [
this.kINSERT_BEFORE, this.kINSERT_BEFORE,
this.kINSERT_AFTER this.kINSERT_AFTER
])) ];
for (let i = 0, maxi = keys.length; i < maxi; i++)
{ {
let key = keys[i];
let tab = this.getTabValue(aTab, key); let tab = this.getTabValue(aTab, key);
if (this.getTabById(tab)) if (this.getTabById(tab))
this.setTabValue(aTab, aKey, tab); this.setTabValue(aTab, key, tab);
} }
let parentId = this.getTabValue(aTab, this.kPARENT); let parentId = this.getTabValue(aTab, this.kPARENT);
@ -3516,8 +3542,9 @@ TreeStyleTabBrowser.prototype = {
return this.redirectId(aChild); return this.redirectId(aChild);
}, this); }, this);
for (let [, childTab] in Iterator(aChildrenList)) for (let i = 0, maxi = aChildrenList.length; i < maxi; i++)
{ {
let childTab = aChildrenList[i];
if (childTab && (childTab = this.getTabById(childTab))) { if (childTab && (childTab = this.getTabById(childTab))) {
let options = aOptions; let options = aOptions;
if (options && typeof options == 'function') if (options && typeof options == 'function')
@ -3647,10 +3674,10 @@ TreeStyleTabBrowser.prototype = {
var children = aTab.getAttribute(this.kCHILDREN); var children = aTab.getAttribute(this.kCHILDREN);
if (restoringChildren != children) { if (restoringChildren != children) {
var restoringChildrenIDs = restoringChildren.split('|'); var restoringChildrenIDs = restoringChildren.split('|').reverse();
for (let [i, child] in Iterator(restoringChildrenIDs.reverse())) for (let i = 0, maxi = restoringChildrenIDs.length; i < maxi; i++)
{ {
child = this.getTabById(child); let child = this.getTabById(restoringChildrenIDs[i]);
if (!child) continue; if (!child) continue;
let nextTab = i > 0 ? let nextTab = i > 0 ?
@ -3708,8 +3735,10 @@ TreeStyleTabBrowser.prototype = {
return; return;
var indexes = []; var indexes = [];
for (let [i, item] in Iterator(this.evalInSandbox('('+this.SessionStore.getClosedTabData(this.window)+')'))) var items = this.evalInSandbox('('+this.SessionStore.getClosedTabData(this.window)+')');
for (let i = 0, maxi = items.length; i < maxi; i++)
{ {
let item = items[i];
if (item.state.extData && if (item.state.extData &&
item.state.extData[this.kCLOSED_SET_ID] && item.state.extData[this.kCLOSED_SET_ID] &&
item.state.extData[this.kCLOSED_SET_ID] == aId) item.state.extData[this.kCLOSED_SET_ID] == aId)
@ -3754,9 +3783,9 @@ TreeStyleTabBrowser.prototype = {
this.windowService.restoringTree = true; this.windowService.restoringTree = true;
var offset = 0; var offset = 0;
for (let [, index] in Iterator(aIndexes)) for (let i = 0, maxi = aIndexes.length; i < maxi; i++)
{ {
this.window.undoCloseTab(index - (offset++)); this.window.undoCloseTab(aIndexes[i] - (offset++));
} }
this.window.setTimeout(function(aSelf, aNextFocused) { this.window.setTimeout(function(aSelf, aNextFocused) {
@ -3791,8 +3820,10 @@ TreeStyleTabBrowser.prototype = {
*/ */
let b = this.browser; let b = this.browser;
this.internallyTabMovingCount++; this.internallyTabMovingCount++;
for (let [, childTab] in Iterator(this.getDescendantTabs(aTab).reverse())) let children = this.getDescendantTabs(aTab).reverse();
for (let i = 0, maxi = children.length; i < maxi; i++)
{ {
let childTab = children[i];
if (childTab.__treestyletab__previousPosition > childTab._tPos) if (childTab.__treestyletab__previousPosition > childTab._tPos)
b.moveTabTo(childTab, childTab.__treestyletab__previousPosition); b.moveTabTo(childTab, childTab.__treestyletab__previousPosition);
} }
@ -3806,8 +3837,10 @@ TreeStyleTabBrowser.prototype = {
*/ */
let b = this.browser; let b = this.browser;
this.internallyTabMovingCount++; this.internallyTabMovingCount++;
for (let [, childTab] in Iterator(this.getChildTabs(aTab).reverse())) let children = this.getChildTabs(aTab).reverse();
for (let i = 0, maxi = children.length; i < maxi; i++)
{ {
let childTab = children[i];
if (childTab._tPos < parentTab._tPos) if (childTab._tPos < parentTab._tPos)
b.moveTabTo(childTab, parentTab._tPos); b.moveTabTo(childTab, parentTab._tPos);
} }
@ -4195,7 +4228,7 @@ TreeStyleTabBrowser.prototype = {
var b = this.mTabBrowser; var b = this.mTabBrowser;
var sep, items = {}; var sep, items = {};
for (let [, id] in Iterator([ var ids = [
this.kMENUITEM_RELOADSUBTREE, this.kMENUITEM_RELOADSUBTREE,
this.kMENUITEM_RELOADCHILDREN, this.kMENUITEM_RELOADCHILDREN,
this.kMENUITEM_REMOVESUBTREE, this.kMENUITEM_REMOVESUBTREE,
@ -4206,8 +4239,10 @@ TreeStyleTabBrowser.prototype = {
this.kMENUITEM_AUTOHIDE, this.kMENUITEM_AUTOHIDE,
this.kMENUITEM_FIXED, this.kMENUITEM_FIXED,
this.kMENUITEM_BOOKMARKSUBTREE this.kMENUITEM_BOOKMARKSUBTREE
])) ];
for (let i = 0, maxi = ids.length; i < maxi; i++)
{ {
let id = ids[i];
let item = this.evaluateXPath( let item = this.evaluateXPath(
'descendant::xul:*[starts-with(@id, "'+id+'")]', 'descendant::xul:*[starts-with(@id, "'+id+'")]',
aEvent.currentTarget, aEvent.currentTarget,
@ -4405,9 +4440,10 @@ TreeStyleTabBrowser.prototype = {
resetAllTabs : function TSTBrowser_resetAllTabs(aDetachAllChildren) resetAllTabs : function TSTBrowser_resetAllTabs(aDetachAllChildren)
{ {
for (let [, tab] in Iterator(this.getAllTabsArray(this.mTabBrowser))) var tabs = this.getAllTabsArray(this.mTabBrowser);
for (let i = 0, maxi = tabs.length; i < maxi; i++)
{ {
this.resetTab(tab, aDetachAllChildren); this.resetTab(tabs[i], aDetachAllChildren);
} }
}, },
@ -4442,8 +4478,10 @@ TreeStyleTabBrowser.prototype = {
this.allowSubtreeCollapseExpand = true; this.allowSubtreeCollapseExpand = true;
delete this._lastAllowSubtreeCollapseExpand; delete this._lastAllowSubtreeCollapseExpand;
for (let [, tab] in Iterator(this.getAllTabsArray(this.browser))) let tabs = this.getAllTabsArray(this.browser);
for (let i = 0, maxi = tabs.length; i < maxi; i++)
{ {
let tab = tabs[i];
if (tab._TSTLastSubtreeCollapsed) if (tab._TSTLastSubtreeCollapsed)
this.collapseExpandSubtree(tab, true, true); this.collapseExpandSubtree(tab, true, true);
if (tab._TSTLastSubtreeExpandedManually) if (tab._TSTLastSubtreeExpandedManually)
@ -4455,8 +4493,10 @@ TreeStyleTabBrowser.prototype = {
this.updateTabsIndent(this.rootTabs, undefined, true); this.updateTabsIndent(this.rootTabs, undefined, true);
} }
else { else {
for (let [, tab] in Iterator(this.getAllTabsArray(this.browser))) let tabs = this.getAllTabsArray(this.browser);
for (let i = 0, maxi = tabs.length; i < maxi; i++)
{ {
let tab = tabs[i];
this.updateTabIndent(tab, 0, true); this.updateTabIndent(tab, 0, true);
tab._TSTLastSubtreeCollapsed = this.isSubtreeCollapsed(tab); tab._TSTLastSubtreeCollapsed = this.isSubtreeCollapsed(tab);
tab._TSTLastSubtreeExpandedManually = this.getTabValue(tab, this.kSUBTREE_EXPANDED_MANUALLY) == 'true'; tab._TSTLastSubtreeExpandedManually = this.getTabValue(tab, this.kSUBTREE_EXPANDED_MANUALLY) == 'true';
@ -4717,8 +4757,9 @@ TreeStyleTabBrowser.prototype = {
!this.getTreePref('closeParentBehavior.moveDetachedTabsToBottom')) { !this.getTreePref('closeParentBehavior.moveDetachedTabsToBottom')) {
insertBefore = this.getNextSiblingTab(this.getRootTab(aTab)); insertBefore = this.getNextSiblingTab(this.getRootTab(aTab));
} }
for (let [i, tab] in Iterator(children)) for (let i = 0, maxi = children.length; i < maxi; i++)
{ {
let tab = children[i];
if (aInfo.behavior == this.kCLOSE_PARENT_BEHAVIOR_DETACH_ALL_CHILDREN) { if (aInfo.behavior == this.kCLOSE_PARENT_BEHAVIOR_DETACH_ALL_CHILDREN) {
this.detachTab(tab, aInfo); this.detachTab(tab, aInfo);
this.moveTabSubtreeTo(tab, insertBefore ? insertBefore._tPos - 1 : this.getLastTab(b)._tPos ); this.moveTabSubtreeTo(tab, insertBefore ? insertBefore._tPos - 1 : this.getLastTab(b)._tPos );
@ -4763,8 +4804,9 @@ TreeStyleTabBrowser.prototype = {
detachTabs : function TSTBrowser_detachTabs(aTabs) detachTabs : function TSTBrowser_detachTabs(aTabs)
{ {
for (let [, tab] in Iterator(aTabs)) for (let i = 0, maxi = aTabs.length; i < maxi; i++)
{ {
let tab = aTabs[i];
if (aTabs.indexOf(this.getParentTab(tab)) > -1) if (aTabs.indexOf(this.getParentTab(tab)) > -1)
continue; continue;
this.detachAllChildren(tab, { this.detachAllChildren(tab, {
@ -4816,8 +4858,9 @@ TreeStyleTabBrowser.prototype = {
indent = Math.min(aLevel * 3, maxIndent); indent = Math.min(aLevel * 3, maxIndent);
} }
for (let [, tab] in Iterator(aTabs)) for (let i = 0, maxi = aTabs.length; i < maxi; i++)
{ {
let tab = aTabs[i];
if (!tab.parentNode) continue; // ignore removed tabs if (!tab.parentNode) continue; // ignore removed tabs
this.updateTabIndent(tab, indent, aJustNow); this.updateTabIndent(tab, indent, aJustNow);
tab.setAttribute(this.kNEST, aLevel); tab.setAttribute(this.kNEST, aLevel);
@ -4833,8 +4876,9 @@ TreeStyleTabBrowser.prototype = {
this.updateTabsIndentWithDelayTabs = this.updateTabsIndentWithDelayTabs.concat(aTabs); this.updateTabsIndentWithDelayTabs = this.updateTabsIndentWithDelayTabs.concat(aTabs);
this.updateTabsIndentWithDelayTimer = this.window.setTimeout(function(aSelf) { this.updateTabsIndentWithDelayTimer = this.window.setTimeout(function(aSelf) {
var tabs = []; var tabs = [];
for (let [, tab] in Iterator(aSelf.updateTabsIndentWithDelayTabs)) for (let i = 0, maxi = aSelf.updateTabsIndentWithDelayTabs.length; i < maxi; i++)
{ {
let tab = aSelf.updateTabsIndentWithDelayTabs[i];
if (tabs.indexOf(tab) < 0 && tab.parentNode) tabs.push(tab); if (tabs.indexOf(tab) < 0 && tab.parentNode) tabs.push(tab);
} }
aSelf.updateTabsIndentWithDelayTabs = []; aSelf.updateTabsIndentWithDelayTabs = [];
@ -4866,8 +4910,10 @@ TreeStyleTabBrowser.prototype = {
retVal.push('ThreeDShadow'); retVal.push('ThreeDShadow');
return retVal.length == 1 ? 'none' : retVal.join(' ') ; return retVal.length == 1 ? 'none' : retVal.join(' ') ;
})()+' !important;'; })()+' !important;';
for (let [, box] in Iterator(this.document.getAnonymousNodes(aTab))) let boxes = this.document.getAnonymousNodes(aTab);
for (let i = 0, box = boxes.length; i < maxi; i++)
{ {
let box = boxes[i];
if (box.nodeType != Node.ELEMENT_NODE) continue; if (box.nodeType != Node.ELEMENT_NODE) continue;
box.setAttribute( box.setAttribute(
'style', 'style',
@ -5051,8 +5097,10 @@ TreeStyleTabBrowser.prototype = {
updateAllTabsCount : function TSTBrowser_updateAllTabsCount() updateAllTabsCount : function TSTBrowser_updateAllTabsCount()
{ {
for (let [, tab] in Iterator(this.rootTabs)) var tabs = this.rootTabs;
for (let i = 0, maxi = tabs.length; i < maxi; i++)
{ {
let tab = tabs[i];
this.updateTabsCount(tab, this); this.updateTabsCount(tab, this);
} }
}, },
@ -5062,7 +5110,8 @@ TreeStyleTabBrowser.prototype = {
if (this.maxTreeLevel < 0 || !this.maxTreeLevelPhisical) if (this.maxTreeLevel < 0 || !this.maxTreeLevelPhisical)
return; return;
for (let [, tab] in Iterator(aParent ? this.getDescendantTabs(aParent) : this.getAllTabsArray(this.mTabBrowser) )) var tabs = aParent ? this.getDescendantTabs(aParent) : this.getAllTabsArray(this.mTabBrowser) ;
for (let i = 0, maxi = tabs.length; i < maxi; i++)
{ {
let level = parseInt(tab.getAttribute(this.kNEST) || 0); let level = parseInt(tab.getAttribute(this.kNEST) || 0);
if (level <= this.maxTreeLevel) if (level <= this.maxTreeLevel)
@ -5098,8 +5147,10 @@ TreeStyleTabBrowser.prototype = {
this.subTreeChildrenMovingCount++; this.subTreeChildrenMovingCount++;
this.internallyTabMovingCount++; this.internallyTabMovingCount++;
for (let [i, descendantTab] in Iterator(this.getDescendantTabs(aTab))) var descendantTabs = this.getDescendantTabs(aTab);
for (let i = 0, maxi = descendantTabs.length; i < maxi; i++)
{ {
let descendantTab = descendantTabs[i];
b.moveTabTo(descendantTab, aTab._tPos + i + (aTab._tPos < descendantTab._tPos ? 1 : 0 )); b.moveTabTo(descendantTab, aTab._tPos + i + (aTab._tPos < descendantTab._tPos ? 1 : 0 ));
} }
this.internallyTabMovingCount--; this.internallyTabMovingCount--;
@ -5312,8 +5363,9 @@ TreeStyleTabBrowser.prototype = {
var expandedTabs = this.getChildTabs(aTab); var expandedTabs = this.getChildTabs(aTab);
var lastExpandedTabIndex = expandedTabs.length - 1; var lastExpandedTabIndex = expandedTabs.length - 1;
for (let [i, childTab] in Iterator(expandedTabs)) for (let i = 0, maxi = expandedTabs.length; i < maxi; i++)
{ {
let childTab = expandedTabs[i];
if (!aCollapse && !aJustNow && i == lastExpandedTabIndex) { if (!aCollapse && !aJustNow && i == lastExpandedTabIndex) {
let self = this; let self = this;
this.collapseExpandTab(childTab, aCollapse, aJustNow, function() { this.collapseExpandTab(childTab, aCollapse, aJustNow, function() {
@ -5366,9 +5418,10 @@ TreeStyleTabBrowser.prototype = {
} }
if (!this.isSubtreeCollapsed(aTab)) { if (!this.isSubtreeCollapsed(aTab)) {
for (let [, tab] in Iterator(this.getChildTabs(aTab))) let tabs = this.getChildTabs(aTab);
for (let i = 0, maxi = tabs.length; i < maxi; i++)
{ {
this.collapseExpandTab(tab, aCollapse, aJustNow); this.collapseExpandTab(tabs[i], aCollapse, aJustNow);
} }
} }
}, },
@ -5881,8 +5934,9 @@ TreeStyleTabBrowser.prototype = {
if (tabs.length <= 1) if (tabs.length <= 1)
return; return;
for (let [, tab] in Iterator(tabs)) for (let i = 0, maxi = tabs.length; i < maxi; i++)
{ {
let tab = tabs[i];
let currentId = tab.getAttribute(this.kID); let currentId = tab.getAttribute(this.kID);
if (this.tabsHash[currentId] == tab) if (this.tabsHash[currentId] == tab)
delete this.tabsHash[currentId]; delete this.tabsHash[currentId];

View File

@ -413,8 +413,9 @@ FullTooltipManager.prototype = {
if (aExtraLabels) { if (aExtraLabels) {
if (typeof aExtraLabels == 'string') if (typeof aExtraLabels == 'string')
aExtraLabels = [aExtraLabels]; aExtraLabels = [aExtraLabels];
for (let [, label] in Iterator(aExtraLabels)) for (let i = 0, maxi = aExtraLabels.length; i < maxi; i++)
{ {
let label = aExtraLabels[i];
label = label.replace(/^\s+|\s+$/g, ''); label = label.replace(/^\s+|\s+$/g, '');
if (!label) if (!label)
continue; continue;

View File

@ -127,9 +127,9 @@ var PseudoTreeBuilder = {
return null; return null;
var container = doc.createElement('vbox'); var container = doc.createElement('vbox');
for (let [, child] in Iterator(children)) for (let i = 0, maxi = children.length; i < maxi; i++)
{ {
container.appendChild(this.createTabItem(child)); container.appendChild(this.createTabItem(children[i]));
} }
container.setAttribute('class', this.kTREECHILDREN); container.setAttribute('class', this.kTREECHILDREN);
return container; return container;

View File

@ -414,11 +414,13 @@ catch(e) {
var tabs = sv.getTabsArray(targetBrowser); var tabs = sv.getTabsArray(targetBrowser);
var draggedWholeTree = [].concat(draggedRoots); var draggedWholeTree = [].concat(draggedRoots);
for (let [, root] in Iterator(draggedRoots)) for (let i = 0, maxi = draggedRoots.length; i < maxi; i++)
{ {
let root = draggedRoots[i];
let tabs = sourceService.getDescendantTabs(root); let tabs = sourceService.getDescendantTabs(root);
for (let [, tab] in Iterator(tabs)) for (let i = 0, maxi = tabs.length; i < maxi; i++)
{ {
let tab = tabs[i];
if (draggedWholeTree.indexOf(tab) < 0) if (draggedWholeTree.indexOf(tab) < 0)
draggedWholeTree.push(tab); draggedWholeTree.push(tab);
} }
@ -515,8 +517,9 @@ catch(e) {
var sv = b.treeStyleTab; var sv = b.treeStyleTab;
b.movingSelectedTabs = true; // Multiple Tab Handler b.movingSelectedTabs = true; // Multiple Tab Handler
for (let [, tab] in Iterator(aTabs)) for (let i = 0, maxi = aTabs.length; i < maxi; i++)
{ {
let tab = aTabs[i];
if (!tab.parentNode) continue; // ignore removed tabs if (!tab.parentNode) continue; // ignore removed tabs
if (aParent) if (aParent)
sv.attachTabTo(tab, aParent); sv.attachTabTo(tab, aParent);
@ -533,8 +536,9 @@ catch(e) {
var sv = b.treeStyleTab; var sv = b.treeStyleTab;
b.movingSelectedTabs = true; // Multiple Tab Handler b.movingSelectedTabs = true; // Multiple Tab Handler
for (let [, tab] in Iterator(aTabs)) for (let i = 0, maxi = aTabs.length; i < maxi; i++)
{ {
let tab = aTabs[i];
if (!tab.parentNode) continue; // ignore removed tabs if (!tab.parentNode) continue; // ignore removed tabs
sv.detachTab(tab); sv.detachTab(tab);
sv.collapseExpandTab(tab, false); sv.collapseExpandTab(tab, false);
@ -863,9 +867,9 @@ catch(e) {
var sv = this.treeStyleTab; var sv = this.treeStyleTab;
if (this.mAutoExpandedTabs.length) { if (this.mAutoExpandedTabs.length) {
if (sv.getTreePref('autoExpand.collapseFinally')) { if (sv.getTreePref('autoExpand.collapseFinally')) {
for (let [, target] in Iterator(this.mAutoExpandedTabs)) for (let i = 0, maxi = this.mAutoExpandedTabs.length; i < maxi; i++)
{ {
sv.collapseExpandSubtree(sv.getTabById(target), true, true); sv.collapseExpandSubtree(sv.getTabById(this.mAutoExpandedTabs[i]), true, true);
} }
} }
this.mAutoExpandedTabs = []; this.mAutoExpandedTabs = [];

View File

@ -54,8 +54,9 @@ TreeStyleTabThemeManager.prototype = {
set : function(aStyle, aPosition) set : function(aStyle, aPosition)
{ {
if (this._lastStyles) { if (this._lastStyles) {
for (let [, style] in Iterator(this._lastStyles)) for (let i = 0, maxi = this._lastStyles.length; i < maxi; i++)
{ {
let style = this._lastStyles[i];
style.parentNode.removeChild(style); style.parentNode.removeChild(style);
} }
} }
@ -130,8 +131,9 @@ TreeStyleTabThemeManager.prototype = {
null ; null ;
if (!images) return; if (!images) return;
for (let [, image] in Iterator(images)) for (let i = 0, maxi = images.length; i < maxi; i++)
{ {
let image = images[i];
if (this._preLoadImagesForStyleDoneImages.indexOf(image) > -1) if (this._preLoadImagesForStyleDoneImages.indexOf(image) > -1)
continue; continue;

View File

@ -394,14 +394,18 @@ var TreeStyleTabUtils = {
{ {
var OS = this.XULAppInfo.OS; var OS = this.XULAppInfo.OS;
var processed = {}; var processed = {};
for (let [, originalKey] in Iterator(this.getDescendant('extensions.treestyletab.platform.'+OS))) var originalKeys = this.getDescendant('extensions.treestyletab.platform.'+OS);
for (let i = 0, maxi = originalKeys.length; i < maxi; i++)
{ {
let originalKey = originalKeys[i];
let key = originalKey.replace('platform.'+OS+'.', ''); let key = originalKey.replace('platform.'+OS+'.', '');
this.setDefaultPref(key, this.getPref(originalKey)); this.setDefaultPref(key, this.getPref(originalKey));
processed[key] = true; processed[key] = true;
} }
for (let [, originalKey] in Iterator(this.getDescendant('extensions.treestyletab.platform.default'))) originalKeys = this.getDescendant('extensions.treestyletab.platform.default');
for (let i = 0, maxi = originalKeys.length; i < maxi; i++)
{ {
let originalKey = originalKeys[i];
let key = originalKey.replace('platform.default.', ''); let key = originalKey.replace('platform.default.', '');
if (!(key in processed)) if (!(key in processed))
this.setDefaultPref(key, this.getPref(originalKey)); this.setDefaultPref(key, this.getPref(originalKey));
@ -713,8 +717,9 @@ var TreeStyleTabUtils = {
doAndWaitDOMEvent : function TSTUtils_doAndWaitDOMEvent() doAndWaitDOMEvent : function TSTUtils_doAndWaitDOMEvent()
{ {
var type, target, delay, task; var type, target, delay, task;
for (let [, arg] in Iterator(arguments)) for (let i = 0, maxi = arguments.length; i < maxi; i++)
{ {
let arg = arguments[i];
switch(typeof arg) switch(typeof arg)
{ {
case 'string': case 'string':
@ -928,8 +933,9 @@ var TreeStyleTabUtils = {
fireDataContainerEvent : function TSTUtils_fireDataContainerEvent() fireDataContainerEvent : function TSTUtils_fireDataContainerEvent()
{ {
var target, document, type, data, canBubble, cancellable; var target, document, type, data, canBubble, cancellable;
for (let [, arg] in Iterator(arguments)) for (let i = 0, maxi = arguments.length; i < maxi; i++)
{ {
let arg = arguments[i];
if (typeof arg == 'boolean') { if (typeof arg == 'boolean') {
if (canBubble === void(0)) if (canBubble === void(0))
canBubble = arg; canBubble = arg;
@ -952,8 +958,11 @@ var TreeStyleTabUtils = {
var event = document.createEvent('DataContainerEvent'); var event = document.createEvent('DataContainerEvent');
event.initEvent(type, canBubble, cancellable); event.initEvent(type, canBubble, cancellable);
for (let [property, value] in Iterator(data)) var properties = Object.keys(data);
for (let i = 0, maxi = properties.length; i < maxi; i++)
{ {
let property = properties[i];
let value = data[property];
event.setData(property, value); event.setData(property, value);
event[property] = value; // for backward compatibility event[property] = value; // for backward compatibility
} }
@ -1131,18 +1140,18 @@ var TreeStyleTabUtils = {
{ {
if (!aTabs || aTabs.length <= 1) return; if (!aTabs || aTabs.length <= 1) return;
var id = this.makeNewClosedSetId() + '::' + aTabs.length; var id = this.makeNewClosedSetId() + '::' + aTabs.length;
for (let [, tab] in Iterator(aTabs)) for (let i = 0, maxi = aTabs.length; i < maxi; i++)
{ {
this.setTabValue(tab, this.kCLOSED_SET_ID, id); this.setTabValue(aTabs[i], this.kCLOSED_SET_ID, id);
} }
}, },
unmarkAsClosedSet : function TSTUtils_unmarkAsClosedSet(aTabs) /* PUBLIC API */ unmarkAsClosedSet : function TSTUtils_unmarkAsClosedSet(aTabs) /* PUBLIC API */
{ {
if (!aTabs || !aTabs.length) return; if (!aTabs || !aTabs.length) return;
for (let [, tab] in Iterator(aTabs)) for (let i = 0, maxi = aTabs.length; i < maxi; i++)
{ {
this.deleteTabValue(tab, this.kCLOSED_SET_ID); this.deleteTabValue(aTabs[i], this.kCLOSED_SET_ID);
} }
}, },
@ -1281,8 +1290,9 @@ var TreeStyleTabUtils = {
var b = aTabBrowser || this.browser; var b = aTabBrowser || this.browser;
var top = aFrame.top; var top = aFrame.top;
var tabs = this.getAllTabsArray(b); var tabs = this.getAllTabsArray(b);
for (let [, tab] in Iterator(tabs)) for (let i = 0, maxi = tabs.length; i < maxi; i++)
{ {
let tab = tabs[i];
if (tab.linkedBrowser.contentWindow == top) if (tab.linkedBrowser.contentWindow == top)
return tab; return tab;
} }
@ -1321,8 +1331,9 @@ var TreeStyleTabUtils = {
cleanUpTabsArray : function TSTUtils_cleanUpTabsArray(aTabs) cleanUpTabsArray : function TSTUtils_cleanUpTabsArray(aTabs)
{ {
var newTabs = []; var newTabs = [];
for (let [, tab] in Iterator(aTabs)) for (let i = 0, maxi = aTabs.length; i < maxi; i++)
{ {
let tab = aTabs[i];
if (!tab || !tab.parentNode) continue; // ignore removed tabs if (!tab || !tab.parentNode) continue; // ignore removed tabs
if (newTabs.indexOf(tab) < 0) newTabs.push(tab); if (newTabs.indexOf(tab) < 0) newTabs.push(tab);
} }
@ -1357,8 +1368,10 @@ var TreeStyleTabUtils = {
var groups = []; var groups = [];
var group = []; var group = [];
for (let [, tab] in Iterator(this.cleanUpTabsArray(aTabs))) aTabs = this.cleanUpTabsArray(aTabs);
for (let i = 0, maxi = aTabs.length; i < maxi; i++)
{ {
let tab = aTabs[i];
let parent = this.getParentTab(tab); let parent = this.getParentTab(tab);
if (!parent || group.indexOf(parent) < 0) { if (!parent || group.indexOf(parent) < 0) {
if (group.length) groups.push(group); if (group.length) groups.push(group);
@ -2324,8 +2337,9 @@ var TreeStyleTabUtils = {
var collapsedStates = aTabs.map(function(aTab) { var collapsedStates = aTabs.map(function(aTab) {
return this.getTabValue(aTab, this.kSUBTREE_COLLAPSED) == 'true'; return this.getTabValue(aTab, this.kSUBTREE_COLLAPSED) == 'true';
}, this); }, this);
for (let [, tab] in Iterator(aTabs)) for (let i = 0, maxi = aTabs.length; i < maxi; i++)
{ {
let tab = aTabs[i];
this.collapseExpandSubtree(tab, false, true); this.collapseExpandSubtree(tab, false, true);
this.collapseExpandTab(tab, false, true); this.collapseExpandTab(tab, false, true);
} }
@ -2392,8 +2406,9 @@ var TreeStyleTabUtils = {
while (aExpandStates.length < aTabs.length) aExpandStates.push(-1); while (aExpandStates.length < aTabs.length) aExpandStates.push(-1);
var parentTab = null; var parentTab = null;
for (let [i, tab] in Iterator(aTabs)) for (let i = 0, maxi = aTabs.length; i < maxi; i++)
{ {
let tab = aTabs[i];
if (sv.isCollapsed(tab)) sv.collapseExpandTab(tab, false, true); if (sv.isCollapsed(tab)) sv.collapseExpandTab(tab, false, true);
sv.detachTab(tab); sv.detachTab(tab);

View File

@ -375,7 +375,7 @@ TreeStyleTabWindow.prototype = {
this.setPref('browser.tabs.loadFolderAndReplace', !!(behavior & this.kGROUP_BOOKMARK_REPLACE)); this.setPref('browser.tabs.loadFolderAndReplace', !!(behavior & this.kGROUP_BOOKMARK_REPLACE));
} }
case 4: case 4:
for (let [, pref] in Iterator([ let (prefs = [
'extensions.treestyletab.autoCollapseExpandSubTreeOnSelect', 'extensions.treestyletab.autoCollapseExpandSubTreeOnSelect',
'extensions.treestyletab.autoCollapseExpandSubTreeOnSelect.onCurrentTabRemove', 'extensions.treestyletab.autoCollapseExpandSubTreeOnSelect.onCurrentTabRemove',
'extensions.treestyletab.autoCollapseExpandSubTreeOnSelect.whileFocusMovingByShortcut', 'extensions.treestyletab.autoCollapseExpandSubTreeOnSelect.whileFocusMovingByShortcut',
@ -388,13 +388,16 @@ TreeStyleTabWindow.prototype = {
'extensions.treestyletab.show.context-item-bookmarkTabSubTree', 'extensions.treestyletab.show.context-item-bookmarkTabSubTree',
'extensions.multipletab.show.multipletab-selection-item-removeTabSubTree', 'extensions.multipletab.show.multipletab-selection-item-removeTabSubTree',
'extensions.multipletab.show.multipletab-selection-item-createSubTree' 'extensions.multipletab.show.multipletab-selection-item-createSubTree'
])) ]) {
for (let i = 0, maxi = pref.length; i < maxi; i++)
{ {
let pref = prefs[i];
let value = this.getPref(pref); let value = this.getPref(pref);
if (value === null) continue; if (value === null) continue;
this.setPref(pref.replace('SubTree', 'Subtree'), value); this.setPref(pref.replace('SubTree', 'Subtree'), value);
this.clearPref(pref); this.clearPref(pref);
} }
}
case 5: case 5:
let (behavior = this.getTreePref('openGroupBookmark.behavior')) { let (behavior = this.getTreePref('openGroupBookmark.behavior')) {
behavior = behavior | 2048; behavior = behavior | 2048;
@ -411,8 +414,9 @@ TreeStyleTabWindow.prototype = {
this.setTreePref('autoAttach.searchResult', search); this.setTreePref('autoAttach.searchResult', search);
} }
default: default:
for (let [, pref] in Iterator(orientalPrefs)) for (let i = 0, maxi = orientalPrefs.length; i < maxi; i++)
{ {
let pref = orientalPrefs[i];
let value = this.getPref(pref); let value = this.getPref(pref);
if (value === null) continue; if (value === null) continue;
this.setPref(pref+'.horizontal', value); this.setPref(pref+'.horizontal', value);
@ -501,12 +505,15 @@ TreeStyleTabWindow.prototype = {
} }
if (!prefs) return; if (!prefs) return;
for (let [, pref] in Iterator([
let restorePrefs = [
'browser.tabs.loadFolderAndReplace', 'browser.tabs.loadFolderAndReplace',
'browser.tabs.insertRelatedAfterCurrent', 'browser.tabs.insertRelatedAfterCurrent',
'extensions.stm.tabBarMultiRows' // Super Tab Mode 'extensions.stm.tabBarMultiRows' // Super Tab Mode
])) ];
for (let i = 0, maxi = pref.length; i < maxi; i++)
{ {
let pref = restorePrefs[i];
let backup = prefs.getPref(pref+'.backup'); let backup = prefs.getPref(pref+'.backup');
if (backup === null) continue; if (backup === null) continue;
prefs.setPref(pref+'.override', backup); // we have to set to ".override" pref, to avoid unexpectedly reset by the preference listener. prefs.setPref(pref+'.override', backup); // we have to set to ".override" pref, to avoid unexpectedly reset by the preference listener.
@ -552,8 +559,9 @@ TreeStyleTabWindow.prototype = {
var items = Array.slice(aEvent.originalTarget.childNodes); var items = Array.slice(aEvent.originalTarget.childNodes);
var firstItemIndex = 0; var firstItemIndex = 0;
// ignore menu items inserted by Weave (Firefox Sync), Tab Utilities, and others. // ignore menu items inserted by Weave (Firefox Sync), Tab Utilities, and others.
for (let [i, item] in Iterator(items)) for (let i = 0, maxi = items.length; i < maxi; i++)
{ {
let item = items[i];
if ( if (
item.getAttribute('anonid') || item.getAttribute('anonid') ||
item.id || item.id ||
@ -565,9 +573,10 @@ TreeStyleTabWindow.prototype = {
items = items.slice(firstItemIndex); items = items.slice(firstItemIndex);
var b = this.getTabBrowserFromChild(aEvent.originalTarget) || this.browser; var b = this.getTabBrowserFromChild(aEvent.originalTarget) || this.browser;
for (let [i, tab] in Iterator(this.getTabsArray(b))) var tabs = this.getTabsArray(b);
for (let i = 0, maxi = tabs.length; i < maxi; i++)
{ {
items[i].style.marginLeft = tab.getAttribute(this.kNEST)+'em'; items[i].style.marginLeft = tabs[i].getAttribute(this.kNEST)+'em';
} }
}, },
@ -599,9 +608,9 @@ TreeStyleTabWindow.prototype = {
d.removeEventListener(this.kEVENT_TYPE_TABBAR_STATE_CHANGED, this, false); d.removeEventListener(this.kEVENT_TYPE_TABBAR_STATE_CHANGED, this, false);
d.removeEventListener(this.kEVENT_TYPE_FOCUS_NEXT_TAB, this, false); d.removeEventListener(this.kEVENT_TYPE_FOCUS_NEXT_TAB, this, false);
for (let [, listener] in Iterator(this._tabFocusAllowance)) for (let i = 0, maxi = this._tabFocusAllowance.length; i < maxi; i++)
{ {
w.removeEventListener(this.kEVENT_TYPE_FOCUS_NEXT_TAB, listener, false); w.removeEventListener(this.kEVENT_TYPE_FOCUS_NEXT_TAB, this._tabFocusAllowance[i], false);
} }
var appcontent = d.getElementById('appcontent'); var appcontent = d.getElementById('appcontent');
@ -1060,8 +1069,10 @@ TreeStyleTabWindow.prototype = {
this.AeroPeek.windows.some(function(aTabWindow) { this.AeroPeek.windows.some(function(aTabWindow) {
if (aTabWindow.win == this.window) { if (aTabWindow.win == this.window) {
for (let [, preview] in Iterator(aTabWindow.previews)) let previews = aTabWindow.previews;
for (let i = 0, maxi = previews.length; i < maxi; i++)
{ {
let preview = previews[i];
if (!preview) continue; if (!preview) continue;
let tab = preview.controller.wrappedJSObject.tab; let tab = preview.controller.wrappedJSObject.tab;
preview.visible = !this.isCollapsed(tab); preview.visible = !this.isCollapsed(tab);
@ -1211,8 +1222,9 @@ TreeStyleTabWindow.prototype = {
processRestoredTabs : function TSTWindow_processRestoredTabs() processRestoredTabs : function TSTWindow_processRestoredTabs()
{ {
for (let [, tab] in Iterator(this._restoringTabs)) for (let i = 0, maxi = this._restoringTabs.length; i < maxi; i++)
{ {
let tab = this._restoringTabs[i];
try { try {
let b = this.getTabBrowserFromChild(aTab); let b = this.getTabBrowserFromChild(aTab);
if (b) b.treeStyleTab.handleRestoredTab(aTab); if (b) b.treeStyleTab.handleRestoredTab(aTab);
@ -1280,8 +1292,10 @@ TreeStyleTabWindow.prototype = {
if (aOnlyChildren) if (aOnlyChildren)
tabs = this.gatherSubtreeMemberTabs(aTabOrTabs); tabs = this.gatherSubtreeMemberTabs(aTabOrTabs);
for (let [, subtreeTabs] in Iterator(this.splitTabsToSubtrees(tabs))) var allSubtrees = this.splitTabsToSubtrees(tabs);
for (let i = 0, maxi = allSubtrees.length; i < maxi; i++)
{ {
let subtreeTabs = allSubtrees[i];
if (!this.fireTabSubtreeClosingEvent(subtreeTabs[0], subtreeTabs)) if (!this.fireTabSubtreeClosingEvent(subtreeTabs[0], subtreeTabs))
continue; continue;
let b = this.getTabBrowserFromChild(subtreeTabs[0]); let b = this.getTabBrowserFromChild(subtreeTabs[0]);
@ -1397,8 +1411,9 @@ TreeStyleTabWindow.prototype = {
aTabs.shift() ; aTabs.shift() ;
var self = this; var self = this;
this.Deferred.next(function(self) { this.Deferred.next(function(self) {
for (let [, tab] in Iterator(aTabs)) for (let i = 0, maxi = aTabs.length; i < maxi; i++)
{ {
let tab = aTabs[i];
b.treeStyleTab.attachTabTo(tab, root); b.treeStyleTab.attachTabTo(tab, root);
b.treeStyleTab.collapseExpandTab(tab, false); b.treeStyleTab.collapseExpandTab(tab, false);
} }
@ -1435,8 +1450,9 @@ TreeStyleTabWindow.prototype = {
var roots = []; var roots = [];
if (!aTabs || !aTabs.length) return roots; if (!aTabs || !aTabs.length) return roots;
aTabs = this.cleanUpTabsArray(aTabs); aTabs = this.cleanUpTabsArray(aTabs);
for (let [, tab] in Iterator(aTabs)) for (let i = 0, maxi = aTabs.length; i < maxi; i++)
{ {
let tab = aTabs[i];
let parent = this.getParentTab(tab); let parent = this.getParentTab(tab);
if (parent && aTabs.indexOf(parent) > -1) continue; if (parent && aTabs.indexOf(parent) > -1) continue;
roots.push(tab); roots.push(tab);
@ -1518,9 +1534,10 @@ TreeStyleTabWindow.prototype = {
this.stopRendering(); this.stopRendering();
this.markAsClosedSet(closeTabs); this.markAsClosedSet(closeTabs);
for (let [, tab] in Iterator(closeTabs.reverse())) var tabs = closeTabs.reverse();
for (let i = 0, maxi = tabs.length; i < maxi; i++)
{ {
b.removeTab(tab); b.removeTab(tabs[i]);
} }
this.startRendering(); this.startRendering();
}, },