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

pull/24/head
athenian200 3 years ago committed by Roy Tam
parent addf7b2fb1
commit 95492157f1
  1. 22
      application/palemoon/modules/BrowserNewTabPreloader.jsm
  2. 24
      application/palemoon/modules/NetworkPrioritizer.jsm
  3. 46
      application/palemoon/modules/PopupNotifications.jsm
  4. 2
      application/palemoon/modules/RecentWindow.jsm
  5. 52
      application/palemoon/modules/WindowsJumpLists.jsm
  6. 2
      application/palemoon/modules/openLocationLastURL.jsm

@ -49,18 +49,18 @@ function clearTimer(timer) {
}
this.BrowserNewTabPreloader = {
init: function Preloader_init() {
init: function () {
Initializer.start();
},
uninit: function Preloader_uninit() {
uninit: function () {
Initializer.stop();
HostFrame.destroy();
Preferences.uninit();
HiddenBrowsers.uninit();
},
newTab: function Preloader_newTab(aTab) {
newTab: function (aTab) {
let win = aTab.ownerDocument.defaultView;
if (win.gBrowser) {
let utils = win.QueryInterface(Ci.nsIInterfaceRequestor)
@ -83,12 +83,12 @@ var Initializer = {
_timer: null,
_observing: false,
start: function Initializer_start() {
start: function () {
Services.obs.addObserver(this, TOPIC_DELAYED_STARTUP, false);
this._observing = true;
},
stop: function Initializer_stop() {
stop: function () {
this._timer = clearTimer(this._timer);
if (this._observing) {
@ -97,7 +97,7 @@ var Initializer = {
}
},
observe: function Initializer_observe(aSubject, aTopic, aData) {
observe: function (aSubject, aTopic, aData) {
if (aTopic == TOPIC_DELAYED_STARTUP) {
Services.obs.removeObserver(this, TOPIC_DELAYED_STARTUP);
this._observing = false;
@ -108,11 +108,11 @@ var Initializer = {
}
},
_startTimer: function Initializer_startTimer() {
_startTimer: function () {
this._timer = createTimer(this, PRELOADER_INIT_DELAY_MS);
},
_startPreloader: function Initializer_startPreloader() {
_startPreloader: function () {
Preferences.init();
if (Preferences.enabled) {
HiddenBrowsers.init();
@ -133,19 +133,19 @@ var Preferences = {
return this._enabled;
},
init: function Preferences_init() {
init: function () {
this._branch = Services.prefs.getBranch(PREF_BRANCH);
this._branch.addObserver("", this, false);
},
uninit: function Preferences_uninit() {
uninit: function () {
if (this._branch) {
this._branch.removeObserver("", this);
this._branch = null;
}
},
observe: function Preferences_observe() {
observe: function () {
let prevEnabled = this._enabled;
this._enabled = null;

@ -65,13 +65,13 @@ function _handleEvent(aEvent) {
// Methods that impact a browser. Put into single object for organization.
var BrowserHelper = {
onOpen: function NP_BH_onOpen(aBrowser) {
onOpen: function (aBrowser) {
// If the tab is in the focused window, leave priority as it is
if (aBrowser.ownerDocument.defaultView != _lastFocusedWindow)
this.decreasePriority(aBrowser);
},
onSelect: function NP_BH_onSelect(aBrowser) {
onSelect: function (aBrowser) {
let windowEntry = WindowHelper.getEntry(aBrowser.ownerDocument.defaultView);
if (windowEntry.lastSelectedBrowser)
this.decreasePriority(windowEntry.lastSelectedBrowser);
@ -80,11 +80,11 @@ var BrowserHelper = {
windowEntry.lastSelectedBrowser = aBrowser;
},
increasePriority: function NP_BH_increasePriority(aBrowser) {
increasePriority: function (aBrowser) {
aBrowser.adjustPriority(PRIORITY_DELTA);
},
decreasePriority: function NP_BH_decreasePriority(aBrowser) {
decreasePriority: function (aBrowser) {
aBrowser.adjustPriority(PRIORITY_DELTA * -1);
}
};
@ -92,7 +92,7 @@ var BrowserHelper = {
// Methods that impact a window. Put into single object for organization.
var WindowHelper = {
addWindow: function NP_WH_addWindow(aWindow) {
addWindow: function (aWindow) {
// Build internal data object
_windows.push({ window: aWindow, lastSelectedBrowser: null });
@ -115,7 +115,7 @@ var WindowHelper = {
BrowserHelper.onSelect(aWindow.gBrowser.selectedBrowser);
},
removeWindow: function NP_WH_removeWindow(aWindow) {
removeWindow: function (aWindow) {
if (aWindow == _lastFocusedWindow)
_lastFocusedWindow = null;
@ -131,7 +131,7 @@ var WindowHelper = {
});
},
onActivate: function NP_WH_onActivate(aWindow, aHasFocus) {
onActivate: function (aWindow, aHasFocus) {
// If this window was the last focused window, we don't need to do anything
if (aWindow == _lastFocusedWindow)
return;
@ -143,7 +143,7 @@ var WindowHelper = {
this.increasePriority(aWindow);
},
handleFocusedWindow: function NP_WH_handleFocusedWindow(aWindow) {
handleFocusedWindow: function (aWindow) {
// If we have a last focused window, we need to deprioritize it first
if (_lastFocusedWindow)
this.decreasePriority(_lastFocusedWindow);
@ -153,23 +153,23 @@ var WindowHelper = {
},
// Auxiliary methods
increasePriority: function NP_WH_increasePriority(aWindow) {
increasePriority: function (aWindow) {
aWindow.gBrowser.browsers.forEach(function(aBrowser) {
BrowserHelper.increasePriority(aBrowser);
});
},
decreasePriority: function NP_WH_decreasePriority(aWindow) {
decreasePriority: function (aWindow) {
aWindow.gBrowser.browsers.forEach(function(aBrowser) {
BrowserHelper.decreasePriority(aBrowser);
});
},
getEntry: function NP_WH_getEntry(aWindow) {
getEntry: function (aWindow) {
return _windows[this.getEntryIndex(aWindow)];
},
getEntryIndex: function NP_WH_getEntryAtIndex(aWindow) {
getEntryIndex: function (aWindow) {
// Assumes that every object has a unique window & it's in the array
for (let i = 0; i < _windows.length; i++)
if (_windows[i].window == aWindow)

@ -78,7 +78,7 @@ Notification.prototype = {
/**
* Removes the notification and updates the popup accordingly if needed.
*/
remove: function Notification_remove() {
remove: function () {
this.owner.remove(this);
},
@ -178,7 +178,7 @@ PopupNotifications.prototype = {
* @returns the corresponding Notification object, or null if no such
* notification exists.
*/
getNotification: function PopupNotifications_getNotification(id, browser) {
getNotification: function (id, browser) {
let n = null;
let notifications = this._getNotificationsForBrowser(browser || this.tabbrowser.selectedBrowser);
notifications.some(function(x) x.id == id && (n = x));
@ -292,7 +292,7 @@ PopupNotifications.prototype = {
* opens the URL in a new tab.
* @returns the Notification object corresponding to the added notification.
*/
show: function PopupNotifications_show(browser, id, message, anchorID,
show: function (browser, id, message, anchorID,
mainAction, secondaryActions, options) {
function isInvalidAction(a) {
return !a || !(typeof(a.callback) == "function") || !a.label || !a.accessKey;
@ -362,7 +362,7 @@ PopupNotifications.prototype = {
* Called by the consumer to indicate that a browser's location has changed,
* so that we can update the active notifications accordingly.
*/
locationChange: function PopupNotifications_locationChange(aBrowser) {
locationChange: function (aBrowser) {
if (!aBrowser)
throw "PopupNotifications_locationChange: invalid browser";
@ -415,7 +415,7 @@ PopupNotifications.prototype = {
* @param notification
* The Notification object to remove.
*/
remove: function PopupNotifications_remove(notification) {
remove: function (notification) {
this._remove(notification);
if (notification.browser.docShell.isActive) {
@ -459,7 +459,7 @@ PopupNotifications.prototype = {
return this.tabbrowser.selectedBrowser ? this._getNotificationsForBrowser(this.tabbrowser.selectedBrowser) : [];
},
_remove: function PopupNotifications_removeHelper(notification) {
_remove: function (notification) {
// This notification may already be removed, in which case let's just fail
// silently.
let notifications = this._getNotificationsForBrowser(notification.browser);
@ -481,7 +481,7 @@ PopupNotifications.prototype = {
/**
* Dismisses the notification without removing it.
*/
_dismiss: function PopupNotifications_dismiss() {
_dismiss: function () {
let browser = this.panel.firstChild &&
this.panel.firstChild.notification.browser;
if (typeof this.panel.hidePopup === "function") {
@ -494,7 +494,7 @@ PopupNotifications.prototype = {
/**
* Hides the notification popup.
*/
_hidePanel: function PopupNotifications_hide() {
_hidePanel: function () {
this._ignoreDismissal = true;
if (typeof this.panel.hidePopup === "function") {
this.panel.hidePopup();
@ -536,7 +536,7 @@ PopupNotifications.prototype = {
}
},
_refreshPanel: function PopupNotifications_refreshPanel(notificationsToShow) {
_refreshPanel: function (notificationsToShow) {
this._clearPanel();
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
@ -653,7 +653,7 @@ PopupNotifications.prototype = {
}
},
_showPanel: function PopupNotifications_showPanel(notificationsToShow, anchorElement) {
_showPanel: function (notificationsToShow, anchorElement) {
this.panel.hidden = false;
notificationsToShow.forEach(function (n) {
@ -709,7 +709,7 @@ PopupNotifications.prototype = {
* if there are no notifications to show. Otherwise,
* currently displayed notifications will be left alone.
*/
_update: function PopupNotifications_update(notifications, anchor, dismissShowing = false) {
_update: function (notifications, anchor, dismissShowing = false) {
let useIconBox = this.iconBox && (!anchor || anchor.parentNode == this.iconBox);
if (useIconBox) {
// hide icons of the previous tab.
@ -777,7 +777,7 @@ PopupNotifications.prototype = {
}
},
_showIcons: function PopupNotifications_showIcons(aCurrentNotifications) {
_showIcons: function (aCurrentNotifications) {
for (let notification of aCurrentNotifications) {
let anchorElm = notification.anchorElement;
if (anchorElm) {
@ -786,7 +786,7 @@ PopupNotifications.prototype = {
}
},
_hideIcons: function PopupNotifications_hideIcons() {
_hideIcons: function () {
let icons = this.iconBox.querySelectorAll(ICON_SELECTOR);
for (let icon of icons) {
icon.removeAttribute(ICON_ATTRIBUTE_SHOWING);
@ -796,7 +796,7 @@ PopupNotifications.prototype = {
/**
* Gets and sets notifications for the browser.
*/
_getNotificationsForBrowser: function PopupNotifications_getNotifications(browser) {
_getNotificationsForBrowser: function (browser) {
let notifications = popupNotificationsMap.get(browser);
if (!notifications) {
// Initialize the WeakMap for the browser so callers can reference/manipulate the array.
@ -805,12 +805,12 @@ PopupNotifications.prototype = {
}
return notifications;
},
_setNotificationsForBrowser: function PopupNotifications_setNotifications(browser, notifications) {
_setNotificationsForBrowser: function (browser, notifications) {
popupNotificationsMap.set(browser, notifications);
return notifications;
},
_onIconBoxCommand: function PopupNotifications_onIconBoxCommand(event) {
_onIconBoxCommand: function (event) {
// Left click, space or enter only
let type = event.type;
if (type == "click" && event.button != 0)
@ -832,7 +832,7 @@ PopupNotifications.prototype = {
this._reshowNotifications(anchor);
},
_reshowNotifications: function PopupNotifications_reshowNotifications(anchor, browser) {
_reshowNotifications: function (anchor, browser) {
// Mark notifications anchored to this anchor as un-dismissed
let notifications = this._getNotificationsForBrowser(browser || this.tabbrowser.selectedBrowser);
notifications.forEach(function (n) {
@ -844,7 +844,7 @@ PopupNotifications.prototype = {
this._update(notifications, anchor);
},
_swapBrowserNotifications: function PopupNotifications_swapBrowserNoficications(ourBrowser, otherBrowser) {
_swapBrowserNotifications: function (ourBrowser, otherBrowser) {
// When swaping browser docshells (e.g. dragging tab to new window) we need
// to update our notification map.
@ -890,7 +890,7 @@ PopupNotifications.prototype = {
other._update(ourNotifications, ourNotifications[0].anchorElement);
},
_fireCallback: function PopupNotifications_fireCallback(n, event, ...args) {
_fireCallback: function (n, event, ...args) {
try {
if (n.options.eventCallback)
return n.options.eventCallback.call(n, event, ...args);
@ -900,7 +900,7 @@ PopupNotifications.prototype = {
return undefined;
},
_onPopupHidden: function PopupNotifications_onPopupHidden(event) {
_onPopupHidden: function (event) {
if (event.target != this.panel || this._ignoreDismissal)
return;
@ -932,7 +932,7 @@ PopupNotifications.prototype = {
this._update();
},
_onButtonCommand: function PopupNotifications_onButtonCommand(event) {
_onButtonCommand: function (event) {
let notificationEl = getNotificationFromElement(event.originalTarget);
if (!notificationEl)
@ -968,7 +968,7 @@ PopupNotifications.prototype = {
this._update();
},
_onMenuCommand: function PopupNotifications_onMenuCommand(event) {
_onMenuCommand: function (event) {
let target = event.originalTarget;
if (!target.action || !target.notification)
throw "menucommand target has no associated action/notification";
@ -988,7 +988,7 @@ PopupNotifications.prototype = {
this._update();
},
_notify: function PopupNotifications_notify(topic) {
_notify: function (topic) {
Services.obs.notifyObservers(null, "PopupNotifications-" + topic, "");
},
};

@ -25,7 +25,7 @@ this.RecentWindow = {
* Omit the property to search in both groups.
* * allowPopups: true if popup windows are permissable.
*/
getMostRecentBrowserWindow: function RW_getMostRecentBrowserWindow(aOptions) {
getMostRecentBrowserWindow: function (aOptions) {
let checkPrivacy = typeof aOptions == "object" &&
"private" in aOptions;

@ -148,7 +148,7 @@ this.WinTaskbarJumpList =
* Startup, shutdown, and update
*/
startup: function WTBJL_startup() {
startup: function () {
// exit if this isn't win7 or higher.
if (!this._initTaskbar())
return;
@ -175,7 +175,7 @@ this.WinTaskbarJumpList =
this._updateTimer();
},
update: function WTBJL_update() {
update: function () {
// are we disabled via prefs? don't do anything!
if (!this._enabled)
return;
@ -184,7 +184,7 @@ this.WinTaskbarJumpList =
this._buildList();
},
_shutdown: function WTBJL__shutdown() {
_shutdown: function () {
this._shuttingDown = true;
// Correctly handle a clear history on shutdown. If there are no
@ -197,7 +197,7 @@ this.WinTaskbarJumpList =
this._free();
},
_shortcutMaintenance: function WTBJL__maintenace() {
_shortcutMaintenance: function () {
_winShellService.shortcutMaintenance();
},
@ -212,11 +212,11 @@ this.WinTaskbarJumpList =
*/
_pendingStatements: {},
_hasPendingStatements: function WTBJL__hasPendingStatements() {
_hasPendingStatements: function () {
return Object.keys(this._pendingStatements).length > 0;
},
_buildList: function WTBJL__buildList() {
_buildList: function () {
if (this._hasPendingStatements()) {
// We were requested to update the list while another update was in
// progress, this could happen at shutdown, idle or privatebrowsing.
@ -255,7 +255,7 @@ this.WinTaskbarJumpList =
* Taskbar api wrappers
*/
_startBuild: function WTBJL__startBuild() {
_startBuild: function () {
var removedItems = Cc["@mozilla.org/array;1"].
createInstance(Ci.nsIMutableArray);
this._builder.abortListBuild();
@ -267,13 +267,13 @@ this.WinTaskbarJumpList =
return false;
},
_commitBuild: function WTBJL__commitBuild() {
_commitBuild: function () {
if (!this._hasPendingStatements() && !this._builder.commitListBuild()) {
this._builder.abortListBuild();
}
},
_buildTasks: function WTBJL__buildTasks() {
_buildTasks: function () {
var items = Cc["@mozilla.org/array;1"].
createInstance(Ci.nsIMutableArray);
this._tasks.forEach(function (task) {
@ -288,12 +288,12 @@ this.WinTaskbarJumpList =
this._builder.addListToBuild(this._builder.JUMPLIST_CATEGORY_TASKS, items);
},
_buildCustom: function WTBJL__buildCustom(title, items) {
_buildCustom: function (title, items) {
if (items.length > 0)
this._builder.addListToBuild(this._builder.JUMPLIST_CATEGORY_CUSTOMLIST, items, title);
},
_buildFrequent: function WTBJL__buildFrequent() {
_buildFrequent: function () {
// If history is empty, just bail out.
if (!PlacesUtils.history.hasHistoryEntries) {
return;
@ -333,7 +333,7 @@ this.WinTaskbarJumpList =
);
},
_buildRecent: function WTBJL__buildRecent() {
_buildRecent: function () {
// If history is empty, just bail out.
if (!PlacesUtils.history.hasHistoryEntries) {
return;
@ -378,7 +378,7 @@ this.WinTaskbarJumpList =
);
},
_deleteActiveJumpList: function WTBJL__deleteAJL() {
_deleteActiveJumpList: function () {
this._builder.deleteActiveList();
},
@ -386,7 +386,7 @@ this.WinTaskbarJumpList =
* Jump list item creation helpers
*/
_getHandlerAppItem: function WTBJL__getHandlerAppItem(name, description,
_getHandlerAppItem: function (name, description,
args, iconIndex,
faviconPageUri) {
var file = Services.dirsvc.get("XREExeF", Ci.nsILocalFile);
@ -408,7 +408,7 @@ this.WinTaskbarJumpList =
return item;
},
_getSeparatorItem: function WTBJL__getSeparatorItem() {
_getSeparatorItem: function () {
var item = Cc["@mozilla.org/windows-jumplistseparator;1"].
createInstance(Ci.nsIJumpListSeparator);
return item;
@ -419,7 +419,7 @@ this.WinTaskbarJumpList =
*/
_getHistoryResults:
function WTBLJL__getHistoryResults(aSortingMode, aLimit, aCallback, aScope) {
function (aSortingMode, aLimit, aCallback, aScope) {
var options = PlacesUtils.history.getNewQueryOptions();
options.maxResults = aLimit;
options.sortingMode = aSortingMode;
@ -448,7 +448,7 @@ this.WinTaskbarJumpList =
});
},
_clearHistory: function WTBJL__clearHistory(items) {
_clearHistory: function (items) {
if (!items)
return;
var URIsToRemove = [];
@ -471,7 +471,7 @@ this.WinTaskbarJumpList =
* Prefs utilities
*/
_refreshPrefs: function WTBJL__refreshPrefs() {
_refreshPrefs: function () {
this._enabled = _prefs.getBoolPref(PREF_TASKBAR_ENABLED);
this._showFrequent = _prefs.getBoolPref(PREF_TASKBAR_FREQUENT);
this._showRecent = _prefs.getBoolPref(PREF_TASKBAR_RECENT);
@ -483,7 +483,7 @@ this.WinTaskbarJumpList =
* Init and shutdown utilities
*/
_initTaskbar: function WTBJL__initTaskbar() {
_initTaskbar: function () {
this._builder = _taskbarService.createJumpListBuilder();
if (!this._builder || !this._builder.available)
return false;
@ -491,7 +491,7 @@ this.WinTaskbarJumpList =
return true;
},
_initObs: function WTBJL__initObs() {
_initObs: function () {
// If the browser is closed while in private browsing mode, the "exit"
// notification is fired on quit-application-granted.
// History cleanup can happen at profile-change-teardown.
@ -500,13 +500,13 @@ this.WinTaskbarJumpList =
_prefs.addObserver("", this, false);
},
_freeObs: function WTBJL__freeObs() {
_freeObs: function () {
Services.obs.removeObserver(this, "profile-before-change");
Services.obs.removeObserver(this, "browser:purge-session-history");
_prefs.removeObserver("", this);
},
_updateTimer: function WTBJL__updateTimer() {
_updateTimer: function () {
if (this._enabled && !this._shuttingDown && !this._timer) {
this._timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
this._timer.initWithCallback(this,
@ -520,7 +520,7 @@ this.WinTaskbarJumpList =
},
_hasIdleObserver: false,
_updateIdleObserver: function WTBJL__updateIdleObserver() {
_updateIdleObserver: function () {
if (this._enabled && !this._shuttingDown && !this._hasIdleObserver) {
_idle.addIdleObserver(this, IDLE_TIMEOUT_SECONDS);
this._hasIdleObserver = true;
@ -531,7 +531,7 @@ this.WinTaskbarJumpList =
}
},
_free: function WTBJL__free() {
_free: function () {
this._freeObs();
this._updateTimer();
this._updateIdleObserver();
@ -542,13 +542,13 @@ this.WinTaskbarJumpList =
* Notification handlers
*/
notify: function WTBJL_notify(aTimer) {
notify: function (aTimer) {
// Add idle observer on the first notification so it doesn't hit startup.
this._updateIdleObserver();
this.update();
},
observe: function WTBJL_observe(aSubject, aTopic, aData) {
observe: function (aSubject, aTopic, aData) {
switch (aTopic) {
case "nsPref:changed":
if (this._enabled == true && !_prefs.getBoolPref(PREF_TASKBAR_ENABLED))

@ -46,7 +46,7 @@ this.OpenLocationLastURL = function OpenLocationLastURL(aWindow) {
}
OpenLocationLastURL.prototype = {
isPrivate: function OpenLocationLastURL_isPrivate() {
isPrivate: function () {
// Assume not in private browsing mode, unless the browser window is
// in private mode.
if (!this.window)

Loading…
Cancel
Save