Commit edd8eb8c authored by Botond Ballo's avatar Botond Ballo Committed by bballo@mozilla.com
Browse files

Bug 1964721 - Do not cancel an autoscroll animation when starting a touchpad hold gesture. r=hiro

parent 3d88fd62
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ enum CancelAnimationFlags : uint32_t {
  ScrollSnap = 0x2,          /* Snap to snap points */
  TriggeredExternally = 0x4, /* Cancellation was not triggered by APZ in
                                response to an input event */
  ExcludeAutoscroll = 0x16   /* Don't cancel overscroll animations */
};

inline CancelAnimationFlags operator|(CancelAnimationFlags a,
+5 −1
Original line number Diff line number Diff line
@@ -2774,7 +2774,7 @@ nsEventStatus AsyncPanZoomController::OnPanMayBegin(
  StartTouch(aEvent.mLocalPanStartPoint, aEvent.mTimeStamp);
  MOZ_ASSERT(GetCurrentPanGestureBlock());
  GetCurrentPanGestureBlock()->GetOverscrollHandoffChain()->CancelAnimations(
      ExcludeOverscroll);
      ExcludeOverscroll | ExcludeAutoscroll);

  return nsEventStatus_eConsumeNoDefault;
}
@@ -4429,6 +4429,10 @@ void AsyncPanZoomController::CancelAnimation(CancelAnimationFlags aFlags) {
  APZC_LOG_DETAIL("running CancelAnimation(0x%x) in state %s\n", this, aFlags,
                  ToString(mState).c_str());

  if ((aFlags & ExcludeAutoscroll) && mState == AUTOSCROLL) {
    return;
  }

  if (mAnimation) {
    mAnimation->Cancel(aFlags);
  }
+5 −0
Original line number Diff line number Diff line
@@ -401,6 +401,11 @@ class TestAsyncPanZoomController : public AsyncPanZoomController {
    EXPECT_EQ(WHEEL_SCROLL, mState);
  }

  void AssertStateIsAutoscroll() {
    RecursiveMutexAutoLock lock(mRecursiveMutex);
    EXPECT_EQ(AUTOSCROLL, mState);
  }

  void SetAxisLocked(ScrollDirections aDirections, bool aLockValue) {
    if (aDirections.contains(ScrollDirection::eVertical)) {
      mY.SetAxisLocked(aLockValue);
+19 −0
Original line number Diff line number Diff line
@@ -543,3 +543,22 @@ TEST_F(APZCPanningTesterMock, HoldGesture_SubframeTargeting) {
  PanGesture(PanGestureInput::PANGESTURE_END, manager, panPoint,
             ScreenPoint(0, 0), mcc->Time());
}

TEST_F(APZCPanningTester, HoldGesture_DuringAutoscrollAnimation) {
  // Tell APZ about the current mouse position. This is needed for
  // autoscroll to work correctly.
  tm->SetCurrentMousePosition(ScreenPoint(5, 5));

  // Start an autoscroll animation.
  apzc->StartAutoscroll(ScreenPoint(5, 5));
  apzc->AssertStateIsAutoscroll();

  // Send a PANGESTURE_MAYSTART event. With a touchpad, this can happen
  // when you start moving the cursor after a three-finger gesture to
  // start autoscroll.
  PanGesture(PanGestureInput::PANGESTURE_MAYSTART, apzc, ScreenIntPoint(50, 80),
             ScreenPoint(0, 0), mcc->Time());

  // Check that this did NOT cancel the autoscroll animation.
  apzc->AssertStateIsAutoscroll();
}