[iOS] scrollIntoViewIfNeeded is not working with scroll-snap points
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Jun 2015 19:24:59 +0000 (19:24 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 19 Jun 2015 19:24:59 +0000 (19:24 +0000)
commit3ada1c226ad390ac8a2851b5aa38e784ba266858
tree21289ade6c594fb46fa48f141b54e6daedf99dd8
parentff34074c0ef9e025b6d6e70aa8443cc9d00d45bb
[iOS] scrollIntoViewIfNeeded is not working with scroll-snap points
https://bugs.webkit.org/show_bug.cgi?id=145318
<rdar://problem/21081501>

Reviewed by Simon Fraser.

Source/WebCore:

Use the ScrollController in iOS to track the scroll snap point state.
We do not need the animation implementation or timers since the actual
animation is handled by UIKit.

This change lets us communicate the current offset into the scroll snap
offset vector between the WebProcess and RemoteScrollingTree so that
both sides stay in sync regardless of whether user gestures or style
updates have caused us to shift to a different snap point.

* page/scrolling/AsyncScrollingCoordinator.cpp:
(WebCore::AsyncScrollingCoordinator::frameViewLayoutUpdated): Set the
current horizontal and vertical scroll snap offset indices.
(WebCore::AsyncScrollingCoordinator::updateOverflowScrollingNode): Ditto.
* page/scrolling/AsyncScrollingCoordinator.h: Mark the setActiveScrollSnapIndices
for export so that it can be reached by the UIProcess.
* page/scrolling/ScrollingCoordinator.h: Keep track of horizontal and
vertical scroll snap offset indices.
* page/scrolling/ScrollingStateScrollingNode.cpp:
(WebCore::ScrollingStateScrollingNode::setCurrentHorizontalSnapPointIndex): Added.
(WebCore::ScrollingStateScrollingNode::setCurrentVerticalSnapPointIndex): Added.
* page/scrolling/ScrollingStateScrollingNode.h:
(WebCore::ScrollingStateScrollingNode::currentHorizontalSnapPointIndex): Added.
(WebCore::ScrollingStateScrollingNode::currentVerticalSnapPointIndex): Added.
* page/scrolling/ScrollingTree.h:
* page/scrolling/ScrollingTreeScrollingNode.cpp:
(WebCore::ScrollingTreeScrollingNode::updateBeforeChildren): Update the scroll snap
point offset indices if either has changed.
* page/scrolling/ScrollingTreeScrollingNode.h:
(WebCore::ScrollingTreeScrollingNode::currentHorizontalSnapPointIndex): Added.
(WebCore::ScrollingTreeScrollingNode::currentVerticalSnapPointIndex): Added.
(WebCore::ScrollingTreeScrollingNode::setCurrentHorizontalSnapPointIndex): Added.
(WebCore::ScrollingTreeScrollingNode::setCurrentVerticalSnapPointIndex): Added.
* page/scrolling/ThreadedScrollingTree.cpp:
(WebCore::ThreadedScrollingTree::currentSnapPointIndicesDidChange): New method
to handle notifications about scroll snap index changes from the UIProcess.
* page/scrolling/ThreadedScrollingTree.h:
* page/scrolling/ios/ScrollingTreeIOS.cpp:
(WebCore::ScrollingTreeIOS::currentSnapPointIndicesDidChange): New method
to handle notifications about scroll snap index changes from the UIProcess.
* page/scrolling/ios/ScrollingTreeIOS.h:
* page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
(WebCore::ScrollingTreeFrameScrollingNodeMac::updateBeforeChildren): Update scroll
snap point current offset indices if they have changed.
(WebCore::ScrollingTreeFrameScrollingNodeMac::scrollOffsetOnAxis): Remove unneeded
PLATFORM(MAC) macro.
* platform/ScrollAnimator.cpp:
(WebCore::ScrollAnimator::ScrollAnimator): We have a ScrollController if we are
supporting scroll snap points or rubber banding.
(WebCore::ScrollAnimator::processWheelEventForScrollSnap): This method is not needed
for iOS builds.
(WebCore::ScrollAnimator::updateActiveScrollSnapIndexForOffset): Enable this on iOS.
(WebCore::ScrollAnimator::updateScrollSnapState): Renamed from 'updateScrollAnimatorsAndTimers'
and enabled on iOS.
(WebCore::ScrollAnimator::updateScrollAnimatorsAndTimers): Deleted.
* platform/ScrollAnimator.h: Enable some scroll snap methods on iOS.
* platform/ScrollableArea.cpp:
(WebCore::ScrollableArea::handleWheelEvent): Enable scroll snap index bookkeeping on iOS, too.
(WebCore::ScrollableArea::updateScrollSnapState): Revise to call 'updateScrollSnapState' instead
of 'updateScrollAnimatorsAndTimers'.
* platform/cocoa/ScrollController.h: Enable some methods on iOS. Reorder methods to
reduce the number of macros needed to do so.
* platform/cocoa/ScrollController.mm:
(systemUptime): Only build for Mac.
(WebCore::ScrollController::ScrollController): Disable rubber band-specific members on iOS.
(WebCore::ScrollController::handleWheelEvent): Only build this on Mac.
(WebCore::ScrollController::isRubberBandInProgress): Always return 'false' on iOS.
(WebCore::ScrollController::startSnapRubberbandTimer): Only build this on Mac.
(WebCore::ScrollController::shouldRubberBandInHorizontalDirection): Ditto.
(WebCore::ScrollController::scrollSnapPointState): Enable on iOS.
(WebCore::ScrollController::hasActiveScrollSnapTimerForAxis): Only build on Mac.
(WebCore::ScrollController::updateScrollSnapState): renamed from 'updateScrollAnimatorsAndTimers'
(WebCore::ScrollController::startScrollSnapTimer): Only build on Mac.
(WebCore::ScrollController::initializeGlideParameters): Ditto.
(WebCore::ScrollController::activeScrollSnapIndexForAxis): Enable on iOS.
(WebCore::ScrollController::setActiveScrollSnapIndicesForOffset): Ditto.
(WebCore::ScrollController::beginScrollSnapAnimation): Only build on Mac.
(WebCore::ScrollController::computeGlideDelta): Ditto.
(WebCore::ScrollController::updateScrollAnimatorsAndTimers): Deleted.
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::updateScrollCoordinatedLayer): Capture any changes in scroll
snap offset indices.

