<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[184139] trunk/Source</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/184139">184139</a></dd>
<dt>Author</dt> <dd>bfulgham@apple.com</dd>
<dt>Date</dt> <dd>2015-05-11 18:12:01 -0700 (Mon, 11 May 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Scroll snap logic should be triggered when resizing the WebView
https://bugs.webkit.org/show_bug.cgi?id=142590
<rdar://problem/20125088>
Reviewed by Simon Fraser.
Source/WebCore:
Tests coming in a second patch.
Resizing of the main frame or overflow regions was properly recalculating the scroll snap points,
but there was no code to honor these values when window resizing was occurring. The correction was
handled in two ways:
1. Scrolling thread operations that moved to new snap points needed to notify the main thread that
it had shifted to a new snap point, so that the resize code (which happens on the main thread)
could ensure that we stayed clamped to the correct 'tile' in the snap region.
2. Main thread (overflow) resizes were likewise missing code to honor the current snap position
after resizing calculations were complete.
This change also required the addition of two indices to the scrollable area to track which scroll
snap point was currently being used. We don't bother with a 'none' case because you cannot have a
'none' state when you have an active set of scroll snap points, and we do not execute this code
if the scroll snap points are null.
The FrameView code was computing updated snap offsets after it had dispatched frame view layout
information to the scrolling thread, which was wrong. This was also corrected.
I think it might be possible to track all of this state inside the ScrollController, but the current
scroll snap architecture destroys and recreates the state each time a new set of interactions starts.
This should be fixed in the future, which would allow us to remove some of this local state.
* page/FrameView.cpp:
(WebCore::FrameView::performPostLayoutTasks): Make sure 'updateSnapOffsets' is called prior to
calling 'frameViewLayoutUpdated' so the scrolling thread gets correct updated points. Add a new
call to 'scrollToNearestActiveSnapPoint', which will keep us on our current snap point during
resize (if appropriate).
* page/scrolling/AsyncScrollingCoordinator.cpp:
(WebCore::AsyncScrollingCoordinator::updateScrollSnapOffsetIndices): Added. This finds and notifies
the correct scroll region when a new snap position (index) has been selected by user interaction on
the scrolling thread.
(WebCore::AsyncScrollingCoordinator::deferTestsForReason): Added an assertion for 'isMainThread'.
(WebCore::AsyncScrollingCoordinator::removeTestDeferralForReason): Ditto.
* page/scrolling/AsyncScrollingCoordinator.h:
* page/scrolling/AxisScrollSnapOffsets.h:
(WebCore::closestSnapOffset): Modified to also return the selected snap point index so we can track
it to handle resize operations.
* page/scrolling/ScrollingTree.h:
(WebCore::ScrollingTree::updateScrollSnapOffsetIndices):
* page/scrolling/ThreadedScrollingTree.cpp:
(WebCore::ThreadedScrollingTree::updateScrollSnapOffsetIndices): Added method to dispatch the active
horizontal and vertical scroll snap indices back to the main thread.
* page/scrolling/ThreadedScrollingTree.h:
* page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
(WebCore::ScrollingTreeFrameScrollingNodeMac::handleWheelEvent): After the scroll controller processes
the current event, notify the main thread of any change in the active scroll snap index.
* platform/ScrollAnimator.cpp:
(WebCore::ScrollAnimator::activeScrollSnapOffsetIndexDidChange): Added method to allow ScrollAnimator
clients to find out about the current scroll snap state, which is only known by the ScrollController.
(WebCore::ScrollAnimator::activeScrollSnapOffsetIndexForAxis): Ditto.
* platform/ScrollAnimator.h:
* platform/ScrollView.cpp:
(WebCore::ScrollView::scrollToNearestActiveSnapPoint): Added method that allows us to set scroll position
to one of our active scroll snap offsets.
* platform/ScrollView.h:
* platform/ScrollableArea.cpp:
(WebCore::ScrollableArea::handleWheelEvent): If the active scroll snap offset has changed, make sure we
keep track of the new values for potential resize operations.
(WebCore::ScrollableArea::clearHorizontalSnapOffsets): Make sure to also clear out the current snap index.
(WebCore::ScrollableArea::clearVerticalSnapOffsets): Ditto.
(WebCore::ScrollableArea::nearestActiveSnapPoint): New method that returns an updated IntPoint reflecting
the proper scroll position based on the active scroll snap offset.
* platform/ScrollableArea.h:
(WebCore::ScrollableArea::currentHorizontalSnapPointIndex): Added.
(WebCore::ScrollableArea::setCurrentHorizontalSnapPointIndex): Added.
(WebCore::ScrollableArea::currentVerticalSnapPointIndex): Added.
(WebCore::ScrollableArea::setCurrentVerticalSnapPointIndex): Added.
(WebCore::ScrollableArea::scrollToNearestActiveSnapPoint): Added.
* platform/cocoa/ScrollController.h:
(WebCore::ScrollControllerClient::activeScrollOffsetIndex): Added new method for clients to implement.
(WebCore::ScrollController::activeScrollSnapOffsetIndexDidChange): Added.
(WebCore::ScrollController::setScrollSnapOffsetIndexDidChange): Added.
* platform/cocoa/ScrollController.mm:
(WebCore::ScrollController::activeScrollSnapOffsetIndexForAxis): Helper method to return current active
index (if applicable).
(WebCore::ScrollController::setActiveScrollSnapOffsetIndexForAxis): Helper function to safely set
the current active index.
(WebCore::ScrollController::beginScrollSnapAnimation): Updated to keep track of the new active scroll snap
index, as well as whether the current animation actually changed the active snap point offset.
* platform/cocoa/ScrollSnapAnimatorState.h: Revise to use modern C++ initializers, and to track a new index
that represents the current scroll snap offset.
* platform/cocoa/ScrollSnapAnimatorState.mm:
(WebCore::ScrollSnapAnimatorState::ScrollSnapAnimatorState): Update for modern C++ syntax.
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::scrollToNearestActiveSnapPoint): New method to set scroll position to be one of our
active scroll snap points.
(WebCore::RenderLayer::updateScrollInfoAfterLayout): Add a new call to 'scrollToNearestActiveSnapPoint' so that
we stay on the current scroll snap offset during resizing.
* rendering/RenderLayer.h:
Source/WebKit2:
* UIProcess/ios/RemoteScrollingCoordinatorProxyIOS.mm:
(RemoteScrollingCoordinatorProxy::closestSnapOffsetForMainFrameScrolling): Modify use of 'closestSnapOffset' to satisfy the additional
argument I added. This is currently not used for anything on iOS.
* UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm: Ditto.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorepageFrameViewcpp">trunk/Source/WebCore/page/FrameView.cpp</a></li>
<li><a href="#trunkSourceWebCorepagescrollingAsyncScrollingCoordinatorcpp">trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp</a></li>
<li><a href="#trunkSourceWebCorepagescrollingAsyncScrollingCoordinatorh">trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h</a></li>
<li><a href="#trunkSourceWebCorepagescrollingAxisScrollSnapOffsetsh">trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.h</a></li>
<li><a href="#trunkSourceWebCorepagescrollingScrollingTreeh">trunk/Source/WebCore/page/scrolling/ScrollingTree.h</a></li>
<li><a href="#trunkSourceWebCorepagescrollingThreadedScrollingTreecpp">trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp</a></li>
<li><a href="#trunkSourceWebCorepagescrollingThreadedScrollingTreeh">trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.h</a></li>
<li><a href="#trunkSourceWebCorepagescrollingmacScrollingTreeFrameScrollingNodeMacmm">trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformScrollAnimatorcpp">trunk/Source/WebCore/platform/ScrollAnimator.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformScrollAnimatorh">trunk/Source/WebCore/platform/ScrollAnimator.h</a></li>
<li><a href="#trunkSourceWebCoreplatformScrollableAreacpp">trunk/Source/WebCore/platform/ScrollableArea.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformScrollableAreah">trunk/Source/WebCore/platform/ScrollableArea.h</a></li>
<li><a href="#trunkSourceWebCoreplatformcocoaScrollControllerh">trunk/Source/WebCore/platform/cocoa/ScrollController.h</a></li>
<li><a href="#trunkSourceWebCoreplatformcocoaScrollControllermm">trunk/Source/WebCore/platform/cocoa/ScrollController.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformcocoaScrollSnapAnimatorStateh">trunk/Source/WebCore/platform/cocoa/ScrollSnapAnimatorState.h</a></li>
<li><a href="#trunkSourceWebCoreplatformcocoaScrollSnapAnimatorStatemm">trunk/Source/WebCore/platform/cocoa/ScrollSnapAnimatorState.mm</a></li>
<li><a href="#trunkSourceWebCorerenderingRenderLayercpp">trunk/Source/WebCore/rendering/RenderLayer.cpp</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessScrollingiosScrollingTreeOverflowScrollingNodeIOSmm">trunk/Source/WebKit2/UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosRemoteScrollingCoordinatorProxyIOSmm">trunk/Source/WebKit2/UIProcess/ios/RemoteScrollingCoordinatorProxyIOS.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (184138 => 184139)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-05-12 01:06:59 UTC (rev 184138)
+++ trunk/Source/WebCore/ChangeLog        2015-05-12 01:12:01 UTC (rev 184139)
</span><span class="lines">@@ -1,3 +1,102 @@
</span><ins>+2015-05-11 Brent Fulgham <bfulgham@apple.com>
+
+ Scroll snap logic should be triggered when resizing the WebView
+ https://bugs.webkit.org/show_bug.cgi?id=142590
+ <rdar://problem/20125088>
+
+ Reviewed by Simon Fraser.
+
+ Tests coming in a second patch.
+
+ Resizing of the main frame or overflow regions was properly recalculating the scroll snap points,
+ but there was no code to honor these values when window resizing was occurring. The correction was
+ handled in two ways:
+ 1. Scrolling thread operations that moved to new snap points needed to notify the main thread that
+ it had shifted to a new snap point, so that the resize code (which happens on the main thread)
+ could ensure that we stayed clamped to the correct 'tile' in the snap region.
+ 2. Main thread (overflow) resizes were likewise missing code to honor the current snap position
+ after resizing calculations were complete.
+
+ This change also required the addition of two indices to the scrollable area to track which scroll
+ snap point was currently being used. We don't bother with a 'none' case because you cannot have a
+ 'none' state when you have an active set of scroll snap points, and we do not execute this code
+ if the scroll snap points are null.
+
+ The FrameView code was computing updated snap offsets after it had dispatched frame view layout
+ information to the scrolling thread, which was wrong. This was also corrected.
+
+ I think it might be possible to track all of this state inside the ScrollController, but the current
+ scroll snap architecture destroys and recreates the state each time a new set of interactions starts.
+ This should be fixed in the future, which would allow us to remove some of this local state.
+
+ * page/FrameView.cpp:
+ (WebCore::FrameView::performPostLayoutTasks): Make sure 'updateSnapOffsets' is called prior to
+ calling 'frameViewLayoutUpdated' so the scrolling thread gets correct updated points. Add a new
+ call to 'scrollToNearestActiveSnapPoint', which will keep us on our current snap point during
+ resize (if appropriate).
+ * page/scrolling/AsyncScrollingCoordinator.cpp:
+ (WebCore::AsyncScrollingCoordinator::updateScrollSnapOffsetIndices): Added. This finds and notifies
+ the correct scroll region when a new snap position (index) has been selected by user interaction on
+ the scrolling thread.
+ (WebCore::AsyncScrollingCoordinator::deferTestsForReason): Added an assertion for 'isMainThread'.
+ (WebCore::AsyncScrollingCoordinator::removeTestDeferralForReason): Ditto.
+ * page/scrolling/AsyncScrollingCoordinator.h:
+ * page/scrolling/AxisScrollSnapOffsets.h:
+ (WebCore::closestSnapOffset): Modified to also return the selected snap point index so we can track
+ it to handle resize operations.
+ * page/scrolling/ScrollingTree.h:
+ (WebCore::ScrollingTree::updateScrollSnapOffsetIndices):
+ * page/scrolling/ThreadedScrollingTree.cpp:
+ (WebCore::ThreadedScrollingTree::updateScrollSnapOffsetIndices): Added method to dispatch the active
+ horizontal and vertical scroll snap indices back to the main thread.
+ * page/scrolling/ThreadedScrollingTree.h:
+ * page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm:
+ (WebCore::ScrollingTreeFrameScrollingNodeMac::handleWheelEvent): After the scroll controller processes
+ the current event, notify the main thread of any change in the active scroll snap index.
+ * platform/ScrollAnimator.cpp:
+ (WebCore::ScrollAnimator::activeScrollSnapOffsetIndexDidChange): Added method to allow ScrollAnimator
+ clients to find out about the current scroll snap state, which is only known by the ScrollController.
+ (WebCore::ScrollAnimator::activeScrollSnapOffsetIndexForAxis): Ditto.
+ * platform/ScrollAnimator.h:
+ * platform/ScrollView.cpp:
+ (WebCore::ScrollView::scrollToNearestActiveSnapPoint): Added method that allows us to set scroll position
+ to one of our active scroll snap offsets.
+ * platform/ScrollView.h:
+ * platform/ScrollableArea.cpp:
+ (WebCore::ScrollableArea::handleWheelEvent): If the active scroll snap offset has changed, make sure we
+ keep track of the new values for potential resize operations.
+ (WebCore::ScrollableArea::clearHorizontalSnapOffsets): Make sure to also clear out the current snap index.
+ (WebCore::ScrollableArea::clearVerticalSnapOffsets): Ditto.
+ (WebCore::ScrollableArea::nearestActiveSnapPoint): New method that returns an updated IntPoint reflecting
+ the proper scroll position based on the active scroll snap offset.
+ * platform/ScrollableArea.h:
+ (WebCore::ScrollableArea::currentHorizontalSnapPointIndex): Added.
+ (WebCore::ScrollableArea::setCurrentHorizontalSnapPointIndex): Added.
+ (WebCore::ScrollableArea::currentVerticalSnapPointIndex): Added.
+ (WebCore::ScrollableArea::setCurrentVerticalSnapPointIndex): Added.
+ (WebCore::ScrollableArea::scrollToNearestActiveSnapPoint): Added.
+ * platform/cocoa/ScrollController.h:
+ (WebCore::ScrollControllerClient::activeScrollOffsetIndex): Added new method for clients to implement.
+ (WebCore::ScrollController::activeScrollSnapOffsetIndexDidChange): Added.
+ (WebCore::ScrollController::setScrollSnapOffsetIndexDidChange): Added.
+ * platform/cocoa/ScrollController.mm:
+ (WebCore::ScrollController::activeScrollSnapOffsetIndexForAxis): Helper method to return current active
+ index (if applicable).
+ (WebCore::ScrollController::setActiveScrollSnapOffsetIndexForAxis): Helper function to safely set
+ the current active index.
+ (WebCore::ScrollController::beginScrollSnapAnimation): Updated to keep track of the new active scroll snap
+ index, as well as whether the current animation actually changed the active snap point offset.
+ * platform/cocoa/ScrollSnapAnimatorState.h: Revise to use modern C++ initializers, and to track a new index
+ that represents the current scroll snap offset.
+ * platform/cocoa/ScrollSnapAnimatorState.mm:
+ (WebCore::ScrollSnapAnimatorState::ScrollSnapAnimatorState): Update for modern C++ syntax.
+ * rendering/RenderLayer.cpp:
+ (WebCore::RenderLayer::scrollToNearestActiveSnapPoint): New method to set scroll position to be one of our
+ active scroll snap points.
+ (WebCore::RenderLayer::updateScrollInfoAfterLayout): Add a new call to 'scrollToNearestActiveSnapPoint' so that
+ we stay on the current scroll snap offset during resizing.
+ * rendering/RenderLayer.h:
+
</ins><span class="cx"> 2015-05-11 Myles C. Maxfield <mmaxfield@apple.com>
</span><span class="cx">
</span><span class="cx"> Addressing post-review comments after r184037.
</span></span></pre></div>
<a id="trunkSourceWebCorepageFrameViewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/FrameView.cpp (184138 => 184139)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/FrameView.cpp        2015-05-12 01:06:59 UTC (rev 184138)
+++ trunk/Source/WebCore/page/FrameView.cpp        2015-05-12 01:12:01 UTC (rev 184139)
</span><span class="lines">@@ -2974,7 +2974,11 @@
</span><span class="cx"> frame().loader().client().dispatchDidLayout();
</span><span class="cx">
</span><span class="cx"> updateWidgetPositions();
</span><del>-
</del><ins>+
+#if ENABLE(CSS_SCROLL_SNAP)
+ updateSnapOffsets();
+#endif
+
</ins><span class="cx"> // layout() protects FrameView, but it still can get destroyed when updateEmbeddedObjects()
</span><span class="cx"> // is called through the post layout timer.
</span><span class="cx"> Ref<FrameView> protect(*this);
</span><span class="lines">@@ -2996,15 +3000,7 @@
</span><span class="cx"> sendResizeEventIfNeeded();
</span><span class="cx"> viewportContentsChanged();
</span><span class="cx">
</span><del>-#if ENABLE(CSS_SCROLL_SNAP)
- if (!frame().isMainFrame()) {
- updateSnapOffsets();
-#if PLATFORM(MAC)
- if (ScrollAnimator* scrollAnimator = existingScrollAnimator())
- return scrollAnimator->updateScrollAnimatorsAndTimers();
-#endif
- }
-#endif
</del><ins>+ updateScrollSnapState();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> IntSize FrameView::sizeForResizeEvent() const
</span></span></pre></div>
<a id="trunkSourceWebCorepagescrollingAsyncScrollingCoordinatorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp (184138 => 184139)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp        2015-05-12 01:06:59 UTC (rev 184138)
+++ trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.cpp        2015-05-12 01:12:01 UTC (rev 184139)
</span><span class="lines">@@ -562,8 +562,33 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(COCOA)
</span><ins>+void AsyncScrollingCoordinator::setActiveScrollSnapIndices(ScrollingNodeID scrollingNodeID, unsigned horizontalIndex, unsigned verticalIndex)
+{
+ ASSERT(isMainThread());
+
+ if (!m_page)
+ return;
+
+ FrameView* frameView = frameViewForScrollingNode(scrollingNodeID);
+ if (!frameView)
+ return;
+
+ if (scrollingNodeID == frameView->scrollLayerID()) {
+ frameView->setCurrentHorizontalSnapPointIndex(horizontalIndex);
+ frameView->setCurrentVerticalSnapPointIndex(verticalIndex);
+ return;
+ }
+
+ // Overflow-scroll area.
+ if (ScrollableArea* scrollableArea = frameView->scrollableAreaForScrollLayerID(scrollingNodeID)) {
+ scrollableArea->setCurrentHorizontalSnapPointIndex(horizontalIndex);
+ scrollableArea->setCurrentVerticalSnapPointIndex(verticalIndex);
+ }
+}
+
</ins><span class="cx"> void AsyncScrollingCoordinator::deferTestsForReason(WheelEventTestTrigger::ScrollableAreaIdentifier identifier, WheelEventTestTrigger::DeferTestTriggerReason reason) const
</span><span class="cx"> {
</span><ins>+ ASSERT(isMainThread());
</ins><span class="cx"> if (!m_page || !m_page->expectsWheelEventTriggers())
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="lines">@@ -575,6 +600,7 @@
</span><span class="cx">
</span><span class="cx"> void AsyncScrollingCoordinator::removeTestDeferralForReason(WheelEventTestTrigger::ScrollableAreaIdentifier identifier, WheelEventTestTrigger::DeferTestTriggerReason reason) const
</span><span class="cx"> {
</span><ins>+ ASSERT(isMainThread());
</ins><span class="cx"> if (!m_page || !m_page->expectsWheelEventTriggers())
</span><span class="cx"> return;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorepagescrollingAsyncScrollingCoordinatorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h (184138 => 184139)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h        2015-05-12 01:06:59 UTC (rev 184138)
+++ trunk/Source/WebCore/page/scrolling/AsyncScrollingCoordinator.h        2015-05-12 01:12:01 UTC (rev 184139)
</span><span class="lines">@@ -57,6 +57,7 @@
</span><span class="cx"> WEBCORE_EXPORT void scheduleUpdateScrollPositionAfterAsyncScroll(ScrollingNodeID, const FloatPoint&, bool programmaticScroll, SetOrSyncScrollingLayerPosition);
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(COCOA)
</span><ins>+ void setActiveScrollSnapIndices(ScrollingNodeID, unsigned horizontalIndex, unsigned verticalIndex);
</ins><span class="cx"> void deferTestsForReason(WheelEventTestTrigger::ScrollableAreaIdentifier, WheelEventTestTrigger::DeferTestTriggerReason) const;
</span><span class="cx"> void removeTestDeferralForReason(WheelEventTestTrigger::ScrollableAreaIdentifier, WheelEventTestTrigger::DeferTestTriggerReason) const;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCorepagescrollingAxisScrollSnapOffsetsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.h (184138 => 184139)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.h        2015-05-12 01:06:59 UTC (rev 184138)
+++ trunk/Source/WebCore/page/scrolling/AxisScrollSnapOffsets.h        2015-05-12 01:12:01 UTC (rev 184139)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2014 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2014-2015 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="cx"> * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -44,12 +44,14 @@
</span><span class="cx"> // as well as a VelocityType indicating the velocity (e.g. float, CGFloat, etc.) This function is templated because the UI process will now
</span><span class="cx"> // use pixel snapped floats to represent snap offsets rather than LayoutUnits.
</span><span class="cx"> template <typename LayoutType, typename VelocityType>
</span><del>-LayoutType closestSnapOffset(const Vector<LayoutType>& snapOffsets, LayoutType scrollDestination, VelocityType velocity)
</del><ins>+LayoutType closestSnapOffset(const Vector<LayoutType>& snapOffsets, LayoutType scrollDestination, VelocityType velocity, unsigned& activeSnapIndex)
</ins><span class="cx"> {
</span><span class="cx"> ASSERT(snapOffsets.size());
</span><ins>+ activeSnapIndex = 0;
</ins><span class="cx"> if (scrollDestination <= snapOffsets.first())
</span><span class="cx"> return snapOffsets.first();
</span><span class="cx">
</span><ins>+ activeSnapIndex = snapOffsets.size() - 1;
</ins><span class="cx"> if (scrollDestination >= snapOffsets.last())
</span><span class="cx"> return snapOffsets.last();
</span><span class="cx">
</span><span class="lines">@@ -70,10 +72,13 @@
</span><span class="cx"> LayoutType lowerSnapPosition = snapOffsets[lowerIndex];
</span><span class="cx"> LayoutType upperSnapPosition = snapOffsets[upperIndex];
</span><span class="cx"> // Nonzero velocity indicates a flick gesture. Even if another snap point is closer, snap to the one in the direction of the flick gesture.
</span><del>- if (velocity)
</del><ins>+ if (velocity) {
+ activeSnapIndex = (velocity < 0) ? lowerIndex : upperIndex;
</ins><span class="cx"> return velocity < 0 ? lowerSnapPosition : upperSnapPosition;
</span><ins>+ }
</ins><span class="cx">
</span><span class="cx"> bool isCloserToLowerSnapPosition = scrollDestination - lowerSnapPosition <= upperSnapPosition - scrollDestination;
</span><ins>+ activeSnapIndex = isCloserToLowerSnapPosition ? lowerIndex : upperIndex;
</ins><span class="cx"> return isCloserToLowerSnapPosition ? lowerSnapPosition : upperSnapPosition;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorepagescrollingScrollingTreeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/scrolling/ScrollingTree.h (184138 => 184139)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/scrolling/ScrollingTree.h        2015-05-12 01:06:59 UTC (rev 184138)
+++ trunk/Source/WebCore/page/scrolling/ScrollingTree.h        2015-05-12 01:12:01 UTC (rev 184139)
</span><span class="lines">@@ -100,6 +100,7 @@
</span><span class="cx">
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx"> virtual void handleWheelEventPhase(PlatformWheelEventPhase) = 0;
</span><ins>+ virtual void setActiveScrollSnapIndices(ScrollingNodeID, unsigned /*horizontalIndex*/, unsigned /*verticalIndex*/) { }
</ins><span class="cx"> virtual void deferTestsForReason(WheelEventTestTrigger::ScrollableAreaIdentifier, WheelEventTestTrigger::DeferTestTriggerReason) { }
</span><span class="cx"> virtual void removeTestDeferralForReason(WheelEventTestTrigger::ScrollableAreaIdentifier, WheelEventTestTrigger::DeferTestTriggerReason) { }
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCorepagescrollingThreadedScrollingTreecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp (184138 => 184139)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp        2015-05-12 01:06:59 UTC (rev 184138)
+++ trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.cpp        2015-05-12 01:12:01 UTC (rev 184139)
</span><span class="lines">@@ -123,6 +123,17 @@
</span><span class="cx"> });
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void ThreadedScrollingTree::setActiveScrollSnapIndices(ScrollingNodeID nodeID, unsigned horizontalIndex, unsigned verticalIndex)
+{
+ if (!m_scrollingCoordinator)
+ return;
+
+ RefPtr<AsyncScrollingCoordinator> scrollingCoordinator = m_scrollingCoordinator;
+ RunLoop::main().dispatch([scrollingCoordinator, nodeID, horizontalIndex, verticalIndex] {
+ scrollingCoordinator->setActiveScrollSnapIndices(nodeID, horizontalIndex, verticalIndex);
+ });
+}
+
</ins><span class="cx"> void ThreadedScrollingTree::deferTestsForReason(WheelEventTestTrigger::ScrollableAreaIdentifier identifier, WheelEventTestTrigger::DeferTestTriggerReason reason)
</span><span class="cx"> {
</span><span class="cx"> if (!m_scrollingCoordinator)
</span></span></pre></div>
<a id="trunkSourceWebCorepagescrollingThreadedScrollingTreeh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.h (184138 => 184139)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.h        2015-05-12 01:06:59 UTC (rev 184138)
+++ trunk/Source/WebCore/page/scrolling/ThreadedScrollingTree.h        2015-05-12 01:12:01 UTC (rev 184139)
</span><span class="lines">@@ -62,6 +62,7 @@
</span><span class="cx"> virtual void scrollingTreeNodeDidScroll(ScrollingNodeID, const FloatPoint& scrollPosition, SetOrSyncScrollingLayerPosition = SyncScrollingLayerPosition) override;
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx"> void handleWheelEventPhase(PlatformWheelEventPhase) override;
</span><ins>+ void setActiveScrollSnapIndices(ScrollingNodeID, unsigned horizontalIndex, unsigned verticalIndex) override;
</ins><span class="cx"> void deferTestsForReason(WheelEventTestTrigger::ScrollableAreaIdentifier, WheelEventTestTrigger::DeferTestTriggerReason) override;
</span><span class="cx"> void removeTestDeferralForReason(WheelEventTestTrigger::ScrollableAreaIdentifier, WheelEventTestTrigger::DeferTestTriggerReason) override;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCorepagescrollingmacScrollingTreeFrameScrollingNodeMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm (184138 => 184139)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm        2015-05-12 01:06:59 UTC (rev 184138)
+++ trunk/Source/WebCore/page/scrolling/mac/ScrollingTreeFrameScrollingNodeMac.mm        2015-05-12 01:12:01 UTC (rev 184139)
</span><span class="lines">@@ -184,6 +184,10 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> m_scrollController.handleWheelEvent(wheelEvent);
</span><ins>+#if ENABLE(CSS_SCROLL_SNAP)
+ if (m_scrollController.activeScrollSnapIndexDidChange())
+ scrollingTree().setActiveScrollSnapIndices(scrollingNodeID(), m_scrollController.activeScrollSnapIndexForAxis(ScrollEventAxis::Horizontal), m_scrollController.activeScrollSnapIndexForAxis(ScrollEventAxis::Vertical));
+#endif
</ins><span class="cx"> scrollingTree().setOrClearLatchedNode(wheelEvent, scrollingNodeID());
</span><span class="cx"> scrollingTree().handleWheelEventPhase(wheelEvent.phase());
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformScrollAnimatorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ScrollAnimator.cpp (184138 => 184139)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ScrollAnimator.cpp        2015-05-12 01:06:59 UTC (rev 184138)
+++ trunk/Source/WebCore/platform/ScrollAnimator.cpp        2015-05-12 01:12:01 UTC (rev 184139)
</span><span class="lines">@@ -87,6 +87,16 @@
</span><span class="cx"> {
</span><span class="cx"> return m_scrollController.processWheelEventForScrollSnap(wheelEvent);
</span><span class="cx"> }
</span><ins>+
+bool ScrollAnimator::activeScrollSnapIndexDidChange() const
+{
+ return m_scrollController.activeScrollSnapIndexDidChange();
+}
+
+unsigned ScrollAnimator::activeScrollSnapIndexForAxis(ScrollEventAxis axis) const
+{
+ return m_scrollController.activeScrollSnapIndexForAxis(axis);
+}
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> bool ScrollAnimator::handleWheelEvent(const PlatformWheelEvent& e)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformScrollAnimatorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ScrollAnimator.h (184138 => 184139)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ScrollAnimator.h        2015-05-12 01:06:59 UTC (rev 184138)
+++ trunk/Source/WebCore/platform/ScrollAnimator.h        2015-05-12 01:12:01 UTC (rev 184139)
</span><span class="lines">@@ -130,6 +130,8 @@
</span><span class="cx"> void updateScrollAnimatorsAndTimers();
</span><span class="cx"> LayoutUnit scrollOffsetOnAxis(ScrollEventAxis) const override;
</span><span class="cx"> void immediateScrollOnAxis(ScrollEventAxis, float delta) override;
</span><ins>+ bool activeScrollSnapIndexDidChange() const;
+ unsigned activeScrollSnapIndexForAxis(ScrollEventAxis) const;
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> protected:
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformScrollableAreacpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ScrollableArea.cpp (184138 => 184139)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ScrollableArea.cpp        2015-05-12 01:06:59 UTC (rev 184138)
+++ trunk/Source/WebCore/platform/ScrollableArea.cpp        2015-05-12 01:12:01 UTC (rev 184139)
</span><span class="lines">@@ -46,6 +46,7 @@
</span><span class="cx"> virtual ~SameSizeAsScrollableArea();
</span><span class="cx"> #if ENABLE(CSS_SCROLL_SNAP)
</span><span class="cx"> void* pointers[3];
</span><ins>+ unsigned currentIndices[2];
</ins><span class="cx"> #else
</span><span class="cx"> void* pointer;
</span><span class="cx"> #endif
</span><span class="lines">@@ -188,7 +189,14 @@
</span><span class="cx"> if (!isScrollableOrRubberbandable())
</span><span class="cx"> return false;
</span><span class="cx">
</span><del>- return scrollAnimator().handleWheelEvent(wheelEvent);
</del><ins>+ bool handledEvent = scrollAnimator().handleWheelEvent(wheelEvent);
+#if ENABLE(CSS_SCROLL_SNAP) && PLATFORM(MAC)
+ if (scrollAnimator().activeScrollSnapIndexDidChange()) {
+ setCurrentHorizontalSnapPointIndex(scrollAnimator().activeScrollSnapIndexForAxis(ScrollEventAxis::Horizontal));
+ setCurrentVerticalSnapPointIndex(scrollAnimator().activeScrollSnapIndexForAxis(ScrollEventAxis::Vertical));
+ }
+#endif
+ return handledEvent;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if ENABLE(TOUCH_EVENTS)
</span><span class="lines">@@ -409,14 +417,64 @@
</span><span class="cx"> void ScrollableArea::clearHorizontalSnapOffsets()
</span><span class="cx"> {
</span><span class="cx"> m_horizontalSnapOffsets = nullptr;
</span><ins>+ m_currentHorizontalSnapPointIndex = 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void ScrollableArea::clearVerticalSnapOffsets()
</span><span class="cx"> {
</span><span class="cx"> m_verticalSnapOffsets = nullptr;
</span><ins>+ m_currentVerticalSnapPointIndex = 0;
</ins><span class="cx"> }
</span><ins>+
+IntPoint ScrollableArea::nearestActiveSnapPoint(const IntPoint& currentPosition)
+{
+ if (!horizontalSnapOffsets() && !verticalSnapOffsets())
+ return currentPosition;
+
+ if (!existingScrollAnimator())
+ return currentPosition;
+
+ IntPoint correctedPosition = currentPosition;
+
+ if (horizontalSnapOffsets()) {
+ const auto& horizontal = *horizontalSnapOffsets();
+
+ size_t activeIndex = currentHorizontalSnapPointIndex();
+ if (activeIndex < horizontal.size())
+ correctedPosition.setX(horizontal[activeIndex].toInt());
+ }
+
+ if (verticalSnapOffsets()) {
+ const auto& vertical = *verticalSnapOffsets();
+
+ size_t activeIndex = currentVerticalSnapPointIndex();
+ if (activeIndex < vertical.size())
+ correctedPosition.setY(vertical[activeIndex].toInt());
+ }
+
+ return correctedPosition;
+}
+
+void ScrollableArea::updateScrollSnapState()
+{
+#if PLATFORM(MAC)
+ if (ScrollAnimator* scrollAnimator = existingScrollAnimator())
+ scrollAnimator->updateScrollAnimatorsAndTimers();
</ins><span class="cx"> #endif
</span><span class="cx">
</span><ins>+ IntPoint currentPosition = scrollPosition();
+ IntPoint correctedPosition = nearestActiveSnapPoint(currentPosition);
+
+ if (correctedPosition != currentPosition)
+ scrollToOffsetWithoutAnimation(correctedPosition);
+}
+#else
+void ScrollableArea::updateScrollSnapState()
+{
+}
+#endif
+
+
</ins><span class="cx"> void ScrollableArea::serviceScrollAnimations()
</span><span class="cx"> {
</span><span class="cx"> if (ScrollAnimator* scrollAnimator = existingScrollAnimator())
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformScrollableAreah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/ScrollableArea.h (184138 => 184139)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ScrollableArea.h        2015-05-12 01:06:59 UTC (rev 184138)
+++ trunk/Source/WebCore/platform/ScrollableArea.h        2015-05-12 01:12:01 UTC (rev 184139)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2008, 2011, 2014 Apple Inc. All Rights Reserved.
</del><ins>+ * Copyright (C) 2008, 2011, 2014-2015 Apple Inc. All Rights Reserved.
</ins><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="cx"> * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -66,8 +66,15 @@
</span><span class="cx"> void setVerticalSnapOffsets(std::unique_ptr<Vector<LayoutUnit>>);
</span><span class="cx"> void clearHorizontalSnapOffsets();
</span><span class="cx"> void clearVerticalSnapOffsets();
</span><ins>+ unsigned currentHorizontalSnapPointIndex() const { return m_currentHorizontalSnapPointIndex; }
+ void setCurrentHorizontalSnapPointIndex(unsigned index) { m_currentHorizontalSnapPointIndex = index; }
+ unsigned currentVerticalSnapPointIndex() const { return m_currentVerticalSnapPointIndex; }
+ void setCurrentVerticalSnapPointIndex(unsigned index) { m_currentVerticalSnapPointIndex = index; }
+ IntPoint nearestActiveSnapPoint(const IntPoint&);
</ins><span class="cx"> #endif
</span><span class="cx">
</span><ins>+ void updateScrollSnapState();
+
</ins><span class="cx"> #if ENABLE(TOUCH_EVENTS)
</span><span class="cx"> virtual bool isTouchScrollable() const { return false; }
</span><span class="cx"> virtual bool handleTouchEvent(const PlatformTouchEvent&);
</span><span class="lines">@@ -305,6 +312,8 @@
</span><span class="cx"> #if ENABLE(CSS_SCROLL_SNAP)
</span><span class="cx"> std::unique_ptr<Vector<LayoutUnit>> m_horizontalSnapOffsets;
</span><span class="cx"> std::unique_ptr<Vector<LayoutUnit>> m_verticalSnapOffsets;
</span><ins>+ unsigned m_currentHorizontalSnapPointIndex { 0 };
+ unsigned m_currentVerticalSnapPointIndex { 0 };
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> // There are 8 possible combinations of writing mode and direction. Scroll origin will be non-zero in the x or y axis
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaScrollControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/cocoa/ScrollController.h (184138 => 184139)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/ScrollController.h        2015-05-12 01:06:59 UTC (rev 184138)
+++ trunk/Source/WebCore/platform/cocoa/ScrollController.h        2015-05-12 01:12:01 UTC (rev 184139)
</span><span class="lines">@@ -97,6 +97,11 @@
</span><span class="cx"> {
</span><span class="cx"> return 1.0f;
</span><span class="cx"> }
</span><ins>+
+ virtual unsigned activeScrollOffsetIndex(ScrollEventAxis) const
+ {
+ return 0;
+ }
</ins><span class="cx"> #endif
</span><span class="cx"> };
</span><span class="cx">
</span><span class="lines">@@ -114,6 +119,10 @@
</span><span class="cx"> bool processWheelEventForScrollSnap(const PlatformWheelEvent&);
</span><span class="cx"> void updateScrollAnimatorsAndTimers(const ScrollableArea&);
</span><span class="cx"> void updateScrollSnapPoints(ScrollEventAxis, const Vector<LayoutUnit>&);
</span><ins>+ unsigned activeScrollSnapIndexForAxis(ScrollEventAxis) const;
+ void setActiveScrollSnapIndexForAxis(ScrollEventAxis, unsigned);
+ bool activeScrollSnapIndexDidChange() const { return m_activeScrollSnapIndexDidChange; }
+ void setScrollSnapIndexDidChange(bool state) { m_activeScrollSnapIndexDidChange = state; }
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> private:
</span><span class="lines">@@ -172,6 +181,7 @@
</span><span class="cx"> bool m_momentumScrollInProgress { false };
</span><span class="cx"> bool m_ignoreMomentumScrolls { false };
</span><span class="cx"> bool m_snapRubberbandTimerIsActive { false };
</span><ins>+ bool m_activeScrollSnapIndexDidChange { false };
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaScrollControllermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/cocoa/ScrollController.mm (184138 => 184139)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/ScrollController.mm        2015-05-12 01:06:59 UTC (rev 184138)
+++ trunk/Source/WebCore/platform/cocoa/ScrollController.mm        2015-05-12 01:12:01 UTC (rev 184139)
</span><span class="lines">@@ -685,6 +685,26 @@
</span><span class="cx"> snapState.m_glidePhaseShift = acos((snapState.m_glideInitialWheelDelta - targetFinalWheelDelta) / (snapState.m_glideInitialWheelDelta + targetFinalWheelDelta));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+unsigned ScrollController::activeScrollSnapIndexForAxis(ScrollEventAxis axis) const
+{
+ if ((axis == ScrollEventAxis::Horizontal) && !m_horizontalScrollSnapState)
+ return 0;
+ if ((axis == ScrollEventAxis::Vertical) && !m_verticalScrollSnapState)
+ return 0;
+
+ const ScrollSnapAnimatorState& snapState = scrollSnapPointState(axis);
+ return snapState.m_activeSnapIndex;
+}
+
+void ScrollController::setActiveScrollSnapIndexForAxis(ScrollEventAxis axis, unsigned index)
+{
+ auto* snapState = (axis == ScrollEventAxis::Horizontal) ? m_horizontalScrollSnapState.get() : m_verticalScrollSnapState.get();
+ if (!snapState)
+ return;
+
+ snapState->m_activeSnapIndex = index;
+}
+
</ins><span class="cx"> void ScrollController::beginScrollSnapAnimation(ScrollEventAxis axis, ScrollSnapState newState)
</span><span class="cx"> {
</span><span class="cx"> ASSERT(newState == ScrollSnapState::Gliding || newState == ScrollSnapState::Snapping);
</span><span class="lines">@@ -701,10 +721,12 @@
</span><span class="cx">
</span><span class="cx"> projectedScrollDestination = std::min(std::max(LayoutUnit(projectedScrollDestination / scaleFactor), snapState.m_snapOffsets.first()), snapState.m_snapOffsets.last());
</span><span class="cx"> snapState.m_initialOffset = offset;
</span><del>- snapState.m_targetOffset = scaleFactor * closestSnapOffset<LayoutUnit, float>(snapState.m_snapOffsets, projectedScrollDestination, initialWheelDelta);
</del><ins>+ m_activeScrollSnapIndexDidChange = false;
+ snapState.m_targetOffset = scaleFactor * closestSnapOffset<LayoutUnit, float>(snapState.m_snapOffsets, projectedScrollDestination, initialWheelDelta, snapState.m_activeSnapIndex);
</ins><span class="cx"> if (snapState.m_initialOffset == snapState.m_targetOffset)
</span><span class="cx"> return;
</span><span class="cx">
</span><ins>+ m_activeScrollSnapIndexDidChange = true;
</ins><span class="cx"> snapState.m_currentState = newState;
</span><span class="cx"> if (newState == ScrollSnapState::Gliding) {
</span><span class="cx"> snapState.m_shouldOverrideWheelEvent = true;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaScrollSnapAnimatorStateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/cocoa/ScrollSnapAnimatorState.h (184138 => 184139)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/ScrollSnapAnimatorState.h        2015-05-12 01:06:59 UTC (rev 184138)
+++ trunk/Source/WebCore/platform/cocoa/ScrollSnapAnimatorState.h        2015-05-12 01:12:01 UTC (rev 184139)
</span><span class="lines">@@ -59,12 +59,13 @@
</span><span class="cx"> LayoutUnit m_targetOffset;
</span><span class="cx"> // Used to track gliding behavior.
</span><span class="cx"> LayoutUnit m_beginTrackingWheelDeltaOffset;
</span><del>- int m_numWheelDeltasTracked;
</del><ins>+ int m_numWheelDeltasTracked { 0 };
+ unsigned m_activeSnapIndex { 0 };
</ins><span class="cx"> float m_wheelDeltaWindow[wheelDeltaWindowSize];
</span><del>- float m_glideMagnitude;
- float m_glidePhaseShift;
- float m_glideInitialWheelDelta;
- bool m_shouldOverrideWheelEvent;
</del><ins>+ float m_glideMagnitude { 0 };
+ float m_glidePhaseShift { 0 };
+ float m_glideInitialWheelDelta { 0 };
+ bool m_shouldOverrideWheelEvent { false };
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformcocoaScrollSnapAnimatorStatemm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/cocoa/ScrollSnapAnimatorState.mm (184138 => 184139)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/cocoa/ScrollSnapAnimatorState.mm        2015-05-12 01:06:59 UTC (rev 184138)
+++ trunk/Source/WebCore/platform/cocoa/ScrollSnapAnimatorState.mm        2015-05-12 01:12:01 UTC (rev 184139)
</span><span class="lines">@@ -37,11 +37,6 @@
</span><span class="cx"> , m_initialOffset(0)
</span><span class="cx"> , m_targetOffset(0)
</span><span class="cx"> , m_beginTrackingWheelDeltaOffset(0)
</span><del>- , m_numWheelDeltasTracked(0)
- , m_glideMagnitude(0)
- , m_glidePhaseShift(0)
- , m_glideInitialWheelDelta(0)
- , m_shouldOverrideWheelEvent(false)
</del><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCorerenderingRenderLayercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (184138 => 184139)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/rendering/RenderLayer.cpp        2015-05-12 01:06:59 UTC (rev 184138)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp        2015-05-12 01:12:01 UTC (rev 184139)
</span><span class="lines">@@ -3461,6 +3461,12 @@
</span><span class="cx">
</span><span class="cx"> computeScrollDimensions();
</span><span class="cx">
</span><ins>+#if ENABLE(CSS_SCROLL_SNAP)
+ // FIXME: Ensure that offsets are also updated in case of programmatic style changes.
+ // https://bugs.webkit.org/show_bug.cgi?id=135964
+ updateSnapOffsets();
+#endif
+
</ins><span class="cx"> if (box->style().overflowX() != OMARQUEE && !isRubberBandInProgress()) {
</span><span class="cx"> // Layout may cause us to be at an invalid scroll position. In this case we need
</span><span class="cx"> // to pull our scroll offsets back to the max (or push them up to the min).
</span><span class="lines">@@ -3488,15 +3494,7 @@
</span><span class="cx"> if (compositor().updateLayerCompositingState(*this))
</span><span class="cx"> compositor().setCompositingLayersNeedRebuild();
</span><span class="cx">
</span><del>-#if ENABLE(CSS_SCROLL_SNAP)
- // FIXME: Ensure that offsets are also updated in case of programmatic style changes.
- // https://bugs.webkit.org/show_bug.cgi?id=135964
- updateSnapOffsets();
-#if PLATFORM(MAC)
- if (ScrollAnimator* scrollAnimator = existingScrollAnimator())
- return scrollAnimator->updateScrollAnimatorsAndTimers();
-#endif
-#endif
</del><ins>+ updateScrollSnapState();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool RenderLayer::overflowControlsIntersectRect(const IntRect& localRect) const
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (184138 => 184139)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-05-12 01:06:59 UTC (rev 184138)
+++ trunk/Source/WebKit2/ChangeLog        2015-05-12 01:12:01 UTC (rev 184139)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2015-05-11 Brent Fulgham <bfulgham@apple.com>
+
+ Scroll snap logic should be triggered when resizing the WebView
+ https://bugs.webkit.org/show_bug.cgi?id=142590
+ <rdar://problem/20125088>
+
+ Reviewed by Simon Fraser.
+
+ * UIProcess/ios/RemoteScrollingCoordinatorProxyIOS.mm:
+ (RemoteScrollingCoordinatorProxy::closestSnapOffsetForMainFrameScrolling): Modify use of 'closestSnapOffset' to satisfy the additional
+ argument I added. This is currently not used for anything on iOS.
+ * UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm: Ditto.
+
</ins><span class="cx"> 2015-05-11 Andreas Kling <akling@apple.com>
</span><span class="cx">
</span><span class="cx"> Force a rebuild of JSNPObject.cpp on bots.
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessScrollingiosScrollingTreeOverflowScrollingNodeIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm (184138 => 184139)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm        2015-05-12 01:06:59 UTC (rev 184138)
+++ trunk/Source/WebKit2/UIProcess/Scrolling/ios/ScrollingTreeOverflowScrollingNodeIOS.mm        2015-05-12 01:12:01 UTC (rev 184139)
</span><span class="lines">@@ -80,10 +80,11 @@
</span><span class="cx"> #if ENABLE(CSS_SCROLL_SNAP)
</span><span class="cx"> - (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset
</span><span class="cx"> {
</span><ins>+ unsigned ignore;
</ins><span class="cx"> if (!_scrollingTreeNode->horizontalSnapOffsets().isEmpty())
</span><del>- targetContentOffset->x = closestSnapOffset<float, CGFloat>(_scrollingTreeNode->horizontalSnapOffsets(), targetContentOffset->x, velocity.x);
</del><ins>+ targetContentOffset->x = closestSnapOffset<float, CGFloat>(_scrollingTreeNode->horizontalSnapOffsets(), targetContentOffset->x, velocity.x, ignore);
</ins><span class="cx"> if (!_scrollingTreeNode->verticalSnapOffsets().isEmpty())
</span><del>- targetContentOffset->y = closestSnapOffset<float, CGFloat>(_scrollingTreeNode->verticalSnapOffsets(), targetContentOffset->y, velocity.y);
</del><ins>+ targetContentOffset->y = closestSnapOffset<float, CGFloat>(_scrollingTreeNode->verticalSnapOffsets(), targetContentOffset->y, velocity.y, ignore);
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosRemoteScrollingCoordinatorProxyIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/RemoteScrollingCoordinatorProxyIOS.mm (184138 => 184139)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/RemoteScrollingCoordinatorProxyIOS.mm        2015-05-12 01:06:59 UTC (rev 184138)
+++ trunk/Source/WebKit2/UIProcess/ios/RemoteScrollingCoordinatorProxyIOS.mm        2015-05-12 01:12:01 UTC (rev 184139)
</span><span class="lines">@@ -150,8 +150,9 @@
</span><span class="cx"> ScrollingTreeFrameScrollingNode* rootFrame = static_cast<ScrollingTreeFrameScrollingNode*>(root);
</span><span class="cx"> const Vector<float>& snapOffsets = axis == ScrollEventAxis::Horizontal ? rootFrame->horizontalSnapOffsets() : rootFrame->verticalSnapOffsets();
</span><span class="cx">
</span><ins>+ unsigned ignore = 0;
</ins><span class="cx"> float scaledScrollDestination = scrollDestination / m_webPageProxy.displayedContentScale();
</span><del>- float rawClosestSnapOffset = closestSnapOffset<float, float>(snapOffsets, scaledScrollDestination, velocity);
</del><ins>+ float rawClosestSnapOffset = closestSnapOffset<float, float>(snapOffsets, scaledScrollDestination, velocity, ignore);
</ins><span class="cx"> return rawClosestSnapOffset * m_webPageProxy.displayedContentScale();
</span><span class="cx"> }
</span><span class="cx"> #endif
</span></span></pre>
</div>
</div>
</body>
</html>