<!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>[164466] 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/164466">164466</a></dd>
<dt>Author</dt> <dd>benjamin@webkit.org</dd>
<dt>Date</dt> <dd>2014-02-20 20:53:48 -0800 (Thu, 20 Feb 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Start fixing the view states driven by the WKScrollView
https://bugs.webkit.org/show_bug.cgi?id=129140

Patch by Benjamin Poulain &lt;bpoulain@apple.com&gt; on 2014-02-20
Reviewed by Tim Horton and Simon Fraser.

Source/WebCore: 

* platform/graphics/ca/mac/TileController.mm:
(WebCore::TileController::scaledExposedRect):
That comment was more confusing than helping. FrameView-relative coordinates should not need
scaling.

Source/WebKit2: 

WKScrollView creates a &quot;window&quot; over WKContentView with an area that is exposed,
an area that is unobcured and with a certain scale.

Instead of having 3 loosely related paths for updating WKContentView
when the content &quot;window&quot; change, everything is consolidated behind the
single API -[WKContentView didUpdateVisibleRect:unobscuredRect:scale:].

This patch only fixes the content updates from the UI process side to keep things simple.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _didFinishScrolling]):
(-[WKWebView scrollViewDidEndDragging:willDecelerate:]):
(-[WKWebView scrollViewDidEndDecelerating:]):
(-[WKWebView scrollViewDidScrollToTop:]):
(-[WKWebView scrollViewDidScroll:]):
(-[WKWebView scrollViewDidEndZooming:withView:atScale:]):
(-[WKWebView _frameOrBoundsChanged]):
(-[WKWebView _updateContentWindow]):
(-[WKWebView _setObscuredInsets:]):
* UIProcess/API/ios/WKContentView.h:
* UIProcess/API/ios/WKContentView.mm:
(-[WKContentView didUpdateVisibleRect:unobscuredRect:scale:]):
(-[WKContentView _updateFixedPositionRect]):
(-[WKContentView didFinishScrolling]):
(-[WKContentView didZoomToScale:]):
* UIProcess/API/ios/WKViewIOS.mm:
(-[WKView contentView:didCommitLayerTree:]):
(-[WKView _didFinishScrolling]):
(-[WKView scrollViewDidEndDragging:willDecelerate:]):
(-[WKView scrollViewDidEndDecelerating:]):
(-[WKView scrollViewDidScrollToTop:]):
(-[WKView scrollViewDidScroll:]):
(-[WKView scrollViewDidEndZooming:withView:atScale:]):
Scrolling is modified to take into account the view position and the obcured content.
Instead of driving the scrolling position from the UIScrollView delegate callbacks,
we use changes in unobscured rect to find changes in &quot;content visible scroll position&quot;.

WebPageProxy::didFinishScrolling() is removed. All the scrollOffset updates now go through
the ScrollingCoordinator.

