Bug 597286, part 9: Fix interaction between mousemodule and gesturemodule r=mfinkle
authorBenjamin Stover <bstover@mozilla.com>
Wed, 22 Sep 2010 16:26:33 -0700
changeset 66688 b79515890c563e82048eb2b8e74e2b86016a68c8
parent 66687 ab521981f5a432600e4821cb0054139ec823f7f5
child 66689 c0dd795c6529c8879dc8c4f6eb3d725cd4822aa5
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)
reviewersmfinkle
bugs597286
Bug 597286, part 9: Fix interaction between mousemodule and gesturemodule r=mfinkle
mobile/chrome/content/InputHandler.js
--- a/mobile/chrome/content/InputHandler.js
+++ b/mobile/chrome/content/InputHandler.js
@@ -344,48 +344,53 @@ function MouseModule(owner, browserViewC
 
   this._singleClickTimeout = new Util.Timeout(this._doSingleClick.bind(this));
   this._longClickTimeout = new Util.Timeout(this._doLongClick.bind(this));
 }
 
 
 MouseModule.prototype = {
   handleEvent: function handleEvent(aEvent) {
-    if (aEvent.button !== 0 && aEvent.type != "contextmenu" && aEvent.type != "MozBeforePaint")
+    if (aEvent.button !== 0 && aEvent.type != "MozMagnifyGestureStart" && aEvent.type != "MozBeforePaint")
       return;
 
     switch (aEvent.type) {
       case "mousedown":
         this._onMouseDown(aEvent);
         break;
       case "mousemove":
         aEvent.stopPropagation();
         aEvent.preventDefault();
         this._onMouseMove(aEvent);
         break;
       case "mouseup":
         this._onMouseUp(aEvent);
         break;
+      case "MozMagnifyGestureStart":
+        this.cancelPending();
+        break;
       case "MozBeforePaint":
         this._waitingForPaint = false;
         removeEventListener("MozBeforePaint", this, false);
         break;
     }
   },
 
   /**
    * This gets invoked by the input handler if another module grabs.  We should
    * reset our state or something here.  This is probably doing the wrong thing
    * in its current form.
    */
   cancelPending: function cancelPending() {
-    if (this._kinetic.isActive())
-      this._kinetic.end();
+    this._doDragStop();
 
-    this._dragData.reset();
+    // Kinetic panning may have already been active or drag stop above may have
+    // made kinetic panning active.
+    this._kinetic.end();
+
     this._targetScrollInterface = null;
 
     this._cleanClickBuffer();
   },
 
   /** Begin possible pan and send tap down event. */
   _onMouseDown: function _onMouseDown(aEvent) {
     this._owner.allowClicks();
@@ -428,18 +433,16 @@ MouseModule.prototype = {
     if (dragger) {
       let draggable = dragger.isDraggable(targetScrollbox, targetScrollInterface);
       dragData.locked = !draggable.x || !draggable.y;
       if (draggable.x || draggable.y) {
         this._dragger = dragger;
         this._doDragStart(aEvent);
       }
     }
-
-    this._owner.grab(this);
   },
 
   /** Send tap up event and any necessary full taps. */
   _onMouseUp: function _onMouseUp(aEvent) {
     this._onMouseMove(aEvent);
 
     let dragData = this._dragData;
     if (dragData.dragging)
@@ -495,16 +498,18 @@ MouseModule.prototype = {
 
         // Let everyone know when mousemove begins a pan
         if (!oldIsPan && dragData.isPan()) {
           this._longClickTimeout.clear();
 
           let event = document.createEvent("Events");
           event.initEvent("PanBegin", true, false);
           aEvent.target.dispatchEvent(event);
+
+          this._owner.grab(this);
         }
       }
     }
   },
 
   /**
    * Inform our dragger of a dragStart.
    */