Reduce use of eval()
This commit is contained in:
parent
1d341ab3a0
commit
a029d82f18
@ -34,14 +34,12 @@ var TreeStyleTabWindowHelper = {
|
|||||||
));
|
));
|
||||||
}, 'TreeStyleTab');
|
}, 'TreeStyleTab');
|
||||||
|
|
||||||
TreeStyleTabUtils.doPatching(nsBrowserAccess.prototype.openURIInFrame, 'nsBrowserAccess.prototype.openURIInFrame', function(aName, aSource) {
|
nsBrowserAccess.prototype.__treesytletab__openURIInFrame = nsBrowserAccess.prototype.openURIInFrame;
|
||||||
return eval(aName+' = '+aSource.replace(
|
nsBrowserAccess.prototype.openURIInFrame = function(aURI, aParams, aWhere, aContext) {
|
||||||
'let browser = ',
|
if (aWhere === Ci.nsIBrowserDOMWindow.OPEN_NEWTAB)
|
||||||
// Use "arguments[1]" instead of "aOwner" or "aParams".
|
TreeStyleTabService.onBeforeBrowserAccessOpenURI(aParams, aWhere, aContext);
|
||||||
// The argument name is changed from "aOwner" to "aParams" by https://bugzilla.mozilla.org/show_bug.cgi?id=1058116
|
return this.__treesytletab__openURIInFrame.call(aURI, aParams, aWhere, aContext);
|
||||||
'TreeStyleTabService.onBeforeBrowserAccessOpenURI(arguments[1], aWhere, aContext); $&'
|
};
|
||||||
));
|
|
||||||
}, 'TreeStyleTab');
|
|
||||||
|
|
||||||
if ('TabsInTitlebar' in window) {
|
if ('TabsInTitlebar' in window) {
|
||||||
TreeStyleTabUtils.doPatching(TabsInTitlebar._update, 'TabsInTitlebar._update', function(aName, aSource) {
|
TreeStyleTabUtils.doPatching(TabsInTitlebar._update, 'TabsInTitlebar._update', function(aName, aSource) {
|
||||||
@ -179,20 +177,17 @@ var TreeStyleTabWindowHelper = {
|
|||||||
return this.__treestyletab__openFrameInTab.apply(this, aArgs);
|
return this.__treestyletab__openFrameInTab.apply(this, aArgs);
|
||||||
};
|
};
|
||||||
|
|
||||||
var viewImageMethod = ('viewImage' in nsContextMenu.prototype) ? 'viewImage' : 'viewMedia' ;
|
nsContextMenu.prototype.__treestyletab__viewMedia = nsContextMenu.prototype.viewMedia;
|
||||||
TreeStyleTabUtils.doPatching(nsContextMenu.prototype[viewImageMethod], 'nsContextMenu.prototype.'+viewImageMethod, function(aName, aSource) {
|
nsContextMenu.prototype.viewMedia = function(aEvent) {
|
||||||
return eval(aName+' = '+aSource.replace(
|
TreeStyleTabService.onBeforeViewMedia(aEvent, this.target.ownerDocument.defaultView);
|
||||||
/(openUILink\()/g,
|
return this.__treestyletab__viewMedia.call(this, aEvent);
|
||||||
'TreeStyleTabService.onBeforeViewMedia(e, this.target.ownerDocument.defaultView); $1'
|
};
|
||||||
));
|
|
||||||
}, 'TreeStyleTab');
|
|
||||||
|
|
||||||
TreeStyleTabUtils.doPatching(nsContextMenu.prototype.viewBGImage, 'nsContextMenu.prototype.viewBGImage', function(aName, aSource) {
|
nsContextMenu.prototype.__treestyletab__viewBGImage = nsContextMenu.prototype.viewBGImage;
|
||||||
return eval(aName+' = '+aSource.replace(
|
nsContextMenu.prototype.viewBGImage = function(aEvent) {
|
||||||
'openUILink(',
|
TreeStyleTabService.onBeforeViewMedia(aEvent, this.target.ownerDocument.defaultView);
|
||||||
'TreeStyleTabService.onBeforeViewMedia(e, this.target.ownerDocument.defaultView); $&'
|
return this.__treestyletab__viewBGImage.call(this, aEvent);
|
||||||
));
|
};
|
||||||
}, 'TreeStyleTab');
|
|
||||||
|
|
||||||
TreeStyleTabUtils.doPatching(nsContextMenu.prototype.addDictionaries, 'nsContextMenu.prototype.addDictionaries', function(aName, aSource) {
|
TreeStyleTabUtils.doPatching(nsContextMenu.prototype.addDictionaries, 'nsContextMenu.prototype.addDictionaries', function(aName, aSource) {
|
||||||
return eval(aName+' = '+aSource.replace(
|
return eval(aName+' = '+aSource.replace(
|
||||||
|
Loading…
Reference in New Issue
Block a user