<!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>[178996] branches/safari-600.1.4.15-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/178996">178996</a></dd>
<dt>Author</dt> <dd>ddkilzer@apple.com</dd>
<dt>Date</dt> <dd>2015-01-23 02:04:40 -0800 (Fri, 23 Jan 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merged <a href="http://trac.webkit.org/projects/webkit/changeset/172966">r172966</a>.  rdar://problem/19395075</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari6001415branchSourceWebKit2ChangeLog">branches/safari-600.1.4.15-branch/Source/WebKit2/ChangeLog</a></li>
<li><a href="#branchessafari6001415branchSourceWebKit2UIProcessAPImacWKViewmm">branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm</a></li>
<li><a href="#branchessafari6001415branchSourceWebKit2UIProcessAPImacWKViewInternalh">branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h</a></li>
<li><a href="#branchessafari6001415branchSourceWebKit2UIProcessPageClienth">branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/PageClient.h</a></li>
<li><a href="#branchessafari6001415branchSourceWebKit2UIProcessWebPageProxycpp">branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#branchessafari6001415branchSourceWebKit2UIProcessiosPageClientImplIOSh">branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h</a></li>
<li><a href="#branchessafari6001415branchSourceWebKit2UIProcessiosPageClientImplIOSmm">branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm</a></li>
<li><a href="#branchessafari6001415branchSourceWebKit2UIProcessmacPageClientImplh">branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.h</a></li>
<li><a href="#branchessafari6001415branchSourceWebKit2UIProcessmacPageClientImplmm">branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari6001415branchSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/ChangeLog (178995 => 178996)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/ChangeLog        2015-01-23 10:04:37 UTC (rev 178995)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/ChangeLog        2015-01-23 10:04:40 UTC (rev 178996)
</span><span class="lines">@@ -1,5 +1,83 @@
</span><span class="cx"> 2015-01-22  David Kilzer  &lt;ddkilzer@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r172966.
+
+    2014-08-26  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        REGRESSION (r172771): Amazon product page becomes unresponsive after swiping back to it
+        https://bugs.webkit.org/show_bug.cgi?id=136260
+        &lt;rdar://problem/18107826&gt;
+
+        Reviewed by Dan Bernstein.
+
+        Previously, when a swipe ended up performing a same-document navigation,
+        we would never get didFinishLoadForMainFrame nor didFirstVisuallyNonEmptyLayoutForMainFrame
+        nor would we even get didHitRenderTreeSizeThreshold in all cases, so we would never
+        remove the swipe snapshot. Previous implementations removed the snapshot on
+        didSameDocumentNavigation for the main frame if the navigation type was Replace or Pop,
+        so we will match that behavior.
+
+        Also, reinstate the watchdog that starts at swipe-end which would have prevented
+        this bug from forever breaking the view it was associated with.
+
+        Also, defend against removing the snapshot before the swipe has finished (before
+        we have even caused the navigation that we're watching for the effects of).
+
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView _didSameDocumentNavigationForMainFrame:]):
+        * UIProcess/API/mac/WKViewInternal.h:
+        * UIProcess/PageClient.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::didSameDocumentNavigationForFrame):
+        * UIProcess/ios/PageClientImplIOS.h:
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::didSameDocumentNavigationForMainFrame):
+        * UIProcess/mac/PageClientImpl.h:
+        * UIProcess/mac/PageClientImpl.mm:
+        (WebKit::PageClientImpl::didSameDocumentNavigationForMainFrame):
+        Plumb main-frame same-document navigation notification from WebPageProxy
+        to ViewGestureControllerMac via PageClient and WKView.
+
+        * UIProcess/mac/ViewGestureController.h:
+        * UIProcess/mac/ViewGestureControllerMac.mm:
+        (WebKit::ViewGestureController::ViewGestureController):
+        (WebKit::ViewGestureController::beginSwipeGesture):
+        (WebKit::ViewGestureController::endSwipeGesture):
+        Keep track of whether a swipe is currently occurring. We can't use
+        activeGestureType for this because the swipe currently remains the &quot;active&quot;
+        gesture until the snapshot is removed.
+
+        Reintroduce the old swipeWatchdogTimer (and rename the shorter timer that starts
+        when we get a visually non-empty layout) so that we will always remove the
+        snapshot after 5 seconds, even if we haven't committed the load.
+        This could lead to flashing back to the old content if we fail to get a single
+        byte for 5 seconds, but that is a rare case and should eventually get additional
+        special treatment (dropping the tiles until we do get content, or some such).
+
+        (WebKit::ViewGestureController::didHitRenderTreeSizeThreshold):
+        If a swipe is still in progress, we haven't done our navigation and thus
+        don't care about render tree size changes.
+
+        (WebKit::ViewGestureController::didFirstVisuallyNonEmptyLayoutForMainFrame):
+        If a swipe is still in progress, we haven't done our navigation and thus
+        don't care about layouts.
+
+        Stop the 5 second overall watchdog if we start the 3 second after-visuallyNonEmptyLayout
+        watchdog. This means that the snapshot could stay up for a maximum of 8 seconds
+        for a very, very slow load.
+
+        (WebKit::ViewGestureController::didFinishLoadForMainFrame):
+        If a swipe is still in progress, we haven't done our navigation and thus
+        don't care about loads that complete.
+
+        (WebKit::ViewGestureController::didSameDocumentNavigationForMainFrame):
+        Remove the swipe snapshot after painting if we do replaceState or popState.
+
+        (WebKit::ViewGestureController::removeSwipeSnapshotAfterRepaint):
+        If a swipe is still in progress, we shouldn't remove the snapshot yet.
+
+2015-01-22  David Kilzer  &lt;ddkilzer@apple.com&gt;
+
</ins><span class="cx">         Merge r173762.
</span><span class="cx"> 
</span><span class="cx">     2014-09-19  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebKit2UIProcessAPImacWKViewmm"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm (178995 => 178996)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm        2015-01-23 10:04:37 UTC (rev 178995)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm        2015-01-23 10:04:40 UTC (rev 178996)
</span><span class="lines">@@ -3598,6 +3598,12 @@
</span><span class="cx"> 
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+- (void)_didSameDocumentNavigationForMainFrame:(SameDocumentNavigationType)type
+{
+    if (_data-&gt;_gestureController)
+        _data-&gt;_gestureController-&gt;didSameDocumentNavigationForMainFrame(type);
+}
+
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> @implementation WKView (Private)
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebKit2UIProcessAPImacWKViewInternalh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h (178995 => 178996)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h        2015-01-23 10:04:37 UTC (rev 178995)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h        2015-01-23 10:04:40 UTC (rev 178996)
</span><span class="lines">@@ -26,6 +26,7 @@
</span><span class="cx"> #import &quot;WKViewPrivate.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #import &quot;PluginComplexTextInputState.h&quot;
</span><ins>+#import &quot;SameDocumentNavigationType.h&quot;
</ins><span class="cx"> #import &quot;WebFindOptions.h&quot;
</span><span class="cx"> #import &lt;wtf/Forward.h&gt;
</span><span class="cx"> #import &lt;wtf/RetainPtr.h&gt;
</span><span class="lines">@@ -107,6 +108,8 @@
</span><span class="cx"> - (void)_setSuppressVisibilityUpdates:(BOOL)suppressVisibilityUpdates;
</span><span class="cx"> - (BOOL)_suppressVisibilityUpdates;
</span><span class="cx"> 
</span><ins>+- (void)_didSameDocumentNavigationForMainFrame:(WebKit::SameDocumentNavigationType)type;
+
</ins><span class="cx"> #if WK_API_ENABLED
</span><span class="cx"> @property (nonatomic, setter=_setThumbnailView:) _WKThumbnailView *_thumbnailView;
</span><span class="cx"> - (void)_reparentLayerTreeInThumbnailView;
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebKit2UIProcessPageClienth"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/PageClient.h (178995 => 178996)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/PageClient.h        2015-01-23 10:04:37 UTC (rev 178995)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/PageClient.h        2015-01-23 10:04:40 UTC (rev 178996)
</span><span class="lines">@@ -302,6 +302,8 @@
</span><span class="cx">     virtual void navigationGestureWillEnd(bool willNavigate, WebBackForwardListItem&amp;) = 0;
</span><span class="cx">     virtual void navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem&amp;) = 0;
</span><span class="cx">     virtual void willRecordNavigationSnapshot(WebBackForwardListItem&amp;) = 0;
</span><ins>+
+    virtual void didSameDocumentNavigationForMainFrame(SameDocumentNavigationType) = 0;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp (178995 => 178996)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp        2015-01-23 10:04:37 UTC (rev 178995)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp        2015-01-23 10:04:40 UTC (rev 178996)
</span><span class="lines">@@ -2708,14 +2708,20 @@
</span><span class="cx"> 
</span><span class="cx">     auto transaction = m_pageLoadState.transaction();
</span><span class="cx"> 
</span><del>-    if (frame-&gt;isMainFrame())
</del><ins>+    bool isMainFrame = frame-&gt;isMainFrame();
+    if (isMainFrame)
</ins><span class="cx">         m_pageLoadState.didSameDocumentNavigation(transaction, url);
</span><span class="cx"> 
</span><span class="cx">     m_pageLoadState.clearPendingAPIRequestURL(transaction);
</span><span class="cx">     frame-&gt;didSameDocumentNavigation(url);
</span><span class="cx"> 
</span><span class="cx">     m_pageLoadState.commitChanges();
</span><del>-    m_loaderClient-&gt;didSameDocumentNavigationForFrame(this, frame, navigationID, static_cast&lt;SameDocumentNavigationType&gt;(opaqueSameDocumentNavigationType), userData.get());
</del><ins>+
+    SameDocumentNavigationType navigationType = static_cast&lt;SameDocumentNavigationType&gt;(opaqueSameDocumentNavigationType);
+    m_loaderClient-&gt;didSameDocumentNavigationForFrame(this, frame, navigationID, navigationType, userData.get());
+
+    if (isMainFrame)
+        m_pageClient.didSameDocumentNavigationForMainFrame(navigationType);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPageProxy::didReceiveTitleForFrame(uint64_t frameID, const String&amp; title, IPC::MessageDecoder&amp; decoder)
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebKit2UIProcessiosPageClientImplIOSh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h (178995 => 178996)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h        2015-01-23 10:04:37 UTC (rev 178995)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h        2015-01-23 10:04:40 UTC (rev 178996)
</span><span class="lines">@@ -176,6 +176,8 @@
</span><span class="cx">     virtual void navigationGestureDidEnd(bool willNavigate, WebBackForwardListItem&amp;) override;
</span><span class="cx">     virtual void willRecordNavigationSnapshot(WebBackForwardListItem&amp;) override;
</span><span class="cx"> 
</span><ins>+    virtual void didSameDocumentNavigationForMainFrame(SameDocumentNavigationType) 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="branchessafari6001415branchSourceWebKit2UIProcessiosPageClientImplIOSmm"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm (178995 => 178996)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm        2015-01-23 10:04:37 UTC (rev 178995)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm        2015-01-23 10:04:40 UTC (rev 178996)
</span><span class="lines">@@ -687,6 +687,10 @@
</span><span class="cx">     NavigationState::fromWebPage(*m_webView-&gt;_page).willRecordNavigationSnapshot(item);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void PageClientImpl::didSameDocumentNavigationForMainFrame(SameDocumentNavigationType)
+{
+}
+
</ins><span class="cx"> } // namespace WebKit
</span><span class="cx"> 
</span><span class="cx"> #endif // PLATFORM(IOS)
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebKit2UIProcessmacPageClientImplh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.h (178995 => 178996)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.h        2015-01-23 10:04:37 UTC (rev 178995)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.h        2015-01-23 10:04:40 UTC (rev 178996)
</span><span class="lines">@@ -180,6 +180,8 @@
</span><span class="cx"> 
</span><span class="cx">     NSView *activeView() const;
</span><span class="cx"> 
</span><ins>+    virtual void didSameDocumentNavigationForMainFrame(SameDocumentNavigationType) override;
+
</ins><span class="cx">     WKView *m_wkView;
</span><span class="cx">     WKWebView *m_webView;
</span><span class="cx">     RetainPtr&lt;WKEditorUndoTargetObjC&gt; m_undoTarget;
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebKit2UIProcessmacPageClientImplmm"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.mm (178995 => 178996)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.mm        2015-01-23 10:04:37 UTC (rev 178995)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/mac/PageClientImpl.mm        2015-01-23 10:04:40 UTC (rev 178996)
</span><span class="lines">@@ -727,6 +727,11 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void PageClientImpl::didSameDocumentNavigationForMainFrame(SameDocumentNavigationType type)
+{
+    [m_wkView _didSameDocumentNavigationForMainFrame:type];
+}
+
</ins><span class="cx"> } // namespace WebKit
</span><span class="cx"> 
</span><span class="cx"> #endif // PLATFORM(MAC)
</span></span></pre>
</div>
</div>

</body>
</html>