use Iterator instead of forEach (for performance optimization)

This commit is contained in:
Piro / SHIMODA Hiroshi 2012-02-05 03:15:38 +09:00
parent 35d1bfce99
commit 59444c68a6
12 changed files with 710 additions and 628 deletions

View File

@ -52,41 +52,43 @@ var TreeStyleTabBookmarksService = {
return;
}
aBookarmks.forEach(function(aItem) {
aItem.position = this.BookmarksService.getItemIndex(aItem.id);
},this);
for (let [, item] in Iterator(aBookarmks))
{
item.position = this.BookmarksService.getItemIndex(item.id);
}
aBookarmks.sort(function(aA, aB) {
return aA.position - aB.position;
});
aBookarmks.forEach(function(aItem, aIndex) {
if (this.BookmarksService.getItemType(aItem.id) != this.BookmarksService.TYPE_BOOKMARK)
return;
for (let [i, item] in Iterator(aBookarmks))
{
if (this.BookmarksService.getItemType(item.id) != this.BookmarksService.TYPE_BOOKMARK)
continue;
let uri = this.BookmarksService.getBookmarkURI(aItem.id);
let uri = this.BookmarksService.getBookmarkURI(item.id);
if (/^about:treestyletab-group\b/.test(uri.spec)) {
let title = this.BookmarksService.getItemTitle(aItem.id);
let folderId = this.BookmarksService.createFolder(aItem.parent, title, aItem.position);
this.BookmarksService.removeItem(aItem.id);
aItem.id = folderId;
aItem.isFolder = true;
let title = this.BookmarksService.getItemTitle(item.id);
let folderId = this.BookmarksService.createFolder(item.parent, title, item.position);
this.BookmarksService.removeItem(item.id);
item.id = folderId;
item.isFolder = true;
}
let index = aTreeStructure[aIndex];
let index = aTreeStructure[i];
let parent = index > -1 ? aBookarmks[index] : null ;
if (parent && (parent.folder || parent).isFolder) {
let folder = parent.folder || parent;
this.BookmarksService.moveItem(aItem.id, folder.id, -1);
aItem.folder = folder;
this.BookmarksService.moveItem(item.id, folder.id, -1);
item.folder = folder;
}
if (parent && !parent.isFolder) {
PlacesUtils.setAnnotationsForItem(aItem.id, [{
PlacesUtils.setAnnotationsForItem(item.id, [{
name : this.kPARENT,
value : parent ? parent.id : -1,
expires : PlacesUtils.annotations.EXPIRE_NEVER
}]);
}
}, this);
}
},
bookmarkTabSubtree : function TSTBMService_bookmarkTabSubtree(aTabOrTabs)
@ -102,10 +104,11 @@ var TreeStyleTabBookmarksService = {
var b = this.getTabBrowserFromChild(tabs[0]);
var bookmarkedTabs = [];
tabs.forEach(function(aTab, aIndex) {
if (!this.isGroupTab(aTab, aIndex == 0)) bookmarkedTabs.push(aTab);
bookmarkedTabs = bookmarkedTabs.concat(b.treeStyleTab.getDescendantTabs(aTab));
}, this);
for (let [i, tab] in Iterator(tabs))
{
if (!this.isGroupTab(tab, i == 0)) bookmarkedTabs.push(tab);
bookmarkedTabs = bookmarkedTabs.concat(b.treeStyleTab.getDescendantTabs(tab));
}
this.beginAddBookmarksFromTabs(bookmarkedTabs);
try {
@ -357,12 +360,13 @@ var TreeStyleTabBookmarksService = {
TreeStyleTabBookmarksService.beginAddBookmarksFromTabs((function() {
var tabs = [];
var seen = {};
Array.forEach(getBrowser().mTabContainer.childNodes, function(aTab) {
let uri = aTab.linkedBrowser.currentURI.spec;
if (uri in seen) return;
for (let [, tab] in Iterator(getBrowser().mTabContainer.childNodes))
{
let uri = tab.linkedBrowser.currentURI.spec;
if (uri in seen) continue;
seen[uri] = true;
tabs.push(aTab);
});
tabs.push(tab);
}
return tabs;
})());
try {

View File

@ -155,12 +155,13 @@ var TreeStyleTabBookmarksServiceEditable = {
}
var fragment = document.createDocumentFragment();
items.forEach(function(aId, aIndex) {
let label = PlacesUtils.bookmarks.getItemTitle(aId);
for (let [i, id] in Iterator(items))
{
let label = PlacesUtils.bookmarks.getItemTitle(id);
let item = document.createElement('menuitem');
item.setAttribute('value', aId);
item.setAttribute('value', id);
let parent = aIndex;
let parent = i;
let nest = 0;
let disabled = false;
while ((parent = treeStructure[parent]) != -1)
@ -170,17 +171,17 @@ var TreeStyleTabBookmarksServiceEditable = {
}
if (nest) item.setAttribute('style', 'padding-left:'+nest+'em');
if (disabled || aId == aCurrentItem) {
if (disabled || id == aCurrentItem) {
item.setAttribute('disabled', true);
if (aId == aCurrentItem)
if (id == aCurrentItem)
label = this.treeBundle.getFormattedString('bookmarkProperty.parent.current.label', [label]);
}
if (aId == selected) item.setAttribute('selected', true);
if (id == selected) item.setAttribute('selected', true);
item.setAttribute('label', label);
fragment.appendChild(item);
}, this);
}
return fragment;
},
_getItemsInFolder : function TSTBMEditable__getItemsInFolder(aId)

View File

@ -89,15 +89,14 @@ function initAppearancePane()
document.getElementById('extensions.treestyletab.tabbar.style-arrowscrollbox'),
document.getElementById('extensions.treestyletab.twisty.style-arrowscrollbox')
];
Array.slice(boxes[0].childNodes).concat(Array.slice(boxes[1].childNodes))
.forEach(function(aItem) {
var start = 0;
var delta = 200;
var radian = 90 * Math.PI / 180;
Array.slice(boxes[0].childNodes).concat(Array.slice(boxes[1].childNodes)).forEach(function(aItem) {
let start = 0;
let delta = 200;
let radian = 90 * Math.PI / 180;
aItem.style.overflow = 'hidden';
aItem.width = 0;
aItem.style.maxWidth = 0;
var task = function(aTime, aBeginning, aChange, aDuration) {
let task = function(aTime, aBeginning, aChange, aDuration) {
var width;
if (aTime >= aDuration) {
width = start + delta;
@ -186,17 +185,18 @@ function onSyncGroupBookmarkUIToPref()
if (gGroupBookmarkUnderParent.checked) behavior |= 256;
if (gGroupBookmarkType.value == 'true') behavior |= 512;
[
for (let [, node] in Iterator([
gGroupBookmarkUnderParent,
gGroupBookmarkType,
gGroupBookmarkType.previousSibling,
gGroupBookmarkType.nextSibling
].forEach(function(aNode) {
]))
{
if (behavior & 1)
aNode.removeAttribute('disabled');
node.removeAttribute('disabled');
else
aNode.setAttribute('disabled', true);
});
node.setAttribute('disabled', true);
}
return behavior;
}

View File

@ -201,24 +201,24 @@ var TreeStyleTabWindowHelper = {
);
}
this._splitFunctionNames(<![CDATA[
for (let [, func] in Iterator(this._splitFunctionNames(<![CDATA[
window.duplicateTab.handleLinkClick
window.duplicatethistab.handleLinkClick
window.__treestyletab__highlander__origHandleLinkClick
window.__splitbrowser__handleLinkClick
window.__ctxextensions__handleLinkClick
window.handleLinkClick
]]>).some(function(aFunc) {
let source = this._getFunctionSource(aFunc);
]]>)))
{
let source = this._getFunctionSource(func);
if (!source || !/^\(?function handleLinkClick/.test(source))
return false;
eval(aFunc+' = '+source.replace(
continue;
eval(func+' = '+source.replace(
/(charset\s*:\s*doc\.characterSet\s*)/,
'$1, event : event, linkNode : linkNode'
));
source = null;
return true;
}, this);
break;
}
if ('openLinkIn' in window) {
eval('window.openLinkIn = '+
@ -233,16 +233,17 @@ var TreeStyleTabWindowHelper = {
);
}
this._splitFunctionNames(<![CDATA[
for (let [, func] in Iterator(this._splitFunctionNames(<![CDATA[
window.permaTabs.utils.wrappedFunctions["window.contentAreaClick"]
window.__contentAreaClick
window.__ctxextensions__contentAreaClick
window.contentAreaClick
]]>).forEach(function(aFunc) {
let source = this._getFunctionSource(aFunc);
]]>)))
{
let source = this._getFunctionSource(func);
if (!source || !/^\(?function contentAreaClick/.test(source))
return;
eval(aFunc+' = '+source.replace(
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,
@ -250,10 +251,9 @@ var TreeStyleTabWindowHelper = {
if (!TreeStyleTabService.checkToOpenChildTab(event.target.ownerDocument.defaultView)) TreeStyleTabService.readyToOpenChildTab(event.target.ownerDocument.defaultView);
$1]]>
));
source = null;
}, this);
}
this._splitFunctionNames(<![CDATA[
for (let [, func] in Iterator(this._splitFunctionNames(<![CDATA[
window.duplicateTab.gotoHistoryIndex
window.duplicateTab.BrowserBack
window.duplicateTab.BrowserForward
@ -265,52 +265,52 @@ var TreeStyleTabWindowHelper = {
window.gotoHistoryIndex
window.BrowserForward
window.BrowserBack
]]>).forEach(function(aFunc) {
let source = this._getFunctionSource(aFunc);
]]>)))
{
let source = this._getFunctionSource(func);
if (!source || !/^\(?function (gotoHistoryIndex|BrowserForward|BrowserBack)/.test(source))
return;
eval(aFunc+' = '+source.replace(
continue;
eval(func+' = '+source.replace(
/((?:openUILinkIn|duplicateTabIn)\()/g,
<![CDATA[
if (where == 'tab' || where == 'tabshifted')
TreeStyleTabService.readyToOpenChildTab();
$1]]>
));
source = null;
}, this);
}
this._splitFunctionNames(<![CDATA[
for (let [, func] in Iterator(this._splitFunctionNames(<![CDATA[
window.BrowserReloadOrDuplicate
]]>).forEach(function(aFunc) {
let source = this._getFunctionSource(aFunc);
]]>)))
{
let source = this._getFunctionSource(func);
if (!source || !/^\(?function (BrowserReloadOrDuplicate)/.test(source))
return;
eval(aFunc+' = '+source.replace(
continue;
eval(func+' = '+source.replace(
/((?:openUILinkIn|duplicateTabIn)\()/g,
<![CDATA[
if (where == 'tab' || where == 'tabshifted')
TreeStyleTabService.onBeforeTabDuplicate(null);
$&]]>
));
source = null;
}, this);
}
this._splitFunctionNames(<![CDATA[
for (let [, func] in Iterator(this._splitFunctionNames(<![CDATA[
permaTabs.utils.wrappedFunctions["window.BrowserHomeClick"]
window.BrowserHomeClick
window.BrowserGoHome
]]>).forEach(function(aFunc) {
let source = this._getFunctionSource(aFunc);
]]>)))
{
let source = this._getFunctionSource(func);
if (!source || !/^\(?function (BrowserHomeClick|BrowserGoHome)/.test(source))
return;
eval(aFunc+' = '+source.replace(
continue;
eval(func+' = '+source.replace(
'gBrowser.loadTabs(',
<![CDATA[
TreeStyleTabService.readyToOpenNewTabGroup(gBrowser);
$&]]>
));
source = null;
}, this);
}
eval('FeedHandler.loadFeed = '+
FeedHandler.loadFeed.toSource().replace(

View File

@ -86,16 +86,17 @@ TreeStyleTabWindowHelper.overrideExtensionsPreInit = function TSTWH_overrideExte
(function() {
var tabsInfo = {};
var TST = TreeStyleTabService;
Array.slice(getBrowser().mTabContainer.childNodes)
.forEach(function(aTab) {
var index = this.getPermaTabLocalIndex(aTab);
if (index < 0) return;
var info = {};
TST.extraProperties.forEach(function(aProperty) {
info[aProperty] = TST.getTabValue(aTab, aProperty);
});
for (let [, tab] in Iterator(getBrowser().mTabContainer.childNodes))
{
let index = this.getPermaTabLocalIndex(tab);
if (index < 0) continue;
let info = {};
for (let [, property] in Iterator(TST.extraProperties))
{
info[property] = TST.getTabValue(tab, property);
}
tabsInfo[this.permaTabs[index].id] = info;
}, this);
}
TST.setTreePref('permaTabsInfo', tabsInfo.toSource());
}).call(this);
]]>
@ -124,9 +125,10 @@ TreeStyleTabWindowHelper.overrideExtensionsPreInit = function TSTWH_overrideExte
sessionData.getTabProperties.toSource().replace(
'return tabProperties;',
<![CDATA[
this.tabTSTProperties.forEach(function(aProp) {
tabProperties += '|' + aProp + '=' + encodeURIComponent(aTab.getAttribute(aProp));
});
for (let [, property] in Iterator(this.tabTSTProperties))
{
tabProperties += '|' + property + '=' + encodeURIComponent(aTab.getAttribute(property));
}
$&]]>
)
);
@ -136,13 +138,14 @@ TreeStyleTabWindowHelper.overrideExtensionsPreInit = function TSTWH_overrideExte
<![CDATA[$&
var TSTProps = tabProperties.split('|');
tabProperties = TSTProps.shift();
TSTProps.forEach(function(aSet) {
var index = aSet.indexOf('=');
var name = aSet.substring(0, index);
var value = decodeURIComponent(aSet.substring(index+1));
for (let [, property] in Iterator(TSTProps))
{
let index = property.indexOf('=');
let name = property.substring(0, index);
let value = decodeURIComponent(property.substring(index+1));
if (name && value)
aTab.setAttribute(name, value);
});
}
]]>
)
);
@ -197,12 +200,10 @@ TreeStyleTabWindowHelper.overrideExtensionsPreInit = function TSTWH_overrideExte
'var tabcount = ',
<![CDATA[
gBrowser.treeStyleTab.collapseExpandAllSubtree(false, true);
gBrowser.treeStyleTab.getTabsArray(gBrowser)
.slice(1)
.reverse()
.forEach(function(aTab, aIndex) {
gBrowser.removeTab(aTab);
});
for (let [, tab] in Iterator(gBrowser.treeStyleTab.getTabsArray(gBrowser).slice(1).reverse()))
{
gBrowser.removeTab(tab);
}
TreeStyleTabService.restoringTree = true;
$&]]>
));
@ -213,13 +214,14 @@ TreeStyleTabWindowHelper.overrideExtensionsPreInit = function TSTWH_overrideExte
// https://addons.mozilla.org/firefox/addon/4650
if ('FS_onFullerScreen' in window &&
sv.getTreePref('compatibility.FullerScreen')) {
'CheckIfFullScreen,FS_onFullerScreen,FS_onMouseMove'.split(',').forEach(function(aFunc) {
if (!(aFunc in window)) return;
eval('window.'+aFunc+' = '+window[aFunc].toSource().replace(
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") { $& }'
));
}, this);
}
}
// TooManyTabs
@ -815,11 +817,11 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
if ('LinkyContext' in window &&
'prototype' in LinkyContext &&
sv.getTreePref('compatibility.Linky')) {
'doSelected,doSelectedText,doImages,doAll,doAllPics,doValidateAll,doValidateSelected'
.split(',').forEach(function(aMethod) {
if (!(aMethod in LinkyContext.prototype)) return;
eval('LinkyContext.prototype.'+aMethod+' = '+
LinkyContext.prototype[aMethod].toSource().replace(
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(
@ -827,7 +829,7 @@ TreeStyleTabWindowHelper.overrideExtensionsAfterBrowserInit = function TSTWH_ove
'TreeStyleTabService.stopToOpenChildTab(); $1'
)
);
});
}
}
// QuickDrag
@ -1322,16 +1324,18 @@ TreeStyleTabWindowHelper.overrideExtensionsDelayed = function TSTWH_overrideExte
break;
case sv.kEVENT_TYPE_BEFORE_TOOLBAR_CUSTOMIZATION:
tabbarToolboxes.forEach(function(aToolbox) {
aToolbox.removeAttribute('collapsed');
});
for (let [, toolbox] in Iterator(tabbarToolboxes))
{
toolbox.removeAttribute('collapsed');
}
break;
case sv.kEVENT_TYPE_AFTER_TOOLBAR_CUSTOMIZATION:
tabbarToolboxes.forEach(function(aToolbox) {
if (!aToolbox.firstChild.hasChildNodes())
aToolbox.setAttribute('collapsed', true);
});
for (let [, toolbox] in Iterator(tabbarToolboxes))
{
if (!toolbox.firstChild.hasChildNodes())
toolbox.setAttribute('collapsed', true);
}
break;
case 'unload':
@ -1348,10 +1352,11 @@ 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);
tabbarToolboxes.forEach(function(aToolbox) {
if (!aToolbox.firstChild.hasChildNodes())
aToolbox.setAttribute('collapsed', true);
});
for (let [, toolbox] in Iterator(tabbarToolboxes))
{
if (!toolbox.firstChild.hasChildNodes())
toolbox.setAttribute('collapsed', true);
}
}
}

View File

@ -523,15 +523,13 @@ TreeStyleTabBrowser.prototype = {
{
var tabs = this.getTabsArray(this.mTabBrowser);
var count = tabs.length;
tabs.forEach(
aStacked ?
function(aTab, aIndex) {
aTab.style.zIndex = count * 1000 - aIndex;
} :
function(aTab, aIndex) {
aTab.style.zIndex = '';
for (let [i, tab] in Iterator(tabs))
{
if (aStacked)
tab.style.zIndex = count * 1000 - index;
else
tab.style.zIndex = '';
}
);
},
fixTooNarrowTabbar : function TSTBrowser_fixTooNarrowTabbar()
@ -723,7 +721,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([
aSelf.kMENUITEM_RELOADSUBTREE,
aSelf.kMENUITEM_RELOADCHILDREN,
aSelf.kMENUITEM_REMOVESUBTREE,
@ -736,8 +734,9 @@ TreeStyleTabBrowser.prototype = {
aSelf.kMENUITEM_AUTOHIDE,
aSelf.kMENUITEM_FIXED,
aSelf.kMENUITEM_BOOKMARKSUBTREE
].forEach(function(aID) {
let item = d.getElementById(aID).cloneNode(true);
]))
{
let item = d.getElementById(id).cloneNode(true);
item.setAttribute('id', item.getAttribute('id')+suffix);
let refNode = void(0);
@ -758,7 +757,7 @@ TreeStyleTabBrowser.prototype = {
}
}
aPopup.insertBefore(item, refNode || null);
});
}
tabContextMenu = null;
}, 0, this, b, tabContextMenu);
}
@ -974,16 +973,15 @@ TreeStyleTabBrowser.prototype = {
namedNodes.counterAnchor = namedNodes.label;
var foundContainers = [];
var containers = [
for (let [, container] in Iterator([
namedNodes.twistyAnchor.parentNode,
namedNodes.label.parentNode,
namedNodes.counter.parentNode,
namedNodes.closeAnchor.parentNode
];
for (let [, container] in Iterator(containers))
]))
{
if (foundContainers.indexOf(container) > -1)
return;
continue;
this.initTabContentsOrderInternal(container, namedNodes, aForce);
foundContainers.push(container);
}
@ -1070,9 +1068,10 @@ TreeStyleTabBrowser.prototype = {
(typeof aTarget == 'object' && 'length' in aTarget) ?
Array.slice(aTarget) :
self.getAllTabsArray(b);
tabs.forEach(function(aTab) {
this.initTabContentsOrder(aTab);
}, self);
for (let [, tab] in Iterator(tabs))
{
this.initTabContentsOrder(tab);
}
});
},
@ -1186,13 +1185,14 @@ TreeStyleTabBrowser.prototype = {
b.mPanelContainer.removeAttribute('height');
if (strip.localName == 'toolbar') {
Array.forEach(strip.childNodes, function(aNode) {
if (aNode.localName == 'tabs')
return;
if (aNode.hasAttribute('flex'))
aNode.setAttribute('treestyletab-backup-flex', aNode.getAttribute('flex'));
aNode.removeAttribute('flex');
}, this);
for (let [, node] in Iterator(strip.childNodes))
{
if (node.localName == 'tabs')
continue;
if (node.hasAttribute('flex'))
node.setAttribute('treestyletab-backup-flex', node.getAttribute('flex'));
node.removeAttribute('flex');
}
}
if (pos == this.kTABBAR_RIGHT) {
@ -1265,15 +1265,16 @@ TreeStyleTabBrowser.prototype = {
this.removeTabbrowserAttribute(this.kTAB_INVERTED);
if (strip.localName == 'toolbar') {
Array.forEach(strip.childNodes, function(aNode) {
if (aNode.localName == 'tabs')
return;
var flex = aNode.hasAttribute('treestyletab-backup-flex');
for (let [, node] in Iterator(strip.childNodes))
{
if (node.localName == 'tabs')
continue;
let flex = node.hasAttribute('treestyletab-backup-flex');
if (!flex)
return;
aNode.setAttribute('flex', flex);
aNode.removeAttribute('treestyletab-backup-flex');
}, this);
continue;
node.setAttribute('flex', flex);
node.removeAttribute('treestyletab-backup-flex');
}
}
if (pos == this.kTABBAR_BOTTOM) {
@ -1299,18 +1300,20 @@ TreeStyleTabBrowser.prototype = {
}
var tabs = this.getAllTabsArray(b);
tabs.forEach(function(aTab) {
aTab.style.removeProperty(this.indentCSSProp);
aTab.style.removeProperty(this.collapseCSSProp);
}, this);
for (let [, tab] in Iterator(tabs))
{
tab.style.removeProperty(this.indentCSSProp);
tab.style.removeProperty(this.collapseCSSProp);
}
this.indentProp = this.getTreePref('indent.property');
this.indentCSSProp = this.indentProp+'-'+this.indentTarget;
this.collapseCSSProp = 'margin-'+this.collapseTarget;
tabs.forEach(function(aTab) {
this.updateTabCollapsed(aTab, aTab.getAttribute(this.kCOLLAPSED) == 'true', true);
}, this);
for (let [i, tab] in Iterator(tabs))
{
this.updateTabCollapsed(tab, tab.getAttribute(this.kCOLLAPSED) == 'true', true);
}
// for updateTabbarOverflow(), we should reset the "overflow" now.
b.mTabContainer.removeAttribute('overflow');
@ -1800,13 +1803,13 @@ TreeStyleTabBrowser.prototype = {
reinitAllTabs : function TSTBrowser_reinitAllTabs(aSouldUpdateCount)
{
var tabs = this.getAllTabsArray(this.mTabBrowser);
tabs.forEach(function(aTab) {
this.initTabAttributes(aTab);
this.initTabContents(aTab);
for (let [, tab] in Iterator(this.getAllTabsArray(this.mTabBrowser)))
{
this.initTabAttributes(tab);
this.initTabContents(tab);
if (aSouldUpdateCount)
this.updateTabsCount(aTab);
}, this);
this.updateTabsCount(tab);
}
},
destroy : function TSTBrowser_destroy()
@ -1832,11 +1835,12 @@ TreeStyleTabBrowser.prototype = {
var b = this.mTabBrowser;
delete b.tabContainer.treeStyleTab;
this.getAllTabsArray(b).forEach(function(aTab) {
this.stopTabIndentAnimation(aTab);
this.stopTabCollapseAnimation(aTab);
this.destroyTab(aTab);
}, this);
for (let [, tab] in Iterator(this.getAllTabsArray(b)))
{
this.stopTabIndentAnimation(tab);
this.stopTabCollapseAnimation(tab);
this.destroyTab(tab);
}
this._endListenTabbarEvents();
@ -2002,9 +2006,7 @@ TreeStyleTabBrowser.prototype = {
this.ownerToolbar.classList.add(this.kTABBAR_TOOLBAR);
this.ownerToolbar.classList.remove(this.kTABBAR_TOOLBAR_READY);
Array.slice(this.document.querySelectorAll('.'+this.kTABBAR_TOOLBAR_READY_POPUP))
.forEach(function(aPanel) {
this.safeRemovePopup(aPanel);
}, this);
.forEach(this.safeRemovePopup, this);
var position = this._lastTabbarPositionBeforeDestroyed || this.position;
delete this._lastTabbarPositionBeforeDestroyed;
@ -2146,22 +2148,25 @@ TreeStyleTabBrowser.prototype = {
case 'extensions.treestyletab.tabbar.multirow':
this.initTabbar();
this.updateAllTabsIndent();
tabs.forEach(function(aTab) {
this.initTabContents(aTab);
}, this);
for (let [, tab] in Iterator(tabs))
{
this.initTabContents(tab);
}
return;
case 'extensions.treestyletab.tabbar.invertTabContents':
this.setTabbrowserAttribute(this.kTAB_CONTENTS_INVERTED, value);
tabs.forEach(function(aTab) {
this.initTabContents(aTab);
}, this);
for (let [, tab] in Iterator(tabs))
{
this.initTabContents(tab);
}
return;
case 'extensions.treestyletab.tabbar.invertClosebox':
this.setTabbrowserAttribute(this.kCLOSEBOX_INVERTED, value);
tabs.forEach(function(aTab) {
this.initTabContents(aTab);
}, this);
for (let [, tab] in Iterator(tabs))
{
this.initTabContents(tab);
}
return;
case 'extensions.treestyletab.tabbar.style':
@ -2707,9 +2712,10 @@ TreeStyleTabBrowser.prototype = {
this.markAsClosedSet([tab].concat(tabs));
tabs.reverse().forEach(function(aTab) {
b.removeTab(aTab, { animate : true });
}, this);
for (let [, tab] in Iterator(tabs.reverse()))
{
b.removeTab(tab, { animate : true });
}
this.fireTabSubtreeClosedEvent(b, tab, tabs);
@ -2862,9 +2868,7 @@ TreeStyleTabBrowser.prototype = {
var parent = this.getParentTab(aTab);
var siblings = this.getSiblingTabs(aTab);
var groupTabs = siblings.filter(function(aTab) {
return this.isGroupTab(aTab);
}, this);
var groupTabs = siblings.filter(this.isGroupTab, this);
var groupTab = (
groupTabs.length == 1 &&
siblings.length == 1 &&
@ -2893,15 +2897,14 @@ TreeStyleTabBrowser.prototype = {
}, this))
return false;
trees.forEach(function(aTabs) {
this.markAsClosedSet(aTabs);
}, this);
trees.forEach(this.markAsClosedSet, this);
var self = this;
this.Deferred.next(function() {
trees.forEach(function(aTabs) {
self.fireTabSubtreeClosedEvent(b, aTabs[0], aTabs);
});
for (let [, tabs] in Iterator(trees))
{
self.fireTabSubtreeClosedEvent(b, tabs[0], tabs);
}
});
return true;
@ -3113,7 +3116,7 @@ TreeStyleTabBrowser.prototype = {
return;
// restore tree from bottom safely
tabs.filter(function(aChanged) {
var restoreTabs = tabs.filter(function(aChanged) {
return aChanged.type == 'TabShow' &&
aChanged.tab.__treestyletab__restoreState == aSelf.RESTORE_STATE_READY_TO_RESTORE;
})
@ -3123,11 +3126,12 @@ TreeStyleTabBrowser.prototype = {
.sort(function(aA, aB) {
return aB._tPos - aA._tPos;
})
.filter(aSelf.restoreOneTab, aSelf)
.forEach(function(aTab) {
aSelf.updateInsertionPositionInfo(aTab);
delete aTab.__treestyletab__restoreState;
}, aSelf);
.filter(aSelf.restoreOneTab, aSelf);
for (let [, tab] in Iterator(restoreTabs))
{
aSelf.updateInsertionPositionInfo(tab);
delete tab.__treestyletab__restoreState;
}
var currentGroupId = aSelf.getTabViewGroupId();
if (aSelf.lastTabViewGroup && currentGroupId != aSelf.lastTabViewGroup) {
@ -3183,7 +3187,7 @@ TreeStyleTabBrowser.prototype = {
var lastIndex = allTabs.length - 1;
var lastMovedTab;
normalTabs = normalTabs.slice(0).reverse();
for each (let tab in normalTabs)
for (let [, tab] in Iterator(normalTabs))
{
let parent = this.getParentTab(tab);
let attached = false;
@ -3251,10 +3255,11 @@ TreeStyleTabBrowser.prototype = {
this.detachTab(aParent);
b.moveTabTo(aParent, lastCount);
var descendantTabs = this.getDescendantTabs(aParent);
descendantTabs.forEach(function(aTab) {
w.TabView.moveTabTo(aTab, id);
b.moveTabTo(aTab, lastCount);
});
for (let [, tab] in Iterator(descendantTabs))
{
w.TabView.moveTabTo(tab, id);
b.moveTabTo(tab, lastCount);
}
this.internallyTabMovingCount--;
this.tabViewTreeIsMoving = false;
},
@ -3446,14 +3451,15 @@ TreeStyleTabBrowser.prototype = {
* For failsafe, we must override actual attributes by stored
* values.
*/
[
for (let [, key] in Iterator([
this.kINSERT_BEFORE,
this.kINSERT_AFTER
].forEach(function(aKey) {
var tab = this.getTabValue(aTab, aKey);
]))
{
let tab = this.getTabValue(aTab, key);
if (this.getTabById(tab))
this.setTabValue(aTab, aKey, tab);
}, this);
}
let parentId = this.getTabValue(aTab, this.kPARENT);
let parentTab = this.getTabById(parentId);
@ -3508,15 +3514,16 @@ TreeStyleTabBrowser.prototype = {
return this.redirectId(aChild);
}, this);
aChildrenList.forEach(function(aChildTab) {
if (aChildTab && (aChildTab = this.getTabById(aChildTab))) {
for (let [, childTab] in Iterator(aChildrenList))
{
if (childTab && (childTab = this.getTabById(childTab))) {
let options = aOptions;
if (options && typeof options == 'function')
options = options(aChildTab);
this.attachTabTo(aChildTab, aTab, options);
childTabs.push(aChildTab);
options = options(childTab);
this.attachTabTo(childTab, aTab, options);
childTabs.push(childTab);
}
}
}, this);
aChildrenList = aChildrenList.join('|');
if (aTab.getAttribute(this.kCHILDREN) == aChildrenList)
aTab.removeAttribute(this.kCHILDREN_RESTORING);
@ -3639,23 +3646,24 @@ TreeStyleTabBrowser.prototype = {
var children = aTab.getAttribute(this.kCHILDREN);
if (restoringChildren != children) {
var restoringChildrenIDs = restoringChildren.split('|');
restoringChildrenIDs.reverse().forEach(function(aChild, aIndex) {
aChild = this.getTabById(aChild);
if (!aChild) return;
for (let [i, child] in Iterator(restoringChildrenIDs.reverse()))
{
child = this.getTabById(child);
if (!child) continue;
let nextTab = aIndex > 0 ?
this.getTabById(restoringChildrenIDs[aIndex-1]) :
let nextTab = i > 0 ?
this.getTabById(restoringChildrenIDs[i-1]) :
this.getNextSiblingTab(aTab) ;
if (nextTab == this.getNextSiblingTab(aChild)) return;
if (nextTab == this.getNextSiblingTab(child)) continue;
let newPos = -1;
if (nextTab) {
newPos = nextTab._tPos;
if (newPos > aChild._tPos) newPos--;
if (newPos > child._tPos) newPos--;
}
if (newPos > -1)
this.moveTabSubtreeTo(aChild, newPos);
}, this);
this.moveTabSubtreeTo(child, newPos);
}
children = aTab.getAttribute(this.kCHILDREN);
}
@ -3697,14 +3705,14 @@ TreeStyleTabBrowser.prototype = {
)
return;
var items = this.evalInSandbox('('+this.SessionStore.getClosedTabData(this.window)+')');
var indexes = [];
items.forEach(function(aItem, aIndex) {
if (aItem.state.extData &&
aItem.state.extData[this.kCLOSED_SET_ID] &&
aItem.state.extData[this.kCLOSED_SET_ID] == aId)
indexes.push(aIndex);
}, this);
for (let [i, item] in Iterator(this.evalInSandbox('('+this.SessionStore.getClosedTabData(this.window)+')')))
{
if (item.state.extData &&
item.state.extData[this.kCLOSED_SET_ID] &&
item.state.extData[this.kCLOSED_SET_ID] == aId)
indexes.push(i);
}
var count = parseInt(aId.split('::')[1]);
@ -3744,9 +3752,10 @@ TreeStyleTabBrowser.prototype = {
this.windowService.restoringTree = true;
var offset = 0;
aIndexes.forEach(function(aIndex) {
this.window.undoCloseTab(aIndex - (offset++));
}, this);
for (let [, index] in Iterator(aIndexes))
{
this.window.undoCloseTab(index - (offset++));
}
this.window.setTimeout(function(aSelf, aNextFocused) {
aSelf.windowService.restoringTree = false;
@ -3780,10 +3789,11 @@ TreeStyleTabBrowser.prototype = {
*/
let b = this.browser;
this.internallyTabMovingCount++;
this.getDescendantTabs(aTab).reverse().forEach(function(aChildTab) {
if (aChildTab.__treestyletab__previousPosition > aChildTab._tPos)
b.moveTabTo(aChildTab, aChildTab.__treestyletab__previousPosition);
}, this);
for (let [, childTab] in Iterator(this.getDescendantTabs(aTab).reverse()))
{
if (childTab.__treestyletab__previousPosition > childTab._tPos)
b.moveTabTo(childTab, childTab.__treestyletab__previousPosition);
}
this.internallyTabMovingCount--;
}
else {
@ -3794,10 +3804,11 @@ TreeStyleTabBrowser.prototype = {
*/
let b = this.browser;
this.internallyTabMovingCount++;
this.getChildTabs(aTab).reverse().forEach(function(aChildTab) {
if (aChildTab._tPos < parentTab._tPos)
b.moveTabTo(aChildTab, parentTab._tPos);
}, this);
for (let [, childTab] in Iterator(this.getChildTabs(aTab).reverse()))
{
if (childTab._tPos < parentTab._tPos)
b.moveTabTo(childTab, parentTab._tPos);
}
this.internallyTabMovingCount--;
}
@ -4182,7 +4193,7 @@ TreeStyleTabBrowser.prototype = {
var b = this.mTabBrowser;
var sep, items = {};
[
for (let [, id] in Iterator([
this.kMENUITEM_RELOADSUBTREE,
this.kMENUITEM_RELOADCHILDREN,
this.kMENUITEM_REMOVESUBTREE,
@ -4193,19 +4204,20 @@ TreeStyleTabBrowser.prototype = {
this.kMENUITEM_AUTOHIDE,
this.kMENUITEM_FIXED,
this.kMENUITEM_BOOKMARKSUBTREE
].forEach(function(aID) {
]))
{
let item = this.evaluateXPath(
'descendant::xul:*[starts-with(@id, "'+aID+'")]',
'descendant::xul:*[starts-with(@id, "'+id+'")]',
aEvent.currentTarget,
Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE
).singleNodeValue;
if (!item) return;
items[aID] = item;
if (this.getTreePref('show.'+aID))
if (!item) continue;
items[id] = item;
if (this.getTreePref('show.'+id))
item.removeAttribute('hidden');
else
item.setAttribute('hidden', true);
switch (aID)
switch (id)
{
case this.kMENUITEM_RELOADSUBTREE:
case this.kMENUITEM_RELOADCHILDREN:
@ -4216,11 +4228,11 @@ TreeStyleTabBrowser.prototype = {
case this.kMENUITEM_EXPAND:
case this.kMENUITEM_BOOKMARKSUBTREE:
this.showHideSubtreeMenuItem(item, [b.mContextTab]);
break;
continue;
default:
break;
continue;
}
}
}, this);
// collapse/expand all
sep = this.evaluateXPath(
@ -4391,9 +4403,10 @@ TreeStyleTabBrowser.prototype = {
resetAllTabs : function TSTBrowser_resetAllTabs(aDetachAllChildren)
{
this.getAllTabsArray(this.mTabBrowser).forEach(function(aTab) {
this.resetTab(aTab, aDetachAllChildren);
}, this);
for (let [, tab] in Iterator(this.getAllTabsArray(this.mTabBrowser)))
{
this.resetTab(tab, aDetachAllChildren);
}
},
resetTabbarSize : function TSTBrowser_resetTabbarSize()
@ -4427,24 +4440,26 @@ TreeStyleTabBrowser.prototype = {
this.allowSubtreeCollapseExpand = true;
delete this._lastAllowSubtreeCollapseExpand;
this.getAllTabsArray(this.browser).forEach(function(aTab) {
if (aTab._TSTLastSubtreeCollapsed)
this.collapseExpandSubtree(aTab, true, true);
if (aTab._TSTLastSubtreeExpandedManually)
this.setTabValue(aTab, this.kSUBTREE_EXPANDED_MANUALLY, true);
delete aTab._TSTLastSubtreeCollapsed;
delete aTab._TSTLastSubtreeExpandedManually;
this.updateTabIndent(aTab, 0, true);
}, this);
for (let [, tab] in Iterator(this.getAllTabsArray(this.browser)))
{
if (tab._TSTLastSubtreeCollapsed)
this.collapseExpandSubtree(tab, true, true);
if (tab._TSTLastSubtreeExpandedManually)
this.setTabValue(tab, this.kSUBTREE_EXPANDED_MANUALLY, true);
delete tab._TSTLastSubtreeCollapsed;
delete tab._TSTLastSubtreeExpandedManually;
this.updateTabIndent(tab, 0, true);
}
this.updateTabsIndent(this.rootTabs, undefined, true);
}
else {
this.getAllTabsArray(this.browser).forEach(function(aTab) {
this.updateTabIndent(aTab, 0, true);
aTab._TSTLastSubtreeCollapsed = this.isSubtreeCollapsed(aTab);
aTab._TSTLastSubtreeExpandedManually = this.getTabValue(aTab, this.kSUBTREE_EXPANDED_MANUALLY) == 'true';
this.collapseExpandSubtree(aTab, false, true);
}, this);
for (let [, tab] in Iterator(this.getAllTabsArray(this.browser)))
{
this.updateTabIndent(tab, 0, true);
tab._TSTLastSubtreeCollapsed = this.isSubtreeCollapsed(tab);
tab._TSTLastSubtreeExpandedManually = this.getTabValue(tab, this.kSUBTREE_EXPANDED_MANUALLY) == 'true';
this.collapseExpandSubtree(tab, false, true);
}
this._lastAllowSubtreeCollapseExpand = this.allowSubtreeCollapseExpand;
this.allowSubtreeCollapseExpand = false;
@ -4700,47 +4715,44 @@ TreeStyleTabBrowser.prototype = {
!this.getTreePref('closeParentBehavior.moveDetachedTabsToBottom')) {
insertBefore = this.getNextSiblingTab(this.getRootTab(aTab));
}
children.forEach((
aInfo.behavior == this.kCLOSE_PARENT_BEHAVIOR_DETACH_ALL_CHILDREN ?
function(aTab) {
this.detachTab(aTab, aInfo);
this.moveTabSubtreeTo(aTab, insertBefore ? insertBefore._tPos - 1 : this.getLastTab(b)._tPos );
} :
aInfo.behavior == this.kCLOSE_PARENT_BEHAVIOR_PROMOTE_FIRST_CHILD ?
function(aTab, aIndex) {
this.detachTab(aTab, aInfo);
if (aIndex == 0) {
for (let [i, tab] in Iterator(children))
{
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 );
}
else if (aInfo.behavior == this.kCLOSE_PARENT_BEHAVIOR_PROMOTE_FIRST_CHILD) {
this.detachTab(tab, aInfo);
if (i == 0) {
if (parentTab) {
this.attachTabTo(aTab, parentTab, {
this.attachTabTo(tab, parentTab, {
__proto__ : aInfo,
dontExpand : true,
dontMove : true
});
}
this.collapseExpandSubtree(aTab, false);
this.deleteTabValue(aTab, this.kSUBTREE_COLLAPSED);
this.collapseExpandSubtree(tab, false);
this.deleteTabValue(tab, this.kSUBTREE_COLLAPSED);
}
else {
this.attachTabTo(aTab, children[0], {
this.attachTabTo(tab, children[0], {
__proto__ : aInfo,
dontExpand : true,
dontMove : true
});
}
} :
aInfo.behavior == this.kCLOSE_PARENT_BEHAVIOR_PROMOTE_ALL_CHILDREN && parentTab ?
function(aTab) {
this.attachTabTo(aTab, parentTab, {
}
else if (aInfo.behavior == this.kCLOSE_PARENT_BEHAVIOR_PROMOTE_ALL_CHILDREN && parentTab) {
this.attachTabTo(tab, parentTab, {
__proto__ : aInfo,
dontExpand : true,
dontMove : true
});
} :
// aInfo.behavior == this.kCLOSE_PARENT_BEHAVIOR_SIMPLY_DETACH_ALL_CHILDREN ?
function(aTab) {
this.detachTab(aTab, aInfo);
}
), this);
else { // aInfo.behavior == this.kCLOSE_PARENT_BEHAVIOR_SIMPLY_DETACH_ALL_CHILDREN
this.detachTab(tab, aInfo);
}
}
},
partAllChildren : function TSTBrowser_partAllChildren(aTab, aInfo) /* for backward compatibility */
{
@ -4749,8 +4761,7 @@ TreeStyleTabBrowser.prototype = {
detachTabs : function TSTBrowser_detachTabs(aTabs)
{
var aTabs = Array.slice(aTabs);
for each (let tab in aTabs)
for (let [, tab] in Iterator(aTabs))
{
if (aTabs.indexOf(this.getParentTab(tab)) > -1)
continue;
@ -4803,13 +4814,14 @@ TreeStyleTabBrowser.prototype = {
indent = Math.min(aLevel * 3, maxIndent);
}
Array.slice(aTabs).forEach(function(aTab) {
if (!aTab.parentNode) return; // ignore removed tabs
this.updateTabIndent(aTab, indent, aJustNow);
aTab.setAttribute(this.kNEST, aLevel);
this.updateCanCollapseSubtree(aTab, aLevel);
this.updateTabsIndent(this.getChildTabs(aTab), aLevel+1, aJustNow);
}, this);
for (let [, tab] in Iterator(aTabs))
{
if (!tab.parentNode) continue; // ignore removed tabs
this.updateTabIndent(tab, indent, aJustNow);
tab.setAttribute(this.kNEST, aLevel);
this.updateCanCollapseSubtree(tab, aLevel);
this.updateTabsIndent(this.getChildTabs(tab), aLevel+1, aJustNow);
}
},
updateTabsIndentWithDelay : function TSTBrowser_updateTabsIndentWithDelay(aTabs)
{
@ -4819,9 +4831,10 @@ TreeStyleTabBrowser.prototype = {
this.updateTabsIndentWithDelayTabs = this.updateTabsIndentWithDelayTabs.concat(aTabs);
this.updateTabsIndentWithDelayTimer = this.window.setTimeout(function(aSelf) {
var tabs = [];
aSelf.updateTabsIndentWithDelayTabs.forEach(function(aTab) {
if (tabs.indexOf(aTab) < 0 && aTab.parentNode) tabs.push(aTab);
});
for (let [, tab] in Iterator(aSelf.updateTabsIndentWithDelayTabs))
{
if (tabs.indexOf(tab) < 0 && tab.parentNode) tabs.push(tab);
}
aSelf.updateTabsIndentWithDelayTabs = [];
aSelf.updateTabsIndent(tabs);
aSelf.window.clearTimeout(aSelf.updateTabsIndentWithDelayTimer);
@ -4851,15 +4864,16 @@ TreeStyleTabBrowser.prototype = {
retVal.push('ThreeDShadow');
return retVal.length == 1 ? 'none' : retVal.join(' ') ;
})()+' !important;';
Array.slice(this.document.getAnonymousNodes(aTab)).forEach(function(aBox) {
if (aBox.nodeType != Node.ELEMENT_NODE) return;
aBox.setAttribute(
for (let [, box] in Iterator(this.document.getAnonymousNodes(aTab)))
{
if (box.nodeType != Node.ELEMENT_NODE) continue;
box.setAttribute(
'style',
aBox.getAttribute('style').replace(/(-moz-)?border-(top|bottom)(-[^:]*)?.*:[^;]+;?/g, '') +
box.getAttribute('style')
.replace(/(-moz-)?border-(top|bottom)(-[^:]*)?.*:[^;]+;?/g, '') +
'; border-'+this.indentTarget+': solid transparent '+aIndent+'px !important;'+colors
);
}, this);
}
return;
}
@ -5035,9 +5049,10 @@ TreeStyleTabBrowser.prototype = {
updateAllTabsCount : function TSTBrowser_updateAllTabsCount()
{
this.rootTabs.forEach(function(aTab) {
this.updateTabsCount(aTab, this);
}, this);
for (let [, tab] in Iterator(this.rootTabs))
{
this.updateTabsCount(tab, this);
}
},
promoteTooDeepLevelTabs : function TSTBrowser_promoteTooDeepLevelTabs(aParent)
@ -5045,25 +5060,25 @@ TreeStyleTabBrowser.prototype = {
if (this.maxTreeLevel < 0 || !this.maxTreeLevelPhisical)
return;
var tabs = aParent ? this.getDescendantTabs(aParent) : this.getAllTabsArray(this.mTabBrowser) ;
tabs.forEach(function(aTab) {
var level = parseInt(aTab.getAttribute(this.kNEST) || 0);
for (let [, tab] in Iterator(aParent ? this.getDescendantTabs(aParent) : this.getAllTabsArray(this.mTabBrowser) ))
{
let level = parseInt(tab.getAttribute(this.kNEST) || 0);
if (level <= this.maxTreeLevel)
return;
continue;
var parent = this.getParentTab(aTab);
var newParent = this.getParentTab(parent);
let parent = this.getParentTab(tab);
let newParent = this.getParentTab(parent);
if (this.maxTreeLevel == 0 || !newParent) {
this.detachTab(aTab);
}
else {
let nextSibling = this.getNextTab(aTab);
this.attachTabTo(aTab, newParent, {
let nextSibling = this.getNextTab(tab);
this.attachTabTo(tab, newParent, {
dontMove : true,
insertBefore : nextSibling
});
}
}, this);
}
},
/* move */
@ -5081,9 +5096,10 @@ TreeStyleTabBrowser.prototype = {
this.subTreeChildrenMovingCount++;
this.internallyTabMovingCount++;
this.getDescendantTabs(aTab).forEach(function(aDescendantTab, aIndex) {
b.moveTabTo(aDescendantTab, aTab._tPos + aIndex + (aTab._tPos < aDescendantTab._tPos ? 1 : 0 ));
}, this);
for (let [i, descendantTab] in Iterator(this.getDescendantTabs(aTab)))
{
b.moveTabTo(descendantTab, aTab._tPos + i + (aTab._tPos < descendantTab._tPos ? 1 : 0 ));
}
this.internallyTabMovingCount--;
this.subTreeChildrenMovingCount--;
@ -5294,16 +5310,17 @@ TreeStyleTabBrowser.prototype = {
var expandedTabs = this.getChildTabs(aTab);
var lastExpandedTabIndex = expandedTabs.length - 1;
expandedTabs.forEach(function(aChildTab, aIndex) {
if (!aCollapse && !aJustNow && aIndex == lastExpandedTabIndex) {
for (let [i, childTab] in Iterator(expandedTabs))
{
if (!aCollapse && !aJustNow && i == lastExpandedTabIndex) {
let self = this;
this.collapseExpandTab(aChildTab, aCollapse, aJustNow, function() {
this.collapseExpandTab(childTab, aCollapse, aJustNow, function() {
self.scrollToTabSubtree(aTab);
});
}
else
this.collapseExpandTab(aChildTab, aCollapse, aJustNow);
}, this);
this.collapseExpandTab(childTab, aCollapse, aJustNow);
}
if (aCollapse)
this.deleteTabValue(aTab, this.kSUBTREE_EXPANDED_MANUALLY);
@ -5347,9 +5364,10 @@ TreeStyleTabBrowser.prototype = {
}
if (!this.isSubtreeCollapsed(aTab)) {
this.getChildTabs(aTab).forEach(function(aTab) {
this.collapseExpandTab(aTab, aCollapse, aJustNow);
}, this);
for (let [, tab] in Iterator(this.getChildTabs(aTab)))
{
this.collapseExpandTab(tab, aCollapse, aJustNow);
}
}
},
updateTabCollapsed : function TSTBrowser_updateTabCollapsed(aTab, aCollapsed, aJustNow, aCallbackToRunOnStartAnimation)
@ -5861,22 +5879,23 @@ TreeStyleTabBrowser.prototype = {
if (tabs.length <= 1)
return;
tabs.forEach(function(aTab) {
var currentId = aTab.getAttribute(this.kID);
if (this.tabsHash[currentId] == aTab)
for (let [, tab] in Iterator(tabs))
{
let currentId = tab.getAttribute(this.kID);
if (this.tabsHash[currentId] == tab)
delete this.tabsHash[currentId];
this.resetTabState(aTab);
this.resetTabState(tab);
aTab.setAttribute(this.kID, currentId); // to fallback to it
var [id, duplicated] = this._restoreTabId(aTab);
tab.setAttribute(this.kID, currentId); // to fallback to it
let [id, duplicated] = this._restoreTabId(tab);
this.setTabValue(aTab, this.kID, id);
this.tabsHash[id] = aTab;
this.setTabValue(tab, this.kID, id);
this.tabsHash[id] = tab;
aTab.__treestyletab__restoreState = this.RESTORE_STATE_READY_TO_RESTORE;
aTab.__treestyletab__duplicated = duplicated;
}, this);
tab.__treestyletab__restoreState = this.RESTORE_STATE_READY_TO_RESTORE;
tab.__treestyletab__duplicated = duplicated;
}
this.updateAllTabsIndent(true);

View File

@ -413,13 +413,14 @@ FullTooltipManager.prototype = {
if (aExtraLabels) {
if (typeof aExtraLabels == 'string')
aExtraLabels = [aExtraLabels];
aExtraLabels.forEach(function(aLabel) {
aLabel = aLabel.replace(/^\s+|\s+$/g, '');
if (!aLabel)
return;
for (let [, label] in Iterator(aExtraLabels))
{
label = label.replace(/^\s+|\s+$/g, '');
if (!label)
continue;
root.appendChild(this.document.createElement('description'))
.appendChild(this.document.createTextNode(aLabel));
}, this);
.appendChild(this.document.createTextNode(label));
}
}
root.insertBefore(tree, root.firstChild && root.firstChild.nextSibling);

View File

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

View File

@ -414,10 +414,10 @@ catch(e) {
var tabs = sv.getTabsArray(targetBrowser);
var draggedWholeTree = [].concat(draggedRoots);
for each (let root in draggedRoots)
for (let [, root] in Iterator(draggedRoots))
{
let tabs = sourceService.getDescendantTabs(root);
for each (let tab in tabs)
for (let [, tab] in Iterator(tabs))
{
if (draggedWholeTree.indexOf(tab) < 0)
draggedWholeTree.push(tab);
@ -515,14 +515,15 @@ catch(e) {
var sv = b.treeStyleTab;
b.movingSelectedTabs = true; // Multiple Tab Handler
aTabs.forEach(function(aTab) {
if (!aTab.parentNode) return; // ignore removed tabs
for (let [, tab] in Iterator(aTabs))
{
if (!tab.parentNode) continue; // ignore removed tabs
if (aParent)
sv.attachTabTo(aTab, aParent);
sv.attachTabTo(tab, aParent);
else
sv.detachTab(aTab);
sv.collapseExpandTab(aTab, false);
}, sv);
sv.detachTab(tab);
sv.collapseExpandTab(tab, false);
}
b.movingSelectedTabs = false; // Multiple Tab Handler
},
@ -532,11 +533,12 @@ catch(e) {
var sv = b.treeStyleTab;
b.movingSelectedTabs = true; // Multiple Tab Handler
aTabs.forEach(function(aTab) {
if (!aTab.parentNode) return; // ignore removed tabs
sv.detachTab(aTab);
sv.collapseExpandTab(aTab, false);
}, sv);
for (let [, tab] in Iterator(aTabs))
{
if (!tab.parentNode) continue; // ignore removed tabs
sv.detachTab(tab);
sv.collapseExpandTab(tab, false);
}
b.movingSelectedTabs = false; // Multiple Tab Handler
},
@ -861,9 +863,10 @@ catch(e) {
var sv = this.treeStyleTab;
if (this.mAutoExpandedTabs.length) {
if (sv.getTreePref('autoExpand.collapseFinally')) {
this.mAutoExpandedTabs.forEach(function(aTarget) {
this.collapseExpandSubtree(this.getTabById(aTarget), true, true);
}, sv);
for (let [, target] in Iterator(this.mAutoExpandedTabs))
{
sv.collapseExpandSubtree(sv.getTabById(target), true, true);
}
}
this.mAutoExpandedTabs = [];
}

View File

@ -53,10 +53,12 @@ TreeStyleTabThemeManager.prototype = {
set : function(aStyle, aPosition)
{
if (this._lastStyles)
this._lastStyles.forEach(function(aStyle) {
aStyle.parentNode.removeChild(aStyle);
});
if (this._lastStyles) {
for (let [, style] in Iterator(this._lastStyles))
{
style.parentNode.removeChild(style);
}
}
this._lastStyles = null;
var styles = [];
@ -128,13 +130,14 @@ TreeStyleTabThemeManager.prototype = {
null ;
if (!images) return;
images.forEach(function(aImage) {
if (this._preLoadImagesForStyleDoneImages.indexOf(aImage) > -1)
return;
for (let [, image] in Iterator(images))
{
if (this._preLoadImagesForStyleDoneImages.indexOf(image) > -1)
continue;
(new this.window.Image()).src = aImage;
this._preLoadImagesForStyleDoneImages.push(aImage);
}, this);
(new this.window.Image()).src = image;
this._preLoadImagesForStyleDoneImages.push(image);
}
},
_preLoadImages : {

View File

@ -394,16 +394,18 @@ var TreeStyleTabUtils = {
{
var OS = this.XULAppInfo.OS;
var processed = {};
this.getDescendant('extensions.treestyletab.platform.'+OS).forEach(function(aKey) {
var key = aKey.replace('platform.'+OS+'.', '');
this.setDefaultPref(key, this.getPref(aKey));
for (let [, originalKey] in Iterator(this.getDescendant('extensions.treestyletab.platform.'+OS)))
{
let key = originalKey.replace('platform.'+OS+'.', '');
this.setDefaultPref(key, this.getPref(originalKey));
processed[key] = true;
}, this);
this.getDescendant('extensions.treestyletab.platform.default').forEach(function(aKey) {
var key = aKey.replace('platform.default.', '');
}
for (let [, originalKey] in Iterator(this.getDescendant('extensions.treestyletab.platform.default')))
{
let key = originalKey.replace('platform.default.', '');
if (!(key in processed))
this.setDefaultPref(key, this.getPref(aKey));
}, this);
this.setDefaultPref(key, this.getPref(originalKey));
}
},
updateAeroPeek : function TSTUtils_updateAeroPeek()
@ -711,26 +713,27 @@ var TreeStyleTabUtils = {
doAndWaitDOMEvent : function TSTUtils_doAndWaitDOMEvent()
{
var type, target, delay, task;
Array.slice(arguments).forEach(function(aArg) {
switch(typeof aArg)
for (let [, arg] in Iterator(arguments))
{
switch(typeof arg)
{
case 'string':
type = aArg;
break;
type = arg;
continue;
case 'number':
delay = aArg;
break;
delay = arg;
continue;
case 'function':
task = aArg;
break;
task = arg;
continue;
default:
target = aArg;
break;
target = arg;
continue;
}
}
});
if (!target || !type) {
if (task) task();
@ -862,61 +865,86 @@ var TreeStyleTabUtils = {
return false;
var box = twisty.boxObject;
var minX = box.screenX;
var minY = box.screenY;
var maxX = minX + box.width;
var maxY = minY + box.height;
var icon = tab.ownerDocument.getAnonymousElementByAttribute(tab, 'class', 'tab-icon-image');
var iconBox = icon.boxObject;
var throbber = tab.ownerDocument.getAnonymousElementByAttribute(tab, 'class', 'tab-throbber');
var throbberBox = throbber.boxObject;
var extraMinX = Math.min(throbberBox.screenX, iconBox.screenX);
var extraMinY = Math.min(throbberBox.screenY, iconBox.screenY);
var extraMaxX = Math.max(throbberBox.screenX + throbberBox.width, iconBox.screenX + iconBox.width);
var extraMaxY = Math.max(throbberBox.screenY + throbberBox.height, iconBox.screenY + iconBox.height);
var left = box.screenX;
var top = box.screenY;
var right = left + box.width;
var bottom = top + box.height;
var favicon = this.getFaviconRect(tab);
if (!box.width || !box.height) {
minX = extraMinX;
minY = extraMinY;
maxX = extraMaxX;
maxY = extraMaxY;
left = favicon.left;
top = favicon.top;
right = favicon.right;
bottom = favicon.bottom;
}
else if (
this.shouldExpandTwistyArea &&
!this._expandTwistyAreaBlockers.length
) {
minX = Math.min(minX, extraMinX);
minY = Math.min(minY, extraMinY);
maxX = Math.max(maxX, extraMaxX);
maxY = Math.max(maxY, extraMaxY);
left = Math.min(left, favicon.left);
top = Math.min(top, favicon.top);
right = Math.max(right, favicon.right);
bottom = Math.max(bottom, favicon.bottom);
}
var x = aEvent.screenX;
var y = aEvent.screenY;
return (x >= minX && x <= maxX && y >= minY && y <= maxY);
return (x >= left && x <= right && y >= top && y <= bottom);
},
getFaviconRect : function TSTUtils_getFaviconRect(aTab)
{
var icon = aTab.ownerDocument.getAnonymousElementByAttribute(aTab, 'class', 'tab-icon-image');
var iconBox = icon.boxObject;
var iconRect = {
left : iconBox.screenX,
top : iconBox.screenY,
right : iconBox.screenX + iconBox.width,
bottom : iconBox.screenY + iconBox.height
};
var throbber = aTab.ownerDocument.getAnonymousElementByAttribute(aTab, 'class', 'tab-throbber');
var throbberBox = throbber.boxObject;
var throbberRect = {
left : throbberBox.screenX,
top : throbberBox.screenY,
right : throbberBox.screenX + throbberBox.width,
bottom : throbberBox.screenY + throbberBox.height
};
if (!iconBox.width && !iconBox.height)
return throbberRect;
if (!throbberBox.width && !throbberBox.height)
return iconRect;
return {
left : Math.min(throbberRect.left, iconRect.left),
right : Math.max(throbberRect.right, iconRect.right),
top : Math.min(throbberRect.top, iconRect.top),
bottom : Math.max(throbberRect.bottom, iconRect.bottom)
};
},
// called with target(nsIDOMEventTarget), document(nsIDOMDocument), type(string) and data(object)
fireDataContainerEvent : function()
fireDataContainerEvent : function TSTUtils_fireDataContainerEvent()
{
var target, document, type, data, canBubble, cancellable;
Array.slice(arguments).forEach(function(aArg) {
if (typeof aArg == 'boolean') {
for (let [, arg] in Iterator(arguments))
{
if (typeof arg == 'boolean') {
if (canBubble === void(0))
canBubble = aArg;
canBubble = arg;
else
cancellable = aArg;
cancellable = arg;
}
else if (typeof aArg == 'string')
type = aArg;
else if (aArg instanceof Ci.nsIDOMDocument)
document = aArg;
else if (aArg instanceof Ci.nsIDOMEventTarget)
target = aArg;
else if (typeof arg == 'string')
type = arg;
else if (arg instanceof Ci.nsIDOMDocument)
document = arg;
else if (arg instanceof Ci.nsIDOMEventTarget)
target = arg;
else
data = aArg;
});
data = arg;
}
if (!target)
target = document;
if (!document)
@ -924,7 +952,7 @@ var TreeStyleTabUtils = {
var event = document.createEvent('DataContainerEvent');
event.initEvent(type, canBubble, cancellable);
for (var i in data)
for (let i in data)
{
if (!data.hasOwnProperty(i))
continue;
@ -1105,17 +1133,19 @@ var TreeStyleTabUtils = {
{
if (!aTabs || aTabs.length <= 1) return;
var id = this.makeNewClosedSetId() + '::' + aTabs.length;
aTabs.forEach(function(aTab) {
this.setTabValue(aTab, this.kCLOSED_SET_ID, id);
}, this);
for (let [, tab] in Iterator(aTabs))
{
this.setTabValue(tab, this.kCLOSED_SET_ID, id);
}
},
unmarkAsClosedSet : function TSTUtils_unmarkAsClosedSet(aTabs) /* PUBLIC API */
{
if (!aTabs || !aTabs.length) return;
aTabs.forEach(function(aTab) {
this.deleteTabValue(aTab, this.kCLOSED_SET_ID);
}, this);
for (let [, tab] in Iterator(aTabs))
{
this.deleteTabValue(tab, this.kCLOSED_SET_ID);
}
},
useTMPSessionAPI : false,
@ -1253,7 +1283,7 @@ var TreeStyleTabUtils = {
var b = aTabBrowser || this.browser;
var top = aFrame.top;
var tabs = this.getAllTabsArray(b);
for each (var tab in tabs)
for (let [, tab] in Iterator(tabs))
{
if (tab.linkedBrowser.contentWindow == top)
return tab;
@ -1293,10 +1323,11 @@ var TreeStyleTabUtils = {
cleanUpTabsArray : function TSTUtils_cleanUpTabsArray(aTabs)
{
var newTabs = [];
aTabs.forEach(function(aTab) {
if (!aTab || !aTab.parentNode) return; // ignore removed tabs
if (newTabs.indexOf(aTab) < 0) newTabs.push(aTab);
});
for (let [, tab] in Iterator(aTabs))
{
if (!tab || !tab.parentNode) continue; // ignore removed tabs
if (newTabs.indexOf(tab) < 0) newTabs.push(tab);
}
newTabs.sort(this.sortTabsByOrder);
return newTabs;
},
@ -1328,17 +1359,17 @@ var TreeStyleTabUtils = {
var groups = [];
var group = [];
this.cleanUpTabsArray(aTabs)
.forEach(function(aTab) {
var parent = this.getParentTab(aTab);
for (let [, tab] in Iterator(this.cleanUpTabsArray(aTabs)))
{
let parent = this.getParentTab(tab);
if (!parent || group.indexOf(parent) < 0) {
if (group.length) groups.push(group);
group = [aTab];
group = [tab];
}
else {
group.push(aTab);
group.push(tab);
}
}
}, this);
if (group.length) groups.push(group);
return groups;
},
@ -2295,10 +2326,11 @@ var TreeStyleTabUtils = {
var collapsedStates = aTabs.map(function(aTab) {
return this.getTabValue(aTab, this.kSUBTREE_COLLAPSED) == 'true';
}, this);
aTabs.forEach(function(aTab) {
this.collapseExpandSubtree(aTab, false, true);
this.collapseExpandTab(aTab, false, true);
}, this);
for (let [, tab] in Iterator(aTabs))
{
this.collapseExpandSubtree(tab, false, true);
this.collapseExpandTab(tab, false, true);
}
return collapsedStates;
},
@ -2362,26 +2394,27 @@ var TreeStyleTabUtils = {
while (aExpandStates.length < aTabs.length) aExpandStates.push(-1);
var parentTab = null;
aTabs.forEach(function(aTab, aIndex) {
if (sv.isCollapsed(aTab)) sv.collapseExpandTab(aTab, false, true);
sv.detachTab(aTab);
for (let [i, tab] in Iterator(aTabs))
{
if (sv.isCollapsed(tab)) sv.collapseExpandTab(tab, false, true);
sv.detachTab(tab);
var parentIndexInTree = aTreeStructure[aIndex];
let parentIndexInTree = aTreeStructure[i];
if (parentIndexInTree < 0) // there is no parent, so this is a new parent!
parentTab = aTab.getAttribute(sv.kID);
parentTab = tab.getAttribute(sv.kID);
var parent = sv.getTabById(parentTab);
let parent = sv.getTabById(parentTab);
if (parent) {
let tabs = [parent].concat(sv.getDescendantTabs(parent));
parent = parentIndexInTree < tabs.length ? tabs[parentIndexInTree] : parent ;
}
if (parent) {
sv.attachTabTo(aTab, parent, {
sv.attachTabTo(tab, parent, {
forceExpand : true,
dontMove : true
});
}
});
}
for (let i = aTabs.length-1; i > -1; i--)
{

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([
'extensions.treestyletab.autoCollapseExpandSubTreeOnSelect',
'extensions.treestyletab.autoCollapseExpandSubTreeOnSelect.onCurrentTabRemove',
'extensions.treestyletab.autoCollapseExpandSubTreeOnSelect.whileFocusMovingByShortcut',
@ -388,12 +388,13 @@ TreeStyleTabWindow.prototype = {
'extensions.treestyletab.show.context-item-bookmarkTabSubTree',
'extensions.multipletab.show.multipletab-selection-item-removeTabSubTree',
'extensions.multipletab.show.multipletab-selection-item-createSubTree'
].forEach(function(aPref) {
var value = this.getPref(aPref);
if (value === null) return;
this.setPref(aPref.replace('SubTree', 'Subtree'), value);
this.clearPref(aPref);
}, this);
]))
{
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')) {
behavior = behavior | 2048;
@ -410,13 +411,14 @@ TreeStyleTabWindow.prototype = {
this.setTreePref('autoAttach.searchResult', search);
}
default:
orientalPrefs.forEach(function(aPref) {
let value = this.getPref(aPref);
if (value === null) return;
this.setPref(aPref+'.horizontal', value);
this.setPref(aPref+'.vertical', value);
this.clearPref(aPref);
}, this);
for (let [, pref] in Iterator(orientalPrefs))
{
let value = this.getPref(pref);
if (value === null) continue;
this.setPref(pref+'.horizontal', value);
this.setPref(pref+'.vertical', value);
this.clearPref(pref);
}
break;
}
this.setTreePref('prefsVersion', this.kPREF_VERSION);
@ -499,16 +501,17 @@ TreeStyleTabWindow.prototype = {
}
if (!prefs) return;
[
for (let [, pref] in Iterator([
'browser.tabs.loadFolderAndReplace',
'browser.tabs.insertRelatedAfterCurrent',
'extensions.stm.tabBarMultiRows' // Super Tab Mode
].forEach(function(aPref) {
var backup = prefs.getPref(aPref+'.backup');
if (backup === null) return;
prefs.setPref(aPref+'.override', backup); // we have to set to ".override" pref, to avoid unexpectedly reset by the preference listener.
prefs.clearPref(aPref+'.backup');
});
]))
{
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.
prefs.clearPref(pref+'.backup');
}
};
new this.window['piro.sakura.ne.jp'].UninstallationListener({
id : 'treestyletab@piro.sakura.ne.jp',
@ -549,21 +552,23 @@ TreeStyleTabWindow.prototype = {
var items = Array.slice(aEvent.originalTarget.childNodes);
var firstItemIndex = 0;
// ignore menu items inserted by Weave (Firefox Sync), Tab Utilities, and others.
items.forEach(function(aItem, aIndex) {
for (let [i, item] in Iterator(items))
{
if (
aItem.getAttribute('anonid') ||
aItem.id ||
aItem.hidden ||
aItem.localName != 'menuitem'
item.getAttribute('anonid') ||
item.id ||
item.hidden ||
item.localName != 'menuitem'
)
firstItemIndex = aIndex + 1;
});
firstItemIndex = i + 1;
}
items = items.slice(firstItemIndex);
var b = this.getTabBrowserFromChild(aEvent.originalTarget) || this.browser;
this.getTabsArray(b).forEach(function(aTab, aIndex) {
items[aIndex].style.marginLeft = aTab.getAttribute(this.kNEST)+'em';
}, this);
for (let [i, tab] in Iterator(this.getTabsArray(b)))
{
items[i].style.marginLeft = tab.getAttribute(this.kNEST)+'em';
}
},
destroy : function TSTWindow_destroy()
@ -594,9 +599,10 @@ TreeStyleTabWindow.prototype = {
d.removeEventListener(this.kEVENT_TYPE_TABBAR_STATE_CHANGED, this, false);
d.removeEventListener(this.kEVENT_TYPE_FOCUS_NEXT_TAB, this, false);
this._tabFocusAllowance.forEach(function(aListener) {
w.removeEventListener(this.kEVENT_TYPE_FOCUS_NEXT_TAB, aListener, false);
}, this);
for (let [, listener] in Iterator(this._tabFocusAllowance))
{
w.removeEventListener(this.kEVENT_TYPE_FOCUS_NEXT_TAB, listener, false);
}
var appcontent = d.getElementById('appcontent');
appcontent.removeEventListener('SubBrowserAdded', this, false);
@ -1054,11 +1060,12 @@ TreeStyleTabWindow.prototype = {
this.AeroPeek.windows.some(function(aTabWindow) {
if (aTabWindow.win == this.window) {
aTabWindow.previews.forEach(function(aPreview) {
if (!aPreview) return;
var tab = aPreview.controller.wrappedJSObject.tab;
aPreview.visible = !this.isCollapsed(tab);
}, this);
for (let [, preview] in Iterator(aTabWindow.previews))
{
if (!preview) continue;
let tab = preview.controller.wrappedJSObject.tab;
preview.visible = !this.isCollapsed(tab);
}
this.AeroPeek.checkPreviewCount();
return true;
}
@ -1204,14 +1211,15 @@ TreeStyleTabWindow.prototype = {
processRestoredTabs : function TSTWindow_processRestoredTabs()
{
this._restoringTabs.forEach(function(aTab) {
for (let [, tab] in Iterator(this._restoringTabs))
{
try {
var b = this.getTabBrowserFromChild(aTab);
let b = this.getTabBrowserFromChild(aTab);
if (b) b.treeStyleTab.handleRestoredTab(aTab);
}
catch(e) {
}
}, this);
}
this._restoringTabs = [];
},
@ -1272,23 +1280,24 @@ TreeStyleTabWindow.prototype = {
if (aOnlyChildren)
tabs = this.gatherSubtreeMemberTabs(aTabOrTabs);
this.splitTabsToSubtrees(tabs).forEach(function(aTabs) {
if (!this.fireTabSubtreeClosingEvent(aTabs[0], aTabs))
return;
var b = this.getTabBrowserFromChild(aTabs[0]);
if (aOnlyChildren)
aTabs = aTabs.slice(1);
if (!aTabs.length)
return;
this.stopRendering();
this.markAsClosedSet(aTabs);
for (let i = aTabs.length-1; i > -1; i--)
for (let [, subtreeTabs] in Iterator(this.splitTabsToSubtrees(tabs)))
{
b.removeTab(aTabs[i], { animate : true });
if (!this.fireTabSubtreeClosingEvent(subtreeTabs[0], subtreeTabs))
continue;
let b = this.getTabBrowserFromChild(subtreeTabs[0]);
if (aOnlyChildren)
subtreeTabs = subtreeTabs.slice(1);
if (!subtreeTabs.length)
continue;
this.stopRendering();
this.markAsClosedSet(subtreeTabs);
for (let i = subtreeTabs.length-1; i > -1; i--)
{
b.removeTab(subtreeTabs[i], { animate : true });
}
this.startRendering();
this.fireTabSubtreeClosedEvent(b, aTabs[0], aTabs)
}, this);
this.fireTabSubtreeClosedEvent(b, subtreeTabs[0], subtreeTabs)
}
},
removeTabSubTree : function() { return this.removeTabSubtree.apply(this, arguments); }, // obsolete, for backward compatibility
@ -1388,10 +1397,11 @@ TreeStyleTabWindow.prototype = {
aTabs.shift() ;
var self = this;
this.Deferred.next(function(self) {
aTabs.forEach(function(aTab) {
b.treeStyleTab.attachTabTo(aTab, root);
b.treeStyleTab.collapseExpandTab(aTab, false);
}, self);
for (let [, tab] in Iterator(aTabs))
{
b.treeStyleTab.attachTabTo(tab, root);
b.treeStyleTab.collapseExpandTab(tab, false);
}
if (parent) {
b.treeStyleTab.attachTabTo(root, parent, {
insertBefore : next
@ -1425,11 +1435,12 @@ TreeStyleTabWindow.prototype = {
var roots = [];
if (!aTabs || !aTabs.length) return roots;
aTabs = this.cleanUpTabsArray(aTabs);
aTabs.forEach(function(aTab) {
var parent = this.getParentTab(aTab);
if (parent && aTabs.indexOf(parent) > -1) return;
roots.push(aTab);
}, this);
for (let [, tab] in Iterator(aTabs))
{
let parent = this.getParentTab(tab);
if (parent && aTabs.indexOf(parent) > -1) continue;
roots.push(tab);
}
return roots;
},
@ -1507,9 +1518,10 @@ TreeStyleTabWindow.prototype = {
this.stopRendering();
this.markAsClosedSet(closeTabs);
closeTabs.reverse().forEach(function(aTab) {
b.removeTab(aTab);
});
for (let [, tab] in Iterator(closeTabs.reverse()))
{
b.removeTab(tab);
}
this.startRendering();
},