removing unneed variables, commenting out dump, adding HTMLAnchorElements as another element we should ignore if the mouse is pressed down on them. mobile
authordougt@dougt-ubuntu
Wed, 21 May 2008 11:42:28 -0700
branchmobile
changeset 64711 642d2498f0dd09e7ce3f4e63db43d54ac916bdb1
parent 64710 9d4753363b2363e7e3b469c1223dae9de71866d3
child 64712 d34b014362fc1f60a79b1763ae452dc9cfc7a270
push id19389
push userffxbld
push dateWed, 06 Apr 2011 21:33:21 +0000
treeherdermozilla-central@8e9f90073a20 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
removing unneed variables, commenting out dump, adding HTMLAnchorElements as another element we should ignore if the mouse is pressed down on them.
mobile/chrome/content/browser.js
mobile/chrome/content/deckbrowser.xml
--- a/mobile/chrome/content/browser.js
+++ b/mobile/chrome/content/browser.js
@@ -446,19 +446,20 @@ MouseController.prototype = {
     // Start timer for tap-n-hold context menu
     /*
     var self = this;
     this._contextID = setTimeout(function() { self.contextMenu(aEvent); }, 750);
     */
 
     if (aEvent.target instanceof HTMLInputElement ||
         aEvent.target instanceof HTMLTextAreaElement ||
+        aEvent.target instanceof HTMLAnchorElement ||
         aEvent.target instanceof HTMLSelectElement)
       return;
-
+    
     // Check to see if we should treat this as a double-click
     /*
     if (this.firstEvent &&
         (aEvent.timeStamp - this.firstEvent.timeStamp) < 400 &&
         Math.abs(aEvent.screenX - this.firstEvent.screenX) < 30 &&
         Math.abs(aEvent.screenY - this.firstEvent.screenY) < 30) {
       this.dblclick(aEvent);
       return;
@@ -501,57 +502,54 @@ MouseController.prototype = {
     }
     
     // Keep scrolling if there is enough momentum
     function _doKineticScroll(browser, speedX, speedY, step) {
 
       const decayFactor = 0.95;
       const cutoff = 2;
 
-      var x, y;
-
       // enforce a speed limit
       const speedLimit = 55;
       if (Math.abs(speedY) > speedLimit)
         speedY = speedY > 0 ? speedLimit : -speedLimit;
 
       if (Math.abs(speedX) > speedLimit)
         speedX = speedX > 0 ? speedLimit : -speedLimit;
 
       // We want these numbers to be whole and moving in the direction of zero.
       if (speedX < 0)
-        x = Math.ceil(speedX);
+        speedX = Math.ceil(speedX);
       else
-        x = Math.floor(speedX);
+        speedX = Math.floor(speedX);
 
       if (speedY < 0)
-        y = Math.ceil(speedY);
+        speedY = Math.ceil(speedY);
       else
-        y = Math.floor(speedY);
+        speedY = Math.floor(speedY);
         
-      dump("##panning: " + -1 * x + " " + -1 * y + "\n");
-      browser.doPan(- x, - y);
+      //dump("##panning: " + -1 * speedX + " " + -1 * speedY + "\n");
+      browser.doPan(- speedX, - speedY);
 
       // slow down.
-      x *= (decayFactor - step/10);
-      y *= (decayFactor - step/10);
+      speedX *= (decayFactor - step/50);
+      speedY *= (decayFactor - step/50);
 
       // see if we should continue
-      if (Math.abs(x) > cutoff || Math.abs(y) > cutoff)
-        setTimeout( function() {_doKineticScroll(browser, x, y, ++step);}, 0);
+      if (Math.abs(speedX) > cutoff || Math.abs(speedY) > cutoff)
+        setTimeout( function() {_doKineticScroll(browser, speedX, speedY, ++step);}, 0);
       else
         browser.endPan();
 
     };
 
     var browser = this._browser;
-    var speedX  = this._speedX * 100; // 
+    var speedX  = this._speedX * 100;
     var speedY  = this._speedY * 100;
     setTimeout(function() {_doKineticScroll(browser, speedX, speedY, 0);}, 0);
-
   },
 
   mousemove: function(aEvent)
   {
     if (!this._mousedown)
       return;
 
     var delta = aEvent.timeStamp - this.lastEvent.timeStamp;
@@ -562,17 +560,17 @@ MouseController.prototype = {
     if (40 > delta || (2 > Math.abs(x) && 2 > Math.abs(y)))
       return;
 
     // Remember the last event so that we can do the kinetic scrolling
     this._speedX = (x / delta);
     this._speedY = (y / delta);
     this.lastEvent = aEvent;
 
-    dump("##: " + delta + " [" + x + ", " + y + "]\n");
+    //dump("##: " + delta + " [" + x + ", " + y + "]\n");
     if (this._contextID) {
       clearTimeout(this._contextID);
       this._contextID = null;
     }
 
     this._browser.doPan(-x, -y);
 
     //FIX Adjust scrollbars now
--- a/mobile/chrome/content/deckbrowser.xml
+++ b/mobile/chrome/content/deckbrowser.xml
@@ -260,17 +260,17 @@
           <![CDATA[
             var canvas = document.getAnonymousElementByAttribute(this, "anonid", "canvas");
             var domWin = this.browser.contentWindow;
             var ctx = canvas.getContext("2d");
             ctx.clearRect(0, 0, canvas.width, canvas.height);
             var stime = Date.now();
             ctx.drawWindow(domWin, domWin.scrollX - this._panX, domWin.scrollY - this._panY, domWin.innerWidth, domWin.innerHeight, "white");
             var etime = Date.now();
-            dump("drawWindow: " + (etime - stime) + " ms\n");
+            //dump("drawWindow: " + (etime - stime) + " ms\n");
           ]]>
         </body>
       </method>
 
       <method name="startPan">
         <body>
           <![CDATA[
             // Toggle browser visibility so the canvas is visible