<!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>[173595] 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/173595">173595</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2014-09-12 17:59:33 -0700 (Fri, 12 Sep 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Swiping back from a Twitter image to Twitter flashes to the wrong position
https://bugs.webkit.org/show_bug.cgi?id=136798
&lt;rdar://problem/18324338&gt;

Reviewed by Darin Adler and Sam Weinig.

* UIProcess/mac/ViewGestureController.h:
* UIProcess/mac/ViewGestureControllerMac.mm:
(WebKit::ViewGestureController::ViewGestureController):
(WebKit::ViewGestureController::didFinishLoadForMainFrame):
(WebKit::ViewGestureController::didSameDocumentNavigationForMainFrame):
Add a 250ms repeating timer that we start in didFinishLoadForMainFrame
if we are for some reason still loading, and in didSameDocumentNavigationForMainFrame
unconditionally, to match behavior of the old swipe implementation.

Also, do the active gesture check in both of those places so that we don't
start the timer if we're in the middle of a live swipe or have already torn
down the snapshot (removeSwipeSnapshotAfterRepaint does this as well, so
this isn't really a behavior change).

(WebKit::ViewGestureController::activeLoadMonitoringTimerFired):
Every time the timer fires, check if we're still loading; if not,
tear down the swipe snapshot (after repainting).

(WebKit::ViewGestureController::removeSwipeSnapshotAfterRepaint):
Stop the active load monitoring timer.

* wtf/RunLoop.h:
(WTF::RunLoop::TimerBase::startRepeating):
Add a std::chrono veresion of RunLoop::TimerBase::startRepeating.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtfRunLooph">trunk/Source/WTF/wtf/RunLoop.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacViewGestureControllerh">trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacViewGestureControllerMacmm">trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (173594 => 173595)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2014-09-13 00:35:19 UTC (rev 173594)
+++ trunk/Source/WTF/ChangeLog        2014-09-13 00:59:33 UTC (rev 173595)
</span><span class="lines">@@ -1,3 +1,15 @@
</span><ins>+2014-09-12  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        Swiping back from a Twitter image to Twitter flashes to the wrong position
+        https://bugs.webkit.org/show_bug.cgi?id=136798
+        &lt;rdar://problem/18324338&gt;
+
+        Reviewed by Darin Adler and Sam Weinig.
+
+        * wtf/RunLoop.h:
+        (WTF::RunLoop::TimerBase::startRepeating):
+        Add a std::chrono veresion of RunLoop::TimerBase::startRepeating.
+
</ins><span class="cx"> 2014-09-12  Geoffrey Garen  &lt;ggaren@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Rolled out r173540.
</span></span></pre></div>
<a id="trunkSourceWTFwtfRunLooph"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/RunLoop.h (173594 => 173595)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/RunLoop.h        2014-09-13 00:35:19 UTC (rev 173594)
+++ trunk/Source/WTF/wtf/RunLoop.h        2014-09-13 00:59:33 UTC (rev 173595)
</span><span class="lines">@@ -76,6 +76,7 @@
</span><span class="cx">         WTF_EXPORT_PRIVATE virtual ~TimerBase();
</span><span class="cx"> 
</span><span class="cx">         void startRepeating(double repeatInterval) { start(repeatInterval, true); }
</span><ins>+        void startRepeating(std::chrono::milliseconds repeatInterval) { startRepeating(repeatInterval.count() * 0.001); }
</ins><span class="cx">         void startOneShot(double interval) { start(interval, false); }
</span><span class="cx"> 
</span><span class="cx">         WTF_EXPORT_PRIVATE void stop();
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (173594 => 173595)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-09-13 00:35:19 UTC (rev 173594)
+++ trunk/Source/WebKit2/ChangeLog        2014-09-13 00:59:33 UTC (rev 173595)
</span><span class="lines">@@ -1,3 +1,32 @@
</span><ins>+2014-09-12  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+        Swiping back from a Twitter image to Twitter flashes to the wrong position
+        https://bugs.webkit.org/show_bug.cgi?id=136798
+        &lt;rdar://problem/18324338&gt;
+
+        Reviewed by Darin Adler and Sam Weinig.
+
+        * UIProcess/mac/ViewGestureController.h:
+        * UIProcess/mac/ViewGestureControllerMac.mm:
+        (WebKit::ViewGestureController::ViewGestureController):
+        (WebKit::ViewGestureController::didFinishLoadForMainFrame):
+        (WebKit::ViewGestureController::didSameDocumentNavigationForMainFrame):
+        Add a 250ms repeating timer that we start in didFinishLoadForMainFrame
+        if we are for some reason still loading, and in didSameDocumentNavigationForMainFrame
+        unconditionally, to match behavior of the old swipe implementation.
+
+        Also, do the active gesture check in both of those places so that we don't
+        start the timer if we're in the middle of a live swipe or have already torn
+        down the snapshot (removeSwipeSnapshotAfterRepaint does this as well, so
+        this isn't really a behavior change).
+
+        (WebKit::ViewGestureController::activeLoadMonitoringTimerFired):
+        Every time the timer fires, check if we're still loading; if not,
+        tear down the swipe snapshot (after repainting).
+
+        (WebKit::ViewGestureController::removeSwipeSnapshotAfterRepaint):
+        Stop the active load monitoring timer.
+
</ins><span class="cx"> 2014-09-12  Commit Queue  &lt;commit-queue@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r173575.
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacViewGestureControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h (173594 => 173595)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h        2014-09-13 00:35:19 UTC (rev 173594)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h        2014-09-13 00:59:33 UTC (rev 173595)
</span><span class="lines">@@ -134,6 +134,7 @@
</span><span class="cx">     void didCollectGeometryForSmartMagnificationGesture(WebCore::FloatPoint origin, WebCore::FloatRect renderRect, WebCore::FloatRect visibleContentBounds, bool isReplacedElement, double viewportMinimumScale, double viewportMaximumScale);
</span><span class="cx">     void didHitRenderTreeSizeThreshold();
</span><span class="cx">     void removeSwipeSnapshotAfterRepaint();
</span><ins>+    void activeLoadMonitoringTimerFired();
</ins><span class="cx"> 
</span><span class="cx">     void endMagnificationGesture();
</span><span class="cx">     WebCore::FloatPoint scaledMagnificationOrigin(WebCore::FloatPoint origin, double scale);
</span><span class="lines">@@ -163,6 +164,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx">     RunLoop::Timer&lt;ViewGestureController&gt; m_swipeWatchdogAfterFirstVisuallyNonEmptyLayoutTimer;
</span><ins>+    RunLoop::Timer&lt;ViewGestureController&gt; m_swipeActiveLoadMonitoringTimer;
</ins><span class="cx"> 
</span><span class="cx">     double m_magnification;
</span><span class="cx">     WebCore::FloatPoint m_magnificationOrigin;
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessmacViewGestureControllerMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm (173594 => 173595)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm        2014-09-13 00:35:19 UTC (rev 173594)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm        2014-09-13 00:59:33 UTC (rev 173595)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx"> 
</span><ins>+#import &quot;FrameLoadState.h&quot;
</ins><span class="cx"> #import &quot;NativeWebWheelEvent.h&quot;
</span><span class="cx"> #import &quot;WebPageGroup.h&quot;
</span><span class="cx"> #import &quot;ViewGestureControllerMessages.h&quot;
</span><span class="lines">@@ -79,6 +80,7 @@
</span><span class="cx"> static const float swipeSnapshotRemovalRenderTreeSizeTargetFraction = 0.5;
</span><span class="cx"> static const std::chrono::seconds swipeSnapshotRemovalWatchdogDuration = 5_s;
</span><span class="cx"> static const std::chrono::seconds swipeSnapshotRemovalWatchdogAfterFirstVisuallyNonEmptyLayoutDuration = 3_s;
</span><ins>+static const std::chrono::milliseconds swipeSnapshotRemovalActiveLoadMonitoringInterval = 250_ms;
</ins><span class="cx"> 
</span><span class="cx"> @interface WKSwipeCancellationTracker : NSObject {
</span><span class="cx"> @private
</span><span class="lines">@@ -100,6 +102,7 @@
</span><span class="cx">     , m_activeGestureType(ViewGestureType::None)
</span><span class="cx">     , m_swipeWatchdogTimer(RunLoop::main(), this, &amp;ViewGestureController::swipeSnapshotWatchdogTimerFired)
</span><span class="cx">     , m_swipeWatchdogAfterFirstVisuallyNonEmptyLayoutTimer(RunLoop::main(), this, &amp;ViewGestureController::swipeSnapshotWatchdogTimerFired)
</span><ins>+    , m_swipeActiveLoadMonitoringTimer(RunLoop::main(), this, &amp;ViewGestureController::activeLoadMonitoringTimerFired)
</ins><span class="cx">     , m_lastMagnificationGestureWasSmartMagnification(false)
</span><span class="cx">     , m_visibleContentRectIsValid(false)
</span><span class="cx">     , m_frameHandlesMagnificationGesture(false)
</span><span class="lines">@@ -717,14 +720,33 @@
</span><span class="cx"> 
</span><span class="cx"> void ViewGestureController::didFinishLoadForMainFrame()
</span><span class="cx"> {
</span><ins>+    if (m_activeGestureType != ViewGestureType::Swipe || m_swipeInProgress)
+        return;
+
+    if (m_webPageProxy.pageLoadState().isLoading()) {
+        m_swipeActiveLoadMonitoringTimer.startRepeating(swipeSnapshotRemovalActiveLoadMonitoringInterval);
+        return;
+    }
+
</ins><span class="cx">     removeSwipeSnapshotAfterRepaint();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void ViewGestureController::didSameDocumentNavigationForMainFrame(SameDocumentNavigationType type)
</span><span class="cx"> {
</span><ins>+    if (m_activeGestureType != ViewGestureType::Swipe || m_swipeInProgress)
+        return;
+
</ins><span class="cx">     if (type != SameDocumentNavigationSessionStateReplace &amp;&amp; type != SameDocumentNavigationSessionStatePop)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><ins>+    m_swipeActiveLoadMonitoringTimer.startRepeating(swipeSnapshotRemovalActiveLoadMonitoringInterval);
+}
+
+void ViewGestureController::activeLoadMonitoringTimerFired()
+{
+    if (m_webPageProxy.pageLoadState().isLoading())
+        return;
+
</ins><span class="cx">     removeSwipeSnapshotAfterRepaint();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -735,6 +757,8 @@
</span><span class="cx"> 
</span><span class="cx"> void ViewGestureController::removeSwipeSnapshotAfterRepaint()
</span><span class="cx"> {
</span><ins>+    m_swipeActiveLoadMonitoringTimer.stop();
+
</ins><span class="cx">     if (m_activeGestureType != ViewGestureType::Swipe || m_swipeInProgress)
</span><span class="cx">         return;
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>