Bug 555725 - Panning allowed after context menu is instanced [r=mfinkle]
authorVivien Nicolas <21@vingtetun.org>
Fri, 09 Apr 2010 11:27:47 -0400
changeset 66123 d7cafeba39c39a2ed6337a67d07c6e26b5722a38
parent 66122 fb001bf9618e6c79242e293bf45775bc183f8410
child 66124 a9558431cf1c58041b9796dca19d0100d7ae2d86
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
bugs555725
Bug 555725 - Panning allowed after context menu is instanced [r=mfinkle]
mobile/chrome/content/InputHandler.js
--- a/mobile/chrome/content/InputHandler.js
+++ b/mobile/chrome/content/InputHandler.js
@@ -314,39 +314,37 @@ InputHandler.prototype = {
     if (this._grabber) {
       this._grabber.handleEvent(evInfo);
     } else {
       let mods = this._modules;
       let i = skipToIndex || 0;
 
       for (let len = mods.length; i < len; ++i) {
         mods[i].handleEvent(evInfo);  // event focus could get grabbed in this invocation
-        if (this._grabbed)            // so don't pass the event to the rest of modules
+        if (this._grabber)            // so don't pass the event to the rest of modules
           break;
       }
     }
   }
 };
 
-
 /**
  * Helper class to InputHandler.  Wraps a DOM event with some additional data.
  */
 InputHandler.EventInfo = function EventInfo(aEvent) {
   this.event = aEvent;
   this.time = Date.now();
 };
 
 InputHandler.EventInfo.prototype = {
   toString: function toString() {
     return '[EventInfo] { event=' + this.event + 'time=' + this.time + ' }';
   }
 };
 
-
 /**
  * MouseModule
  *
  * Input handler module that handles all mouse-related input such as dragging and
  * clicking.
  *
  * The Fennec chrome DOM tree has elements that are augmented dynamically with
  * custom JS properties that tell the MouseModule they have custom support for
@@ -416,18 +414,23 @@ function MouseModule(owner, browserViewC
                                         Util.bind(this._kineticStop, this));
 }
 
 
 MouseModule.prototype = {
   handleEvent: function handleEvent(evInfo) {
     // TODO: Make "contextmenu" a first class part of InputHandler
     // Bug 554639
-    if (evInfo.event.type == "contextmenu")
-      this._cleanClickBuffer();
+    if (evInfo.event.type == "contextmenu") {
+      if (this._clicker)
+        this._clicker.panBegin();
+      if (this._dragger)
+        this._dragger.dragStop(0, 0, this._targetScrollInterface);
+      this.cancelPending();
+    }
 
     if (evInfo.event.button !== 0) // avoid all but a clean left click
       return;
 
     switch (evInfo.event.type) {
       case "mousedown":
         this._onMouseDown(evInfo);
         break;
@@ -490,24 +493,21 @@ MouseModule.prototype = {
 
     let targetClicker = this.getClickerFromElement(evInfo.event.target);
 
     this._targetScrollInterface = targetScrollInterface;
     this._dragger = (targetScrollInterface) ? (targetScrollbox.customDragger || this._defaultDragger)
                                             : null;
     this._clicker = (targetClicker) ? targetClicker.customClicker : null;
 
-    this._owner.grab(this);
-
     if (this._clicker)
       this._clicker.mouseDown(evInfo.event.clientX, evInfo.event.clientY);
 
-    if (targetScrollInterface && this._dragger.isDraggable(targetScrollbox, targetScrollInterface)) {
+    if (targetScrollInterface && this._dragger.isDraggable(targetScrollbox, targetScrollInterface))
       this._doDragStart(evInfo.event);
-    }
 
     if (this._targetIsContent(evInfo.event)) {
       this._recordEvent(evInfo);
     }
     else {
       if (this._clickTimeout) {
         // cancel all pending content clicks
         window.clearTimeout(this._clickTimeout);
@@ -540,17 +540,17 @@ MouseModule.prototype = {
       dragData.setDragPosition(evInfo.event.screenX, evInfo.event.screenY);
       let [sX, sY] = dragData.panPosition();
       this._doDragStop(sX, sY, !dragData.isPan());
     }
 
     if (this._targetIsContent(evInfo.event)) {
       // User possibly clicked on something in content
       this._recordEvent(evInfo);
-      let commitToClicker = this._clicker && dragData.isClick();
+      let commitToClicker = this._clicker && dragData.isClick() && (this._downUpEvents.length > 1);
       if (commitToClicker)
         // commit this click to the doubleclick timewait buffer
         this._commitAnotherClick();
       else
         // clean the click buffer ourselves, since there was no clicker
         // to commit to.  when there is one, the path taken through
         // _commitAnotherClick takes care of this.
         this._cleanClickBuffer();
@@ -582,16 +582,17 @@ MouseModule.prototype = {
     let dragData = this._dragData;
 
     if (dragData.dragging) {
       let oldIsPan = dragData.isPan();
       dragData.setDragPosition(evInfo.event.screenX, evInfo.event.screenY);
       evInfo.event.stopPropagation();
       evInfo.event.preventDefault();
       if (dragData.isPan()) {
+        this._owner.grab(this);
         // Only pan when mouse event isn't part of a click. Prevent jittering on tap.
         let [sX, sY] = dragData.panPosition();
         this._doDragMove(sX, sY);
 
         // Let clicker know when mousemove begins a pan
         let clicker = this._clicker;
         if (!oldIsPan && clicker)
           clicker.panBegin();