<!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>[184439] trunk/Source/WebKit2</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/184439">184439</a></dd>
<dt>Author</dt> <dd>bfulgham@apple.com</dd>
<dt>Date</dt> <dd>2015-05-16 16:00:06 -0700 (Sat, 16 May 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>[iOS] Remote scrolling tree needs to coordinate scroll snap state during resize/rotations
https://bugs.webkit.org/show_bug.cgi?id=145059
&lt;rdar://problem/20975978&gt;

Reviewed by Simon Fraser.

The web view needs to update its scroll snap point offsets to take into account any
adjustments to the view size caused by content insets. We also need to update the
offstes after device rotation.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView scrollViewWillEndDragging:withVelocity:targetContentOffset:]): Retrieve the proper
computed content inset for the view and incorporate into any scroll snap point adjustments.
(-[WKWebView _updateVisibleContentRects]): If we have active scroll snap points, 
* UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h:
* UIProcess/ios/RemoteScrollingCoordinatorProxyIOS.mm:
(WebKit::RemoteScrollingCoordinatorProxy::adjustTargetContentOffsetForSnapping): Update to account
for content inset.
(WebKit::RemoteScrollingCoordinatorProxy::shouldSnapForMainFrameScrolling): Also validate that the
active index is valid.
(WebKit::RemoteScrollingCoordinatorProxy::closestSnapOffsetForMainFrameScrolling): Update to track
current active snap offset index.
(WebKit::RemoteScrollingCoordinatorProxy::hasActiveSnapPoint): Added.
(WebKit::RemoteScrollingCoordinatorProxy::nearestActiveSnapPoint): Added. It calculates the proper
scroll position incorporating any snap point and content insets.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm">trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessScrollingRemoteScrollingCoordinatorProxyh">trunk/Source/WebKit2/UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h</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="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (184438 => 184439)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-05-16 21:01:42 UTC (rev 184438)
+++ trunk/Source/WebKit2/ChangeLog        2015-05-16 23:00:06 UTC (rev 184439)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2015-05-16  Brent Fulgham  &lt;bfulgham@apple.com&gt;
+
+        [iOS] Remote scrolling tree needs to coordinate scroll snap state during resize/rotations
+        https://bugs.webkit.org/show_bug.cgi?id=145059
+        &lt;rdar://problem/20975978&gt;
+
+        Reviewed by Simon Fraser.
+
+        The web view needs to update its scroll snap point offsets to take into account any
+        adjustments to the view size caused by content insets. We also need to update the
+        offstes after device rotation.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView scrollViewWillEndDragging:withVelocity:targetContentOffset:]): Retrieve the proper
+        computed content inset for the view and incorporate into any scroll snap point adjustments.
+        (-[WKWebView _updateVisibleContentRects]): If we have active scroll snap points, 
+        * UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h:
+        * UIProcess/ios/RemoteScrollingCoordinatorProxyIOS.mm:
+        (WebKit::RemoteScrollingCoordinatorProxy::adjustTargetContentOffsetForSnapping): Update to account
+        for content inset.
+        (WebKit::RemoteScrollingCoordinatorProxy::shouldSnapForMainFrameScrolling): Also validate that the
+        active index is valid.
+        (WebKit::RemoteScrollingCoordinatorProxy::closestSnapOffsetForMainFrameScrolling): Update to track
+        current active snap offset index.
+        (WebKit::RemoteScrollingCoordinatorProxy::hasActiveSnapPoint): Added.
+        (WebKit::RemoteScrollingCoordinatorProxy::nearestActiveSnapPoint): Added. It calculates the proper
+        scroll position incorporating any snap point and content insets.
+
</ins><span class="cx"> 2015-05-15  Yongjun Zhang  &lt;yongjun_zhang@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Don't reset the preview recognizer in [WKContentViewInteraction cleanupInteraction]
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (184438 => 184439)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2015-05-16 21:01:42 UTC (rev 184438)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2015-05-16 23:00:06 UTC (rev 184439)
</span><span class="lines">@@ -1413,7 +1413,11 @@
</span><span class="cx">     if (WebKit::RemoteScrollingCoordinatorProxy* coordinator = _page-&gt;scrollingCoordinatorProxy()) {
</span><span class="cx">         // FIXME: Here, I'm finding the maximum horizontal/vertical scroll offsets. There's probably a better way to do this.
</span><span class="cx">         CGSize maxScrollOffsets = CGSizeMake(scrollView.contentSize.width - scrollView.bounds.size.width, scrollView.contentSize.height - scrollView.bounds.size.height);
</span><del>-        coordinator-&gt;adjustTargetContentOffsetForSnapping(maxScrollOffsets, velocity, targetContentOffset);
</del><ins>+        
+        CGRect fullViewRect = self.bounds;
+        CGRect unobscuredRect = UIEdgeInsetsInsetRect(fullViewRect, [self _computedContentInset]);
+        
+        coordinator-&gt;adjustTargetContentOffsetForSnapping(maxScrollOffsets, velocity, unobscuredRect.origin.y, targetContentOffset);
</ins><span class="cx">     }
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="lines">@@ -1533,6 +1537,26 @@
</span><span class="cx">     if (isStableState &amp;&amp; [_scrollView respondsToSelector:@selector(_isInterruptingDeceleration)])
</span><span class="cx">         isStableState = ![_scrollView performSelector:@selector(_isInterruptingDeceleration)];
</span><span class="cx"> 
</span><ins>+#if ENABLE(CSS_SCROLL_SNAP) &amp;&amp; ENABLE(ASYNC_SCROLLING)
+    if (isStableState) {
+        WebKit::RemoteScrollingCoordinatorProxy* coordinator = _page-&gt;scrollingCoordinatorProxy();
+        if (coordinator &amp;&amp; coordinator-&gt;hasActiveSnapPoint()) {
+            CGRect fullViewRect = self.bounds;
+            CGRect unobscuredRect = UIEdgeInsetsInsetRect(fullViewRect, [self _computedContentInset]);
+            
+            CGPoint currentPoint = [_scrollView contentOffset];
+            CGPoint activePoint = coordinator-&gt;nearestActiveContentInsetAdjustedSnapPoint(unobscuredRect.origin.y, currentPoint);
+
+            if (!CGPointEqualToPoint(activePoint, currentPoint)) {
+                RetainPtr&lt;WKScrollView&gt; strongScrollView = _scrollView;
+                dispatch_async(dispatch_get_main_queue(), [strongScrollView, activePoint] {
+                    [strongScrollView setContentOffset:activePoint animated:NO];
+                });
+            }
+        }
+    }
+#endif
+    
</ins><span class="cx">     [_contentView didUpdateVisibleRect:visibleRectInContentCoordinates
</span><span class="cx">         unobscuredRect:unobscuredRectInContentCoordinates
</span><span class="cx">         unobscuredRectInScrollViewCoordinates:unobscuredRect
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessScrollingRemoteScrollingCoordinatorProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h (184438 => 184439)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h        2015-05-16 21:01:42 UTC (rev 184438)
+++ trunk/Source/WebKit2/UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h        2015-05-16 23:00:06 UTC (rev 184439)
</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">@@ -85,7 +85,9 @@
</span><span class="cx">     void scrollingTreeNodeWillStartScroll();
</span><span class="cx">     void scrollingTreeNodeDidEndScroll();
</span><span class="cx"> #if ENABLE(CSS_SCROLL_SNAP)
</span><del>-    void adjustTargetContentOffsetForSnapping(CGSize maxScrollDimensions, CGPoint velocity, CGPoint* targetContentOffset) const;
</del><ins>+    void adjustTargetContentOffsetForSnapping(CGSize maxScrollDimensions, CGPoint velocity, CGFloat topInset, CGPoint* targetContentOffset);
+    bool hasActiveSnapPoint() const;
+    CGPoint nearestActiveContentInsetAdjustedSnapPoint(CGFloat topInset, const CGPoint&amp;) const;
</ins><span class="cx">     bool shouldSetScrollViewDecelerationRateFast() const;
</span><span class="cx"> #endif
</span><span class="cx"> #endif
</span><span class="lines">@@ -94,12 +96,16 @@
</span><span class="cx">     void connectStateNodeLayers(WebCore::ScrollingStateTree&amp;, const RemoteLayerTreeHost&amp;);
</span><span class="cx"> #if ENABLE(CSS_SCROLL_SNAP)
</span><span class="cx">     bool shouldSnapForMainFrameScrolling(WebCore::ScrollEventAxis) const;
</span><del>-    float closestSnapOffsetForMainFrameScrolling(WebCore::ScrollEventAxis, float scrollDestination, float velocity) const;
</del><ins>+    float closestSnapOffsetForMainFrameScrolling(WebCore::ScrollEventAxis, float scrollDestination, float velocity, unsigned&amp; closestIndex) const;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     WebPageProxy&amp; m_webPageProxy;
</span><span class="cx">     RefPtr&lt;RemoteScrollingTree&gt; m_scrollingTree;
</span><span class="cx">     RequestedScrollInfo* m_requestedScrollInfo;
</span><ins>+#if ENABLE(CSS_SCROLL_SNAP)
+    unsigned m_currentHorizontalSnapPointIndex { 0 };
+    unsigned m_currentVerticalSnapPointIndex { 0 };
+#endif
</ins><span class="cx">     bool m_propagatesMainFrameScrolls;
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosRemoteScrollingCoordinatorProxyIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/RemoteScrollingCoordinatorProxyIOS.mm (184438 => 184439)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/RemoteScrollingCoordinatorProxyIOS.mm        2015-05-16 21:01:42 UTC (rev 184438)
+++ trunk/Source/WebKit2/UIProcess/ios/RemoteScrollingCoordinatorProxyIOS.mm        2015-05-16 23:00:06 UTC (rev 184439)
</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">@@ -113,16 +113,17 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(CSS_SCROLL_SNAP)
</span><del>-void RemoteScrollingCoordinatorProxy::adjustTargetContentOffsetForSnapping(CGSize maxScrollOffsets, CGPoint velocity, CGPoint* targetContentOffset) const
</del><ins>+void RemoteScrollingCoordinatorProxy::adjustTargetContentOffsetForSnapping(CGSize maxScrollOffsets, CGPoint velocity, CGFloat topInset, CGPoint* targetContentOffset)
</ins><span class="cx"> {
</span><span class="cx">     // The bounds checking with maxScrollOffsets is to ensure that we won't interfere with rubber-banding when scrolling to the edge of the page.
</span><span class="cx">     if (shouldSnapForMainFrameScrolling(WebCore::ScrollEventAxis::Horizontal) &amp;&amp; targetContentOffset-&gt;x &gt; 0 &amp;&amp; targetContentOffset-&gt;x &lt; maxScrollOffsets.width) {
</span><del>-        float potentialSnapPosition = closestSnapOffsetForMainFrameScrolling(WebCore::ScrollEventAxis::Horizontal, targetContentOffset-&gt;x, velocity.x);
</del><ins>+        float potentialSnapPosition = closestSnapOffsetForMainFrameScrolling(WebCore::ScrollEventAxis::Horizontal, targetContentOffset-&gt;x, velocity.x, m_currentHorizontalSnapPointIndex);
</ins><span class="cx">         targetContentOffset-&gt;x = std::min&lt;float&gt;(maxScrollOffsets.width, potentialSnapPosition);
</span><span class="cx">     }
</span><del>-    // FIXME: We need to account for how the top navigation bar changes in size.
</del><ins>+
</ins><span class="cx">     if (shouldSnapForMainFrameScrolling(WebCore::ScrollEventAxis::Vertical) &amp;&amp; targetContentOffset-&gt;y &gt; 0 &amp;&amp; targetContentOffset-&gt;y &lt; maxScrollOffsets.height) {
</span><del>-        float potentialSnapPosition = closestSnapOffsetForMainFrameScrolling(WebCore::ScrollEventAxis::Vertical, targetContentOffset-&gt;y, velocity.y);
</del><ins>+        float potentialSnapPosition = closestSnapOffsetForMainFrameScrolling(WebCore::ScrollEventAxis::Vertical, targetContentOffset-&gt;y, velocity.y, m_currentVerticalSnapPointIndex);
+        potentialSnapPosition -= topInset;
</ins><span class="cx">         targetContentOffset-&gt;y = std::min&lt;float&gt;(maxScrollOffsets.height, potentialSnapPosition);
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="lines">@@ -138,23 +139,71 @@
</span><span class="cx">     if (root &amp;&amp; root-&gt;isFrameScrollingNode()) {
</span><span class="cx">         ScrollingTreeFrameScrollingNode* rootFrame = static_cast&lt;ScrollingTreeFrameScrollingNode*&gt;(root);
</span><span class="cx">         const Vector&lt;float&gt;&amp; snapOffsets = axis == ScrollEventAxis::Horizontal ? rootFrame-&gt;horizontalSnapOffsets() : rootFrame-&gt;verticalSnapOffsets();
</span><del>-        return snapOffsets.size() &gt; 0;
</del><ins>+        unsigned currentIndex = axis == ScrollEventAxis::Horizontal ? m_currentHorizontalSnapPointIndex : m_currentVerticalSnapPointIndex;
+        return (snapOffsets.size() &gt; 0) &amp;&amp; (currentIndex &lt; snapOffsets.size());
</ins><span class="cx">     }
</span><span class="cx">     return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-float RemoteScrollingCoordinatorProxy::closestSnapOffsetForMainFrameScrolling(ScrollEventAxis axis, float scrollDestination, float velocity) const
</del><ins>+float RemoteScrollingCoordinatorProxy::closestSnapOffsetForMainFrameScrolling(ScrollEventAxis axis, float scrollDestination, float velocity, unsigned&amp; currentIndex) const
</ins><span class="cx"> {
</span><span class="cx">     ScrollingTreeNode* root = m_scrollingTree-&gt;rootNode();
</span><span class="cx">     ASSERT(root &amp;&amp; root-&gt;isFrameScrollingNode());
</span><span class="cx">     ScrollingTreeFrameScrollingNode* rootFrame = static_cast&lt;ScrollingTreeFrameScrollingNode*&gt;(root);
</span><span class="cx">     const Vector&lt;float&gt;&amp; snapOffsets = axis == ScrollEventAxis::Horizontal ? rootFrame-&gt;horizontalSnapOffsets() : rootFrame-&gt;verticalSnapOffsets();
</span><span class="cx"> 
</span><del>-    unsigned ignore = 0;
</del><span class="cx">     float scaledScrollDestination = scrollDestination / m_webPageProxy.displayedContentScale();
</span><del>-    float rawClosestSnapOffset = closestSnapOffset&lt;float, float&gt;(snapOffsets, scaledScrollDestination, velocity, ignore);
</del><ins>+    float rawClosestSnapOffset = closestSnapOffset&lt;float, float&gt;(snapOffsets, scaledScrollDestination, velocity, currentIndex);
</ins><span class="cx">     return rawClosestSnapOffset * m_webPageProxy.displayedContentScale();
</span><span class="cx"> }
</span><ins>+
+bool RemoteScrollingCoordinatorProxy::hasActiveSnapPoint() const
+{
+    ScrollingTreeNode* root = m_scrollingTree-&gt;rootNode();
+    if (!root)
+        return false;
+
+    if (!is&lt;ScrollingTreeFrameScrollingNode&gt;(root))
+        return false;
+
+    ScrollingTreeFrameScrollingNode&amp; rootFrame = downcast&lt;ScrollingTreeFrameScrollingNode&gt;(*root);
+    const Vector&lt;float&gt;&amp; horizontal = rootFrame.horizontalSnapOffsets();
+    const Vector&lt;float&gt;&amp; vertical = rootFrame.verticalSnapOffsets();
+
+    if (horizontal.isEmpty() &amp;&amp; vertical.isEmpty())
+        return false;
+
+    if ((!horizontal.isEmpty() &amp;&amp; m_currentHorizontalSnapPointIndex &gt;= horizontal.size())
+        || (!vertical.isEmpty() &amp;&amp; m_currentVerticalSnapPointIndex &gt;= vertical.size())) {
+        return false;
+    }
+    
+    return true;
+}
+    
+CGPoint RemoteScrollingCoordinatorProxy::nearestActiveContentInsetAdjustedSnapPoint(CGFloat topInset, const CGPoint&amp; currentPoint) const
+{
+    CGPoint activePoint = currentPoint;
+
+    ScrollingTreeNode* root = m_scrollingTree-&gt;rootNode();
+    ASSERT(root &amp;&amp; is&lt;ScrollingTreeFrameScrollingNode&gt;(root));
+    ScrollingTreeFrameScrollingNode&amp; rootFrame = downcast&lt;ScrollingTreeFrameScrollingNode&gt;(*root);
+    const Vector&lt;float&gt;&amp; horizontal = rootFrame.horizontalSnapOffsets();
+    const Vector&lt;float&gt;&amp; vertical = rootFrame.verticalSnapOffsets();
+
+    // The bounds checking with maxScrollOffsets is to ensure that we won't interfere with rubber-banding when scrolling to the edge of the page.
+    if (!horizontal.isEmpty() &amp;&amp; m_currentHorizontalSnapPointIndex &lt; horizontal.size())
+        activePoint.x = horizontal[m_currentHorizontalSnapPointIndex] * m_webPageProxy.displayedContentScale();
+
+    if (!vertical.isEmpty() &amp;&amp; m_currentVerticalSnapPointIndex &lt; vertical.size()) {
+        float potentialSnapPosition = vertical[m_currentVerticalSnapPointIndex] * m_webPageProxy.displayedContentScale();
+        potentialSnapPosition -= topInset;
+        activePoint.y = potentialSnapPosition;
+    }
+
+    return activePoint;
+}
+
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre>
</div>
</div>

</body>
</html>