Reduce eval hack

This commit is contained in:
Piro / YUKI Hiroshi 2016-01-22 00:13:56 +09:00
parent 190d8cd71c
commit d5b05b6017
2 changed files with 35 additions and 18 deletions

View File

@ -505,24 +505,34 @@ var TreeStyleTabWindowHelper = {
)); ));
}, 'treeStyleTab'); }, 'treeStyleTab');
TreeStyleTabUtils.doPatching(b.loadTabs, 'b.loadTabs', function(aName, aSource) { b.__treestyletab__loadTabs = b.loadTabs;
return eval(aName+' = '+aSource.replace( b.loadTabs = function(aURIs, aLoadInBackground, aReplace, ...aArgs) {
'var tabNum = ', if (aReplace)
'if (this.treeStyleTab.readiedToAttachNewTabGroup)\n' + this.treeStyleTab.readyToOpenChildTab(this.selectedTab, true);
' TreeStyleTabService.readyToOpenChildTab(firstTabAdded || this.selectedTab, true);\n' + else
'$&' this.treeStyleTab.nextOpenedTabToBeParent = true;
).replace(
'if (!aLoadInBackground)', var result;
'if (TreeStyleTabService.checkToOpenChildTab(this))\n' + var tabs = [];
' TreeStyleTabService.stopToOpenChildTab(this);\n' + var firstTabAdded;
'$&' try {
).replace( tabs = this.treeStyleTab.doAndGetNewTabs((function() {
'this.selectedTab = firstTabAdded;', result = this.__treestyletab__loadTabs.apply(this, [aURIs, aLoadInBackground, aReplace].concat(aArgs));
'this.selectedTab = aURIs[0].indexOf("about:treestyletab-group") < 0 ? \n' + }).bind(this));
' firstTabAdded :\n' + firstTabAdded = tabs[0];
' TreeStyleTabService.getNextTab(firstTabAdded) ;' }
)); finally {
}, 'TreeStyleTab'); if (!aReplace && firstTabAdded) {
this.selectedTab = aURIs[0].indexOf('about:treestyletab-group') == 0 ?
TreeStyleTabService.getNextTab(firstTabAdded) :
firstTabAdded;
}
if (this.treeStyleTab.checkToOpenChildTab(this))
this.treeStyleTab.stopToOpenChildTab(this);
delete this.treeStyleTab.nextOpenedTabToBeParent;
}
return result;
};
TreeStyleTabUtils.doPatching(b._beginRemoveTab, 'b._beginRemoveTab', function(aName, aSource) { TreeStyleTabUtils.doPatching(b._beginRemoveTab, 'b._beginRemoveTab', function(aName, aSource) {
return eval(aName+' = '+aSource.replace( return eval(aName+' = '+aSource.replace(

View File

@ -3287,8 +3287,15 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
*/ */
b._lastRelatedTab = lastRelatedTab; b._lastRelatedTab = lastRelatedTab;
// this is the first tab of loading group.
if (this.nextOpenedTabToBeParent) {
this.readyToOpenChildTab(tab, true);
delete this.nextOpenedTabToBeParent;
}
return true; return true;
}, },
loadingMultipleTabs : false,
_addedCountInThisLoop : 0, _addedCountInThisLoop : 0,
_addedCountClearTimer : null, _addedCountClearTimer : null,
_checkRestoringWindowTimerOnTabAdded : null, _checkRestoringWindowTimerOnTabAdded : null,