Bug 536944 - this._clicker is null error in InputHandler.js#doSingleClick [r=stechz]
authorVivien Nicolas <21@vingtetun.org>
Tue, 16 Feb 2010 21:06:03 -0500
changeset 66009 f22d03b66965b2ff2316e76f7d54b6bdd78ed6ce
parent 66008 792709626f64165519dfcc8e72b7a81993bcca6b
child 66010 c6e9e321c631167119b3871633600861b7fd7c00
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
bugs536944
Bug 536944 - this._clicker is null error in InputHandler.js#doSingleClick [r=stechz]
mobile/chrome/content/InputHandler.js
--- a/mobile/chrome/content/InputHandler.js
+++ b/mobile/chrome/content/InputHandler.js
@@ -493,22 +493,30 @@ MouseModule.prototype = {
 
     if (targetScrollInterface && this._dragger.isDraggable(targetScrollbox, targetScrollInterface)) {
       this._doDragStart(evInfo.event);
     }
 
     if (this._targetIsContent(evInfo.event)) {
       this._recordEvent(evInfo);
     }
-    else if (targetScrollInterface) {
-      // do not allow axis locking if panning is only possible in one direction
-      let cX = {}, cY = {};
-      targetScrollInterface.getScrolledSize(cX, cY);
-      let rect = targetScrollbox.getBoundingClientRect();
-      dragData.locked = ((cX.value > rect.width) != (cY.value > rect.height));
+    else {
+      if (this._clickTimeout) {
+        // cancel all pending content clicks
+        window.clearTimeout(this._clickTimeout);
+        this._cleanClickBuffer();
+      }
+
+      if (targetScrollInterface) {
+        // do not allow axis locking if panning is only possible in one direction
+        let cX = {}, cY = {};
+        targetScrollInterface.getScrolledSize(cX, cY);
+        let rect = targetScrollbox.getBoundingClientRect();
+        dragData.locked = ((cX.value > rect.width) != (cY.value > rect.height));
+      }
     }
   },
 
   /**
    * Handle a mouseup by swallowing the event (just as we did the mousedown) as
    * well as the possible DOM click event that follows, making one last drag
    * (which, do note, might just be the beginning of a kinetic drag that will
    * linger long after we are gone), and recording the mousedown for later
@@ -531,17 +539,17 @@ MouseModule.prototype = {
       let commitToClicker = this._clicker && dragData.isClick();
       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();    
+        this._cleanClickBuffer();
     }
     else if (dragData.isPan()) {
       // User was panning around, do not allow chrome click
       // XXX Instead of having suppressNextClick, we could grab until click is seen
       // and THEN ungrab so that owner does not need to know anything about clicking.
       let generatesClick = evInfo.event.detail;
       if (generatesClick)
         this._owner.suppressNextClick();
@@ -662,58 +670,45 @@ MouseModule.prototype = {
   /**
    * 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 click, and
    * the timeout is cancelled.  Otherwise, the timeout issues a single click to
    * the clicker.
    */
   _commitAnotherClick: function _commitAnotherClick() {
-
     if (this._clickTimeout) {   // we're waiting for a second click for double
       window.clearTimeout(this._clickTimeout);
       this._doDoubleClick();
     } else {
       this._clickTimeout = window.setTimeout(function _clickTimeout(self) { self._doSingleClick(); },
                                              kDoubleClickInterval, this);
     }
   },
 
   /**
    * Endpoint of _commitAnotherClick().  Finalize a single click and tell the clicker.
    */
   _doSingleClick: function _doSingleClick() {
-    //dump('doing single click with ' + this._downUpEvents.length + '\n');
-    //for (let i = 0; i < this._downUpEvents.length; ++i)
-    //  dump('      ' + this._downUpEvents[i].event.type
-    //       + " :: " + this._downUpEvents[i].event.button
-    //       + " :: " + this._downUpEvents[i].event.detail + '\n');/**/
-
     let ev = this._downUpEvents[1].event;
     this._cleanClickBuffer(2);
 
     // borrowed from nsIDOMNSEvent.idl
     let modifiers =
       (ev.altKey   ? Ci.nsIDOMNSEvent.ALT_MASK     : 0) |
       (ev.ctrlKey  ? Ci.nsIDOMNSEvent.CONTROL_MASK : 0) |
       (ev.shiftKey ? Ci.nsIDOMNSEvent.SHIFT_MASK   : 0) |
       (ev.metaKey  ? Ci.nsIDOMNSEvent.META_MASK    : 0);
     this._clicker.singleClick(ev.clientX, ev.clientY, modifiers);
   },
 
   /**
    * Endpoint of _commitAnotherClick().  Finalize a double click and tell the clicker.
    */
   _doDoubleClick: function _doDoubleClick() {
-    //dump('doing double click with ' + this._downUpEvents.length + '\n');
-    //for (let i = 0; i < this._downUpEvents.length; ++i)
-    //  dump('      ' + this._downUpEvents[i].event.type
-    //       + " :: " + this._downUpEvents[i].event.button
-    //       + " :: " + this._downUpEvents[i].event.detail + '\n');/**/
-
     let mouseUp1 = this._downUpEvents[1].event;
     let mouseUp2 = this._downUpEvents[3].event;
     this._cleanClickBuffer(4);
     this._clicker.doubleClick(mouseUp1.clientX, mouseUp1.clientY,
                               mouseUp2.clientX, mouseUp2.clientY);
   },
 
   /**
@@ -1035,18 +1030,18 @@ KineticController.prototype = {
     // x(t) = v0*t + .5*t^2*a
     // where: v0 is initial velocity
     //        a is acceleration
     //        t is time elapsed
     //
     // x(t)
     //  ^
     //  |                |
-    //  | 
-    //  |                |  
+    //  |
+    //  |                |
     //  |           ....^^^^....
     //  |      ...^^     |      ^^...
     //  |  ...^                      ^...
     //  |..              |               ..
     //   -----------------------------------> t
     //  t0             tf=-v0/a
     //
     // Using this formula, distance moved is independent of the time between each frame, unlike time
@@ -1164,17 +1159,17 @@ KineticController.prototype = {
     let mbLength = this.momentumBuffer.length;
     let now = Date.now();
 
     if (this.isActive()) {
       // Stop active movement when dragging in other direction.
       if (dx * this._velocity.x < 0 || dy * this._velocity.y < 0)
         this.end();
     }
- 
+
     this.momentumBuffer.push({'t': now, 'dx' : dx, 'dy' : dy});
   }
 };
 
 /**
  * Input module for basic scrollwheel input.  Currently just zooms the browser
  * view accordingly.
  */