Scroll-snap points needs to be updated during programmatic scrolls
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 May 2015 19:37:50 +0000 (19:37 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 May 2015 19:37:50 +0000 (19:37 +0000)
commitdff860f2388a464a5dbfe3f3bc3a0a0725f30fe3
tree5b3e9e804114f759bd210646fe92dc923001db70
parent1e7746bc180f93d24c240c47af66ad8d059ca825
Scroll-snap points needs to be updated during programmatic scrolls
https://bugs.webkit.org/show_bug.cgi?id=145216
<rdar://problem/21051039>

Reviewed by Dean Jackson.

Whenever we adjust the current scroll position, make sure we also update the current
active scroll snap offset index (if applicable).

* platform/ScrollAnimator.cpp:
(WebCore::ScrollAnimator::scrollToOffsetWithoutAnimation): Call the new 'updateActiveScrollSnapIndexForOffset'
method after moving to a new position.
(WebCore::ScrollAnimator::setCurrentPosition): Ditto.
(WebCore::ScrollAnimator::updateActiveScrollSnapIndexForOffset): New method. Asks the scroll controller to
identify the closest scroll snap offset index. If it finds something relevant, update the ScrollableArea state
to track these new values.
* platform/ScrollAnimator.h:
* platform/cocoa/ScrollController.h:
(WebCore::ScrollController::activeScrollSnapIndexDidChange):
(WebCore::ScrollController::setScrollSnapIndexDidChange):
* platform/cocoa/ScrollController.mm:
(WebCore::ScrollController::setNearestScrollSnapIndexForAxisAndOffset): Added. Find the closest relevant scroll snap offset
index for the given scroll offset, and update the internal scroll snap state to reflect it.
(WebCore::ScrollController::setActiveScrollSnapIndicesForOffset): Given the x and y offset for a scroll,
set the relevant scroll snap offset indices.
* platform/mac/ScrollAnimatorMac.mm:
(WebCore::ScrollAnimatorMac::immediateScrollTo): Call the new 'updateActiveScrollSnapIndexForOffset' method
after moving to a new position.
(WebCore::ScrollAnimatorMac::immediateScrollBy): Ditto.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@184728 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/platform/ScrollAnimator.cpp
Source/WebCore/platform/ScrollAnimator.h
Source/WebCore/platform/cocoa/ScrollController.h
Source/WebCore/platform/cocoa/ScrollController.mm
Source/WebCore/platform/mac/ScrollAnimatorMac.mm