Bug 1151474 - Part 3: Remove use of expression closure from im/modules/. r=florian
authorTooru Fujisawa <arai_a@mac.com>
Fri, 10 Apr 2015 00:14:23 +0900
changeset 22397 00a06f6524151eda384f97b68e899b89eded5e8e
parent 22396 eeefdaff1e6ca87a9c2f6cacaf3b8d13b045643d
child 22398 a0cba0d60fcd758e279fcf405c32497f6913ea8d
push id1420
push usermbanner@mozilla.com
push dateMon, 29 Jun 2015 20:47:24 +0000
treeherdercomm-beta@b3db00bb24e8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflorian
bugs1151474
Bug 1151474 - Part 3: Remove use of expression closure from im/modules/. r=florian
im/modules/ibCore.jsm
im/modules/ibInterruptions.jsm
im/modules/ibSounds.jsm
im/modules/ibTagMenu.jsm
im/modules/ibWinJumpList.jsm
im/modules/imWindows.jsm
--- a/im/modules/ibCore.jsm
+++ b/im/modules/ibCore.jsm
@@ -14,23 +14,23 @@ Cu.import("resource:///modules/imXPCOMUt
 var Core = {
   _events: [
     "account-disconnected",
     "browser-request",
     "handle-xul-text-link",
     "quit-application-requested"
   ],
 
-  get bundle() l10nHelper("chrome://instantbird/locale/core.properties"),
+  get bundle() { return l10nHelper("chrome://instantbird/locale/core.properties"); },
 
   initLibpurpleOverrides: function() {
     let forcePurple = Services.prefs.getCharPref("chat.prpls.forcePurple")
                               .split(",")
                               .map(String.trim)
-                              .filter(function(aPrplId) !!aPrplId);
+                              .filter(aPrplId => !!aPrplId);
     if (!forcePurple.length)
       return;
 
     let catMan =
       Cc["@mozilla.org/categorymanager;1"].getService(Ci.nsICategoryManager);
     for (let prplId of forcePurple) {
       catMan.addCategoryEntry("im-protocol-plugin", prplId,
                               "@instantbird.org/purple/protocol;1",
@@ -92,17 +92,17 @@ var Core = {
 
     this._events.forEach(function (aTopic) {
       Services.obs.addObserver(Core, aTopic, false);
     });
 
     let self = this;
     Services.cmd.registerCommand({
       name: "about",
-      get helpString() self.bundle("aboutCommand.help"),
+      get helpString() { return self.bundle("aboutCommand.help"); },
       usageContext: Ci.imICommand.CMD_CONTEXT_ALL,
       priority: Ci.imICommand.CMD_PRIORITY_DEFAULT,
       run: function (aMsg, aConv) {
         let page = aMsg.replace(/^about:/, "");
         let url = "about:" + page;
         // If the page doesn't exist, we avoid opening a tab.
         try {
           Services.io.newChannelFromURI(Services.io.newURI(url, null, null));
@@ -117,17 +117,17 @@ var Core = {
         }
         self.showTab("aboutPanel", aPanel => aPanel.showAboutPage(page));
         return true;
       }
     });
 
     Services.cmd.registerCommand({
       name: "debug",
-      get helpString() self.bundle("debugCommand.help"),
+      get helpString() { return self.bundle("debugCommand.help"); },
       usageContext: Ci.imICommand.CMD_CONTEXT_ALL,
       priority: Ci.imICommand.CMD_PRIORITY_DEFAULT,
       run: (aMsg, aConv) => {
         this.showDebugLog(aConv.account.id);
         return true;
       }
     });
 
@@ -225,17 +225,17 @@ var Core = {
                                  "_blank", "chrome,toolbar,resizable", null);
     win.addEventListener("load", showPanel.bind(null, win));
   },
 
   getIter: function(aEnumerator) {
     while (aEnumerator.hasMoreElements())
       yield aEnumerator.getNext();
   },
-  getAccounts: function() this.getIter(Services.accounts.getAccounts()),
+  getAccounts: function() { return this.getIter(Services.accounts.getAccounts()); },
 
   /* This function pops up the account manager if no account is
    * connected or connecting.
    * When called during startup (aIsStarting == true), it will also
    * look for crashed accounts.
    */
   _showAccountManagerIfNeeded: function (aIsStarting) {
     // If the current status is offline, we don't need the account manager
@@ -299,17 +299,17 @@ var Core = {
          && aCancelQuit.data)
       return;
 
     if (!Services.prefs.getBoolPref("messenger.warnOnQuit"))
       return;
 
     let unreadConvsCount =
       Services.conversations.getUIConversations()
-              .filter(function(c) c.unreadTargetedMessageCount)
+              .filter(c => c.unreadTargetedMessageCount)
               .length;
     if (unreadConvsCount == 0)
       return;
 
     let bundle =
       Services.strings.createBundle("chrome://instantbird/locale/quitDialog.properties");
     let promptTitle    = bundle.GetStringFromName("dialogTitle");
     let promptMessage  = bundle.GetStringFromName("message");
--- a/im/modules/ibInterruptions.jsm
+++ b/im/modules/ibInterruptions.jsm
@@ -6,26 +6,27 @@ const EXPORTED_SYMBOLS = ["Interruptions
 
 var Interruptions = {
   _listeners: [],
   addListener: function(aListener) {
     if (this._listeners.indexOf(aListener) == -1)
       this._listeners.push(aListener);
   },
   removeListener: function(aListener) {
-    this._listeners = this._listeners.filter(function(o) o !== aListener);
+    this._listeners = this._listeners.filter(o => o !== aListener);
   },
 
   /* All code about to perform an action that could interrupt the
    * user's train of thoughts should call this method.
    *
    * aReason should be the notification that justifies the interruption.
    *         (eg. "new-ui-conversation", "contact-signed-on", ...)
    * aSubject should be the related object that listeners can analyse.
    *         (eg. imIConversation, imIContact, ...)
    * aType Is the action that can be prevented by denying the request.
    *       (eg. "sound", "notification", "show-conversation")
    *
    * Returns true if the request is granted, false otherwise.
    */
-  requestInterrupt: function(aReason, aSubject, aType)
-    this._listeners.every(function (l) l(aReason, aSubject, aType))
+  requestInterrupt: function(aReason, aSubject, aType) {
+    return this._listeners.every(l => l(aReason, aSubject, aType));
+  }
 };
--- a/im/modules/ibSounds.jsm
+++ b/im/modules/ibSounds.jsm
@@ -13,17 +13,17 @@ var Sounds = {
   soundFiles: {
     incoming: "chrome://instantbird-sounds/skin/receive.wav",
     outgoing: "chrome://instantbird-sounds/skin/send.wav",
     login: "chrome://instantbird-sounds/skin/login.wav",
     logout: "chrome://instantbird-sounds/skin/logout.wav",
     alert: "chrome://instantbird-sounds/skin/alert.wav"
   },
 
-  getBoolPref: function(aPrefName)
+  getBoolPref: aPrefName =>
     Services.prefs.getBoolPref("messenger.options.playSounds." + aPrefName),
 
   play: function sh_play(aEvent, aPref, aSubject, aTopic) {
     if (!this.getBoolPref(aPref) || !this.getBoolPref(aEvent) ||
         !Interruptions.requestInterrupt(aTopic, aSubject, "sound"))
       return;
 
     new (getHiddenHTMLWindow().Audio)(this.soundFiles[aEvent])
--- a/im/modules/ibTagMenu.jsm
+++ b/im/modules/ibTagMenu.jsm
@@ -3,17 +3,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 const EXPORTED_SYMBOLS = ["TagMenu"];
 
 const Cu = Components.utils;
 Cu.import("resource:///modules/imServices.jsm");
 Cu.import("resource:///modules/imXPCOMUtils.jsm");
 
-XPCOMUtils.defineLazyGetter(this, "_", function()
+XPCOMUtils.defineLazyGetter(this, "_", () =>
   l10nHelper("chrome://instantbird/locale/instantbird.properties")
 );
 
 // aOnTag and aOnAddTag will be called with aParent as the this value.
 // If a contact binding is given in aTarget, the menu checkmarks the existing
 // tags on this contact.
 function TagMenu(aParent, aWindow, aMenuId, aOnTag, aOnAddTag, aTarget = null) {
   this.parent = aParent;
@@ -74,17 +74,17 @@ TagMenu.prototype = {
     let allTags = Services.tags.getTags().reverse();
     for (let tag of allTags) {
       item = this.document.createElement("menuitem");
       item.setAttribute("label", tag.name);
       let id = tag.id;
       item.groupId = id;
       if (this.target) {
         item.setAttribute("type", "checkbox");
-        if (tags.some(function(t) t.id == id)) {
+        if (tags.some(t => t.id == id)) {
           item.setAttribute("checked", "true");
           if (tags.length == 1)
             item.setAttribute("disabled", "true"); // can't remove the last tag.
         }
       }
       this.popup.insertBefore(item, this.popup.firstChild);
     }
     return true;
--- a/im/modules/ibWinJumpList.jsm
+++ b/im/modules/ibWinJumpList.jsm
@@ -25,31 +25,31 @@ var WinJumpList = {
      or
       type: "separator"       // nsIJumpListSeparator, no way to customize this
         id: <string>          //  see description of shortcut id
   */
   // Default jumplist entries for changing the status.
   jumplistEntries: [
     { type: "shortcut",
       id: "status_available",
-      get label() Status.toLabel("available"),
+      get label() { return Status.toLabel("available"); },
       description: null,
       parameter: "-status available",
       iconIndex: 1
     },
     { type: "shortcut",
       id: "status_unavailable",
-      get label() Status.toLabel("unavailable"),
+      get label() { return Status.toLabel("unavailable"); },
       description: null,
       parameter: "-status unavailable",
       iconIndex: 2
     },
     { type: "shortcut",
       id: "status_offline",
-      get label() Status.toLabel("offline"),
+      get label() { return Status.toLabel("offline"); },
       description: null,
       parameter: "-status offline",
       iconIndex: 3
     }
   ],
 
   // This is called by the Instantbird core and does not need to be re-called by
   // any other code working with jump lists.
--- a/im/modules/imWindows.jsm
+++ b/im/modules/imWindows.jsm
@@ -5,17 +5,17 @@
 const CONVERSATION_WINDOW_URI = "chrome://instantbird/content/instantbird.xul";
 const EXPORTED_SYMBOLS = ["Conversations"];
 
 Components.utils.import("resource:///modules/imServices.jsm");
 Components.utils.import("resource:///modules/ibInterruptions.jsm");
 
 var Conversations = {
   _unreadCount: 0,
-  get unreadCount() this._unreadCount,
+  get unreadCount() { return this._unreadCount; },
   set unreadCount(val) {
     if (val == this._unreadCount)
       return val;
     Services.obs.notifyObservers(null, "unread-im-count-changed", val);
     return (this._unreadCount = val);
   },
   _windows: [],
   registerWindow: function(aWindow) {
@@ -61,19 +61,20 @@ var Conversations = {
         this.forgetHiddenConversation(uiConv);
         uiConv.close();
       }
       else if (aShouldClose === false || !uiConv.checkClose())
         this.hideConversation(uiConv);
     }
   },
 
-  isConversationWindowFocused: function()
-    this._windows.length > 0 && this._windows[0].document.hasFocus(),
-  isUIConversationDisplayed: function(aUIConv) aUIConv.id in this._uiConv,
+  isConversationWindowFocused: function() {
+    return this._windows.length > 0 && this._windows[0].document.hasFocus();
+  },
+  isUIConversationDisplayed: function(aUIConv) { return aUIConv.id in this._uiConv; },
   focusConversation: function(aConv) {
     let uiConv = Services.conversations.getUIConversation(aConv);
     uiConv.target = aConv;
     if (!this.isUIConversationDisplayed(uiConv))
       this.showConversation(uiConv);
     // The conversation may still not be displayed if we are waiting
     // for a new window. In this case the conversation will be focused
     // automatically anyway.
@@ -173,17 +174,17 @@ var Conversations = {
 
   _isConversationHidden: function(aConv) {
     let accountId = aConv.account.id;
     return aConv.isChat && accountId in this._hiddenConversations &&
            Object.prototype.hasOwnProperty.call(this._hiddenConversations[accountId],
                                                 aConv.normalizedName);
   },
 
-  _requestShowConversation: function(aTopic, aSubject)
+  _requestShowConversation: (aTopic, aSubject) =>
     Interruptions.requestInterrupt(aTopic, aSubject, "show-conversation"),
 
   showConversation: function(aConv) {
     if (this.isUIConversationDisplayed(aConv) ||
         (this._pendingConversations &&
         this._pendingConversations.indexOf(aConv) != -1))
       return;