зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1707605 - Call SnapBackIfOverscrolled() on mouse-up. r=hiro
Differential Revision: https://phabricator.services.mozilla.com/D114806
This commit is contained in:
Родитель
c0ab7eb79a
Коммит
0b27bb5bc9
|
@ -925,11 +925,15 @@ nsEventStatus AsyncPanZoomController::HandleDragEvent(
|
|||
|
||||
{
|
||||
RecursiveMutexAutoLock lock(mRecursiveMutex);
|
||||
if (aEvent.mType == MouseInput::MouseType::MOUSE_UP &&
|
||||
mState == SCROLLBAR_DRAG) {
|
||||
APZC_LOG("%p ending drag\n", this);
|
||||
SetState(NOTHING);
|
||||
ScrollSnap();
|
||||
|
||||
if (aEvent.mType == MouseInput::MouseType::MOUSE_UP) {
|
||||
if (mState == SCROLLBAR_DRAG) {
|
||||
APZC_LOG("%p ending drag\n", this);
|
||||
SetState(NOTHING);
|
||||
}
|
||||
|
||||
SnapBackIfOverscrolled();
|
||||
|
||||
return nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1402,6 +1402,49 @@ TEST_F(APZCOverscrollTester, NoOverscrollForMousewheel) {
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifndef MOZ_WIDGET_ANDROID // Only applies to GenericOverscrollEffect
|
||||
TEST_F(APZCOverscrollTester, ClickWhileOverscrolled) {
|
||||
SCOPED_GFX_PREF_BOOL("apz.overscroll.enabled", true);
|
||||
|
||||
ScrollMetadata metadata;
|
||||
FrameMetrics& metrics = metadata.GetMetrics();
|
||||
metrics.SetCompositionBounds(ParentLayerRect(0, 0, 100, 100));
|
||||
metrics.SetScrollableRect(CSSRect(0, 0, 100, 1000));
|
||||
metrics.SetVisualScrollOffset(CSSPoint(0, 0));
|
||||
apzc->SetFrameMetrics(metrics);
|
||||
|
||||
// Pan into overscroll at the top.
|
||||
ScreenIntPoint panPoint(50, 50);
|
||||
PanGesture(PanGestureInput::PANGESTURE_START, apzc, panPoint,
|
||||
ScreenPoint(0, -1), mcc->Time());
|
||||
mcc->AdvanceByMillis(10);
|
||||
PanGesture(PanGestureInput::PANGESTURE_PAN, apzc, panPoint,
|
||||
ScreenPoint(0, -100), mcc->Time());
|
||||
EXPECT_TRUE(apzc->IsOverscrolled());
|
||||
EXPECT_TRUE(apzc->GetOverscrollAmount().y < 0); // overscrolled at top
|
||||
|
||||
// End the pan. This should start an overscroll animation.
|
||||
mcc->AdvanceByMillis(10);
|
||||
PanGesture(PanGestureInput::PANGESTURE_END, apzc, panPoint, ScreenPoint(0, 0),
|
||||
mcc->Time());
|
||||
EXPECT_TRUE(apzc->GetOverscrollAmount().y < 0); // overscrolled at top
|
||||
EXPECT_TRUE(apzc->IsOverscrollAnimationRunning());
|
||||
|
||||
// Send a mouse-down. This should interrupt the animation but not relieve
|
||||
// overscroll yet.
|
||||
ParentLayerPoint overscrollBefore = apzc->GetOverscrollAmount();
|
||||
MouseDown(apzc, panPoint, mcc->Time());
|
||||
EXPECT_FALSE(apzc->IsOverscrollAnimationRunning());
|
||||
EXPECT_EQ(overscrollBefore, apzc->GetOverscrollAmount());
|
||||
|
||||
// Send a mouse-up. This should start an overscroll animation again.
|
||||
MouseUp(apzc, panPoint, mcc->Time());
|
||||
EXPECT_TRUE(apzc->IsOverscrollAnimationRunning());
|
||||
|
||||
SampleAnimationUntilRecoveredFromOverscroll(ParentLayerPoint(0, 0));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef MOZ_WIDGET_ANDROID // Only applies to GenericOverscrollEffect
|
||||
TEST_F(APZCOverscrollTester, DynamicallyLoadingContent) {
|
||||
SCOPED_GFX_PREF_BOOL("apz.overscroll.enabled", true);
|
||||
|
|
Загрузка…
Ссылка в новой задаче