Bug 745381 - Don't call GetFrameFromPoint for non touchstart touch events. r=smaug
☠☠ backed out by 200d81544f02 ☠ ☠
authorKartikaya Gupta <kgupta@mozilla.com>
Tue, 17 Apr 2012 09:28:10 -0700
changeset 95181 a43a33ddd2b3d64d7e5b098ec523437d5f2a439a
parent 95180 1f86ad4f883dde71aa6a8951f8e1583979dd6754
child 95182 200d81544f0253301aa7c1bb107bc2b4d819e4ab
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs745381
milestone14.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 745381 - Don't call GetFrameFromPoint for non touchstart touch events. r=smaug
mobile/android/base/gfx/TouchEventHandler.java
--- a/mobile/android/base/gfx/TouchEventHandler.java
+++ b/mobile/android/base/gfx/TouchEventHandler.java
@@ -63,16 +63,21 @@ public final class TouchEventHandler imp
 
     // the listener we use to notify gecko of touch events
     private OnTouchListener mOnTouchListener;
 
     // whether or not we should wait for touch listeners to respond (this state is
     // per-tab and is updated when we switch tabs).
     private boolean mWaitForTouchListeners;
 
+    // true if we should send the current block of events to gecko. this
+    // is false if mWaitForTouchListeners was false when we received the
+    // touchstart event.
+    private boolean mSendBlockToListeners;
+
     // true if we should hold incoming events in our queue. this is re-set for every
     // block of events, this is cleared once we find out if the block has been
     // default-prevented or not (or we time out waiting for that).
     private boolean mHoldInQueue;
 
     // true if we should dispatch incoming events to the gesture detector and the pan/zoom
     // controller. if this is false, then the current block of events has been
     // default-prevented, and we should not dispatch these events (although we'll still send
@@ -139,43 +144,43 @@ public final class TouchEventHandler imp
         // and be done with it, no extra work needed.
         if (mOnTouchListener == null) {
             dispatchEvent(event);
             return true;
         }
 
         if (isDownEvent(event)) {
             // this is the start of a new block of events! whee!
+            mSendBlockToListeners = mWaitForTouchListeners;
             mHoldInQueue = mWaitForTouchListeners;
             if (mHoldInQueue) {
                 // if we're holding the events in the queue, set the timeout so that
                 // we dispatch these events if we don't get a default-prevented notification
                 mView.postDelayed(mListenerTimeoutProcessor, EVENT_LISTENER_TIMEOUT);
-            } else {
-                // if we're not holding these events, then we still need to pretend like
-                // we did and had a ListenerTimeoutProcessor fire so that when we get
-                // the default-prevented notification for this block, it doesn't accidentally
-                // act upon some other block
-                mProcessingBalance++;
             }
+            // if mSendBlockToListeners is false, then we're neither going to hold it
+            // in the queue nor send it to the listeners, so we don't need to update
+            // the mProcessingBalance here.
         }
 
         // if we need to hold the events, add it to the queue. if we need to dispatch
         // it directly, do that. it is possible that both mHoldInQueue and mDispatchEvents
         // are false, in which case we are processing a block of events that we know
         // has been default-prevented. in that case we don't keep the events as we don't
         // need them (but we still pass them to the gecko listener).
         if (mHoldInQueue) {
             mEventQueue.add(MotionEvent.obtain(event));
         } else if (mDispatchEvents) {
             dispatchEvent(event);
         }
 
-        // notify gecko of the event
-        mOnTouchListener.onTouch(mView, event);
+        if (mSendBlockToListeners) {
+            // notify gecko of the event
+            mOnTouchListener.onTouch(mView, event);
+        }
 
         return true;
     }
 
     /**
      * This function is how gecko sends us a default-prevented notification. It is called
      * once gecko knows definitively whether the block of events has had preventDefault
      * called on it (either on the initial down event that starts the block, or on