Bug 522517: Panning sometimes causes link clicks [r=vingtetun]
authorBenjamin Stover <webapps@stechz.com>
Fri, 23 Oct 2009 23:20:35 -0400
changeset 65705 921feddec453c5a11e04622c278bc2d8c2c85fe4
parent 65704 8191e6a60722eec940c8aa0df206072ad612b781
child 65706 91ec70f2310d5b750ebf78af17219181baa75af2
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)
reviewersvingtetun
bugs522517
Bug 522517: Panning sometimes causes link clicks [r=vingtetun]
mobile/chrome/content/InputHandler.js
--- a/mobile/chrome/content/InputHandler.js
+++ b/mobile/chrome/content/InputHandler.js
@@ -538,17 +538,17 @@ MouseModule.prototype = {
       this._doDragStop(sX, sY, !dragData.checkPan(sX, sY));
 
     if (this._clicker)
       this._clicker.mouseUp(evInfo.event.clientX, evInfo.event.clientY);
 
     if (this._targetIsContent(evInfo.event)) {
       // User possibly clicked on something in content
       this._recordEvent(evInfo);
-      let commitToClicker = this._clicker && !dragData.checkPan(sX, sY);
+      let commitToClicker = this._clicker && dragData.checkClick(sX, sY);
       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();    
@@ -891,16 +891,21 @@ DragData.prototype = {
       return false;
     if (this._isPan)
       return true;
 
     let distanceSquared = (Math.pow(sX - this._originX, 2) + Math.pow(sY - this._originY, 2));
     return (this._isPan = (distanceSquared > Math.pow(this._dragRadius, 2)));
   },
 
+  /** Return true if drag should be parsed as a click. */
+  checkClick: function(sX, sY) {
+    return Date.now() - this._dragStartTime >= kMsUntilLock && !this.checkPan(sX, sY);
+  },
+
   lockAxis: function lockAxis(sX, sY) {
     if (this.locked) {
       if (this.lockedX !== null) {
         sX = this.lockedX;
       }
       else if (this.lockedY !== null) {
         sY = this.lockedY;
       }