Source/WebKit2:

* Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp:
(ArgumentCoder<ScrollingStateScrollingNode>::encode): Handle scroll snap point offset indices.
(ArgumentCoder<ScrollingStateScrollingNode>::decode): Ditto.
* UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.cpp:
(WebKit::RemoteScrollingCoordinatorProxy::currentSnapPointIndicesDidChange): Added. Send message
to WebProcess when scroll snap indices have changed.
* UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h:
* UIProcess/Scrolling/RemoteScrollingTree.cpp:
(WebKit::RemoteScrollingTree::currentSnapPointIndicesDidChange): Added. Notify the
RemoteScrollingCoordinatorProxy when scroll snap indices have changed.
* UIProcess/Scrolling/RemoteScrollingTree.h:
* UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.h:
* UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm:
(-[WKOverflowScrollViewDelegate scrollViewWillEndDragging:withVelocity:targetContentOffset:]): Revised.
Identify changes in the current scroll snap point offset index (in either the horizontal or vertical
directions), and send a notification when this happens.
(WebKit::ScrollingTreeOverflowScrollingNodeIOS::currentSnapPointIndicesDidChange): Added. Notify the
Scrolling Tree when indices changed.
* UIProcess/ios/RemoteScrollingCoordinatorProxyIOS.mm:
(WebKit::RemoteScrollingCoordinatorProxy::adjustTargetContentOffsetForSnapping): Revised. Always compute
the new scroll snap offset index (even when we will rubber band).
* WebProcess/Scrolling/RemoteScrollingCoordinator.h:
* WebProcess/Scrolling/RemoteScrollingCoordinator.messages.in: Add a new message to relay changes in scroll
snap index.
* WebProcess/Scrolling/RemoteScrollingCoordinator.mm:
(WebKit::RemoteScrollingCoordinator::currentSnapPointIndicesChangedForNode): Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@185762 268f45cc-cd09-0410-ab3c-d52691b4dbfc
32 files changed:
Source/WebCore/ChangeLog
Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp
Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h
Source/WebCore/page/scrolling/ScrollingCoordinator.h
Source/WebCore/page/scrolling/ScrollingStateScrollingNode.cpp
Source/WebCore/page/scrolling/ScrollingStateScrollingNode.h
Source/WebCore/page/scrolling/ScrollingTree.h
Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.cpp
Source/WebCore/page/scrolling/ScrollingTreeScrollingNode.h
Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp
Source/WebCore/page/scrolling/ThreadedScrollingTree.h
Source/WebCore/page/scrolling/ios/ScrollingTreeIOS.cpp
Source/WebCore/page/scrolling/ios/ScrollingTreeIOS.h
Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm
Source/WebCore/platform/ScrollAnimator.cpp
Source/WebCore/platform/ScrollAnimator.h
Source/WebCore/platform/ScrollableArea.cpp
Source/WebCore/platform/cocoa/ScrollController.h
Source/WebCore/platform/cocoa/ScrollController.mm
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/Scrolling/RemoteScrollingCoordinatorTransaction.cpp
Source/WebKit2/UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.cpp
Source/WebKit2/UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h
Source/WebKit2/UIProcess/Scrolling/RemoteScrollingTree.cpp
Source/WebKit2/UIProcess/Scrolling/RemoteScrollingTree.h
Source/WebKit2/UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.h
Source/WebKit2/UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm
Source/WebKit2/UIProcess/ios/RemoteScrollingCoordinatorProxyIOS.mm
Source/WebKit2/WebProcess/Scrolling/RemoteScrollingCoordinator.h
Source/WebKit2/WebProcess/Scrolling/RemoteScrollingCoordinator.messages.in
Source/WebKit2/WebProcess/Scrolling/RemoteScrollingCoordinator.mm