зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
2be50a2e9c
Коммит
d34124045b
|
@ -3248,34 +3248,45 @@ void AsyncPanZoomController::HandlePanningUpdate(
|
|||
|
||||
if (fabs(aPanDistance.x) > breakThreshold ||
|
||||
fabs(aPanDistance.y) > breakThreshold) {
|
||||
if (mState == 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())) {
|
||||
mX.SetAxisLocked(true);
|
||||
SetState(PANNING_LOCKED_Y);
|
||||
} else {
|
||||
SetState(PANNING);
|
||||
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())) {
|
||||
mX.SetAxisLocked(true);
|
||||
SetState(PANNING_LOCKED_Y);
|
||||
} else {
|
||||
SetState(PANNING);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (mState == PANNING_LOCKED_Y) {
|
||||
if (!apz::IsCloseToVertical(
|
||||
angle, StaticPrefs::apz_axis_lock_breakout_angle())) {
|
||||
mX.SetAxisLocked(false);
|
||||
// If we are within the lock angle from the X axis, lock
|
||||
// onto the X axis.
|
||||
if (apz::IsCloseToHorizontal(
|
||||
angle, StaticPrefs::apz_axis_lock_lock_angle())) {
|
||||
mY.SetAxisLocked(true);
|
||||
SetState(PANNING_LOCKED_X);
|
||||
} else {
|
||||
SetState(PANNING);
|
||||
break;
|
||||
|
||||
case PANNING_LOCKED_Y:
|
||||
if (!apz::IsCloseToVertical(
|
||||
angle, StaticPrefs::apz_axis_lock_breakout_angle())) {
|
||||
mX.SetAxisLocked(false);
|
||||
// If we are within the lock angle from the X axis, lock
|
||||
// onto the X axis.
|
||||
if (apz::IsCloseToHorizontal(
|
||||
angle, StaticPrefs::apz_axis_lock_lock_angle())) {
|
||||
mY.SetAxisLocked(true);
|
||||
SetState(PANNING_LOCKED_X);
|
||||
} else {
|
||||
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) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче