Bug 1181703 - Allow re-entering the panning state if a second finger is tapped while panning with one finger. r=botond
authorKartikaya Gupta <kgupta@mozilla.com>
Sun, 22 Nov 2015 08:57:45 -0500
changeset 273718 012257e6f0bf57021aa5b039d0792d826caef905
parent 273717 dddbad2aa1aea05d1d1d5aade5a63797c36292d3
child 273719 9dfe9b8e6d78ec0a84e4930d7772af2c21b523ed
push id29710
push usercbook@mozilla.com
push dateMon, 23 Nov 2015 13:09:07 +0000
treeherdermozilla-central@d3d286102ba7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbotond
bugs1181703
milestone45.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 1181703 - Allow re-entering the panning state if a second finger is tapped while panning with one finger. r=botond
gfx/layers/apz/src/AsyncPanZoomController.cpp
gfx/layers/apz/src/InputBlockState.cpp
gfx/layers/apz/src/InputBlockState.h
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -1332,20 +1332,28 @@ nsEventStatus AsyncPanZoomController::On
 
   case TOUCHING:
   case CROSS_SLIDING_X:
   case CROSS_SLIDING_Y:
     // We may have some velocity stored on the axis from move events
     // that were not big enough to trigger scrolling. Clear that out.
     mX.SetVelocity(0);
     mY.SetVelocity(0);
-    // It's possible we may be overscrolled if the user tapped during a
-    // previous overscroll pan. Make sure to snap back in this situation.
-    if (!SnapBackIfOverscrolled()) {
-      SetState(NOTHING);
+    APZC_LOG("%p still has %u touch points active\n", this,
+        CurrentTouchBlock()->GetActiveTouchCount());
+    // In cases where the user is panning, then taps the second finger without
+    // entering a pinch, we will arrive here when the second finger is lifted.
+    // However the first finger is still down so we want to remain in state
+    // TOUCHING.
+    if (CurrentTouchBlock()->GetActiveTouchCount() == 0) {
+      // It's possible we may be overscrolled if the user tapped during a
+      // previous overscroll pan. Make sure to snap back in this situation.
+      if (!SnapBackIfOverscrolled()) {
+        SetState(NOTHING);
+      }
     }
     return nsEventStatus_eIgnore;
 
   case PANNING_LOCKED_X_SMOOTH_SCROLL:
   case PANNING_LOCKED_Y_SMOOTH_SCROLL:
     CancelAnimation();
     MOZ_FALLTHROUGH;
   case PANNING:
--- a/gfx/layers/apz/src/InputBlockState.cpp
+++ b/gfx/layers/apz/src/InputBlockState.cpp
@@ -856,10 +856,16 @@ TouchBlockState::UpdateSlopState(const M
       // this block
       TBS_LOG("%p exiting slop\n", this);
       mInSlop = false;
     }
   }
   return mInSlop;
 }
 
+uint32_t
+TouchBlockState::GetActiveTouchCount() const
+{
+  return mTouchCounter.GetActiveTouchCount();
+}
+
 } // namespace layers
 } // namespace mozilla
--- a/gfx/layers/apz/src/InputBlockState.h
+++ b/gfx/layers/apz/src/InputBlockState.h
@@ -437,16 +437,21 @@ public:
    * see them. The |aApzcCanConsumeEvents| parameter is factored into how large
    * the slop area is - if this is true the slop area is larger.
    * @return true iff the provided event is a touchmove in the slop area and
    *         so should not be sent to content.
    */
   bool UpdateSlopState(const MultiTouchInput& aInput,
                        bool aApzcCanConsumeEvents);
 
+  /**
+   * Returns the number of touch points currently active.
+   */
+  uint32_t GetActiveTouchCount() const;
+
   bool HasEvents() const override;
   void DropEvents() override;
   void HandleEvents() override;
   void DispatchEvent(const InputData& aEvent) const override;
   bool MustStayActive() override;
   const char* Type() override;
 
 private: