<!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>[192898] 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/192898">192898</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2015-12-01 11:57:07 -0800 (Tue, 01 Dec 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Remove swipe snapshot before main document load if scroll position is already restored
https://bugs.webkit.org/show_bug.cgi?id=151224

Reviewed by Darin Adler.

* UIProcess/Cocoa/WebViewImpl.h:
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::didRestoreScrollPosition):
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didRestoreScrollPosition):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/mac/PageClientImpl.h:
* UIProcess/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::didRestoreScrollPosition):
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::didRestoreScrollPosition):
* WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::didRestoreScrollPosition):
* WebProcess/WebPage/WebPage.h:
Plumb didRestoreScrollPosition through to ViewGestureController (yikes!).

* UIProcess/ViewGestureController.cpp:
(WebKit::ViewGestureController::didFirstVisuallyNonEmptyLayoutForMainFrame):
Cancel waiting for any more loads if we get to firstVisuallyNonEmptyLayout.

(WebKit::ViewGestureController::didReachMainFrameLoadTerminalState):
Cancel waiting for scroll position restoration if we make it to main frame load,
because there is a chance we won't be able to restore the old scroll position, and
by main frame load time we've tried as hard as we're going to to restore it.

* UIProcess/mac/ViewGestureControllerMac.mm:
(WebKit::ViewGestureController::endSwipeGesture):
Make some legacy-style-only code clearer that it's legacy-style-only.
Wait for scroll position restoration.

