[Pale-Moon] Issue MoonchildProductions/UXP#516 - Remove named function syntax from palemoon/components/fuel.

This commit is contained in:
athenian200 2020-02-06 06:49:24 -06:00 • committed by Roy Tam
commit f5a1756738

View file

@ -49,14 +49,14 @@ var Utilities = {
return this.windowMediator; return this.windowMediator;
}, },
makeURI: function fuelutil_makeURI(aSpec) { makeURI: function (aSpec) {
if (!aSpec) if (!aSpec)
return null; return null;
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService); var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
return ios.newURI(aSpec, null, null); return ios.newURI(aSpec, null, null);
}, },
free: function fuelutil_free() { free: function () {
delete this.bookmarks; delete this.bookmarks;
delete this.bookmarksObserver; delete this.bookmarksObserver;
delete this.annotations; delete this.annotations;
@ -103,12 +103,12 @@ Window.prototype = {
* Helper used to setup event handlers on the XBL element. Note that the events * Helper used to setup event handlers on the XBL element. Note that the events
* are actually dispatched to tabs, so we capture them. * are actually dispatched to tabs, so we capture them.
*/ */
_watch: function win_watch(aType) { _watch: function (aType) {
this._tabbrowser.tabContainer.addEventListener(aType, this, this._tabbrowser.tabContainer.addEventListener(aType, this,
/* useCapture = */ true); /* useCapture = */ true);
}, },
handleEvent: function win_handleEvent(aEvent) { handleEvent: function (aEvent) {
this._events.dispatch(aEvent.type, getBrowserTab(this, aEvent.originalTarget.linkedBrowser)); this._events.dispatch(aEvent.type, getBrowserTab(this, aEvent.originalTarget.linkedBrowser));
}, },
@ -124,7 +124,7 @@ Window.prototype = {
return getBrowserTab(this, this._tabbrowser.selectedBrowser); return getBrowserTab(this, this._tabbrowser.selectedBrowser);
}, },
open: function win_open(aURI) { open: function (aURI) {
return getBrowserTab(this, this._tabbrowser.addTab(aURI.spec).linkedBrowser); return getBrowserTab(this, this._tabbrowser.addTab(aURI.spec).linkedBrowser);
}, },
@ -192,12 +192,12 @@ BrowserTab.prototype = {
/* /*
* Helper used to setup event handlers on the XBL element * Helper used to setup event handlers on the XBL element
*/ */
_watch: function bt_watch(aType) { _watch: function (aType) {
this._browser.addEventListener(aType, this, this._browser.addEventListener(aType, this,
/* useCapture = */ true); /* useCapture = */ true);
}, },
handleEvent: function bt_handleEvent(aEvent) { handleEvent: function (aEvent) {
if (aEvent.type == "load") { if (aEvent.type == "load") {
if (!(aEvent.originalTarget instanceof Ci.nsIDOMDocument)) if (!(aEvent.originalTarget instanceof Ci.nsIDOMDocument))
return; return;
@ -211,29 +211,29 @@ BrowserTab.prototype = {
/* /*
* Helper used to determine the index offset of the browsertab * Helper used to determine the index offset of the browsertab
*/ */
_getTab: function bt_gettab() { _getTab: function () {
var tabs = this._tabbrowser.tabs; var tabs = this._tabbrowser.tabs;
return tabs[this.index] || null; return tabs[this.index] || null;
}, },
load: function bt_load(aURI) { load: function (aURI) {
this._browser.loadURI(aURI.spec, null, null); this._browser.loadURI(aURI.spec, null, null);
}, },
focus: function bt_focus() { focus: function () {
this._tabbrowser.selectedTab = this._getTab(); this._tabbrowser.selectedTab = this._getTab();
this._tabbrowser.focus(); this._tabbrowser.focus();
}, },
close: function bt_close() { close: function () {
this._tabbrowser.removeTab(this._getTab()); this._tabbrowser.removeTab(this._getTab());
}, },
moveBefore: function bt_movebefore(aBefore) { moveBefore: function (aBefore) {
this._tabbrowser.moveTabTo(this._getTab(), aBefore.index); this._tabbrowser.moveTabTo(this._getTab(), aBefore.index);
}, },
moveToEnd: function bt_moveend() { moveToEnd: function () {
this._tabbrowser.moveTabTo(this._getTab(), this._tabbrowser.browsers.length); this._tabbrowser.moveTabTo(this._getTab(), this._tabbrowser.browsers.length);
}, },
@ -252,21 +252,21 @@ Annotations.prototype = {
return Utilities.annotations.getItemAnnotationNames(this._id); return Utilities.annotations.getItemAnnotationNames(this._id);
}, },
has: function ann_has(aName) { has: function (aName) {
return Utilities.annotations.itemHasAnnotation(this._id, aName); return Utilities.annotations.itemHasAnnotation(this._id, aName);
}, },
get: function ann_get(aName) { get: function (aName) {
if (this.has(aName)) if (this.has(aName))
return Utilities.annotations.getItemAnnotation(this._id, aName); return Utilities.annotations.getItemAnnotation(this._id, aName);
return null; return null;
}, },
set: function ann_set(aName, aValue, aExpiration) { set: function (aName, aValue, aExpiration) {
Utilities.annotations.setItemAnnotation(this._id, aName, aValue, 0, aExpiration); Utilities.annotations.setItemAnnotation(this._id, aName, aValue, 0, aExpiration);
}, },
remove: function ann_remove(aName) { remove: function (aName) {
if (aName) if (aName)
Utilities.annotations.removeItemAnnotation(this._id, aName); Utilities.annotations.removeItemAnnotation(this._id, aName);
}, },
@ -308,33 +308,33 @@ BookmarksObserver.prototype = {
onEndUpdateBatch: function () {}, onEndUpdateBatch: function () {},
onItemVisited: function () {}, onItemVisited: function () {},
onItemAdded: function bo_onItemAdded(aId, aFolder, aIndex, aItemType, aURI) { onItemAdded: function (aId, aFolder, aIndex, aItemType, aURI) {
this._rootEvents.dispatch("add", aId); this._rootEvents.dispatch("add", aId);
this._dispatchToEvents("addchild", aId, this._folderEventsDict[aFolder]); this._dispatchToEvents("addchild", aId, this._folderEventsDict[aFolder]);
}, },
onItemRemoved: function bo_onItemRemoved(aId, aFolder, aIndex) { onItemRemoved: function (aId, aFolder, aIndex) {
this._rootEvents.dispatch("remove", aId); this._rootEvents.dispatch("remove", aId);
this._dispatchToEvents("remove", aId, this._eventsDict[aId]); this._dispatchToEvents("remove", aId, this._eventsDict[aId]);
this._dispatchToEvents("removechild", aId, this._folderEventsDict[aFolder]); this._dispatchToEvents("removechild", aId, this._folderEventsDict[aFolder]);
}, },
onItemChanged: function bo_onItemChanged(aId, aProperty, aIsAnnotationProperty, aValue) { onItemChanged: function (aId, aProperty, aIsAnnotationProperty, aValue) {
this._rootEvents.dispatch("change", aProperty); this._rootEvents.dispatch("change", aProperty);
this._dispatchToEvents("change", aProperty, this._eventsDict[aId]); this._dispatchToEvents("change", aProperty, this._eventsDict[aId]);
}, },
onItemMoved: function bo_onItemMoved(aId, aOldParent, aOldIndex, aNewParent, aNewIndex) { onItemMoved: function (aId, aOldParent, aOldIndex, aNewParent, aNewIndex) {
this._dispatchToEvents("move", aId, this._eventsDict[aId]); this._dispatchToEvents("move", aId, this._eventsDict[aId]);
}, },
_dispatchToEvents: function bo_dispatchToEvents(aEvent, aData, aEvents) { _dispatchToEvents: function (aEvent, aData, aEvents) {
if (aEvents) { if (aEvents) {
aEvents.dispatch(aEvent, aData); aEvents.dispatch(aEvent, aData);
} }
}, },
_addListenerToDict: function bo_addListenerToDict(aId, aEvent, aListener, aDict) { _addListenerToDict: function (aId, aEvent, aListener, aDict) {
var events = aDict[aId]; var events = aDict[aId];
if (!events) { if (!events) {
events = new Events(); events = new Events();
@ -343,7 +343,7 @@ BookmarksObserver.prototype = {
events.addListener(aEvent, aListener); events.addListener(aEvent, aListener);
}, },
_removeListenerFromDict: function bo_removeListenerFromDict(aId, aEvent, aListener, aDict) { _removeListenerFromDict: function (aId, aEvent, aListener, aDict) {
var events = aDict[aId]; var events = aDict[aId];
if (!events) { if (!events) {
return; return;
@ -354,27 +354,27 @@ BookmarksObserver.prototype = {
} }
}, },
addListener: function bo_addListener(aId, aEvent, aListener) { addListener: function (aId, aEvent, aListener) {
this._addListenerToDict(aId, aEvent, aListener, this._eventsDict); this._addListenerToDict(aId, aEvent, aListener, this._eventsDict);
}, },
removeListener: function bo_removeListener(aId, aEvent, aListener) { removeListener: function (aId, aEvent, aListener) {
this._removeListenerFromDict(aId, aEvent, aListener, this._eventsDict); this._removeListenerFromDict(aId, aEvent, aListener, this._eventsDict);
}, },
addFolderListener: function addFolderListener(aId, aEvent, aListener) { addFolderListener: function (aId, aEvent, aListener) {
this._addListenerToDict(aId, aEvent, aListener, this._folderEventsDict); this._addListenerToDict(aId, aEvent, aListener, this._folderEventsDict);
}, },
removeFolderListener: function removeFolderListener(aId, aEvent, aListener) { removeFolderListener: function (aId, aEvent, aListener) {
this._removeListenerFromDict(aId, aEvent, aListener, this._folderEventsDict); this._removeListenerFromDict(aId, aEvent, aListener, this._folderEventsDict);
}, },
addRootListener: function addRootListener(aEvent, aListener) { addRootListener: function (aEvent, aListener) {
this._rootEvents.addListener(aEvent, aListener); this._rootEvents.addListener(aEvent, aListener);
}, },
removeRootListener: function removeRootListener(aEvent, aListener) { removeRootListener: function (aEvent, aListener) {
this._rootEvents.removeListener(aEvent, aListener); this._rootEvents.removeListener(aEvent, aListener);
}, },
@ -408,10 +408,10 @@ function Bookmark(aId, aParent, aType) {
// Our _events object forwards to bookmarksObserver. // Our _events object forwards to bookmarksObserver.
var self = this; var self = this;
this._events = { this._events = {
addListener: function bookmarkevents_al(aEvent, aListener) { addListener: function (aEvent, aListener) {
Utilities.bookmarksObserver.addListener(self._id, aEvent, aListener); Utilities.bookmarksObserver.addListener(self._id, aEvent, aListener);
}, },
removeListener: function bookmarkevents_rl(aEvent, aListener) { removeListener: function (aEvent, aListener) {
Utilities.bookmarksObserver.removeListener(self._id, aEvent, aListener); Utilities.bookmarksObserver.removeListener(self._id, aEvent, aListener);
}, },
QueryInterface: XPCOMUtils.generateQI([Ci.extIEvents]) QueryInterface: XPCOMUtils.generateQI([Ci.extIEvents])
@ -479,7 +479,7 @@ Bookmark.prototype = {
return this._events; return this._events;
}, },
remove : function bm_remove() { remove : function () {
Utilities.bookmarks.removeItem(this._id); Utilities.bookmarks.removeItem(this._id);
}, },
@ -528,7 +528,7 @@ function BookmarkFolder(aId, aParent) {
var self = this; var self = this;
this._events = { this._events = {
addListener: function bmfevents_al(aEvent, aListener) { addListener: function (aEvent, aListener) {
if (self._parent) { if (self._parent) {
if (/child$/.test(aEvent)) { if (/child$/.test(aEvent)) {
Utilities.bookmarksObserver.addFolderListener(self._id, aEvent, aListener); Utilities.bookmarksObserver.addFolderListener(self._id, aEvent, aListener);
@ -541,7 +541,7 @@ function BookmarkFolder(aId, aParent) {
Utilities.bookmarksObserver.addRootListener(aEvent, aListener); Utilities.bookmarksObserver.addRootListener(aEvent, aListener);
} }
}, },
removeListener: function bmfevents_rl(aEvent, aListener) { removeListener: function (aEvent, aListener) {
if (self._parent) { if (self._parent) {
if (/child$/.test(aEvent)) { if (/child$/.test(aEvent)) {
Utilities.bookmarksObserver.removeFolderListener(self._id, aEvent, aListener); Utilities.bookmarksObserver.removeFolderListener(self._id, aEvent, aListener);
@ -633,25 +633,25 @@ BookmarkFolder.prototype = {
return items; return items;
}, },
addBookmark: function bmf_addbm(aTitle, aUri) { addBookmark: function (aTitle, aUri) {
var newBookmarkID = Utilities.bookmarks.insertBookmark(this._id, aUri, Utilities.bookmarks.DEFAULT_INDEX, aTitle); var newBookmarkID = Utilities.bookmarks.insertBookmark(this._id, aUri, Utilities.bookmarks.DEFAULT_INDEX, aTitle);
var newBookmark = new Bookmark(newBookmarkID, this, "bookmark"); var newBookmark = new Bookmark(newBookmarkID, this, "bookmark");
return newBookmark; return newBookmark;
}, },
addSeparator: function bmf_addsep() { addSeparator: function () {
var newBookmarkID = Utilities.bookmarks.insertSeparator(this._id, Utilities.bookmarks.DEFAULT_INDEX); var newBookmarkID = Utilities.bookmarks.insertSeparator(this._id, Utilities.bookmarks.DEFAULT_INDEX);
var newBookmark = new Bookmark(newBookmarkID, this, "separator"); var newBookmark = new Bookmark(newBookmarkID, this, "separator");
return newBookmark; return newBookmark;
}, },
addFolder: function bmf_addfolder(aTitle) { addFolder: function (aTitle) {
var newFolderID = Utilities.bookmarks.createFolder(this._id, aTitle, Utilities.bookmarks.DEFAULT_INDEX); var newFolderID = Utilities.bookmarks.createFolder(this._id, aTitle, Utilities.bookmarks.DEFAULT_INDEX);
var newFolder = new BookmarkFolder(newFolderID, this); var newFolder = new BookmarkFolder(newFolderID, this);
return newFolder; return newFolder;
}, },
remove: function bmf_remove() { remove: function () {
Utilities.bookmarks.removeItem(this._id); Utilities.bookmarks.removeItem(this._id);
}, },
@ -662,7 +662,7 @@ BookmarkFolder.prototype = {
onItemRemoved : function () {}, onItemRemoved : function () {},
onItemChanged : function () {}, onItemChanged : function () {},
onItemMoved: function bf_onItemMoved(aId, aOldParent, aOldIndex, aNewParent, aNewIndex) { onItemMoved: function (aId, aOldParent, aOldIndex, aNewParent, aNewIndex) {
if (this._id == aId) { if (this._id == aId) {
this._parent = new BookmarkFolder(aNewParent, Utilities.bookmarks.getFolderIdForItem(aNewParent)); this._parent = new BookmarkFolder(aNewParent, Utilities.bookmarks.getFolderIdForItem(aNewParent));
} }
@ -718,7 +718,7 @@ BookmarkRoots.prototype = {
// See bug 386535. // See bug 386535.
var gSingleton = null; var gSingleton = null;
var ApplicationFactory = { var ApplicationFactory = {
createInstance: function af_ci(aOuter, aIID) { createInstance: function (aOuter, aIID) {
if (aOuter != null) if (aOuter != null)
throw Components.results.NS_ERROR_NO_AGGREGATION; throw Components.results.NS_ERROR_NO_AGGREGATION;