(-[WKView _frameOrBoundsChanged]):
(-[WKView _updateContentWindow]):
(-[WKView _setObscuredInsets:]):
* UIProcess/WebPageProxy.h:
* UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::unobscuredContentRect):
(WebKit::WebPageProxy::setUnobscuredContentRect):
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/ios/WebPageIOS.mm:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicscamacTileControllermm">trunk/Source/WebCore/platform/graphics/ca/mac/TileController.mm</a></li>
<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="#trunkSourceWebKit2UIProcessAPIiosWKContentViewh">trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIiosWKContentViewmm">trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIiosWKViewIOSmm">trunk/Source/WebKit2/UIProcess/API/ios/WKViewIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxyh">trunk/Source/WebKit2/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosWebPageProxyIOSmm">trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagemessagesin">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageiosWebPageIOSmm">trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (164465 => 164466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-02-21 04:04:23 UTC (rev 164465)
+++ trunk/Source/WebCore/ChangeLog        2014-02-21 04:53:48 UTC (rev 164466)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2014-02-20  Benjamin Poulain  &lt;bpoulain@apple.com&gt;
+
+        Start fixing the view states driven by the WKScrollView
+        https://bugs.webkit.org/show_bug.cgi?id=129140
+
+        Reviewed by Tim Horton and Simon Fraser.
+
+        * platform/graphics/ca/mac/TileController.mm:
+        (WebCore::TileController::scaledExposedRect):
+        That comment was more confusing than helping. FrameView-relative coordinates should not need
+        scaling.
+
</ins><span class="cx"> 2014-02-20  Gyuyoung Kim  &lt;gyuyoung.kim@samsung.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Start to use std::unique_ptr for DragImageLoader
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicscamacTileControllermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/ca/mac/TileController.mm (164465 => 164466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/ca/mac/TileController.mm        2014-02-21 04:04:23 UTC (rev 164465)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/TileController.mm        2014-02-21 04:53:48 UTC (rev 164466)
</span><span class="lines">@@ -319,7 +319,6 @@
</span><span class="cx"> 
</span><span class="cx"> FloatRect TileController::scaledExposedRect() const
</span><span class="cx"> {
</span><del>-    // Since the exposedRect is in FrameView-relative coordinates, we need to scale into document space.
</del><span class="cx">     FloatRect scaledExposedRect = m_exposedRect;
</span><span class="cx">     scaledExposedRect.scale(1 / m_scale);
</span><span class="cx">     return scaledExposedRect;
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (164465 => 164466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-02-21 04:04:23 UTC (rev 164465)
+++ trunk/Source/WebKit2/ChangeLog        2014-02-21 04:53:48 UTC (rev 164466)
</span><span class="lines">@@ -1,3 +1,60 @@
</span><ins>+2014-02-20  Benjamin Poulain  &lt;bpoulain@apple.com&gt;
+
+        Start fixing the view states driven by the WKScrollView
+        https://bugs.webkit.org/show_bug.cgi?id=129140
+
+        Reviewed by Tim Horton and Simon Fraser.
+
+        WKScrollView creates a &quot;window&quot; over WKContentView with an area that is exposed,
+        an area that is unobcured and with a certain scale.
+
+        Instead of having 3 loosely related paths for updating WKContentView
+        when the content &quot;window&quot; change, everything is consolidated behind the
+        single API -[WKContentView didUpdateVisibleRect:unobscuredRect:scale:].
+
+        This patch only fixes the content updates from the UI process side to keep things simple.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _didFinishScrolling]):
+        (-[WKWebView scrollViewDidEndDragging:willDecelerate:]):
+        (-[WKWebView scrollViewDidEndDecelerating:]):
+        (-[WKWebView scrollViewDidScrollToTop:]):
+        (-[WKWebView scrollViewDidScroll:]):
+        (-[WKWebView scrollViewDidEndZooming:withView:atScale:]):
+        (-[WKWebView _frameOrBoundsChanged]):
+        (-[WKWebView _updateContentWindow]):
+        (-[WKWebView _setObscuredInsets:]):
+        * UIProcess/API/ios/WKContentView.h:
+        * UIProcess/API/ios/WKContentView.mm:
+        (-[WKContentView didUpdateVisibleRect:unobscuredRect:scale:]):
+        (-[WKContentView _updateFixedPositionRect]):
+        (-[WKContentView didFinishScrolling]):
+        (-[WKContentView didZoomToScale:]):
+        * UIProcess/API/ios/WKViewIOS.mm:
+        (-[WKView contentView:didCommitLayerTree:]):
+        (-[WKView _didFinishScrolling]):
+        (-[WKView scrollViewDidEndDragging:willDecelerate:]):
+        (-[WKView scrollViewDidEndDecelerating:]):
+        (-[WKView scrollViewDidScrollToTop:]):
+        (-[WKView scrollViewDidScroll:]):
+        (-[WKView scrollViewDidEndZooming:withView:atScale:]):
+        Scrolling is modified to take into account the view position and the obcured content.
+        Instead of driving the scrolling position from the UIScrollView delegate callbacks,
+        we use changes in unobscured rect to find changes in &quot;content visible scroll position&quot;.
+
+        WebPageProxy::didFinishScrolling() is removed. All the scrollOffset updates now go through
+        the ScrollingCoordinator.
+
+        (-[WKView _frameOrBoundsChanged]):
+        (-[WKView _updateContentWindow]):
+        (-[WKView _setObscuredInsets:]):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/ios/WebPageProxyIOS.mm:
+        (WebKit::WebPageProxy::unobscuredContentRect):
+        (WebKit::WebPageProxy::setUnobscuredContentRect):
+        * WebProcess/WebPage/WebPage.messages.in:
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+
</ins><span class="cx"> 2014-02-20  Tim Horton  &lt;timothy_horton@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix a build warning by moving some WKWebView methods from the private category to WKWebView itself.
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPICocoaWKWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (164465 => 164466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2014-02-21 04:04:23 UTC (rev 164465)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm        2014-02-21 04:53:48 UTC (rev 164466)
</span><span class="lines">@@ -356,38 +356,38 @@
</span><span class="cx">     [_contentView willStartZoomOrScroll];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)_didFinishScroll
</del><ins>+- (void)_didFinishScrolling
</ins><span class="cx"> {
</span><del>-    CGPoint position = [_scrollView convertPoint:[_scrollView contentOffset] toView:_contentView.get()];
-    [_contentView didFinishScrollTo:position];
</del><ins>+    [self _updateVisibleContentRects];
+    [_contentView didFinishScrolling];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
</span><span class="cx"> {
</span><span class="cx">     // If we're decelerating, scroll offset will be updated when scrollViewDidFinishDecelerating: is called.
</span><span class="cx">     if (!decelerate)
</span><del>-        [self _didFinishScroll];
</del><ins>+        [self _didFinishScrolling];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
</span><span class="cx"> {
</span><del>-    [self _didFinishScroll];
</del><ins>+    [self _didFinishScrolling];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView
</span><span class="cx"> {
</span><del>-    [self _didFinishScroll];
</del><ins>+    [self _didFinishScrolling];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)scrollViewDidScroll:(UIScrollView *)scrollView
</span><span class="cx"> {
</span><del>-    CGPoint position = [_scrollView convertPoint:[_scrollView contentOffset] toView:_contentView.get()];
-    [_contentView didScrollTo:position];
</del><ins>+    [self _updateVisibleContentRects];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(CGFloat)scale
</span><span class="cx"> {
</span><span class="cx">     ASSERT(scrollView == _scrollView);
</span><ins>+    [self _updateVisibleContentRects];
</ins><span class="cx">     [_contentView didZoomToScale:scale];
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -399,17 +399,20 @@
</span><span class="cx">         [_contentView setMinimumLayoutSize:bounds.size];
</span><span class="cx">     [_scrollView setFrame:bounds];
</span><span class="cx">     [_contentView setMinimumSize:bounds.size];
</span><ins>+    [self _updateVisibleContentRects];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)_setDocumentScale:(CGFloat)newScale
</del><ins>+- (void)_updateVisibleContentRects
</ins><span class="cx"> {
</span><del>-    CGPoint contentOffsetInDocumentCoordinates = [_scrollView convertPoint:[_scrollView contentOffset] toView:_contentView.get()];
</del><ins>+    CGRect fullViewRect = self.bounds;
+    CGRect visibleRectInContentCoordinates = [self convertRect:fullViewRect toView:_contentView.get()];
</ins><span class="cx"> 
</span><del>-    [_scrollView setZoomScale:newScale];
-    [_contentView didZoomToScale:newScale];
</del><ins>+    CGRect unobscuredRect = UIEdgeInsetsInsetRect(fullViewRect, _obscuredInsets);
+    CGRect unobscuredRectInContentCoordinates = [self convertRect:unobscuredRect toView:_contentView.get()];
</ins><span class="cx"> 
</span><del>-    CGPoint contentOffset = [_scrollView convertPoint:contentOffsetInDocumentCoordinates fromView:_contentView.get()];
-    [_scrollView setContentOffset:contentOffset];
</del><ins>+    CGFloat scaleFactor = [_scrollView zoomScale];
+
+    [_contentView didUpdateVisibleRect:visibleRectInContentCoordinates unobscuredRect:unobscuredRectInContentCoordinates scale:scaleFactor];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_keyboardChangedWithInfo:(NSDictionary *)keyboardInfo adjustScrollView:(BOOL)adjustScrollView
</span><span class="lines">@@ -672,6 +675,7 @@
</span><span class="cx">     ASSERT(obscuredInsets.bottom &gt;= 0);
</span><span class="cx">     ASSERT(obscuredInsets.right &gt;= 0);
</span><span class="cx">     _obscuredInsets = obscuredInsets;
</span><ins>+    [self _updateVisibleContentRects];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (UIColor *)_pageExtendedBackgroundColor
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIiosWKContentViewh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.h (164465 => 164466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.h        2014-02-21 04:04:23 UTC (rev 164465)
+++ trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.h        2014-02-21 04:53:48 UTC (rev 164466)
</span><span class="lines">@@ -62,9 +62,9 @@
</span><span class="cx"> 
</span><span class="cx"> - (void)setMinimumSize:(CGSize)size;
</span><span class="cx"> - (void)setMinimumLayoutSize:(CGSize)size;
</span><ins>+- (void)didUpdateVisibleRect:(CGRect)visibleRect unobscuredRect:(CGRect)unobscuredRect scale:(CGFloat)scale;
</ins><span class="cx"> 
</span><del>-- (void)didFinishScrollTo:(CGPoint)contentOffset;
-- (void)didScrollTo:(CGPoint)contentOffset;
</del><ins>+- (void)didFinishScrolling;
</ins><span class="cx"> - (void)didZoomToScale:(CGFloat)scale;
</span><span class="cx"> - (void)willStartZoomOrScroll;
</span><span class="cx"> - (void)willStartUserTriggeredZoom;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIiosWKContentViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.mm (164465 => 164466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.mm        2014-02-21 04:04:23 UTC (rev 164465)
+++ trunk/Source/WebKit2/UIProcess/API/ios/WKContentView.mm        2014-02-21 04:53:48 UTC (rev 164466)
</span><span class="lines">@@ -68,8 +68,6 @@
</span><span class="cx"> 
</span><span class="cx">     RetainPtr&lt;UIView&gt; _rootContentView;
</span><span class="cx">     RetainPtr&lt;WKInteractionView&gt; _interactionView;
</span><del>-
-    WebCore::FloatPoint _currentExposedRectPosition;
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (instancetype)initWithFrame:(CGRect)frame context:(WebKit::WebContext&amp;)context configuration:(WebKit::WebPageConfiguration)webPageConfiguration
</span><span class="lines">@@ -150,6 +148,20 @@
</span><span class="cx">     return [_interactionView isEditable];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (void)didUpdateVisibleRect:(CGRect)visibleRect unobscuredRect:(CGRect)unobscuredRect scale:(CGFloat)scale
+{
+    _page-&gt;setUnobscuredContentRect(unobscuredRect);
+    _page-&gt;scrollingCoordinatorProxy()-&gt;scrollPositionChangedViaDelegatedScrolling(_page-&gt;scrollingCoordinatorProxy()-&gt;rootScrollingNodeID(), roundedIntPoint(unobscuredRect.origin));
+
+    if (auto drawingArea = _page-&gt;drawingArea()) {
+        FloatRect exposedRect = visibleRect;
+        exposedRect.scale(scale);
+        drawingArea-&gt;setExposedRect(exposedRect);
+    }
+
+    [self _updateFixedPositionRect];
+}
+
</ins><span class="cx"> - (void)setMinimumSize:(CGSize)size
</span><span class="cx"> {
</span><span class="cx">     _page-&gt;drawingArea()-&gt;setSize(IntSize(size), IntSize(), IntSize());
</span><span class="lines">@@ -162,22 +174,12 @@
</span><span class="cx">     return exposedRect;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)_updateViewExposedRect
-{
-    FloatPoint exposedRectPosition = _currentExposedRectPosition;
-    exposedRectPosition.scale(_page-&gt;pageScaleFactor(), _page-&gt;pageScaleFactor());
-
-    if (auto drawingArea = _page-&gt;drawingArea())
-        drawingArea-&gt;setExposedRect(FloatRect(exposedRectPosition, _page-&gt;drawingArea()-&gt;size()));
-}
-
</del><span class="cx"> - (void)_updateFixedPositionRect
</span><span class="cx"> {
</span><span class="cx">     auto drawingArea = _page-&gt;drawingArea();
</span><span class="cx">     if (!drawingArea)
</span><span class="cx">         return;
</span><del>-    FloatRect exposedRect(_currentExposedRectPosition, drawingArea-&gt;size());
-    FloatRect fixedPosRect = [self fixedPositionRectFromExposedRect:exposedRect scale:_page-&gt;pageScaleFactor()];
</del><ins>+    FloatRect fixedPosRect = [self fixedPositionRectFromExposedRect:_page-&gt;unobscuredContentRect() scale:_page-&gt;pageScaleFactor()];
</ins><span class="cx">     drawingArea-&gt;setCustomFixedPositionRect(fixedPosRect);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -186,23 +188,12 @@
</span><span class="cx">     _page-&gt;setViewportConfigurationMinimumLayoutSize(IntSize(CGCeiling(size.width), CGCeiling(size.height)));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)didFinishScrollTo:(CGPoint)contentOffset
</del><ins>+- (void)didFinishScrolling
</ins><span class="cx"> {
</span><del>-    _currentExposedRectPosition = contentOffset;
-    _page-&gt;didFinishScrolling(contentOffset);
-    [self _updateViewExposedRect];
</del><span class="cx">     [self _updateFixedPositionRect];
</span><span class="cx">     [_interactionView _didEndScrollingOrZooming];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)didScrollTo:(CGPoint)contentOffset
-{
-    _currentExposedRectPosition = contentOffset;
-    [self _updateViewExposedRect];
-
-    _page-&gt;scrollingCoordinatorProxy()-&gt;scrollPositionChangedViaDelegatedScrolling(_page-&gt;scrollingCoordinatorProxy()-&gt;rootScrollingNodeID(), roundedIntPoint(contentOffset));
-}
-
</del><span class="cx"> - (void)willStartZoomOrScroll
</span><span class="cx"> {
</span><span class="cx">     [_interactionView _willStartScrollingOrZooming];
</span><span class="lines">@@ -216,8 +207,6 @@
</span><span class="cx"> - (void)didZoomToScale:(CGFloat)scale
</span><span class="cx"> {
</span><span class="cx">     _page-&gt;didFinishZooming(scale);
</span><del>-    [self _updateViewExposedRect];
-    [self _updateFixedPositionRect];
</del><span class="cx">     [_interactionView _didEndScrollingOrZooming];
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIiosWKViewIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/ios/WKViewIOS.mm (164465 => 164466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/ios/WKViewIOS.mm        2014-02-21 04:04:23 UTC (rev 164465)
+++ trunk/Source/WebKit2/UIProcess/API/ios/WKViewIOS.mm        2014-02-21 04:53:48 UTC (rev 164466)
</span><span class="lines">@@ -44,7 +44,6 @@
</span><span class="cx"> using namespace WebKit;
</span><span class="cx"> 
</span><span class="cx"> @interface WKView () &lt;UIScrollViewDelegate, WKContentViewDelegate&gt;
</span><del>-- (void)_setDocumentScale:(CGFloat)newScale;
</del><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> @interface UIScrollView (UIScrollViewInternal)
</span><span class="lines">@@ -171,7 +170,7 @@
</span><span class="cx">         [_scrollView setContentOffset:CGPointMake(-inset.left, -inset.top)];
</span><span class="cx">         _isWaitingForNewLayerTreeAfterDidCommitLoad = NO;
</span><span class="cx">     }
</span><del>-
</del><ins>+    [self _updateVisibleContentRects];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #pragma mark - UIScrollViewDelegate
</span><span class="lines">@@ -194,38 +193,38 @@
</span><span class="cx">     [_contentView willStartZoomOrScroll];
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)_didFinishScroll
</del><ins>+- (void)_didFinishScrolling
</ins><span class="cx"> {
</span><del>-    CGPoint position = [_scrollView convertPoint:[_scrollView contentOffset] toView:_contentView.get()];
-    [_contentView didFinishScrollTo:position];
</del><ins>+    [self _updateVisibleContentRects];
+    [_contentView didFinishScrolling];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
</span><span class="cx"> {
</span><span class="cx">     // If we're decelerating, scroll offset will be updated when scrollViewDidFinishDecelerating: is called.
</span><span class="cx">     if (!decelerate)
</span><del>-        [self _didFinishScroll];
</del><ins>+        [self _didFinishScrolling];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
</span><span class="cx"> {
</span><del>-    [self _didFinishScroll];
</del><ins>+    [self _didFinishScrolling];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView
</span><span class="cx"> {
</span><del>-    [self _didFinishScroll];
</del><ins>+    [self _didFinishScrolling];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)scrollViewDidScroll:(UIScrollView *)scrollView
</span><span class="cx"> {
</span><del>-    CGPoint position = [_scrollView convertPoint:[_scrollView contentOffset] toView:_contentView.get()];
-    [_contentView didScrollTo:position];
</del><ins>+    [self _updateVisibleContentRects];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(CGFloat)scale
</span><span class="cx"> {
</span><span class="cx">     ASSERT(scrollView == _scrollView);
</span><ins>+    [self _updateVisibleContentRects];
</ins><span class="cx">     [_contentView didZoomToScale:scale];
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -271,20 +270,22 @@
</span><span class="cx">         [_contentView setMinimumLayoutSize:bounds.size];
</span><span class="cx">     [_scrollView setFrame:bounds];
</span><span class="cx">     [_contentView setMinimumSize:bounds.size];
</span><ins>+    [self _updateVisibleContentRects];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-- (void)_setDocumentScale:(CGFloat)newScale
</del><ins>+- (void)_updateVisibleContentRects
</ins><span class="cx"> {
</span><del>-    CGPoint contentOffsetInDocumentCoordinates = [_scrollView convertPoint:[_scrollView contentOffset] toView:_contentView.get()];
</del><ins>+    CGRect fullViewRect = self.bounds;
+    CGRect visibleRectInContentCoordinates = [self convertRect:fullViewRect toView:_contentView.get()];
</ins><span class="cx"> 
</span><del>-    [_scrollView setZoomScale:newScale];
-    [_contentView didZoomToScale:newScale];
</del><ins>+    CGRect unobscuredRect = UIEdgeInsetsInsetRect(fullViewRect, _obscuredInsets);
+    CGRect unobscuredRectInContentCoordinates = [self convertRect:unobscuredRect toView:_contentView.get()];
</ins><span class="cx"> 
</span><del>-    CGPoint contentOffset = [_scrollView convertPoint:contentOffsetInDocumentCoordinates fromView:_contentView.get()];
-    [_scrollView setContentOffset:contentOffset];
</del><ins>+    CGFloat scaleFactor = [_scrollView zoomScale];
+
+    [_contentView didUpdateVisibleRect:visibleRectInContentCoordinates unobscuredRect:unobscuredRectInContentCoordinates scale:scaleFactor];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-
</del><span class="cx"> - (RetainPtr&lt;CGImageRef&gt;)takeViewSnapshotForContentView:(WKContentView *)contentView
</span><span class="cx"> {
</span><span class="cx">     // FIXME: We should be able to use acquire an IOSurface directly, instead of going to CGImage here and back in ViewSnapshotStore.
</span><span class="lines">@@ -378,6 +379,7 @@
</span><span class="cx">     ASSERT(obscuredInsets.bottom &gt;= 0);
</span><span class="cx">     ASSERT(obscuredInsets.right &gt;= 0);
</span><span class="cx">     _obscuredInsets = obscuredInsets;
</span><ins>+    [self _updateVisibleContentRects];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)_beginInteractiveObscuredInsetsChange
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (164465 => 164466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2014-02-21 04:04:23 UTC (rev 164465)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2014-02-21 04:53:48 UTC (rev 164466)
</span><span class="lines">@@ -450,8 +450,11 @@
</span><span class="cx">     void executeEditCommand(const String&amp; commandName);
</span><span class="cx">     void validateCommand(const String&amp; commandName, PassRefPtr&lt;ValidateCommandCallback&gt;);
</span><span class="cx"> #if PLATFORM(IOS)
</span><ins>+    const WebCore::FloatRect&amp; unobscuredContentRect() const;
+    void setUnobscuredContentRect(const WebCore::FloatRect&amp; unobscuredRect);
</ins><span class="cx">     void setViewportConfigurationMinimumLayoutSize(const WebCore::IntSize&amp;);
</span><span class="cx">     void didCommitLayerTree(const WebKit::RemoteLayerTreeTransaction&amp;);
</span><ins>+
</ins><span class="cx">     void selectWithGesture(const WebCore::IntPoint, WebCore::TextGranularity, uint32_t gestureType, uint32_t gestureState, PassRefPtr&lt;GestureCallback&gt;);
</span><span class="cx">     void updateSelectionWithTouches(const WebCore::IntPoint, uint32_t touches, bool baseIsStart, PassRefPtr&lt;TouchesCallback&gt;);
</span><span class="cx">     void selectWithTwoTouches(const WebCore::IntPoint from, const WebCore::IntPoint to, uint32_t gestureType, uint32_t gestureState, PassRefPtr&lt;GestureCallback&gt;);
</span><span class="lines">@@ -841,7 +844,6 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     void willStartUserTriggeredZooming();
</span><del>-    void didFinishScrolling(const WebCore::FloatPoint&amp; contentOffset);
</del><span class="cx">     void didFinishZooming(float newScale);
</span><span class="cx"> 
</span><span class="cx">     void tapHighlightAtPosition(const WebCore::FloatPoint&amp;, uint64_t&amp; requestID);
</span><span class="lines">@@ -1235,6 +1237,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     RefPtr&lt;WebVideoFullscreenManagerProxy&gt; m_videoFullscreenManager;
</span><ins>+    WebCore::FloatRect m_unobscuredRect;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(VIBRATION)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosWebPageProxyIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm (164465 => 164466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm        2014-02-21 04:04:23 UTC (rev 164465)
+++ trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm        2014-02-21 04:53:48 UTC (rev 164466)
</span><span class="lines">@@ -229,6 +229,16 @@
</span><span class="cx">     callback-&gt;performCallbackWithReturnValue(beforeText, markedText, selectedText, afterText, location, length);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+const FloatRect&amp; WebPageProxy::unobscuredContentRect() const
+{
+    return m_unobscuredRect;
+}
+
+void WebPageProxy::setUnobscuredContentRect(const FloatRect&amp; unobscuredRect)
+{
+    m_unobscuredRect = unobscuredRect;
+}
+
</ins><span class="cx"> void WebPageProxy::setViewportConfigurationMinimumLayoutSize(const WebCore::IntSize&amp; size)
</span><span class="cx"> {
</span><span class="cx">     m_process-&gt;send(Messages::WebPage::SetViewportConfigurationMinimumLayoutSize(size), m_pageID);
</span><span class="lines">@@ -432,11 +442,6 @@
</span><span class="cx">     process().send(Messages::WebPage::WillStartUserTriggeredZooming(), m_pageID);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPageProxy::didFinishScrolling(const WebCore::FloatPoint&amp; contentOffset)
-{
-    process().send(Messages::WebPage::DidFinishScrolling(contentOffset), m_pageID);
-}
-
</del><span class="cx"> void WebPageProxy::didFinishZooming(float newScale)
</span><span class="cx"> {
</span><span class="cx">     m_pageScaleFactor = newScale;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagemessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (164465 => 164466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in        2014-02-21 04:04:23 UTC (rev 164465)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in        2014-02-21 04:53:48 UTC (rev 164466)
</span><span class="lines">@@ -314,7 +314,6 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS)
</span><span class="cx">     WillStartUserTriggeredZooming();
</span><del>-    DidFinishScrolling(WebCore::FloatPoint contentOffset);
</del><span class="cx">     DidFinishZooming(float scale);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageiosWebPageIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm (164465 => 164466)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm        2014-02-21 04:04:23 UTC (rev 164465)
+++ trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm        2014-02-21 04:53:48 UTC (rev 164466)
</span><span class="lines">@@ -1080,11 +1080,6 @@
</span><span class="cx">     m_userHasChangedPageScaleFactor = true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPage::didFinishScrolling(const WebCore::FloatPoint&amp; contentOffset)
-{
-    m_page-&gt;mainFrame().view()-&gt;setScrollOffset(WebCore::IntPoint(contentOffset));
-}
-
</del><span class="cx"> void WebPage::didFinishZooming(float newScale)
</span><span class="cx"> {
</span><span class="cx">     m_page-&gt;setPageScaleFactor(newScale, m_page-&gt;mainFrame().view()-&gt;scrollPosition());
</span></span></pre>
</div>
</div>

</body>
</html>