Bug 969072 - Move the CANCEL event handling into the pinch gesture code. r=drs
authorKartikaya Gupta <kgupta@mozilla.com>
Fri, 07 Feb 2014 11:26:32 -0500
changeset 167561 eddf0ede2cb2c4b47ace7ae3a623dc0e6542f3e9
parent 167560 c4e6cf3136620af9c7c21e77fda5d09daed8fb66
child 167562 414676ce184c530e9bc8255aa77e09584643eb0d
push id26174
push userkwierso@gmail.com
push dateSat, 08 Feb 2014 00:55:48 +0000
treeherdermozilla-central@2c873eff7dc2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdrs
bugs969072
milestone30.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 969072 - Move the CANCEL event handling into the pinch gesture code. r=drs
gfx/layers/ipc/GestureEventListener.cpp
gfx/layers/ipc/GestureEventListener.h
--- a/gfx/layers/ipc/GestureEventListener.cpp
+++ b/gfx/layers/ipc/GestureEventListener.cpp
@@ -188,30 +188,34 @@ nsEventStatus GestureEventListener::Hand
 
     if (!mTouches.Length()) {
       mSpanChange = 0.0f;
     }
 
     break;
   }
   case MultiTouchInput::MULTITOUCH_CANCEL:
-    // This gets called if there's a touch that has to bail for weird reasons
-    // like pinching and then moving away from the window that the pinch was
-    // started in without letting go of the screen.
-    return HandlePinchGestureEvent(aEvent, true);
+    // FIXME: we should probably clear a bunch of gesture state here
+    break;
   }
 
-  return HandlePinchGestureEvent(aEvent, false);
+  return HandlePinchGestureEvent(aEvent);
 }
 
-nsEventStatus GestureEventListener::HandlePinchGestureEvent(const MultiTouchInput& aEvent, bool aClearTouches)
+nsEventStatus GestureEventListener::HandlePinchGestureEvent(const MultiTouchInput& aEvent)
 {
   nsEventStatus rv = nsEventStatus_eIgnore;
 
-  if (mTouches.Length() > 1 && !aClearTouches) {
+  if (aEvent.mType == MultiTouchInput::MULTITOUCH_CANCEL) {
+    mTouches.Clear();
+    mState = GESTURE_NONE;
+    return rv;
+  }
+
+  if (mTouches.Length() > 1) {
     const ScreenIntPoint& firstTouch = mTouches[0].mScreenPoint,
                          secondTouch = mTouches[1].mScreenPoint;
     ScreenPoint focusPoint = ScreenPoint(firstTouch + secondTouch) / 2;
     ScreenIntPoint delta = secondTouch - firstTouch;
     float currentSpan = float(NS_hypot(delta.x, delta.y));
 
     switch (mState) {
     case GESTURE_NONE:
@@ -278,20 +282,16 @@ nsEventStatus GestureEventListener::Hand
       mAsyncPanZoomController->HandleInputEvent(touchEvent);
     }
 
     rv = nsEventStatus_eConsumeNoDefault;
   } else if (mState == GESTURE_WAITING_PINCH) {
     mState = GESTURE_NONE;
   }
 
-  if (aClearTouches) {
-    mTouches.Clear();
-  }
-
   return rv;
 }
 
 nsEventStatus GestureEventListener::HandleSingleTapUpEvent(const MultiTouchInput& aEvent)
 {
   TapGestureInput tapEvent(TapGestureInput::TAPGESTURE_UP, aEvent.mTime,
       aEvent.mTouches[0].mScreenPoint, aEvent.modifiers);
   return mAsyncPanZoomController->HandleInputEvent(tapEvent);
--- a/gfx/layers/ipc/GestureEventListener.h
+++ b/gfx/layers/ipc/GestureEventListener.h
@@ -89,21 +89,18 @@ protected:
     // A long tap has happened, wait for the tap to be released in case we need
     // to fire a click event in the case the long tap was not handled.
     GESTURE_LONG_TAP_UP
   };
 
   /**
    * Attempts to handle the event as a pinch event. If it is not a pinch event,
    * then we simply tell the next consumer to consume the event instead.
-   *
-   * |aClearTouches| marks whether or not to terminate any pinch currently
-   * happening.
    */
-  nsEventStatus HandlePinchGestureEvent(const MultiTouchInput& aEvent, bool aClearTouches);
+  nsEventStatus HandlePinchGestureEvent(const MultiTouchInput& aEvent);
 
   /**
    * Attempts to handle the event as a single tap event, which highlights links
    * before opening them. In general, this will not attempt to block the touch
    * event from being passed along to AsyncPanZoomController since APZC needs to
    * know about touches ending (and we only know if a touch was a tap once it
    * ends).
    */