Bug 524170: [Regression] Panning is not responsive [r=mark.finkle]
authorBenjamin Stover <webapps@stechz.com>
Fri, 23 Oct 2009 16:11:15 -0400
changeset 65704 8191e6a60722eec940c8aa0df206072ad612b781
parent 65703 4dd89bfaf8f0b5bbce57ef37bbb9068edbab0802
child 65705 921feddec453c5a11e04622c278bc2d8c2c85fe4
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmark.finkle
bugs524170
Bug 524170: [Regression] Panning is not responsive [r=mark.finkle]
mobile/chrome/content/InputHandler.js
--- a/mobile/chrome/content/InputHandler.js
+++ b/mobile/chrome/content/InputHandler.js
@@ -427,17 +427,17 @@ function MouseModule(owner, browserViewC
   this._clicker = null;
 
   this._downUpEvents = [];
   this._targetScrollInterface = null;
 
   var self = this;
   this._kinetic = new KineticController(
     function _dragByBound(dx, dy) { return self._dragBy(dx, dy); },
-    function _dragStopBound() { return self._doDragStop(0, 0, 0, true); }
+    function _dragStopBound() { return self._doDragStop(0, 0, true); }
   );
 }
 
 
 MouseModule.prototype = {
   handleEvent: function handleEvent(evInfo) {
     if (evInfo.event.button !== 0) // avoid all but a clean left click
       return;
@@ -598,54 +598,56 @@ MouseModule.prototype = {
   },
 
   /**
    * Inform our dragger of a dragStart and update kinetic with new data.
    */
   _doDragStart: function _doDragStart(event) {
     let dragData = this._dragData;
 
+    // addData must be called before setDragStart. Otherwise addData may end kinetic panning and
+    // thus accidentally end the drag we've just begun.
+    this._kinetic.addData(event.screenX, event.screenY);
     dragData.setDragStart(event.screenX, event.screenY);
-    this._kinetic.addData(event.screenX, event.screenY, event.timeStamp);
 
     this._dragger.dragStart(event.clientX, event.clientY, event.target, this._targetScrollInterface);
   },
 
   /**
    * Finish a drag.  The third parameter is a secret one used to distinguish
    * between the supposed end of drag caused by a mouseup and the real end
    * of drag which happens when KineticController::end() is called.
    */
-  _doDragStop: function _doDragStop(sX, sY, t, kineticStop) {
+  _doDragStop: function _doDragStop(sX, sY, kineticStop) {
     let dragData = this._dragData;
 
     if (!kineticStop) {    // we're not really done, since now it is
                            // kinetic's turn to scroll about
       let dx = dragData.sX - sX;
       let dy = dragData.sY - sY;
 
       dragData.endDrag();
 
-      this._kinetic.addData(sX, sY, t);
+      this._kinetic.addData(sX, sY);
 
       this._kinetic.start();
     } else {               // now we're done, says our secret 3rd argument
       this._dragger.dragStop(0, 0, this._targetScrollInterface);
       dragData.reset();
     }
   },
 
   /**
    * Update kinetic with new data and drag.
    */
-  _doDragMove: function _doDragMove(sX, sY, t) {
+  _doDragMove: function _doDragMove(sX, sY) {
     let dragData = this._dragData;
     let dX = dragData.sX - sX;
     let dY = dragData.sY - sY;
-    this._kinetic.addData(sX, sY, t);
+    this._kinetic.addData(sX, sY);
     return this._dragBy(dX, dY);
   },
 
   /**
    * Used by _doDragMove() above and by KineticController's timer to do the
    * actual dragMove signalling to the dragger.  We'd put this in _doDragMove()
    * but then KineticController would be adding to its own data as it signals
    * the dragger of dragMove()s.
@@ -903,17 +905,17 @@ DragData.prototype = {
         sY = this.lockedY;
       }
       return [sX, sY];
     }
     // check to see if mouse move is after the timeout
     let now = Date.now();
     if (now - this._dragStartTime < kMsUntilLock) {
       // Util.dumpLn("*** pre-lock, return no movement");
-      return [this.sX, this.sY];      
+      return [this.sX, this.sY];
     }
     
     // Util.dumpLn("*** this.sX/sY: ", this.sX, ",", this.sY, "   sX/sY: ", sX, ",", sY);
 
     // look at difference from stored coord to lock movement, but only
     // do it if initial movement is sufficient to detect intent
     let absX = Math.abs(this.sX - sX);
     let absY = Math.abs(this.sY - sY);
@@ -1090,23 +1092,23 @@ KineticController.prototype = {
   },
 
   end: function end() {
     if (this._beforeEnd)
       this._beforeEnd();
     this._reset();
   },
 
-  addData: function addData(sx, sy, t) {
+  addData: function addData(sx, sy) {
     // if we're active, end that move before adding data
     if (this.isActive())
       this.end();
 
     let mbLength = this.momentumBuffer.length;
-    let now = t || Date.now();
+    let now = Date.now();
  
     // avoid adding duplicates which would otherwise slow down the speed
     if (mbLength > 0) {
       let mbLast = this.momentumBuffer[mbLength - 1];
       if ((mbLast.sx == sx && mbLast.sy == sy) || mbLast.t == now) {
         mbLast.sx = sx;
         mbLast.sy = sy;
         mbLast.t = now;