Bug 524661 - Fix places in browser.js that use for each...in to loop over arrays. r=gavin
authorMarkus Stange <mstange@themasta.com>
Wed, 28 Oct 2009 19:59:15 +0100
changeset 34252 57b3b6d119fd905266b5a8e60892b8900cc34e0e
parent 34251 ea6f9b5338b345646f67bbc8a51b5d7f66fef116
child 34253 a812503aff1c8941f4f01a220075e9ec30735308
push id9981
push usermstange@themasta.com
push dateWed, 28 Oct 2009 18:59:47 +0000
treeherdermozilla-central@57b3b6d119fd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin
bugs524661
milestone1.9.3a1pre
Bug 524661 - Fix places in browser.js that use for each...in to loop over arrays. r=gavin
browser/base/content/browser.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -677,18 +677,18 @@ let gGestureSupport = {
     const gestureEvents = ["SwipeGesture",
       "MagnifyGestureStart", "MagnifyGestureUpdate", "MagnifyGesture",
       "RotateGestureStart", "RotateGestureUpdate", "RotateGesture",
       "TapGesture", "PressTapGesture"];
 
     let addRemove = aAddListener ? window.addEventListener :
       window.removeEventListener;
 
-    for each (let event in gestureEvents)
-      addRemove("Moz" + event, this, true);
+    gestureEvents.forEach(function (event) addRemove("Moz" + event, this, true),
+                          this);
   },
 
   /**
    * Dispatch events based on the type of mouse gesture event. For now, make
    * sure to stop propagation of every gesture event so that web content cannot
    * receive gesture events.
    *
    * @param aEvent
@@ -866,19 +866,20 @@ let gGestureSupport = {
   /**
    * Convert the swipe gesture into a browser action based on the direction
    *
    * @param aEvent
    *        The swipe event to handle
    */
   onSwipe: function GS_onSwipe(aEvent) {
     // Figure out which one (and only one) direction was triggered 
-    for each (let dir in ["UP", "RIGHT", "DOWN", "LEFT"])
+    ["UP", "RIGHT", "DOWN", "LEFT"].forEach(function (dir) {
       if (aEvent.direction == aEvent["DIRECTION_" + dir])
         return this._doAction(aEvent, ["swipe", dir.toLowerCase()]);
+    }, this);
   },
 
   /**
    * Get a gesture preference or use a default if it doesn't exist
    *
    * @param aPref
    *        Name of the preference to load under the gesture branch
    * @param aDef
@@ -2625,31 +2626,31 @@ function FillInHTMLTooltip(tipElement)
         .getPropertyValue("direction");
     }
     tipElement = tipElement.parentNode;
   }
 
   var tipNode = document.getElementById("aHTMLTooltip");
   tipNode.style.direction = direction;
   
-  for each (var t in [titleText, XLinkTitleText]) {
+  [titleText, XLinkTitleText].forEach(function (t) {
     if (t && /\S/.test(t)) {
 
       // Per HTML 4.01 6.2 (CDATA section), literal CRs and tabs should be
       // replaced with spaces, and LFs should be removed entirely.
       // XXX Bug 322270: We don't preserve the result of entities like &#13;,
       // which should result in a line break in the tooltip, because we can't
       // distinguish that from a literal character in the source by this point.
       t = t.replace(/[\r\t]/g, ' ');
       t = t.replace(/\n/g, '');
 
       tipNode.setAttribute("label", t);
       retVal = true;
     }
-  }
+  });
 
   return retVal;
 }
 
 var browserDragAndDrop = {
   getDragURLFromDataTransfer : function (dt)
   {
     var types = dt.types;