Bug 515789: Awesome bar pops up when click on form autocomplete fields [r=combee r=froystig r=mark.finkle]
authorVivien Nicolas <21@vingtetun.org>
Mon, 14 Sep 2009 12:50:21 -0400
changeset 65554 d2dbdbb896519519f439846b51c0b476e5b481d4
parent 65553 33576779d3035236170046f15cba07e7a97950c2
child 65555 22b0d6a96db0efd6dd181d1d3d1bc6a1efa18f8b
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)
reviewerscombee, froystig, mark
bugs515789
Bug 515789: Awesome bar pops up when click on form autocomplete fields [r=combee r=froystig r=mark.finkle]
mobile/chrome/content/InputHandler.js
--- a/mobile/chrome/content/InputHandler.js
+++ b/mobile/chrome/content/InputHandler.js
@@ -400,17 +400,16 @@ function MouseModule(owner, browserViewC
   this._owner = owner;
   this._browserViewContainer = browserViewContainer;
   this._dragData = new DragData(this, 15, 200);
 
   this._dragger = null;
   this._clicker = null;
 
   this._downUpEvents = [];
-  this._downUpDispatchedIndex = 0;
   this._targetScrollInterface = null;
 
   var self = this;
   this._kinetic = new KineticController(
     function _dragByBound(dx, dy) { return self._dragBy(dx, dy); },
     function _dragStopBound() { return self._doDragStop(0, 0, true); }
   );
 }
