<!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>[184572] branches/safari-601.1.32.2-branch/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/184572">184572</a></dd>
<dt>Author</dt> <dd>matthew_hanson@apple.com</dd>
<dt>Date</dt> <dd>2015-05-19 09:46:43 -0700 (Tue, 19 May 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/184439">r184439</a>. rdar://problem/20975978</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari6011322branchSourceWebKit2ChangeLog">branches/safari-601.1.32.2-branch/Source/WebKit2/ChangeLog</a></li>
<li><a href="#branchessafari6011322branchSourceWebKit2UIProcessAPICocoaWKWebViewmm">branches/safari-601.1.32.2-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm</a></li>
<li><a href="#branchessafari6011322branchSourceWebKit2UIProcessScrollingRemoteScrollingCoordinatorProxyh">branches/safari-601.1.32.2-branch/Source/WebKit2/UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h</a></li>
<li><a href="#branchessafari6011322branchSourceWebKit2UIProcessiosRemoteScrollingCoordinatorProxyIOSmm">branches/safari-601.1.32.2-branch/Source/WebKit2/UIProcess/ios/RemoteScrollingCoordinatorProxyIOS.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari6011322branchSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.32.2-branch/Source/WebKit2/ChangeLog (184571 => 184572)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.32.2-branch/Source/WebKit2/ChangeLog        2015-05-19 16:46:40 UTC (rev 184571)
+++ branches/safari-601.1.32.2-branch/Source/WebKit2/ChangeLog        2015-05-19 16:46:43 UTC (rev 184572)
</span><span class="lines">@@ -1,5 +1,37 @@
</span><span class="cx"> 2015-05-18 Matthew Hanson <matthew_hanson@apple.com>
</span><span class="cx">
</span><ins>+ Merge r184439. rdar://problem/20975978
+
+ 2015-05-16 Brent Fulgham <bfulgham@apple.com>
+
+ [iOS] Remote scrolling tree needs to coordinate scroll snap state during resize/rotations
+ https://bugs.webkit.org/show_bug.cgi?id=145059
+ <rdar://problem/20975978>
+
+ 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.
+
+2015-05-18 Matthew Hanson <matthew_hanson@apple.com>
+
</ins><span class="cx"> Merge custom patch. rdar://problem/20950052
</span><span class="cx">
</span><span class="cx"> 2015-05-15 Dean Jackson <dino@apple.com>
</span></span></pre></div>
<a id="branchessafari6011322branchSourceWebKit2UIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.32.2-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (184571 => 184572)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.32.2-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2015-05-19 16:46:40 UTC (rev 184571)
+++ branches/safari-601.1.32.2-branch/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2015-05-19 16:46:43 UTC (rev 184572)
</span><span class="lines">@@ -1402,7 +1402,11 @@
</span><span class="cx"> if (WebKit::RemoteScrollingCoordinatorProxy* coordinator = _page->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->adjustTargetContentOffsetForSnapping(maxScrollOffsets, velocity, targetContentOffset);
</del><ins>+
+ CGRect fullViewRect = self.bounds;
+ CGRect unobscuredRect = UIEdgeInsetsInsetRect(fullViewRect, [self _computedContentInset]);
+
+ coordinator->adjustTargetContentOffsetForSnapping(maxScrollOffsets, velocity, unobscuredRect.origin.y, targetContentOffset);
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="lines">@@ -1522,6 +1526,26 @@
</span><span class="cx"> if (isStableState && [_scrollView respondsToSelector:@selector(_isInterruptingDeceleration)])
</span><span class="cx"> isStableState = ![_scrollView performSelector:@selector(_isInterruptingDeceleration)];
</span><span class="cx">
</span><ins>+#if ENABLE(CSS_SCROLL_SNAP) && ENABLE(ASYNC_SCROLLING)
+ if (isStableState) {
+ WebKit::RemoteScrollingCoordinatorProxy* coordinator = _page->scrollingCoordinatorProxy();
+ if (coordinator && coordinator->hasActiveSnapPoint()) {
+ CGRect fullViewRect = self.bounds;
+ CGRect unobscuredRect = UIEdgeInsetsInsetRect(fullViewRect, [self _computedContentInset]);
+
+ CGPoint currentPoint = [_scrollView contentOffset];
+ CGPoint activePoint = coordinator->nearestActiveContentInsetAdjustedSnapPoint(unobscuredRect.origin.y, currentPoint);
+
+ if (!CGPointEqualToPoint(activePoint, currentPoint)) {
+ RetainPtr<WKScrollView> 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="branchessafari6011322branchSourceWebKit2UIProcessScrollingRemoteScrollingCoordinatorProxyh"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.32.2-branch/Source/WebKit2/UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h (184571 => 184572)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.32.2-branch/Source/WebKit2/UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h        2015-05-19 16:46:40 UTC (rev 184571)
+++ branches/safari-601.1.32.2-branch/Source/WebKit2/UIProcess/Scrolling/RemoteScrollingCoordinatorProxy.h        2015-05-19 16:46:43 UTC (rev 184572)
</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&) 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&, const RemoteLayerTreeHost&);
</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& closestIndex) const;
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> WebPageProxy& m_webPageProxy;
</span><span class="cx"> RefPtr<RemoteScrollingTree> 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="branchessafari6011322branchSourceWebKit2UIProcessiosRemoteScrollingCoordinatorProxyIOSmm"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.32.2-branch/Source/WebKit2/UIProcess/ios/RemoteScrollingCoordinatorProxyIOS.mm (184571 => 184572)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-601.1.32.2-branch/Source/WebKit2/UIProcess/ios/RemoteScrollingCoordinatorProxyIOS.mm        2015-05-19 16:46:40 UTC (rev 184571)
+++ branches/safari-601.1.32.2-branch/Source/WebKit2/UIProcess/ios/RemoteScrollingCoordinatorProxyIOS.mm        2015-05-19 16:46:43 UTC (rev 184572)
</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) && targetContentOffset->x > 0 && targetContentOffset->x < maxScrollOffsets.width) {
</span><del>- float potentialSnapPosition = closestSnapOffsetForMainFrameScrolling(WebCore::ScrollEventAxis::Horizontal, targetContentOffset->x, velocity.x);
</del><ins>+ float potentialSnapPosition = closestSnapOffsetForMainFrameScrolling(WebCore::ScrollEventAxis::Horizontal, targetContentOffset->x, velocity.x, m_currentHorizontalSnapPointIndex);
</ins><span class="cx"> targetContentOffset->x = std::min<float>(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) && targetContentOffset->y > 0 && targetContentOffset->y < maxScrollOffsets.height) {
</span><del>- float potentialSnapPosition = closestSnapOffsetForMainFrameScrolling(WebCore::ScrollEventAxis::Vertical, targetContentOffset->y, velocity.y);
</del><ins>+ float potentialSnapPosition = closestSnapOffsetForMainFrameScrolling(WebCore::ScrollEventAxis::Vertical, targetContentOffset->y, velocity.y, m_currentVerticalSnapPointIndex);
+ potentialSnapPosition -= topInset;
</ins><span class="cx"> targetContentOffset->y = std::min<float>(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 && root->isFrameScrollingNode()) {
</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><del>- return snapOffsets.size() > 0;
</del><ins>+ unsigned currentIndex = axis == ScrollEventAxis::Horizontal ? m_currentHorizontalSnapPointIndex : m_currentVerticalSnapPointIndex;
+ return (snapOffsets.size() > 0) && (currentIndex < 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& currentIndex) const
</ins><span class="cx"> {
</span><span class="cx"> ScrollingTreeNode* root = m_scrollingTree->rootNode();
</span><span class="cx"> ASSERT(root && root->isFrameScrollingNode());
</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><del>- unsigned ignore = 0;
</del><span class="cx"> float scaledScrollDestination = scrollDestination / m_webPageProxy.displayedContentScale();
</span><del>- float rawClosestSnapOffset = closestSnapOffset<float, float>(snapOffsets, scaledScrollDestination, velocity, ignore);
</del><ins>+ float rawClosestSnapOffset = closestSnapOffset<float, float>(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->rootNode();
+ if (!root)
+ return false;
+
+ if (!is<ScrollingTreeFrameScrollingNode>(root))
+ return false;
+
+ ScrollingTreeFrameScrollingNode& rootFrame = downcast<ScrollingTreeFrameScrollingNode>(*root);
+ const Vector<float>& horizontal = rootFrame.horizontalSnapOffsets();
+ const Vector<float>& vertical = rootFrame.verticalSnapOffsets();
+
+ if (horizontal.isEmpty() && vertical.isEmpty())
+ return false;
+
+ if ((!horizontal.isEmpty() && m_currentHorizontalSnapPointIndex >= horizontal.size())
+ || (!vertical.isEmpty() && m_currentVerticalSnapPointIndex >= vertical.size())) {
+ return false;
+ }
+
+ return true;
+}
+
+CGPoint RemoteScrollingCoordinatorProxy::nearestActiveContentInsetAdjustedSnapPoint(CGFloat topInset, const CGPoint& currentPoint) const
+{
+ CGPoint activePoint = currentPoint;
+
+ ScrollingTreeNode* root = m_scrollingTree->rootNode();
+ ASSERT(root && is<ScrollingTreeFrameScrollingNode>(root));
+ ScrollingTreeFrameScrollingNode& rootFrame = downcast<ScrollingTreeFrameScrollingNode>(*root);
+ const Vector<float>& horizontal = rootFrame.horizontalSnapOffsets();
+ const Vector<float>& 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() && m_currentHorizontalSnapPointIndex < horizontal.size())
+ activePoint.x = horizontal[m_currentHorizontalSnapPointIndex] * m_webPageProxy.displayedContentScale();
+
+ if (!vertical.isEmpty() && m_currentVerticalSnapPointIndex < 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>