<!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>[153459] branches/safari-537-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/153459">153459</a></dd>
<dt>Author</dt> <dd>lforschler@apple.com</dd>
<dt>Date</dt> <dd>2013-07-29 21:51:50 -0700 (Mon, 29 Jul 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merged <a href="http://trac.webkit.org/projects/webkit/changeset/153458">r153458</a>.  &lt;rdar://problem/14568841&gt;</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari537branchSourceWebKit2ChangeLog">branches/safari-537-branch/Source/WebKit2/ChangeLog</a></li>
<li><a href="#branchessafari537branchSourceWebKit2UIProcessAPImacWKViewmm">branches/safari-537-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm</a></li>
<li><a href="#branchessafari537branchSourceWebKit2UIProcessWebPageProxycpp">branches/safari-537-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#branchessafari537branchSourceWebKit2UIProcessWebPageProxyh">branches/safari-537-branch/Source/WebKit2/UIProcess/WebPageProxy.h</a></li>
<li><a href="#branchessafari537branchSourceWebKit2WebProcessWebPageWebPagecpp">branches/safari-537-branch/Source/WebKit2/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#branchessafari537branchSourceWebKit2WebProcessWebPageWebPageh">branches/safari-537-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h</a></li>
<li><a href="#branchessafari537branchSourceWebKit2WebProcessWebPageWebPagemessagesin">branches/safari-537-branch/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in</a></li>
<li><a href="#branchessafari537branchSourceWebKit2WebProcessWebPagemacWebPageMacmm">branches/safari-537-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari537branchSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-537-branch/Source/WebKit2/ChangeLog (153458 => 153459)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-537-branch/Source/WebKit2/ChangeLog        2013-07-30 04:45:06 UTC (rev 153458)
+++ branches/safari-537-branch/Source/WebKit2/ChangeLog        2013-07-30 04:51:50 UTC (rev 153459)
</span><span class="lines">@@ -1,5 +1,52 @@
</span><span class="cx"> 2013-07-29  Lucas Forschler  &lt;lforschler@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r153458
+
+    2013-07-29  Tim Horton  &lt;timothy_horton@apple.com&gt;
+
+            [wk2] Flush the WebProcess’ implicit transaction when using endDeferringViewInWindowChangesSync
+            https://bugs.webkit.org/show_bug.cgi?id=119225
+            &lt;rdar://problem/14568841&gt;
+
+            Reviewed by Simon Fraser.
+
+            Tell CoreAnimation to flush the implicit transaction before replying
+            when using endDeferringViewInWindowChangesSync, as that method's contract
+            is that the WebProcess is totally ready to be in-window when it returns.
+
+            * UIProcess/API/mac/WKView.mm:
+            (-[WKView endDeferringViewInWindowChanges]):
+            Adopt viewInWindowStateDidChange.
+
+            (-[WKView endDeferringViewInWindowChangesSync]):
+            Adopt viewInWindowStateDidChange, asking it to send a reply only if we're going to wait for one.
+
+            * UIProcess/WebPageProxy.cpp:
+            (WebKit::WebPageProxy::viewInWindowStateDidChange):
+            (WebKit::WebPageProxy::viewStateDidChange):
+            Pull viewInWindowStateDidChange out of viewStateDidChange.
+            Request a reply from SetIsInWindow if we're told to.
+
+            * UIProcess/WebPageProxy.h: Add WantsReplyOrNot and viewInWindowStateDidChange.
+            * WebProcess/WebPage/WebPage.cpp:
+            (WebKit::WebPage::didUpdateInWindowStateTimerFired):
+            Don't build this version on Mac, we'll have a WebPageMac version.
+
+            (WebKit::WebPage::setIsInWindow):
+            Only start the timer to send the didUpdateInWindowState reply if we're asked to.
+
+            * WebProcess/WebPage/WebPage.h:
+            * WebProcess/WebPage/WebPage.messages.in:
+            Add an argument to the SetIsInWindow message for whether the WebProcess
+            should inform the UIProcess when SetIsInWindow completes or not.
+
+            * WebProcess/WebPage/mac/WebPageMac.mm:
+            (WebKit::WebPage::didUpdateInWindowStateTimerFired):
+            Tell CA to flush the implicit transaction before telling the UIProcess that
+            we're finished moving in-window.
+
+2013-07-29  Lucas Forschler  &lt;lforschler@apple.com&gt;
+
</ins><span class="cx">         Merge r153449
</span><span class="cx"> 
</span><span class="cx">     2013-07-29  Tim Horton  &lt;timothy_horton@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari537branchSourceWebKit2UIProcessAPImacWKViewmm"></a>
<div class="modfile"><h4>Modified: branches/safari-537-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm (153458 => 153459)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-537-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm        2013-07-30 04:45:06 UTC (rev 153458)
+++ branches/safari-537-branch/Source/WebKit2/UIProcess/API/mac/WKView.mm        2013-07-30 04:51:50 UTC (rev 153459)
</span><span class="lines">@@ -3387,7 +3387,7 @@
</span><span class="cx">     _data-&gt;_shouldDeferViewInWindowChanges = NO;
</span><span class="cx"> 
</span><span class="cx">     if (_data-&gt;_viewInWindowChangeWasDeferred) {
</span><del>-        _data-&gt;_page-&gt;viewStateDidChange(WebPageProxy::ViewIsInWindow);
</del><ins>+        _data-&gt;_page-&gt;viewInWindowStateDidChange();
</ins><span class="cx">         _data-&gt;_viewInWindowChangeWasDeferred = NO;
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="lines">@@ -3402,8 +3402,13 @@
</span><span class="cx">     PageClient* pageClient = _data-&gt;_pageClient.get();
</span><span class="cx">     bool hasPendingViewInWindowChange = _data-&gt;_viewInWindowChangeWasDeferred &amp;&amp; _data-&gt;_page-&gt;isInWindow() != pageClient-&gt;isViewInWindow();
</span><span class="cx"> 
</span><del>-    [self endDeferringViewInWindowChanges];
</del><ins>+    _data-&gt;_shouldDeferViewInWindowChanges = NO;
</ins><span class="cx"> 
</span><ins>+    if (_data-&gt;_viewInWindowChangeWasDeferred) {
+        _data-&gt;_page-&gt;viewInWindowStateDidChange(hasPendingViewInWindowChange ? WebPageProxy::WantsReplyOrNot::DoesWantReply : WebPageProxy::WantsReplyOrNot::DoesNotWantReply);
+        _data-&gt;_viewInWindowChangeWasDeferred = NO;
+    }
+
</ins><span class="cx">     if (hasPendingViewInWindowChange)
</span><span class="cx">         _data-&gt;_page-&gt;waitForDidUpdateInWindowState();
</span><span class="cx"> }
</span></span></pre></div>
<a id="branchessafari537branchSourceWebKit2UIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: branches/safari-537-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp (153458 => 153459)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-537-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp        2013-07-30 04:45:06 UTC (rev 153458)
+++ branches/safari-537-branch/Source/WebKit2/UIProcess/WebPageProxy.cpp        2013-07-30 04:51:50 UTC (rev 153459)
</span><span class="lines">@@ -1035,6 +1035,26 @@
</span><span class="cx">     m_pageClient-&gt;scrollView(scrollRect, scrollOffset);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebPageProxy::viewInWindowStateDidChange(WantsReplyOrNot wantsReply)
+{
+    if (!isValid())
+        return;
+
+    bool isInWindow = m_pageClient-&gt;isViewInWindow();
+    if (m_isInWindow != isInWindow) {
+        m_isInWindow = isInWindow;
+        m_process-&gt;send(Messages::WebPage::SetIsInWindow(isInWindow, wantsReply == WantsReplyOrNot::DoesWantReply), m_pageID);
+    }
+
+    if (isInWindow) {
+        LayerHostingMode layerHostingMode = m_pageClient-&gt;viewLayerHostingMode();
+        if (m_layerHostingMode != layerHostingMode) {
+            m_layerHostingMode = layerHostingMode;
+            m_drawingArea-&gt;layerHostingModeDidChange();
+        }
+    }
+}
+
</ins><span class="cx"> void WebPageProxy::viewStateDidChange(ViewStateFlags flags)
</span><span class="cx"> {
</span><span class="cx">     if (!isValid())
</span><span class="lines">@@ -1067,22 +1087,9 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    if (flags &amp; ViewIsInWindow) {
-        bool isInWindow = m_pageClient-&gt;isViewInWindow();
-        if (m_isInWindow != isInWindow) {
-            m_isInWindow = isInWindow;
-            m_process-&gt;send(Messages::WebPage::SetIsInWindow(isInWindow), m_pageID);
-        }
</del><ins>+    if (flags &amp; ViewIsInWindow)
+        viewInWindowStateDidChange();
</ins><span class="cx"> 
</span><del>-        if (isInWindow) {
-            LayerHostingMode layerHostingMode = m_pageClient-&gt;viewLayerHostingMode();
-            if (m_layerHostingMode != layerHostingMode) {
-                m_layerHostingMode = layerHostingMode;
-                m_drawingArea-&gt;layerHostingModeDidChange();
-            }
-        }
-    }
-
</del><span class="cx"> #if ENABLE(PAGE_VISIBILITY_API)
</span><span class="cx">     PageVisibilityState visibilityState = PageVisibilityStateHidden;
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari537branchSourceWebKit2UIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: branches/safari-537-branch/Source/WebKit2/UIProcess/WebPageProxy.h (153458 => 153459)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-537-branch/Source/WebKit2/UIProcess/WebPageProxy.h        2013-07-30 04:45:06 UTC (rev 153458)
+++ branches/safari-537-branch/Source/WebKit2/UIProcess/WebPageProxy.h        2013-07-30 04:51:50 UTC (rev 153459)
</span><span class="lines">@@ -343,6 +343,8 @@
</span><span class="cx">     };
</span><span class="cx">     typedef unsigned ViewStateFlags;
</span><span class="cx">     void viewStateDidChange(ViewStateFlags flags);
</span><ins>+    enum class WantsReplyOrNot { DoesNotWantReply, DoesWantReply };
+    void viewInWindowStateDidChange(WantsReplyOrNot = WantsReplyOrNot::DoesNotWantReply);
</ins><span class="cx">     bool isInWindow() const { return m_isInWindow; }
</span><span class="cx">     void waitForDidUpdateInWindowState();
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari537branchSourceWebKit2WebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: branches/safari-537-branch/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (153458 => 153459)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-537-branch/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2013-07-30 04:45:06 UTC (rev 153458)
+++ branches/safari-537-branch/Source/WebKit2/WebProcess/WebPage/WebPage.cpp        2013-07-30 04:51:50 UTC (rev 153459)
</span><span class="lines">@@ -2128,10 +2128,12 @@
</span><span class="cx">         m_page-&gt;setCanStartMedia(true);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+#if !PLATFORM(MAC)
</ins><span class="cx"> void WebPage::didUpdateInWindowStateTimerFired()
</span><span class="cx"> {
</span><span class="cx">     send(Messages::WebPageProxy::DidUpdateInWindowState());
</span><span class="cx"> }
</span><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx"> inline bool WebPage::canHandleUserEvents() const
</span><span class="cx"> {
</span><span class="lines">@@ -2142,7 +2144,7 @@
</span><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void WebPage::setIsInWindow(bool isInWindow)
</del><ins>+void WebPage::setIsInWindow(bool isInWindow, bool wantsDidUpdateViewInWindowState)
</ins><span class="cx"> {
</span><span class="cx">     bool pageWasInWindow = m_page-&gt;isInWindow();
</span><span class="cx">     
</span><span class="lines">@@ -2167,7 +2169,9 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     m_page-&gt;setIsInWindow(isInWindow);
</span><del>-    m_sendDidUpdateInWindowStateTimer.startOneShot(0);
</del><ins>+
+    if (wantsDidUpdateViewInWindowState)
+        m_sendDidUpdateInWindowStateTimer.startOneShot(0);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPage::didReceivePolicyDecision(uint64_t frameID, uint64_t listenerID, uint32_t policyAction, uint64_t downloadID)
</span></span></pre></div>
<a id="branchessafari537branchSourceWebKit2WebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: branches/safari-537-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h (153458 => 153459)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-537-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h        2013-07-30 04:45:06 UTC (rev 153458)
+++ branches/safari-537-branch/Source/WebKit2/WebProcess/WebPage/WebPage.h        2013-07-30 04:51:50 UTC (rev 153459)
</span><span class="lines">@@ -714,7 +714,7 @@
</span><span class="cx">     void setFocused(bool);
</span><span class="cx">     void setInitialFocus(bool forward, bool isKeyboardEventValid, const WebKeyboardEvent&amp;);
</span><span class="cx">     void setWindowResizerSize(const WebCore::IntSize&amp;);
</span><del>-    void setIsInWindow(bool);
</del><ins>+    void setIsInWindow(bool isInWindow, bool wantsDidUpdateViewInWindowState = false);
</ins><span class="cx">     void validateCommand(const String&amp;, uint64_t);
</span><span class="cx">     void executeEditCommand(const String&amp;);
</span><span class="cx"> 
</span></span></pre></div>
<a id="branchessafari537branchSourceWebKit2WebProcessWebPageWebPagemessagesin"></a>
<div class="modfile"><h4>Modified: branches/safari-537-branch/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in (153458 => 153459)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-537-branch/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in        2013-07-30 04:45:06 UTC (rev 153458)
+++ branches/safari-537-branch/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in        2013-07-30 04:51:50 UTC (rev 153459)
</span><span class="lines">@@ -24,7 +24,7 @@
</span><span class="cx">     SetActive(bool active)
</span><span class="cx">     SetFocused(bool focused)
</span><span class="cx">     SetInitialFocus(bool forward, bool isKeyboardEventValid, WebKit::WebKeyboardEvent event)
</span><del>-    SetIsInWindow(bool isInWindow)
</del><ins>+    SetIsInWindow(bool isInWindow, bool wantsDidUpdateViewInWindowState)
</ins><span class="cx"> 
</span><span class="cx">     SetDrawsBackground(bool drawsBackground)
</span><span class="cx">     SetDrawsTransparentBackground(bool drawsTransparentBackground)
</span></span></pre></div>
<a id="branchessafari537branchSourceWebKit2WebProcessWebPagemacWebPageMacmm"></a>
<div class="modfile"><h4>Modified: branches/safari-537-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (153458 => 153459)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-537-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm        2013-07-30 04:45:06 UTC (rev 153458)
+++ branches/safari-537-branch/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm        2013-07-30 04:51:50 UTC (rev 153459)
</span><span class="lines">@@ -980,4 +980,10 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebPage::didUpdateInWindowStateTimerFired()
+{
+    [CATransaction flush];
+    send(Messages::WebPageProxy::DidUpdateInWindowState());
+}
+
</ins><span class="cx"> } // namespace WebKit
</span></span></pre>
</div>
</div>

</body>
</html>