* loader/FrameLoaderClient.h:
* loader/HistoryController.cpp:
(WebCore::HistoryController::restoreScrollPositionAndViewState):
Each time we try to restore the scroll position, see if the requested
scroll position is something we can scroll to by going through ScrollView's
scroll position constraint logic. If we can scroll there, tell our client
(and eventually ViewGestureController) that we successfully restored the
scroll position!</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreloaderFrameLoaderClienth">trunk/Source/WebCore/loader/FrameLoaderClient.h</a></li>
<li><a href="#trunkSourceWebCoreloaderHistoryControllercpp">trunk/Source/WebCore/loader/HistoryController.cpp</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIgtkPageClientImplh">trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWebViewImplh">trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCocoaWebViewImplmm">trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessCoordinatedGraphicsWebViewh">trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/WebView.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessPageClienth">trunk/Source/WebKit2/UIProcess/PageClient.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessViewGestureControllercpp">trunk/Source/WebKit2/UIProcess/ViewGestureController.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxycpp">trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxyh">trunk/Source/WebKit2/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebPageProxymessagesin">trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in</a></li>
<li><a href="#trunkSourceWebKit2UIProcesseflWebViewEflh">trunk/Source/WebKit2/UIProcess/efl/WebViewEfl.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosPageClientImplIOSh">trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessiosPageClientImplIOSmm">trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacPageClientImplh">trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacPageClientImplmm">trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacViewGestureControllerMacmm">trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportWebFrameLoaderClientcpp">trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebCoreSupportWebFrameLoaderClienth">trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPagecpp">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPageWebPageh">trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (192897 => 192898)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-12-01 19:44:28 UTC (rev 192897)
+++ trunk/Source/WebCore/ChangeLog        2015-12-01 19:57:07 UTC (rev 192898)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2015-12-01  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        Remove swipe snapshot before main document load if scroll position is already restored
+        https://bugs.webkit.org/show_bug.cgi?id=151224
+
+        Reviewed by Darin Adler.
+
+        * loader/FrameLoaderClient.h:
+        * loader/HistoryController.cpp:
+        (WebCore::HistoryController::restoreScrollPositionAndViewState):
+        Each time we try to restore the scroll position, see if the requested
+        scroll position is something we can scroll to by going through ScrollView's
+        scroll position constraint logic. If we can scroll there, tell our client
+        (and eventually ViewGestureController) that we successfully restored the
+        scroll position!
+
</ins><span class="cx"> 2015-12-01  Myles C. Maxfield  &lt;mmaxfield@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [iOS] Adjacent emoji overlap each other
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderFrameLoaderClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/FrameLoaderClient.h (192897 => 192898)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/FrameLoaderClient.h        2015-12-01 19:44:28 UTC (rev 192897)
+++ trunk/Source/WebCore/loader/FrameLoaderClient.h        2015-12-01 19:57:07 UTC (rev 192898)
</span><span class="lines">@@ -349,6 +349,8 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">         virtual void prefetchDNS(const String&amp;) = 0;
</span><ins>+
+        virtual void didRestoreScrollPosition() { }
</ins><span class="cx">     };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderHistoryControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/HistoryController.cpp (192897 => 192898)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/HistoryController.cpp        2015-12-01 19:44:28 UTC (rev 192897)
+++ trunk/Source/WebCore/loader/HistoryController.cpp        2015-12-01 19:57:07 UTC (rev 192898)
</span><span class="lines">@@ -153,10 +153,20 @@
</span><span class="cx">     // Don't restore scroll point on iOS as FrameLoaderClient::restoreViewState() does that.
</span><span class="cx">     if (view &amp;&amp; !view-&gt;wasScrolledByUser()) {
</span><span class="cx">         Page* page = m_frame.page();
</span><ins>+        auto desiredScrollPosition = m_currentItem-&gt;scrollPoint();
+
</ins><span class="cx">         if (page &amp;&amp; m_frame.isMainFrame() &amp;&amp; m_currentItem-&gt;pageScaleFactor())
</span><del>-            page-&gt;setPageScaleFactor(m_currentItem-&gt;pageScaleFactor() * page-&gt;viewScaleFactor(), m_currentItem-&gt;scrollPoint());
</del><ins>+            page-&gt;setPageScaleFactor(m_currentItem-&gt;pageScaleFactor() * page-&gt;viewScaleFactor(), desiredScrollPosition);
</ins><span class="cx">         else
</span><del>-            view-&gt;setScrollPosition(m_currentItem-&gt;scrollPoint());
</del><ins>+            view-&gt;setScrollPosition(desiredScrollPosition);
+
+        // If the scroll position doesn't have to be clamped, consider it successfully restored.
+        if (m_frame.isMainFrame()) {
+            auto adjustedDesiredScrollPosition = view-&gt;adjustScrollPositionWithinRange(desiredScrollPosition);
+            if (desiredScrollPosition == adjustedDesiredScrollPosition)
+                m_frame.loader().client().didRestoreScrollPosition();
+        }
+
</ins><span class="cx">     }
</span><span class="cx"> #endif
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (192897 => 192898)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-12-01 19:44:28 UTC (rev 192897)
+++ trunk/Source/WebKit2/ChangeLog        2015-12-01 19:57:07 UTC (rev 192898)
</span><span class="lines">@@ -1,3 +1,43 @@
</span><ins>+2015-12-01  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        Remove swipe snapshot before main document load if scroll position is already restored
+        https://bugs.webkit.org/show_bug.cgi?id=151224
+
+        Reviewed by Darin Adler.
+
+        * UIProcess/Cocoa/WebViewImpl.h:
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::WebViewImpl::didRestoreScrollPosition):
+        * UIProcess/PageClient.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::didRestoreScrollPosition):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/mac/PageClientImpl.h:
+        * UIProcess/mac/PageClientImpl.mm:
+        (WebKit::PageClientImpl::didRestoreScrollPosition):
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebKit::WebFrameLoaderClient::didRestoreScrollPosition):
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::didRestoreScrollPosition):
+        * WebProcess/WebPage/WebPage.h:
+        Plumb didRestoreScrollPosition through to ViewGestureController (yikes!).
+
+        * UIProcess/ViewGestureController.cpp:
+        (WebKit::ViewGestureController::didFirstVisuallyNonEmptyLayoutForMainFrame):
+        Cancel waiting for any more loads if we get to firstVisuallyNonEmptyLayout.
+
+        (WebKit::ViewGestureController::didReachMainFrameLoadTerminalState):
+        Cancel waiting for scroll position restoration if we make it to main frame load,
+        because there is a chance we won't be able to restore the old scroll position, and
+        by main frame load time we've tried as hard as we're going to to restore it.
+
+        * UIProcess/mac/ViewGestureControllerMac.mm:
+        (WebKit::ViewGestureController::endSwipeGesture):
+        Make some legacy-style-only code clearer that it's legacy-style-only.
+        Wait for scroll position restoration.
+
</ins><span class="cx"> 2015-12-01  Carlos Garcia Campos  &lt;cgarcia@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION(r192834): [GTK] Test /webkit2/WebKitWebView/editor-state/typing-attributes times out after r192834
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIgtkPageClientImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h (192897 => 192898)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h        2015-12-01 19:44:28 UTC (rev 192897)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h        2015-12-01 19:57:07 UTC (rev 192898)
</span><span class="lines">@@ -139,6 +139,8 @@
</span><span class="cx">     virtual void refView() override;
</span><span class="cx">     virtual void derefView() override;
</span><span class="cx"> 
</span><ins>+    virtual void didRestoreScrollPosition() override { }
+
</ins><span class="cx"> #if ENABLE(VIDEO)
</span><span class="cx">     virtual bool decicePolicyForInstallMissingMediaPluginsPermissionRequest(InstallMissingMediaPluginsPermissionRequest&amp;) override;
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWebViewImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h (192897 => 192898)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h        2015-12-01 19:44:28 UTC (rev 192897)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.h        2015-12-01 19:57:07 UTC (rev 192898)
</span><span class="lines">@@ -413,6 +413,8 @@
</span><span class="cx">     void gestureEventWasNotHandledByWebCore(NSEvent *);
</span><span class="cx">     void gestureEventWasNotHandledByWebCoreFromViewOnly(NSEvent *);
</span><span class="cx"> 
</span><ins>+    void didRestoreScrollPosition();
+
</ins><span class="cx">     void setTotalHeightOfBanners(CGFloat totalHeightOfBanners) { m_totalHeightOfBanners = totalHeightOfBanners; }
</span><span class="cx">     CGFloat totalHeightOfBanners() const { return m_totalHeightOfBanners; }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCocoaWebViewImplmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm (192897 => 192898)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm        2015-12-01 19:44:28 UTC (rev 192897)
+++ trunk/Source/WebKit2/UIProcess/Cocoa/WebViewImpl.mm        2015-12-01 19:57:07 UTC (rev 192898)
</span><span class="lines">@@ -3183,6 +3183,12 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebViewImpl::didRestoreScrollPosition()
+{
+    if (m_gestureController)
+        m_gestureController-&gt;didRestoreScrollPosition();
+}
+
</ins><span class="cx"> void WebViewImpl::doneWithKeyEvent(NSEvent *event, bool eventWasHandled)
</span><span class="cx"> {
</span><span class="cx">     if ([event type] != NSKeyDown)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessCoordinatedGraphicsWebViewh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/WebView.h (192897 => 192898)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/WebView.h        2015-12-01 19:44:28 UTC (rev 192897)
+++ trunk/Source/WebKit2/UIProcess/CoordinatedGraphics/WebView.h        2015-12-01 19:57:07 UTC (rev 192898)
</span><span class="lines">@@ -214,6 +214,8 @@
</span><span class="cx">     virtual void didChangeBackgroundColor() override { }
</span><span class="cx">     virtual void didFailLoadForMainFrame() override { }
</span><span class="cx"> 
</span><ins>+    virtual void didRestoreScrollPosition() override { }
+
</ins><span class="cx">     WebViewClient m_client;
</span><span class="cx">     RefPtr&lt;WebPageProxy&gt; m_page;
</span><span class="cx">     DefaultUndoController m_undoController;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessPageClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/PageClient.h (192897 => 192898)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/PageClient.h        2015-12-01 19:44:28 UTC (rev 192897)
+++ trunk/Source/WebKit2/UIProcess/PageClient.h        2015-12-01 19:57:07 UTC (rev 192898)
</span><span class="lines">@@ -355,6 +355,8 @@
</span><span class="cx"> #if USE(GSTREAMER)
</span><span class="cx">     virtual bool decicePolicyForInstallMissingMediaPluginsPermissionRequest(InstallMissingMediaPluginsPermissionRequest&amp;) = 0;
</span><span class="cx"> #endif
</span><ins>+
+    virtual void didRestoreScrollPosition() = 0;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessViewGestureControllercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ViewGestureController.cpp (192897 => 192898)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ViewGestureController.cpp        2015-12-01 19:44:28 UTC (rev 192897)
+++ trunk/Source/WebKit2/UIProcess/ViewGestureController.cpp        2015-12-01 19:57:07 UTC (rev 192898)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> #import &quot;ViewGestureController.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #import &quot;Logging.h&quot;
</span><ins>+#import &quot;RemoteLayerTreeDrawingAreaProxy.h&quot;
</ins><span class="cx"> #import &quot;ViewGestureControllerMessages.h&quot;
</span><span class="cx"> #import &quot;WebPageProxy.h&quot;
</span><span class="cx"> #import &quot;WebProcessProxy.h&quot;
</span><span class="lines">@@ -86,12 +87,9 @@
</span><span class="cx">     if (!m_snapshotRemovalTracker.eventOccurred(SnapshotRemovalTracker::VisuallyNonEmptyLayout))
</span><span class="cx">         return;
</span><span class="cx"> 
</span><ins>+    m_snapshotRemovalTracker.cancelOutstandingEvent(SnapshotRemovalTracker::MainFrameLoad);
+    m_snapshotRemovalTracker.cancelOutstandingEvent(SnapshotRemovalTracker::SubresourceLoads);
</ins><span class="cx">     m_snapshotRemovalTracker.startWatchdog(swipeSnapshotRemovalWatchdogAfterFirstVisuallyNonEmptyLayoutDuration);
</span><del>-
-    // FIXME: Ideally, this would be sufficient to cancel waiting for the main frame load,
-    // and would make snapshot removal faster, but we need didRestoreScrollPosition
-    // to be usable/accurate on all platforms before doing that, or we get a flash
-    // of the new page in the wrong position.
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ViewGestureController::didRepaintAfterNavigation()
</span><span class="lines">@@ -119,6 +117,17 @@
</span><span class="cx">     // enough for us too.
</span><span class="cx">     m_snapshotRemovalTracker.cancelOutstandingEvent(SnapshotRemovalTracker::VisuallyNonEmptyLayout);
</span><span class="cx"> 
</span><ins>+    // With Web-process scrolling, we check if the scroll position restoration succeeded by comparing the
+    // requested and actual scroll position. It's possible that we will never succeed in restoring
+    // the exact scroll position we wanted, in the case of a dynamic page, but we know that by
+    // main frame load time that we've gotten as close as we're going to get, so stop waiting.
+    // We don't want to do this with UI-side scrolling because scroll position restoration is baked into the transaction.
+    // FIXME: It seems fairly dirty to type-check the DrawingArea like this.
+    if (auto drawingArea = m_webPageProxy.drawingArea()) {
+        if (is&lt;RemoteLayerTreeDrawingAreaProxy&gt;(drawingArea))
+            m_snapshotRemovalTracker.cancelOutstandingEvent(SnapshotRemovalTracker::ScrollPositionRestoration);
+    }
+
</ins><span class="cx">     checkForActiveLoads();
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (192897 => 192898)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2015-12-01 19:44:28 UTC (rev 192897)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp        2015-12-01 19:57:07 UTC (rev 192898)
</span><span class="lines">@@ -6085,4 +6085,9 @@
</span><span class="cx">     m_process-&gt;send(Messages::WebPage::SetShouldScaleViewToFitDocument(shouldScaleViewToFitDocument), m_pageID);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebPageProxy::didRestoreScrollPosition()
+{
+    m_pageClient.didRestoreScrollPosition();
+}
+
</ins><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (192897 => 192898)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2015-12-01 19:44:28 UTC (rev 192897)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h        2015-12-01 19:57:07 UTC (rev 192898)
</span><span class="lines">@@ -1071,6 +1071,8 @@
</span><span class="cx"> 
</span><span class="cx">     void didLayout(uint32_t layoutMilestones);
</span><span class="cx"> 
</span><ins>+    void didRestoreScrollPosition();
+
</ins><span class="cx"> private:
</span><span class="cx">     WebPageProxy(PageClient&amp;, WebProcessProxy&amp;, uint64_t pageID, Ref&lt;API::PageConfiguration&gt;&amp;&amp;);
</span><span class="cx">     void platformInitialize();
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessWebPageProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in (192897 => 192898)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in        2015-12-01 19:44:28 UTC (rev 192897)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in        2015-12-01 19:57:07 UTC (rev 192898)
</span><span class="lines">@@ -445,4 +445,6 @@
</span><span class="cx"> #if ENABLE(VIDEO) &amp;&amp; USE(GSTREAMER)
</span><span class="cx">     RequestInstallMissingMediaPlugins(String details, String description)
</span><span class="cx"> #endif
</span><ins>+
+    DidRestoreScrollPosition()
</ins><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcesseflWebViewEflh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/efl/WebViewEfl.h (192897 => 192898)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/efl/WebViewEfl.h        2015-12-01 19:44:28 UTC (rev 192897)
+++ trunk/Source/WebKit2/UIProcess/efl/WebViewEfl.h        2015-12-01 19:57:07 UTC (rev 192898)
</span><span class="lines">@@ -93,6 +93,8 @@
</span><span class="cx">     virtual void refView() override final { }
</span><span class="cx">     virtual void derefView() override final { }
</span><span class="cx"> 
</span><ins>+    virtual void didRestoreScrollPosition() override final { }
+
</ins><span class="cx"> #if USE(GSTREAMER)
</span><span class="cx">     virtual bool decicePolicyForInstallMissingMediaPluginsPermissionRequest(InstallMissingMediaPluginsPermissionRequest&amp;) override final { return false; };
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosPageClientImplIOSh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h (192897 => 192898)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h        2015-12-01 19:44:28 UTC (rev 192897)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h        2015-12-01 19:57:07 UTC (rev 192898)
</span><span class="lines">@@ -191,6 +191,8 @@
</span><span class="cx">     virtual void refView() override;
</span><span class="cx">     virtual void derefView() override;
</span><span class="cx"> 
</span><ins>+    virtual void didRestoreScrollPosition() override;
+
</ins><span class="cx">     WKContentView *m_contentView;
</span><span class="cx">     WKWebView *m_webView;
</span><span class="cx">     RetainPtr&lt;WKEditorUndoTargetObjC&gt; m_undoTarget;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessiosPageClientImplIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm (192897 => 192898)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm        2015-12-01 19:44:28 UTC (rev 192897)
+++ trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm        2015-12-01 19:57:07 UTC (rev 192898)
</span><span class="lines">@@ -752,6 +752,10 @@
</span><span class="cx">     [m_webView release];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void PageClientImpl::didRestoreScrollPosition()
+{
+}
+
</ins><span class="cx"> } // namespace WebKit
</span><span class="cx"> 
</span><span class="cx"> #endif // PLATFORM(IOS)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacPageClientImplh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h (192897 => 192898)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h        2015-12-01 19:44:28 UTC (rev 192897)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.h        2015-12-01 19:57:07 UTC (rev 192898)
</span><span class="lines">@@ -237,6 +237,8 @@
</span><span class="cx"> 
</span><span class="cx">     virtual void refView() override;
</span><span class="cx">     virtual void derefView() override;
</span><ins>+
+    virtual void didRestoreScrollPosition() override;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacPageClientImplmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm (192897 => 192898)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm        2015-12-01 19:44:28 UTC (rev 192897)
+++ trunk/Source/WebKit2/UIProcess/mac/PageClientImpl.mm        2015-12-01 19:57:07 UTC (rev 192898)
</span><span class="lines">@@ -827,6 +827,11 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+void PageClientImpl::didRestoreScrollPosition()
+{
+    m_impl-&gt;didRestoreScrollPosition();
+}
+
</ins><span class="cx"> } // namespace WebKit
</span><span class="cx"> 
</span><span class="cx"> #endif // PLATFORM(MAC)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacViewGestureControllerMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm (192897 => 192898)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm        2015-12-01 19:44:28 UTC (rev 192897)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm        2015-12-01 19:57:07 UTC (rev 192898)
</span><span class="lines">@@ -734,11 +734,12 @@
</span><span class="cx"> 
</span><span class="cx">     m_swipeCancellationTracker = nullptr;
</span><span class="cx"> 
</span><ins>+#if ENABLE(LEGACY_SWIPE_SHADOW_STYLE)
</ins><span class="cx">     CALayer *rootLayer = m_webPageProxy.acceleratedCompositingRootLayer();
</span><ins>+    rootLayer.shadowOpacity = 0;
+    rootLayer.shadowRadius = 0;
+#endif
</ins><span class="cx"> 
</span><del>-    [rootLayer setShadowOpacity:0];
-    [rootLayer setShadowRadius:0];
-
</del><span class="cx">     if (cancelled) {
</span><span class="cx">         removeSwipeSnapshot();
</span><span class="cx">         m_webPageProxy.navigationGestureDidEnd(false, *targetItem);
</span><span class="lines">@@ -754,11 +755,10 @@
</span><span class="cx">     m_webPageProxy.navigationGestureDidEnd(true, *targetItem);
</span><span class="cx">     m_webPageProxy.goToBackForwardItem(targetItem);
</span><span class="cx"> 
</span><del>-    // FIXME: We should be able to include scroll position restoration here,
-    // and then can address the FIXME in didFirstVisuallyNonEmptyLayoutForMainFrame.
</del><span class="cx">     SnapshotRemovalTracker::Events desiredEvents = SnapshotRemovalTracker::VisuallyNonEmptyLayout
</span><span class="cx">         | SnapshotRemovalTracker::MainFrameLoad
</span><del>-        | SnapshotRemovalTracker::SubresourceLoads;
</del><ins>+        | SnapshotRemovalTracker::SubresourceLoads
+        | SnapshotRemovalTracker::ScrollPositionRestoration;
</ins><span class="cx">     if (renderTreeSize)
</span><span class="cx">         desiredEvents |= SnapshotRemovalTracker::RenderTreeSizeThreshold;
</span><span class="cx">     m_snapshotRemovalTracker.start(desiredEvents, [this] { this-&gt;forceRepaintIfNeeded(); });
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebFrameLoaderClientcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (192897 => 192898)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp        2015-12-01 19:44:28 UTC (rev 192897)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp        2015-12-01 19:57:07 UTC (rev 192898)
</span><span class="lines">@@ -1726,4 +1726,13 @@
</span><span class="cx">     WebProcess::singleton().prefetchDNS(hostname);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebFrameLoaderClient::didRestoreScrollPosition()
+{
+    WebPage* webPage = m_frame-&gt;page();
+    if (!webPage)
+        return;
+
+    webPage-&gt;didRestoreScrollPosition();
+}
+
</ins><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebCoreSupportWebFrameLoaderClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h (192897 => 192898)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h        2015-12-01 19:44:28 UTC (rev 192897)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h        2015-12-01 19:57:07 UTC (rev 192898)
</span><span class="lines">@@ -248,6 +248,8 @@
</span><span class="cx"> 
</span><span class="cx">     void prefetchDNS(const String&amp;) override;
</span><span class="cx"> 
</span><ins>+    void didRestoreScrollPosition() override;
+
</ins><span class="cx">     WebFrame* m_frame;
</span><span class="cx">     RefPtr&lt;PluginView&gt; m_pluginView;
</span><span class="cx">     bool m_hasSentResponseToPluginView;
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (192897 => 192898)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2015-12-01 19:44:28 UTC (rev 192897)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2015-12-01 19:57:07 UTC (rev 192898)
</span><span class="lines">@@ -5083,4 +5083,9 @@
</span><span class="cx">     send(Messages::WebPageProxy::DidLayout(milestones));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebPage::didRestoreScrollPosition()
+{
+    send(Messages::WebPageProxy::DidRestoreScrollPosition());
+}
+
</ins><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (192897 => 192898)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h        2015-12-01 19:44:28 UTC (rev 192897)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h        2015-12-01 19:57:07 UTC (rev 192898)
</span><span class="lines">@@ -916,6 +916,8 @@
</span><span class="cx"> 
</span><span class="cx">     void dispatchDidLayout(WebCore::LayoutMilestones);
</span><span class="cx"> 
</span><ins>+    void didRestoreScrollPosition();
+
</ins><span class="cx"> private:
</span><span class="cx">     WebPage(uint64_t pageID, const WebPageCreationParameters&amp;);
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>