Scroll position jumps to the origin when scrolling without momentum at the end of...
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Dec 2016 21:50:11 +0000 (21:50 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Dec 2016 21:50:11 +0000 (21:50 +0000)
commitcad871a58cb471b0ee6f5c1076b1fbb4d7827ac6
treebb49cbe893fd35e59fd7dd632fbdd787d7de53de
parentdc16801e6fabdf08e89915336adc8c4f0594da52
Scroll position jumps to the origin when scrolling without momentum at the end of a scroll snapping container
https://bugs.webkit.org/show_bug.cgi?id=165474
<rdar://problem/29534305>

Reviewed by Simon Fraser.

Source/WebCore:

When initializing an AppKit _NSScrollingMomentumCalculator, if the initial and target positions are the same and
the initial velocity is (0, 0), the momentum calculator will output (0, 0) as the animated scroll position when
animating. This causes the scroll position to jump to the top left in some cases when scrolling in scroll snap
containers. To fix this, we teach the ScrollingMomentumCalculatorMac to return an animation duration of 0 and
an animated scroll position equal to the final scroll position when this is the case.

Test: tiled-drawing/scrolling/scroll-snap/scrolling-jumps-to-top.html

* page/scrolling/mac/ScrollingMomentumCalculatorMac.h:
* page/scrolling/mac/ScrollingMomentumCalculatorMac.mm:
(WebCore::ScrollingMomentumCalculatorMac::ScrollingMomentumCalculatorMac):
(WebCore::ScrollingMomentumCalculatorMac::scrollOffsetAfterElapsedTime):
(WebCore::ScrollingMomentumCalculatorMac::animationDuration):

LayoutTests:

Added a new test verifying that if a scroll gesture ends without momentum at the bottom of a scroll snapping
container, the scroll position won't jump to the top.

* tiled-drawing/scrolling/scroll-snap/scrolling-jumps-to-top-expected.txt: Added.
* tiled-drawing/scrolling/scroll-snap/scrolling-jumps-to-top.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@209477 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-scrolling-jumps-to-top.html [new file with mode: 0644]
LayoutTests/tiled-drawing/scrolling/scroll-snap/scroll-snap-scrolling-jumps-to-top.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/page/scrolling/mac/ScrollingMomentumCalculatorMac.h
Source/WebCore/page/scrolling/mac/ScrollingMomentumCalculatorMac.mm