Bug 1207490 - Part 1: Remove use of expression closure from browser/base/. r=dao
authorTooru Fujisawa <arai_a@mac.com>
Mon, 21 Sep 2015 00:29:37 +0900
changeset 265243 fb921354f6ca063a873725e6702156dece1d282c
parent 265242 16b7f24721a10dff70d22447d01fc6f36abc2cd0
child 265244 323a9a3c1608a1420bd5a2aa648dfe15cfbbd30b
push id65891
push userarai_a@mac.com
push dateWed, 30 Sep 2015 16:36:04 +0000
treeherdermozilla-inbound@10194aec7255 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdao
bugs1207490
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1207490 - Part 1: Remove use of expression closure from browser/base/. r=dao
browser/base/content/browser-gestureSupport.js
browser/base/content/browser-places.js
browser/base/content/browser-syncui.js
browser/base/content/browser-tabview.js
browser/base/content/browser.js
browser/base/content/chatWindow.xul
browser/base/content/sanitize.js
browser/base/content/sync/setup.js
browser/base/content/tabbrowser.xml
browser/base/content/urlbarBindings.xml
--- a/browser/base/content/browser-gestureSupport.js
+++ b/browser/base/content/browser-gestureSupport.js
@@ -49,17 +49,17 @@ var gGestureSupport = {
    */
   handleEvent: function GS_handleEvent(aEvent) {
     if (!Services.prefs.getBoolPref(
            "dom.debug.propagate_gesture_events_through_content")) {
       aEvent.stopPropagation();
     }
 
     // Create a preference object with some defaults
-    let def = function(aThreshold, aLatched)
+    let def = (aThreshold, aLatched) =>
       ({ threshold: aThreshold, latched: !!aLatched });
 
     switch (aEvent.type) {
       case "MozSwipeGestureMayStart":
         if (this._shouldDoSwipeGesture(aEvent)) {
           aEvent.preventDefault();
         }
         break;
--- a/browser/base/content/browser-places.js
+++ b/browser/base/content/browser-places.js
@@ -25,17 +25,17 @@ var StarUI = {
     element.addEventListener("keypress", this, false);
     return this.panel = element;
   },
 
   // Array of command elements to disable when the panel is opened.
   get _blockedCommands() {
     delete this._blockedCommands;
     return this._blockedCommands =
-      ["cmd_close", "cmd_closeWindow"].map(function (id) this._element(id), this);
+      ["cmd_close", "cmd_closeWindow"].map(id => this._element(id));
   },
 
   _blockCommands: function SU__blockCommands() {
     this._blockedCommands.forEach(function (elt) {
       // make sure not to permanently disable this item (see bug 409155)
       if (elt.hasAttribute("wasDisabled"))
         return;
       if (elt.getAttribute("disabled") == "true") {
@@ -1493,17 +1493,17 @@ var BookmarkingUI = {
         Components.utils.reportError("BookmarkingUI did not receive current URI");
         return;
       }
 
       // It's possible that onItemAdded gets called before the async statement
       // calls back.  For such an edge case, retain all unique entries from both
       // arrays.
       this._itemIds = this._itemIds.filter(
-        function (id) aItemIds.indexOf(id) == -1
+        id => aItemIds.indexOf(id) == -1
       ).concat(aItemIds);
 
       this._updateStar();
 
       // Start observing bookmarks if needed.
       if (!this._hasBookmarksObserver) {
         try {
           PlacesUtils.addLazyBookmarkObserver(this);
--- a/browser/base/content/browser-syncui.js
+++ b/browser/base/content/browser-syncui.js
@@ -248,17 +248,17 @@ var gSyncUI = {
   },
 
   // Commands
   // doSync forces a sync - it *does not* return a promise as it is called
   // via the various UI components.
   doSync() {
     this._needsSetup().then(needsSetup => {
       if (!needsSetup) {
-        setTimeout(function () Weave.Service.errorHandler.syncAndReportErrors(), 0);
+        setTimeout(() => Weave.Service.errorHandler.syncAndReportErrors(), 0);
       }
       Services.obs.notifyObservers(null, "cloudsync:user-sync", null);
     }).catch(err => {
       this.log.error("Failed to force a sync", err);
     });
   },
 
   // Handle clicking the toolbar button - which either opens the Sync setup
--- a/browser/base/content/browser-tabview.js
+++ b/browser/base/content/browser-tabview.js
@@ -220,17 +220,17 @@ var TabView = {
         self._tabCloseEventListener = null;
       }
       if (self._SSWindowStateReadyListener) {
         window.removeEventListener(
           "SSWindowStateReady", self._SSWindowStateReadyListener, false);
         self._SSWindowStateReadyListener = null;
       }
 
-      self._initFrameCallbacks.forEach(function (cb) cb());
+      self._initFrameCallbacks.forEach(cb => cb());
       self._initFrameCallbacks = [];
     }, false);
 
     this._iframe.setAttribute("src", "chrome://browser/content/tabview.html");
     this._deck.appendChild(this._iframe);
 
     // ___ create tooltip
     let tooltip = document.createElement("tooltip");
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -1718,17 +1718,17 @@ var gBrowserInit = {
      * a) User has customized any privacy.item prefs
      * b) privacy.sanitize.sanitizeOnShutdown is set
      */
     if (!gPrefService.getBoolPref("privacy.sanitize.migrateFx3Prefs")) {
       let itemBranch = gPrefService.getBranch("privacy.item.");
       let itemArray = itemBranch.getChildList("");
 
       // See if any privacy.item prefs are set
-      let doMigrate = itemArray.some(function (name) itemBranch.prefHasUserValue(name));
+      let doMigrate = itemArray.some(name => itemBranch.prefHasUserValue(name));
       // Or if sanitizeOnShutdown is set
       if (!doMigrate)
         doMigrate = gPrefService.getBoolPref("privacy.sanitize.sanitizeOnShutdown");
 
       if (doMigrate) {
         let cpdBranch = gPrefService.getBranch("privacy.cpd.");
         let clearOnShutdownBranch = gPrefService.getBranch("privacy.clearOnShutdown.");
         for (let name of itemArray) {
@@ -3317,17 +3317,17 @@ function getMarkupDocumentViewer()
 
 // This function is obsolete. Newer code should use <tooltip page="true"/> instead.
 function FillInHTMLTooltip(tipElement)
 {
   document.getElementById("aHTMLTooltip").fillInPageTooltip(tipElement);
 }
 
 var browserDragAndDrop = {
-  canDropLink: function (aEvent) Services.droppedLinkHandler.canDropLink(aEvent, true),
+  canDropLink: aEvent => Services.droppedLinkHandler.canDropLink(aEvent, true),
 
   dragOver: function (aEvent)
   {
     if (this.canDropLink(aEvent)) {
       aEvent.preventDefault();
     }
   },
 
@@ -3465,17 +3465,17 @@ const DOMLinkHandler = {
 
 const BrowserSearch = {
   addEngine: function(browser, engine, uri) {
     if (!this.searchBar)
       return;
 
     // Check to see whether we've already added an engine with this title
     if (browser.engines) {
-      if (browser.engines.some(function (e) e.title == engine.title))
+      if (browser.engines.some(e => e.title == engine.title))
         return;
     }
 
     var hidden = false;
     // If this engine (identified by title) is already in the list, add it
     // to the list of hidden engines rather than to the main list.
     // XXX This will need to be changed when engines are identified by URL;
     // see bug 335102.
@@ -4568,17 +4568,19 @@ var LinkTargetDisplay = {
   get DELAY_SHOW() {
      delete this.DELAY_SHOW;
      return this.DELAY_SHOW = Services.prefs.getIntPref("browser.overlink-delay");
   },
 
   DELAY_HIDE: 250,
   _timer: 0,
 
-  get _isVisible () XULBrowserWindow.statusTextField.label != "",
+  get _isVisible () {
+    return XULBrowserWindow.statusTextField.label != "";
+  },
 
   update: function () {
     clearTimeout(this._timer);
     window.removeEventListener("mousemove", this, true);
 
     if (!XULBrowserWindow.overLink) {
       if (XULBrowserWindow.hideOverLinkImmediately)
         this._hide();
@@ -4965,17 +4967,17 @@ nsBrowserAccess.prototype = {
                                         aParams.isPrivate, isExternal);
     if (browser)
       return browser.QueryInterface(Ci.nsIFrameLoaderOwner);
 
     return null;
   },
 
   isTabContentWindow: function (aWindow) {
-    return gBrowser.browsers.some(function (browser) browser.contentWindow == aWindow);
+    return gBrowser.browsers.some(browser => browser.contentWindow == aWindow);
   },
 }
 
 function getTogglableToolbars() {
   let toolbarNodes = Array.slice(gNavToolbox.childNodes);
   toolbarNodes = toolbarNodes.concat(gNavToolbox.externalToolbars);
   toolbarNodes = toolbarNodes.filter(node => node.getAttribute("toolbarname"));
   return toolbarNodes;
@@ -5196,19 +5198,19 @@ var TabsInTitlebar = {
   _lastSizeMode: null,
 
   _readPref: function () {
     this.allowedBy("pref",
                    Services.prefs.getBoolPref(this._prefName));
   },
 
   _update: function (aForce=false) {
-    function $(id) document.getElementById(id);
-    function rect(ele) ele.getBoundingClientRect();
-    function verticalMargins(cstyle) parseFloat(cstyle.marginBottom) + parseFloat(cstyle.marginTop);
+    let $ = id => document.getElementById(id);
+    let rect = ele => ele.getBoundingClientRect();
+    let verticalMargins = cstyle => parseFloat(cstyle.marginBottom) + parseFloat(cstyle.marginTop);
 
     if (!this._initialized || window.fullScreen)
       return;
 
     let allowed = true;
 
     if (!aForce) {
       // _update is called on resize events, because the window is not ready
@@ -7399,18 +7401,22 @@ function getNotificationBox(aWindow) {
 function getTabModalPromptBox(aWindow) {
   var foundBrowser = gBrowser.getBrowserForDocument(aWindow.document);
   if (foundBrowser)
     return gBrowser.getTabModalPromptBox(foundBrowser);
   return null;
 };
 
 /* DEPRECATED */
-function getBrowser() gBrowser;
-function getNavToolbox() gNavToolbox;
+function getBrowser() {
+  return gBrowser;
+}
+function getNavToolbox() {
+  return gNavToolbox;
+}
 
 var gPrivateBrowsingUI = {
   init: function PBUI_init() {
     // Do nothing for normal windows
     if (!PrivateBrowsingUtils.isWindowPrivate(window)) {
       return;
     }
 
--- a/browser/base/content/chatWindow.xul
+++ b/browser/base/content/chatWindow.xul
@@ -123,17 +123,19 @@ chatBrowserAccess.prototype = {
     return browser ? browser.contentWindow : null;
   },
 
   openURIInFrame: function browser_openURIInFrame(aURI, aParams, aWhere, aContext) {
     let browser = this._openURIInNewTab(aURI, aWhere);
     return browser ? browser.QueryInterface(Ci.nsIFrameLoaderOwner) : null;
   },
 
-  isTabContentWindow: function (aWindow) this.contentWindow == aWindow,
+  isTabContentWindow: function (aWindow) {
+    return this.contentWindow == aWindow;
+  },
 };
 
 </script>
 
 #include browser-sets.inc
 
 #ifdef XP_MACOSX
 #include browser-menubar.inc
--- a/browser/base/content/sanitize.js
+++ b/browser/base/content/sanitize.js
@@ -401,18 +401,18 @@ Sanitizer.prototype = {
           if (findBarCanClear) {
             aCallback("formdata", true, aArg);
             return false;
           }
         }
 
         let count = 0;
         let countDone = {
-          handleResult : function(aResult) count = aResult,
-          handleError : function(aError) Components.utils.reportError(aError),
+          handleResult : aResult => count = aResult,
+          handleError : aError => Components.utils.reportError(aError),
           handleCompletion :
             function(aReason) { aCallback("formdata", aReason == 0 && count > 0, aArg); }
         };
         FormHistory.count({}, countDone);
         return false;
       }
     },
 
--- a/browser/base/content/sync/setup.js
+++ b/browser/base/content/sync/setup.js
@@ -46,17 +46,19 @@ var gSyncSetup = {
   _disabledSites: [],
 
   status: {
     password: false,
     email: false,
     server: false
   },
 
-  get _remoteSites() [Weave.Service.serverURL, RECAPTCHA_DOMAIN],
+  get _remoteSites() {
+    return [Weave.Service.serverURL, RECAPTCHA_DOMAIN];
+  },
 
   get _usingMainServers() {
     if (this._settingUpNew)
       return document.getElementById("server").selectedIndex == 0;
     return document.getElementById("existingServer").selectedIndex == 0;
   },
 
   init: function () {
@@ -74,17 +76,17 @@ var gSyncSetup = {
         //        of `this`. Fix in a followup. (bug 583347)
         if (add)
           Weave.Svc.Obs.add(topic, self[func], self);
         else
           Weave.Svc.Obs.remove(topic, self[func], self);
       });
     };
     addRem(true);
-    window.addEventListener("unload", function() addRem(false), false);
+    window.addEventListener("unload", () => addRem(false), false);
 
     window.setTimeout(function () {
       // Force Service to be loaded so that engines are registered.
       // See Bug 670082.
       Weave.Service;
     }, 0);
 
     this.captchaBrowser = document.getElementById("captcha");
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -45,17 +45,17 @@
       <field name="tabs" readonly="true">
         this.tabContainer.childNodes;
       </field>
 
       <property name="visibleTabs" readonly="true">
         <getter><![CDATA[
           if (!this._visibleTabs)
             this._visibleTabs = Array.filter(this.tabs,
-                                             function (tab) !tab.hidden && !tab.closing);
+                                             tab => !tab.hidden && !tab.closing);
           return this._visibleTabs;
         ]]></getter>
       </property>
 
       <field name="closingTabsEnum" readonly="true">({ ALL: 0, OTHER: 1, TO_END: 2 });</field>
 
       <field name="_visibleTabs">null</field>
 
@@ -2697,34 +2697,34 @@
         </body>
       </method>
 
       <method name="removeProgressListener">
         <parameter name="aListener"/>
         <body>
           <![CDATA[
             this.mProgressListeners =
-              this.mProgressListeners.filter(function (l) l != aListener);
+              this.mProgressListeners.filter(l => l != aListener);
          ]]>
         </body>
       </method>
 
       <method name="addTabsProgressListener">
         <parameter name="aListener"/>
         <body>
           this.mTabsProgressListeners.push(aListener);
         </body>
       </method>
 
       <method name="removeTabsProgressListener">
         <parameter name="aListener"/>
         <body>
         <![CDATA[
           this.mTabsProgressListeners =
-            this.mTabsProgressListeners.filter(function (l) l != aListener);
+            this.mTabsProgressListeners.filter(l => l != aListener);
         ]]>
         </body>
       </method>
 
       <method name="getBrowserForTab">
         <parameter name="aTab"/>
         <body>
         <![CDATA[
@@ -2828,17 +2828,17 @@
       <property name="selectedBrowser"
                 onget="return this.mCurrentBrowser;"
                 readonly="true"/>
 
       <property name="browsers" readonly="true">
        <getter>
           <![CDATA[
             return this._browsers ||
-                   (this._browsers = Array.map(this.tabs, function (tab) tab.linkedBrowser));
+                   (this._browsers = Array.map(this.tabs, tab => tab.linkedBrowser));
           ]]>
         </getter>
       </property>
       <field name="_browsers">null</field>
 
       <!-- Moves a tab to a new browser window, unless it's already the only tab
            in the current window, in which case this will do nothing. -->
       <method name="replaceTabWithWindow">
@@ -5517,17 +5517,19 @@
           toDrag = canvas;
         }
         dt.setDragImage(toDrag, -16 * scale, -16 * scale);
 
         // _dragData.offsetX/Y give the coordinates that the mouse should be
         // positioned relative to the corner of the new window created upon
         // dragend such that the mouse appears to have the same position
         // relative to the corner of the dragged tab.
-        function clientX(ele) ele.getBoundingClientRect().left;
+        function clientX(ele) {
+          return ele.getBoundingClientRect().left;
+        }
         let tabOffsetX = clientX(tab) - clientX(this);
         tab._dragData = {
           offsetX: event.screenX - window.screenX - tabOffsetX,
           offsetY: event.screenY - window.screenY,
           scrollX: this.mTabstrip.scrollPosition,
           screenX: event.screenX
         };
 
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -594,17 +594,17 @@ file, You can obtain one at http://mozil
           } catch (ex) {}
 
           // If the entire URL is selected, just use the actual loaded URI.
           if (inputVal == selectedVal) {
             // ... but only if  isn't a javascript: or data: URI, since those
             // are hard to read when encoded
             if (!uri.schemeIs("javascript") && !uri.schemeIs("data")) {
               // Parentheses are known to confuse third-party applications (bug 458565).
-              selectedVal = uri.spec.replace(/[()]/g, function (c) escape(c));
+              selectedVal = uri.spec.replace(/[()]/g, c => escape(c));
             }
 
             return selectedVal;
           }
 
           // Just the beginning of the URL is selected, check for a trimmed
           // value
           let spec = uri.spec;