@@ -483,17 +482,18 @@ MouseModule.prototype = {
 
     if (this._clicker)
       this._clicker.mouseDown(evInfo.event.clientX, evInfo.event.clientY);
 
     if (targetScrollInterface) {
       this._doDragStart(evInfo.event);
     }
 
-    this._recordEvent(evInfo);
+    if (this._targetIsContent(evInfo.event))
+      this._recordEvent(evInfo);
   },
 
   /**
    * 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
    * redispatching.
@@ -505,24 +505,24 @@ MouseModule.prototype = {
 
     let [sX, sY] = dragData.lockAxis(evInfo.event.screenX, evInfo.event.screenY);
 
     this._movedOutOfRadius = this._movedOutOfRadius || dragData.isPointOutsideRadius(sX, sY);
 
     if (dragData.dragging)       // XXX same check as this._dragger but we
       this._doDragStop(sX, sY);  //  are using both, no good reason
 
-    this._recordEvent(evInfo);
 
     if (this._clicker)
       this._clicker.mouseUp(evInfo.event.clientX, evInfo.event.clientY);
 
-    let targetIsContent = this._targetIsContent(evInfo.event);
-    if (targetIsContent)
+    if (this._targetIsContent(evInfo.event)) {
+      this._recordEvent(evInfo);
       this._doClick(this._movedOutOfRadius);
+    }
     else if (this._dragger && this._movedOutOfRadius && evInfo.event.detail)
       this._owner.suppressNextClick();
 
     this._owner.ungrab(this);
   },
 
   /**
    * If we're in a drag, do what we have to do to drag on.
@@ -553,79 +553,16 @@ MouseModule.prototype = {
         return true;
 
       target = target.parentNode;
     }
     return false;
   },
 
   /**
-   * Record a mousedown/mouseup event for later redispatch via
-   * _redispatchDownUpEvents()
-   */
-  _recordEvent: function _recordEvent(evInfo) {
-    this._downUpEvents.push(evInfo);
-  },
-
-  /**
-   * Redispatch all pending (un-redispatched) recorded events to the Fennec
-   * global chrome window.
-   */
-  _redispatchDownUpEvents: function _redispatchDownUpEvents() {
-    let evQueue = this._downUpEvents;
-
-    this._owner.stopListening();
-
-    let len = evQueue.length;
-
-    for (let i = this._downUpDispatchedIndex; i < len; ++i)
-      this._redispatchChromeMouseEvent(evQueue[i].event);
-
-    this._downUpDispatchedIndex = len;
-
-    this._owner.startListening();
-  },
-
-  _skipAllDownUpEvents: function _skipAllDownUpEvents() {
-    this._downUpDispatchedIndex = this._downUpEvents.length;
-  },
-
-  /**
-   * Helper function to _redispatchDownUpEvents() that sends a single DOM mouse
-   * event to the Fennec global chrome window.
-   */
-  _redispatchChromeMouseEvent: function _redispatchChromeMouseEvent(aEvent) {
-    if (!(aEvent instanceof MouseEvent)) {
-      Cu.reportError("_redispatchChromeMouseEvent called with a non-mouse event");
-      return;
-    }
-
-    // we ignore the root scroll frame in this redispatch
-    Browser.windowUtils.sendMouseEvent(aEvent.type, aEvent.clientX, aEvent.clientY,
-                                       aEvent.button, aEvent.detail, 0, true);
-  },
-
-  /**
-   * Clear all recorded events.  This will *not* automagically redispatch any
-   * pending un-redispatched events.  If you desire to redispatch everything
-   * in the recorded events buffer, you should call _redispatchDownUpEvents()
-   * before calling _clearDownUpEvents().
-   *
-   * @param [optional] the number of events to remove from the front of the
-   * recorded events queue.
-   */
-  _clearDownUpEvents: function _clearDownUpEvents(howMany) {
-    if (howMany === undefined)
-      howMany = this._downUpEvents.length;
-
-    this._downUpEvents.splice(0, howMany);
-    this._downUpDispatchedIndex = Math.max(this._downUpDispatchedIndex - howMany, 0);
-  },
-
-  /**
    * Inform our dragger of a dragStart and update kinetic with new data.
    */
   _doDragStart: function _doDragStart(event) {
     let dragData = this._dragData;
 
     dragData.setDragStart(event.screenX, event.screenY);
     this._kinetic.addData(event.screenX, event.screenY);
 
@@ -681,37 +618,26 @@ MouseModule.prototype = {
     dragData.setDragPosition(sX, sY);
 
     return this._dragger.dragMove(dX, dY, this._targetScrollInterface);
   },
 
   /**
    * Helper function to mouseup, called  at the point where a DOM click should
    * occur.  If movedOutOfRadius is true, then we don't call it an internal
-   * clicker-notifiable click.  In either case, we redispatch all pending
-   * recorded mousedown/mouseup events.
+   * clicker-notifiable click.  
    */
   _doClick: function _doClick(movedOutOfRadius) {
     let commitToClicker = this._clicker && !movedOutOfRadius;
-    let needToRedispatch = this._dragger && !movedOutOfRadius;
-
-    if (commitToClicker) {
+    if (commitToClicker)
       this._commitAnotherClick();  // commit this click to the doubleclick timewait buffer
-    }
-
-    if (needToRedispatch) {
-      this._redispatchDownUpEvents();
-    } else {
-      this._skipAllDownUpEvents();
-    }
-
-    if (!commitToClicker) {
+    else
       this._cleanClickBuffer();    // clean the click buffer ourselves, since there was no clicker
                                    // to commit to.  when there is one, the path taken through
-    }                              // _commitAndClick takes care of this.
+                                   // _commitAndClick takes care of this.
   },
 
   /**
    * 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.
@@ -756,26 +682,38 @@ MouseModule.prototype = {
     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);
   },
 
   /**
+   * Record a mousedown/mouseup event for later redispatch via
+   * _redispatchDownUpEvents()
+   */
+  _recordEvent: function _recordEvent(evInfo) {
+    this._downUpEvents.push(evInfo);
+  },
+
+  /**
    * Clean out the click buffer.  Should be called after a single, double, or
    * non-click has been processed and all relevant (re)dispatches of events in
    * the recorded down/up event queue have been issued out.
    *
    * @param [optional] the number of events to remove from the front of the
    * recorded events queue.
    */
   _cleanClickBuffer: function _cleanClickBuffer(howMany) {
     delete this._clickTimeout;
-    this._clearDownUpEvents(howMany);
+
+    if (howMany == undefined)
+      howMany = this._downUpEvents.length;
+
+    this._downUpEvents.splice(0, howMany);
   },
 
   /**
    * The default dragger object used by MouseModule when dragging a scrollable
    * element that provides no customDragger.  Simply performs the expected
    * regular scrollBy calls on the scroller.
    */
   _defaultDragger: {
@@ -863,17 +801,16 @@ MouseModule.prototype = {
   },
 
   toString: function toString() {
     return '[MouseModule] {'
       + '\n\tdragData=' + this._dragData + ', '
       + 'dragger=' + this._dragger + ', '
       + 'clicker=' + this._clicker + ', '
       + '\n\tdownUpEvents=' + this._downUpEvents + ', '
-      + '\n\tdownUpIndex=' + this._downUpDispatchedIndex + ', '
       + 'length=' + this._downUpEvents.length + ', '
       + '\n\ttargetScroller=' + this._targetScrollInterface + ', '
       + '\n\tclickTimeout=' + this._clickTimeout + '\n  }';
   }
 };
 
 /**
  * DragData handles processing drags on the screen, handling both