Bug 1769805 - Implement axis relocking in the sticky axis locking mode. r=botond,dlrobertson

Differential Revision: https://phabricator.services.mozilla.com/D150496
This commit is contained in:
Razvan Cojocaru 2022-07-08 22:27:53 +00:00
Родитель 2be50a2e9c
Коммит d34124045b
2 изменённых файлов: 48 добавлений и 30 удалений

Просмотреть файл

@ -3248,21 +3248,24 @@ void AsyncPanZoomController::HandlePanningUpdate(
if (fabs(aPanDistance.x) > breakThreshold ||
fabs(aPanDistance.y) > breakThreshold) {
if (mState == PANNING_LOCKED_X) {
switch (mState) {
case PANNING_LOCKED_X:
if (!apz::IsCloseToHorizontal(
angle, StaticPrefs::apz_axis_lock_breakout_angle())) {
mY.SetAxisLocked(false);
// If we are within the lock angle from the Y axis, lock
// onto the Y axis.
if (apz::IsCloseToVertical(angle,
StaticPrefs::apz_axis_lock_lock_angle())) {
if (apz::IsCloseToVertical(
angle, StaticPrefs::apz_axis_lock_lock_angle())) {
mX.SetAxisLocked(true);
SetState(PANNING_LOCKED_Y);
} else {
SetState(PANNING);
}
}
} else if (mState == PANNING_LOCKED_Y) {
break;
case PANNING_LOCKED_Y:
if (!apz::IsCloseToVertical(
angle, StaticPrefs::apz_axis_lock_breakout_angle())) {
mX.SetAxisLocked(false);
@ -3276,6 +3279,14 @@ void AsyncPanZoomController::HandlePanningUpdate(
SetState(PANNING);
}
}
break;
case PANNING:
HandlePanning(angle);
break;
default:
break;
}
}
}

Просмотреть файл

@ -334,13 +334,13 @@ TEST_F(APZCAxisLockTester, BreakStickyAxisLock) {
BreakStickyAxisLockTest(ScrollDirections(ScrollDirection::eHorizontal,
ScrollDirection::eVertical));
// Once we're no longer locked onto an axis, there is no way back. Run a
// gesture that would normally lock us onto the X axis, but we should stay
// in a panning state.
BreakStickyAxisLockTestGesture(ScrollDirection::eHorizontal);
// We should be in a panning state.
apzc->AssertStateIsPanning();
apzc->AssertNotAxisLocked();
// Lock back to the X axis.
BreakStickyAxisLockTestGesture(ScrollDirection::eHorizontal);
// End the gesture.
QueueMockHitResult(ScrollableLayerGuid::START_SCROLL_ID);
PanGesture(PanGestureInput::PANGESTURE_END, manager, ScreenIntPoint(50, 50),
@ -361,6 +361,13 @@ TEST_F(APZCAxisLockTester, BreakStickyAxisLock) {
// Test breaking all axis locks from a X axis lock.
BreakStickyAxisLockTest(ScrollDirections(ScrollDirection::eHorizontal,
ScrollDirection::eVertical));
// We should be in a panning state.
apzc->AssertStateIsPanning();
apzc->AssertNotAxisLocked();
// Test switch back to locking onto the Y axis.
BreakStickyAxisLockTest(ScrollDirection::eVertical);
}
TEST_F(APZCAxisLockTester, BreakAxisLockByLockAngle) {