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;
}
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);
}
aBookarmks.sort(function(aA, aB) {
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)
continue;
@ -104,8 +106,9 @@ var TreeStyleTabBookmarksService = {
var b = this.getTabBrowserFromChild(tabs[0]);
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);
bookmarkedTabs = bookmarkedTabs.concat(b.treeStyleTab.getDescendantTabs(tab));
}
@ -360,8 +363,10 @@ var TreeStyleTabBookmarksService = {
TreeStyleTabBookmarksService.beginAddBookmarksFromTabs((function() {
var tabs = [];
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;
if (uri in seen) continue;
seen[uri] = true;

View File

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

View File

@ -201,23 +201,26 @@ var TreeStyleTabWindowHelper = {
);
}
for (let [, func] in Iterator(this._splitFunctionNames(<![CDATA[
let (functions = this._splitFunctionNames(<![CDATA[
window.duplicateTab.handleLinkClick
window.duplicatethistab.handleLinkClick
window.__treestyletab__highlander__origHandleLinkClick
window.__splitbrowser__handleLinkClick
window.__ctxextensions__handleLinkClick
window.handleLinkClick
]]>)))
{
let source = this._getFunctionSource(func);
if (!source || !/^\(?function handleLinkClick/.test(source))
continue;
eval(func+' = '+source.replace(
/(charset\s*:\s*doc\.characterSet\s*)/,
'$1, event : event, linkNode : linkNode'
));
break;
]]>)) {
for (let i = 0, maxi = functions.length; i < maxi; i++)
{
let func = functions[i];
let source = this._getFunctionSource(func);
if (!source || !/^\(?function handleLinkClick/.test(source))
continue;
eval(func+' = '+source.replace(
/(charset\s*:\s*doc\.characterSet\s*)/,
'$1, event : event, linkNode : linkNode'
));
break;
}
}
if ('openLinkIn' in window) {
@ -233,27 +236,30 @@ var TreeStyleTabWindowHelper = {
);
}
for (let [, func] in Iterator(this._splitFunctionNames(<![CDATA[
let (functions = this._splitFunctionNames(<![CDATA[
window.permaTabs.utils.wrappedFunctions["window.contentAreaClick"]
window.__contentAreaClick
window.__ctxextensions__contentAreaClick
window.contentAreaClick
]]>)))
{
let source = this._getFunctionSource(func);
if (!source || !/^\(?function contentAreaClick/.test(source))
continue;
eval(func+' = '+source.replace(
// for Tab Utilities, etc. Some addons insert openNewTabWith() to the function.
// (calls for the function is not included by Firefox default.)
/(openNewTabWith\()/g,
<![CDATA[
if (!TreeStyleTabService.checkToOpenChildTab(event.target.ownerDocument.defaultView)) TreeStyleTabService.readyToOpenChildTab(event.target.ownerDocument.defaultView);
$1]]>
));
]]>)) {
for (let i = 0, maxi = functions.length; i < maxi; i++)
{
let func = functions[i];
let source = this._getFunctionSource(func);
if (!source || !/^\(?function contentAreaClick/.test(source))
continue;
eval(func+' = '+source.replace(
// for Tab Utilities, etc. Some addons insert openNewTabWith() to the function.
// (calls for the function is not included by Firefox default.)
/(openNewTabWith\()/g,
<![CDATA[
if (!TreeStyleTabService.checkToOpenChildTab(event.target.ownerDocument.defaultView)) TreeStyleTabService.readyToOpenChildTab(event.target.ownerDocument.defaultView);
$1]]>
));
}
}
for (let [, func] in Iterator(this._splitFunctionNames(<![CDATA[
let (functions = this._splitFunctionNames(<![CDATA[
window.duplicateTab.gotoHistoryIndex
window.duplicateTab.BrowserBack
window.duplicateTab.BrowserForward
@ -265,51 +271,60 @@ var TreeStyleTabWindowHelper = {
window.gotoHistoryIndex
window.BrowserForward
window.BrowserBack
]]>)))
{
let source = this._getFunctionSource(func);
if (!source || !/^\(?function (gotoHistoryIndex|BrowserForward|BrowserBack)/.test(source))
continue;
eval(func+' = '+source.replace(
/((?:openUILinkIn|duplicateTabIn)\()/g,
<![CDATA[
if (where == 'tab' || where == 'tabshifted')
TreeStyleTabService.readyToOpenChildTab();
$1]]>
));
]]>)) {
for (let i = 0, maxi = functions.length; i < maxi; i++)
{
let func = functions[i];
let source = this._getFunctionSource(func);
if (!source || !/^\(?function (gotoHistoryIndex|BrowserForward|BrowserBack)/.test(source))
continue;
eval(func+' = '+source.replace(
/((?:openUILinkIn|duplicateTabIn)\()/g,
<![CDATA[
if (where == 'tab' || where == 'tabshifted')
TreeStyleTabService.readyToOpenChildTab();
$1]]>
));
}
}
for (let [, func] in Iterator(this._splitFunctionNames(<![CDATA[
let (functions = this._splitFunctionNames(<![CDATA[
window.BrowserReloadOrDuplicate
]]>)))
{
let source = this._getFunctionSource(func);
if (!source || !/^\(?function (BrowserReloadOrDuplicate)/.test(source))
continue;
eval(func+' = '+source.replace(
/((?:openUILinkIn|duplicateTabIn)\()/g,
<![CDATA[
if (where == 'tab' || where == 'tabshifted')
TreeStyleTabService.onBeforeTabDuplicate(null);
$&]]>
));
]]>)) {
for (let i = 0, maxi = functions.length; i < maxi; i++)
{
let func = functions[i];
let source = this._getFunctionSource(func);
if (!source || !/^\(?function (BrowserReloadOrDuplicate)/.test(source))
continue;
eval(func+' = '+source.replace(
/((?:openUILinkIn|duplicateTabIn)\()/g,
<![CDATA[
if (where == 'tab' || where == 'tabshifted')
TreeStyleTabService.onBeforeTabDuplicate(null);
$&]]>
));
}
}
for (let [, func] in Iterator(this._splitFunctionNames(<![CDATA[
let (functions = this._splitFunctionNames(<![CDATA[
permaTabs.utils.wrappedFunctions["window.BrowserHomeClick"]
window.BrowserHomeClick
window.BrowserGoHome
]]>)))
{
let source = this._getFunctionSource(func);
if (!source || !/^\(?function (BrowserHomeClick|BrowserGoHome)/.test(source))
continue;
eval(func+' = '+source.replace(
'gBrowser.loadTabs(',
<![CDATA[
TreeStyleTabService.readyToOpenNewTabGroup(gBrowser);
$&]]>
));
]]>)) {
for (let i = 0, maxi = functions.length; i < maxi; i++)
{
let func = functions[i];
let source = this._getFunctionSource(func);
if (!source || !/^\(?function (BrowserHomeClick|BrowserGoHome)/.test(source))
continue;
eval(func+' = '+source.replace(
'gBrowser.loadTabs(',
<![CDATA[
TreeStyleTabService.readyToOpenNewTabGroup(gBrowser);
$&]]>
));
}
}
eval('FeedHandler.loadFeed = '+

View File

@ -86,13 +86,16 @@ TreeStyleTabWindowHelper.overrideExtensionsPreInit = function TSTWH_overrideExte
(function() {
var tabsInfo = {};
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);
if (index < 0) continue;
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);
}
tabsInfo[this.permaTabs[index].id] = info;
@ -125,8 +128,9 @@ TreeStyleTabWindowHelper.overrideExtensionsPreInit = function TSTWH_overrideExte
sessionData.getTabProperties.toSource().replace(
'return tabProperties;',
<![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));
}
$&]]>
@ -138,8 +142,9 @@ TreeStyleTabWindowHelper.overrideExtensionsPreInit = function TSTWH_overrideExte
<![CDATA[$&
var TSTProps = tabProperties.split('|');
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 name = property.substring(0, index);
let value = decodeURIComponent(property.substring(index+1));
@ -200,9 +205,12 @@ TreeStyleTabWindowHelper.overrideExtensionsPreInit = function TSTWH_overrideExte
'var tabcount = ',
<![CDATA[
gBrowser.treeStyleTab.collapseExpandAllSubtree(false, true);
for (let [, tab] in Iterator(gBrowser.treeStyleTab.getTabsArray(gBrowser).slice(1).reverse()))
{
gBrowser.removeTab(tab);
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);
}
}
TreeStyleTabService.restoringTree = true;
$&]]>
@ -214,13 +222,16 @@ TreeStyleTabWindowHelper.overrideExtensionsPreInit = function TSTWH_overrideExte
// https://addons.mozilla.org/firefox/addon/4650
if ('FS_onFullerScreen' in window &&
sv.getTreePref('compatibility.FullerScreen')) {
for (let [, func] in Iterator('CheckIfFullScreen,FS_onFullerScreen,FS_onMouseMove'.split(',')))
{
if (!(func in window)) continue;
eval('window.'+func+' = '+window[func].toSource().replace(
/FS_data.mTabs.(removeAttribute\("moz-collapsed"\)|setAttribute\("moz-collapsed", "true"\));/g,
'if (gBrowser.treeStyleTab.currentTabbarPosition == "top") { $& }'
));
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;
eval('window.'+func+' = '+window[func].toSource().replace(
/FS_data.mTabs.(removeAttribute\("moz-collapsed"\)|setAttribute\("moz-collapsed", "true"\));/g,
'if (gBrowser.treeStyleTab.currentTabbarPosition == "top") { $& }'
));
}
}
}
@ -817,18 +828,21 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
if ('LinkyContext' in window &&
'prototype' in LinkyContext &&
sv.getTreePref('compatibility.Linky')) {
for (let [, method] in Iterator('doSelected,doSelectedText,doImages,doAll,doAllPics,doValidateAll,doValidateSelected'.split(',')))
{
if (!(method in LinkyContext.prototype)) continue;
eval('LinkyContext.prototype.'+method+' = '+
LinkyContext.prototype[method].toSource().replace(
'{',
'{ TreeStyleTabService.readyToOpenChildTab(null, true);'
).replace(
/(\}\)?)$/,
'TreeStyleTabService.stopToOpenChildTab(); $1'
)
);
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;
eval('LinkyContext.prototype.'+method+' = '+
LinkyContext.prototype[method].toSource().replace(
'{',
'{ TreeStyleTabService.readyToOpenChildTab(null, true);'
).replace(
/(\}\)?)$/,
'TreeStyleTabService.stopToOpenChildTab(); $1'
)
);
}
}
}
@ -1324,15 +1338,16 @@ TreeStyleTabWindowHelper.overrideExtensionsDelayed = function TSTWH_overrideExte
break;
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;
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())
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_AFTER_TOOLBAR_CUSTOMIZATION, 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())
toolbox.setAttribute('collapsed', true);
}

View File

@ -523,8 +523,9 @@ TreeStyleTabBrowser.prototype = {
{
var tabs = this.getTabsArray(this.mTabBrowser);
var count = tabs.length;
for (let [i, tab] in Iterator(tabs))
for (let i = 0; i < count; i++)
{
let tab = tabs[i];
if (aStacked)
tab.style.zIndex = count * 1000 - index;
else
@ -721,7 +722,7 @@ TreeStyleTabBrowser.prototype = {
if (!('MultipleTabService' in w)) {
w.setTimeout(function(aSelf, aTabBrowser, aPopup) {
let suffix = '-tabbrowser-'+(aTabBrowser.id || 'instance-'+parseInt(Math.random() * 65000));
for (let [, id] in Iterator([
let ids = [
aSelf.kMENUITEM_RELOADSUBTREE,
aSelf.kMENUITEM_RELOADCHILDREN,
aSelf.kMENUITEM_REMOVESUBTREE,
@ -734,8 +735,10 @@ TreeStyleTabBrowser.prototype = {
aSelf.kMENUITEM_AUTOHIDE,
aSelf.kMENUITEM_FIXED,
aSelf.kMENUITEM_BOOKMARKSUBTREE
]))
];
for (let i = 0, maxi = ids.length; i < maxi; i++)
{
let id = ids[i];
let item = d.getElementById(id).cloneNode(true);
item.setAttribute('id', item.getAttribute('id')+suffix);
@ -973,13 +976,15 @@ TreeStyleTabBrowser.prototype = {
namedNodes.counterAnchor = namedNodes.label;
var foundContainers = [];
for (let [, container] in Iterator([
var containers = [
namedNodes.twistyAnchor.parentNode,
namedNodes.label.parentNode,
namedNodes.counter.parentNode,
namedNodes.closeAnchor.parentNode
]))
];
for (let i = 0, maxi = containers.length; i < maxi; i++)
{
let container = containers[i];
if (foundContainers.indexOf(container) > -1)
continue;
this.initTabContentsOrderInternal(container, namedNodes, aForce);
@ -994,8 +999,9 @@ TreeStyleTabBrowser.prototype = {
var nodes = Array.slice(this.document.getAnonymousNodes(aContainer) || aContainer.childNodes);
// 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')
continue;
node.setAttribute('ordinal', i);
@ -1030,8 +1036,9 @@ TreeStyleTabBrowser.prototype = {
var count = nodes.length;
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')
continue;
node.setAttribute('ordinal', (count - i + 1) * 100);
@ -1043,14 +1050,16 @@ TreeStyleTabBrowser.prototype = {
* Gecko doesn't re-render them in the new order.
* 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.position = 'fixed';
}
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.visibility = '';
}
@ -1070,9 +1079,9 @@ TreeStyleTabBrowser.prototype = {
(typeof aTarget == 'object' && 'length' in aTarget) ?
Array.slice(aTarget) :
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');
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')
continue;
if (node.hasAttribute('flex'))
@ -1267,8 +1278,10 @@ TreeStyleTabBrowser.prototype = {
this.removeTabbrowserAttribute(this.kTAB_INVERTED);
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')
continue;
let flex = node.hasAttribute('treestyletab-backup-flex');
@ -1302,8 +1315,9 @@ TreeStyleTabBrowser.prototype = {
}
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.collapseCSSProp);
}
@ -1312,8 +1326,9 @@ TreeStyleTabBrowser.prototype = {
this.indentCSSProp = this.indentProp+'-'+this.indentTarget;
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);
}
@ -1805,8 +1820,10 @@ TreeStyleTabBrowser.prototype = {
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.initTabContents(tab);
if (aSouldUpdateCount)
@ -1837,8 +1854,10 @@ TreeStyleTabBrowser.prototype = {
var b = this.mTabBrowser;
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.stopTabCollapseAnimation(tab);
this.destroyTab(tab);
@ -2150,24 +2169,24 @@ TreeStyleTabBrowser.prototype = {
case 'extensions.treestyletab.tabbar.multirow':
this.initTabbar();
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;
case 'extensions.treestyletab.tabbar.invertTabContents':
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;
case 'extensions.treestyletab.tabbar.invertClosebox':
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;
@ -2714,9 +2733,10 @@ TreeStyleTabBrowser.prototype = {
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);
@ -2903,8 +2923,9 @@ TreeStyleTabBrowser.prototype = {
var self = this;
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);
}
});
@ -3129,8 +3150,9 @@ TreeStyleTabBrowser.prototype = {
return aB._tPos - aA._tPos;
})
.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);
delete tab.__treestyletab__restoreState;
}
@ -3189,8 +3211,9 @@ TreeStyleTabBrowser.prototype = {
var lastIndex = allTabs.length - 1;
var lastMovedTab;
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 attached = false;
if (parent && (tab.hidden != parent.hidden)) {
@ -3257,8 +3280,9 @@ TreeStyleTabBrowser.prototype = {
this.detachTab(aParent);
b.moveTabTo(aParent, lastCount);
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);
b.moveTabTo(tab, lastCount);
}
@ -3453,14 +3477,16 @@ TreeStyleTabBrowser.prototype = {
* For failsafe, we must override actual attributes by stored
* values.
*/
for (let [, key] in Iterator([
var keys = [
this.kINSERT_BEFORE,
this.kINSERT_AFTER
]))
];
for (let i = 0, maxi = keys.length; i < maxi; i++)
{
let key = keys[i];
let tab = this.getTabValue(aTab, key);
if (this.getTabById(tab))
this.setTabValue(aTab, aKey, tab);
this.setTabValue(aTab, key, tab);
}
let parentId = this.getTabValue(aTab, this.kPARENT);
@ -3516,8 +3542,9 @@ TreeStyleTabBrowser.prototype = {
return this.redirectId(aChild);
}, 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))) {
let options = aOptions;
if (options && typeof options == 'function')
@ -3647,10 +3674,10 @@ TreeStyleTabBrowser.prototype = {
var children = aTab.getAttribute(this.kCHILDREN);
if (restoringChildren != children) {
var restoringChildrenIDs = restoringChildren.split('|');
for (let [i, child] in Iterator(restoringChildrenIDs.reverse()))
var restoringChildrenIDs = restoringChildren.split('|').reverse();
for (let i = 0, maxi = restoringChildrenIDs.length; i < maxi; i++)
{
child = this.getTabById(child);
let child = this.getTabById(restoringChildrenIDs[i]);
if (!child) continue;
let nextTab = i > 0 ?
@ -3708,8 +3735,10 @@ TreeStyleTabBrowser.prototype = {
return;
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 &&
item.state.extData[this.kCLOSED_SET_ID] &&
item.state.extData[this.kCLOSED_SET_ID] == aId)
@ -3754,9 +3783,9 @@ TreeStyleTabBrowser.prototype = {
this.windowService.restoringTree = true;
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) {
@ -3791,8 +3820,10 @@ TreeStyleTabBrowser.prototype = {
*/
let b = this.browser;
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)
b.moveTabTo(childTab, childTab.__treestyletab__previousPosition);
}
@ -3806,8 +3837,10 @@ TreeStyleTabBrowser.prototype = {
*/
let b = this.browser;
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)
b.moveTabTo(childTab, parentTab._tPos);
}
@ -4195,7 +4228,7 @@ TreeStyleTabBrowser.prototype = {
var b = this.mTabBrowser;
var sep, items = {};
for (let [, id] in Iterator([
var ids = [
this.kMENUITEM_RELOADSUBTREE,
this.kMENUITEM_RELOADCHILDREN,
this.kMENUITEM_REMOVESUBTREE,
@ -4206,8 +4239,10 @@ TreeStyleTabBrowser.prototype = {
this.kMENUITEM_AUTOHIDE,
this.kMENUITEM_FIXED,
this.kMENUITEM_BOOKMARKSUBTREE
]))
];
for (let i = 0, maxi = ids.length; i < maxi; i++)
{
let id = ids[i];
let item = this.evaluateXPath(
'descendant::xul:*[starts-with(@id, "'+id+'")]',
aEvent.currentTarget,
@ -4405,9 +4440,10 @@ TreeStyleTabBrowser.prototype = {
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;
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)
this.collapseExpandSubtree(tab, true, true);
if (tab._TSTLastSubtreeExpandedManually)
@ -4455,8 +4493,10 @@ TreeStyleTabBrowser.prototype = {
this.updateTabsIndent(this.rootTabs, undefined, true);
}
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);
tab._TSTLastSubtreeCollapsed = this.isSubtreeCollapsed(tab);
tab._TSTLastSubtreeExpandedManually = this.getTabValue(tab, this.kSUBTREE_EXPANDED_MANUALLY) == 'true';
@ -4717,8 +4757,9 @@ TreeStyleTabBrowser.prototype = {
!this.getTreePref('closeParentBehavior.moveDetachedTabsToBottom')) {
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) {
this.detachTab(tab, aInfo);
this.moveTabSubtreeTo(tab, insertBefore ? insertBefore._tPos - 1 : this.getLastTab(b)._tPos );
@ -4763,8 +4804,9 @@ TreeStyleTabBrowser.prototype = {
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)
continue;
this.detachAllChildren(tab, {
@ -4816,8 +4858,9 @@ TreeStyleTabBrowser.prototype = {
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
this.updateTabIndent(tab, indent, aJustNow);
tab.setAttribute(this.kNEST, aLevel);
@ -4833,8 +4876,9 @@ TreeStyleTabBrowser.prototype = {
this.updateTabsIndentWithDelayTabs = this.updateTabsIndentWithDelayTabs.concat(aTabs);
this.updateTabsIndentWithDelayTimer = this.window.setTimeout(function(aSelf) {
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);
}
aSelf.updateTabsIndentWithDelayTabs = [];
@ -4866,8 +4910,10 @@ TreeStyleTabBrowser.prototype = {
retVal.push('ThreeDShadow');
return retVal.length == 1 ? 'none' : retVal.join(' ') ;
})()+' !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;
box.setAttribute(
'style',
@ -5051,8 +5097,10 @@ TreeStyleTabBrowser.prototype = {
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);
}
},
@ -5062,7 +5110,8 @@ TreeStyleTabBrowser.prototype = {
if (this.maxTreeLevel < 0 || !this.maxTreeLevelPhisical)
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);
if (level <= this.maxTreeLevel)
@ -5098,8 +5147,10 @@ TreeStyleTabBrowser.prototype = {
this.subTreeChildrenMovingCount++;
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 ));
}
this.internallyTabMovingCount--;
@ -5312,8 +5363,9 @@ TreeStyleTabBrowser.prototype = {
var expandedTabs = this.getChildTabs(aTab);
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) {
let self = this;
this.collapseExpandTab(childTab, aCollapse, aJustNow, function() {
@ -5366,9 +5418,10 @@ TreeStyleTabBrowser.prototype = {
}
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)
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);
if (this.tabsHash[currentId] == tab)
delete this.tabsHash[currentId];

View File

@ -413,8 +413,9 @@ FullTooltipManager.prototype = {
if (aExtraLabels) {
if (typeof aExtraLabels == 'string')
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, '');
if (!label)
continue;

View File

@ -127,9 +127,9 @@ var PseudoTreeBuilder = {
return null;
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);
return container;

View File

@ -414,11 +414,13 @@ catch(e) {
var tabs = sv.getTabsArray(targetBrowser);
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);
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)
draggedWholeTree.push(tab);
}
@ -515,8 +517,9 @@ catch(e) {
var sv = b.treeStyleTab;
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 (aParent)
sv.attachTabTo(tab, aParent);
@ -533,8 +536,9 @@ catch(e) {
var sv = b.treeStyleTab;
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
sv.detachTab(tab);
sv.collapseExpandTab(tab, false);
@ -863,9 +867,9 @@ catch(e) {
var sv = this.treeStyleTab;
if (this.mAutoExpandedTabs.length) {
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 = [];

View File

@ -54,8 +54,9 @@ TreeStyleTabThemeManager.prototype = {
set : function(aStyle, aPosition)
{
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);
}
}
@ -130,8 +131,9 @@ TreeStyleTabThemeManager.prototype = {
null ;
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)
continue;

View File

@ -394,14 +394,18 @@ var TreeStyleTabUtils = {
{
var OS = this.XULAppInfo.OS;
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+'.', '');
this.setDefaultPref(key, this.getPref(originalKey));
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.', '');
if (!(key in processed))
this.setDefaultPref(key, this.getPref(originalKey));
@ -713,8 +717,9 @@ var TreeStyleTabUtils = {
doAndWaitDOMEvent : function TSTUtils_doAndWaitDOMEvent()
{
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)
{
case 'string':
@ -928,8 +933,9 @@ var TreeStyleTabUtils = {
fireDataContainerEvent : function TSTUtils_fireDataContainerEvent()
{
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 (canBubble === void(0))
canBubble = arg;
@ -952,8 +958,11 @@ var TreeStyleTabUtils = {
var event = document.createEvent('DataContainerEvent');
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[property] = value; // for backward compatibility
}
@ -1131,18 +1140,18 @@ var TreeStyleTabUtils = {
{
if (!aTabs || aTabs.length <= 1) return;
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 */
{
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 top = aFrame.top;
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)
return tab;
}
@ -1321,8 +1331,9 @@ var TreeStyleTabUtils = {
cleanUpTabsArray : function TSTUtils_cleanUpTabsArray(aTabs)
{
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 (newTabs.indexOf(tab) < 0) newTabs.push(tab);
}
@ -1357,8 +1368,10 @@ var TreeStyleTabUtils = {
var groups = [];
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);
if (!parent || group.indexOf(parent) < 0) {
if (group.length) groups.push(group);
@ -2324,8 +2337,9 @@ var TreeStyleTabUtils = {
var collapsedStates = aTabs.map(function(aTab) {
return this.getTabValue(aTab, this.kSUBTREE_COLLAPSED) == 'true';
}, 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.collapseExpandTab(tab, false, true);
}
@ -2392,8 +2406,9 @@ var TreeStyleTabUtils = {
while (aExpandStates.length < aTabs.length) aExpandStates.push(-1);
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);
sv.detachTab(tab);

View File

@ -375,7 +375,7 @@ TreeStyleTabWindow.prototype = {
this.setPref('browser.tabs.loadFolderAndReplace', !!(behavior & this.kGROUP_BOOKMARK_REPLACE));
}
case 4:
for (let [, pref] in Iterator([
let (prefs = [
'extensions.treestyletab.autoCollapseExpandSubTreeOnSelect',
'extensions.treestyletab.autoCollapseExpandSubTreeOnSelect.onCurrentTabRemove',
'extensions.treestyletab.autoCollapseExpandSubTreeOnSelect.whileFocusMovingByShortcut',
@ -388,12 +388,15 @@ TreeStyleTabWindow.prototype = {
'extensions.treestyletab.show.context-item-bookmarkTabSubTree',
'extensions.multipletab.show.multipletab-selection-item-removeTabSubTree',
'extensions.multipletab.show.multipletab-selection-item-createSubTree'
]))
{
let value = this.getPref(pref);
if (value === null) continue;
this.setPref(pref.replace('SubTree', 'Subtree'), value);
this.clearPref(pref);
]) {
for (let i = 0, maxi = pref.length; i < maxi; i++)
{
let pref = prefs[i];
let value = this.getPref(pref);
if (value === null) continue;
this.setPref(pref.replace('SubTree', 'Subtree'), value);
this.clearPref(pref);
}
}
case 5:
let (behavior = this.getTreePref('openGroupBookmark.behavior')) {
@ -411,8 +414,9 @@ TreeStyleTabWindow.prototype = {
this.setTreePref('autoAttach.searchResult', search);
}
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);
if (value === null) continue;
this.setPref(pref+'.horizontal', value);
@ -501,12 +505,15 @@ TreeStyleTabWindow.prototype = {
}
if (!prefs) return;
for (let [, pref] in Iterator([
let restorePrefs = [
'browser.tabs.loadFolderAndReplace',
'browser.tabs.insertRelatedAfterCurrent',
'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');
if (backup === null) continue;
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 firstItemIndex = 0;
// 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 (
item.getAttribute('anonid') ||
item.id ||
@ -565,9 +573,10 @@ TreeStyleTabWindow.prototype = {
items = items.slice(firstItemIndex);
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_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');
@ -1060,8 +1069,10 @@ TreeStyleTabWindow.prototype = {
this.AeroPeek.windows.some(function(aTabWindow) {
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;
let tab = preview.controller.wrappedJSObject.tab;
preview.visible = !this.isCollapsed(tab);
@ -1211,8 +1222,9 @@ TreeStyleTabWindow.prototype = {
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 {
let b = this.getTabBrowserFromChild(aTab);
if (b) b.treeStyleTab.handleRestoredTab(aTab);
@ -1280,8 +1292,10 @@ TreeStyleTabWindow.prototype = {
if (aOnlyChildren)
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))
continue;
let b = this.getTabBrowserFromChild(subtreeTabs[0]);
@ -1397,8 +1411,9 @@ TreeStyleTabWindow.prototype = {
aTabs.shift() ;
var self = this;
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.collapseExpandTab(tab, false);
}
@ -1435,8 +1450,9 @@ TreeStyleTabWindow.prototype = {
var roots = [];
if (!aTabs || !aTabs.length) return roots;
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);
if (parent && aTabs.indexOf(parent) > -1) continue;
roots.push(tab);
@ -1518,9 +1534,10 @@ TreeStyleTabWindow.prototype = {
this.stopRendering();
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();
},