Bug 611736 - Long-tap in textbox causes a click, which changes selection [r=stechz]
authorMatt Brubeck <mbrubeck@mozilla.com>
Thu, 18 Nov 2010 15:31:12 -0800
changeset 67053 c4ac817b9f69a2e23c52b9235fe7d1f3a0ecd30f
parent 67052 53bfc760d30dfe80d53a57adfcc3f8f9d97e23e9
child 67054 b19a03a1075bf8c72c6478c874df4f6902810c90
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)
reviewersstechz
bugs611736
Bug 611736 - Long-tap in textbox causes a click, which changes selection [r=stechz]
mobile/chrome/content/input.js
--- a/mobile/chrome/content/input.js
+++ b/mobile/chrome/content/input.js
@@ -90,16 +90,17 @@ const kStateActive = 0x00000001;
 function MouseModule() {
   this._dragData = new DragData();
 
   this._dragger = null;
   this._inputField = null;
 
   this._downUpEvents = [];
   this._targetScrollInterface = null;
+  this._suppressNextMouseUp = false;
 
   this._kinetic = new KineticController(this._dragBy.bind(this),
                                         this._kineticStop.bind(this));
 
   this._singleClickTimeout = new Util.Timeout(this._doSingleClick.bind(this));
   this._longClickTimeout = new Util.Timeout(this._doLongClick.bind(this));
 
   this._doubleClickRadius = Util.getWindowUtils(window).displayDPI * kDoubleClickRadius;
@@ -225,16 +226,22 @@ MouseModule.prototype = {
       this._inputField = inputField;
       aEvent.preventDefault();
       aEvent.stopPropagation();
     }
   },
 
   /** Send tap up event and any necessary full taps. */
   _onMouseUp: function _onMouseUp(aEvent) {
+    if (this._suppressNextMouseUp) {
+      this._suppressNextMouseUp = false;
+      aEvent.stopPropagation();
+      aEvent.preventDefault();
+    }
+
     this._onMouseMove(aEvent);
 
     let dragData = this._dragData;
     this._doDragStop();
 
     // Do tap
     if (this._target) {
       let event = document.createEvent("Events");
@@ -388,22 +395,18 @@ MouseModule.prototype = {
       event.initEvent("PanFinished", true, false);
       document.dispatchEvent(event);
     }
   },
 
   /** Called when tap down times out and becomes a long tap. */
   _doLongClick: function _doLongClick() {
     let ev = this._downUpEvents[0];
-
-    let event = document.createEvent("Events");
-    event.initEvent("TapLong", true, false);
-    event.clientX = ev.clientX;
-    event.clientY = ev.clientY;
-    ev.target.dispatchEvent(event);
+    this._suppressNextMouseUp = true;
+    this._dispatchTap("TapLong", ev);
   },
 
   /**
    * Commit another click event to our click buffer.  The `click buffer' is a
    * timeout initiated by the first click.  If the timeout is still alive when
    * another click is committed, then the click buffer forms a double tap, and
    * the timeout is cancelled.  Otherwise, the timeout issues a single tap.
    */