Bug 1198900 - Don't call OnTouchCancel when the current block is not a touch block. r=botond
authorKartikaya Gupta <kgupta@mozilla.com>
Wed, 26 Aug 2015 15:08:00 -0400
changeset 292087 8205877b3b305cad1ba5b26b28c6f7f1fbbf5988
parent 292086 c1121b67faa0c6f4ded0ad0eb9bcd4dda38e17d5
child 292088 c70338a96e33a92583c27670a065196f7a934d44
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1198900
milestone43.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 1198900 - Don't call OnTouchCancel when the current block is not a touch block. r=botond
gfx/layers/apz/src/AsyncPanZoomController.cpp
gfx/layers/apz/src/AsyncPanZoomController.h
gfx/layers/apz/src/Axis.cpp
gfx/layers/apz/src/Axis.h
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -1256,19 +1256,17 @@ nsEventStatus AsyncPanZoomController::On
   }
 
   return nsEventStatus_eConsumeNoDefault;
 }
 
 nsEventStatus AsyncPanZoomController::OnTouchCancel(const MultiTouchInput& aEvent) {
   APZC_LOG("%p got a touch-cancel in state %d\n", this, mState);
   OnTouchEndOrCancel();
-  mX.CancelTouch();
-  mY.CancelTouch();
-  CancelAnimation();
+  CancelAnimationAndGestureState();
   return nsEventStatus_eConsumeNoDefault;
 }
 
 nsEventStatus AsyncPanZoomController::OnScaleBegin(const PinchGestureInput& aEvent) {
   APZC_LOG("%p got a scale-begin in state %d\n", this, mState);
 
   // Note that there may not be a touch block at this point, if we received the
   // PinchGestureEvent directly from widget code without any touch events.
@@ -1635,18 +1633,18 @@ nsEventStatus AsyncPanZoomController::On
   CurrentPanGestureBlock()->GetOverscrollHandoffChain()->CancelAnimations();
 
   return nsEventStatus_eConsumeNoDefault;
 }
 
 nsEventStatus AsyncPanZoomController::OnPanCancelled(const PanGestureInput& aEvent) {
   APZC_LOG("%p got a pan-cancelled in state %d\n", this, mState);
 
-  mX.CancelTouch();
-  mY.CancelTouch();
+  mX.CancelGesture();
+  mY.CancelGesture();
 
   return nsEventStatus_eConsumeNoDefault;
 }
 
 
 nsEventStatus AsyncPanZoomController::OnPanBegin(const PanGestureInput& aEvent) {
   APZC_LOG("%p got a pan-begin in state %d\n", this, mState);
 
@@ -1763,18 +1761,18 @@ nsEventStatus AsyncPanZoomController::On
   APZC_LOG("%p got a pan-momentumend in state %d\n", this, mState);
 
   // Call into OnPan in order to process any delta included in this event.
   OnPan(aEvent, false);
 
   // We need to reset the velocity to zero. We don't really have a "touch"
   // here because the touch has already ended long before the momentum
   // animation started, but I guess it doesn't really matter for now.
-  mX.CancelTouch();
-  mY.CancelTouch();
+  mX.CancelGesture();
+  mY.CancelGesture();
   SetState(NOTHING);
 
   RequestContentRepaint();
 
   return nsEventStatus_eConsumeNoDefault;
 }
 
 nsEventStatus AsyncPanZoomController::OnLongPress(const TapGestureInput& aEvent) {
@@ -3161,22 +3159,33 @@ PanGestureBlockState*
 AsyncPanZoomController::CurrentPanGestureBlock()
 {
   return GetInputQueue()->CurrentPanGestureBlock();
 }
 
 void
 AsyncPanZoomController::ResetInputState()
 {
+  // This may be called during non-touch input blocks as well. We send
+  // a fake cancel touch event here but on the assumption that none of the
+  // code in GEL assumes a CurrentTouchBlock()
   MultiTouchInput cancel(MultiTouchInput::MULTITOUCH_CANCEL, 0, TimeStamp::Now(), 0);
   nsRefPtr<GestureEventListener> listener = GetGestureEventListener();
   if (listener) {
     listener->HandleInputEvent(cancel);
   }
-  OnTouchCancel(cancel);
+  CancelAnimationAndGestureState();
+}
+
+void
+AsyncPanZoomController::CancelAnimationAndGestureState()
+{
+  mX.CancelGesture();
+  mY.CancelGesture();
+  CancelAnimation();
 }
 
 bool
 AsyncPanZoomController::HasReadyTouchBlock()
 {
   return GetInputQueue()->HasReadyTouchBlock();
 }
 
--- a/gfx/layers/apz/src/AsyncPanZoomController.h
+++ b/gfx/layers/apz/src/AsyncPanZoomController.h
@@ -824,16 +824,18 @@ public:
   bool ArePointerEventsConsumable(TouchBlockState* aBlock, uint32_t aTouchPoints);
 
   /**
    * Clear internal state relating to input handling.
    */
   void ResetInputState();
 
 private:
+  void CancelAnimationAndGestureState();
+
   nsRefPtr<InputQueue> mInputQueue;
   TouchBlockState* CurrentTouchBlock();
   bool HasReadyTouchBlock();
 
   PanGestureBlockState* CurrentPanGestureBlock();
 
   /* ===================================================================
    * The functions and members in this section are used to manage
--- a/gfx/layers/apz/src/Axis.cpp
+++ b/gfx/layers/apz/src/Axis.cpp
@@ -394,17 +394,17 @@ void Axis::EndTouch(uint32_t aTimestampM
   }
   if (count > 1) {
     mVelocity /= count;
   }
   AXIS_LOG("%p|%s ending touch, computed velocity %f\n",
     mAsyncPanZoomController, Name(), mVelocity);
 }
 
-void Axis::CancelTouch() {
+void Axis::CancelGesture() {
   // mVelocityQueue is controller-thread only
   APZThreadUtils::AssertOnControllerThread();
 
   AXIS_LOG("%p|%s cancelling touch, clearing velocity queue\n",
     mAsyncPanZoomController, Name());
   mVelocity = 0.0f;
   while (!mVelocityQueue.IsEmpty()) {
     mVelocityQueue.RemoveElementAt(0);
--- a/gfx/layers/apz/src/Axis.h
+++ b/gfx/layers/apz/src/Axis.h
@@ -54,22 +54,22 @@ public:
 
   /**
    * Notify this Axis that a touch has ended gracefully. This may perform
    * recalculations of the axis velocity.
    */
   void EndTouch(uint32_t aTimestampMs);
 
   /**
-   * Notify this Axis that a touch has ended forcefully. Useful for stopping
+   * Notify this Axis that the gesture has ended forcefully. Useful for stopping
    * flings when a user puts their finger down in the middle of one (i.e. to
    * stop a previous touch including its fling so that a new one can take its
    * place).
    */
-  void CancelTouch();
+  void CancelGesture();
 
   /**
    * Takes a requested displacement to the position of this axis, and adjusts it
    * to account for overscroll (which might decrease the displacement; this is
    * to prevent the viewport from overscrolling the page rect), and axis locking
    * (which might prevent any displacement from happening). If overscroll
    * ocurred, its amount is written to |aOverscrollAmountOut|.
    * The |aDisplacementOut| parameter is set to the adjusted