<!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>[236257] trunk/Source/WebKit</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/236257">236257</a></dd>
<dt>Author</dt> <dd>antti@apple.com</dd>
<dt>Date</dt> <dd>2018-09-20 04:49:55 -0700 (Thu, 20 Sep 2018)</dd>
</dl>

<h3>Log Message</h3>
<pre>REGRESSION (PSON): White or Black flash occurs when process swapping on navigation on Mac
https://bugs.webkit.org/show_bug.cgi?id=189663
<rdar://problem/44184955>

Reviewed by Geoff Garen and Chris Dumez.

We need to keep the layer tree of the previous page alive and visible until we have something
to render on the new page. With PSON on Mac this means that we should keep displaying the
layer tree from the previus process.

This patch moves the management of 'attaching' the drawing area (Mac only concept) from web process
to UI process. This is when we parent the layer tree to the view root layer. It also ensures that
the layer tree is not deleted too early on process swap and that it still eventually gets deleted.

* UIProcess/DrawingAreaProxy.h:
(WebKit::DrawingAreaProxy::attachInWebProcess):
* UIProcess/SuspendedPageProxy.cpp:
(WebKit::messageNamesToIgnoreWhileSuspended):
(WebKit::SuspendedPageProxy::tearDownDrawingAreaInWebProcess):

We no longer tear down drawing area (layer tree) for suspended pages automatically. Send an explicit
message for it.

* UIProcess/SuspendedPageProxy.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didCompletePageTransition):

Attach the drawing area if appropriate.

(WebKit::WebPageProxy::resetStateAfterProcessExited):

Call PageClien::processWillSwap instead of processDidExit when appropriate.

(WebKit::WebPageProxy::enterAcceleratedCompositingMode):

This is called when we have switched to the new layer tree.
Tear down the drawing area in the previus process.

* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::processWillSwap):

On iOS this just call processDidExit for now.

* UIProcess/mac/PageClientImplMac.h:
* UIProcess/mac/PageClientImplMac.mm:
(WebKit::PageClientImpl::processWillSwap):
(WebKit::PageClientImpl::processDidExit):

Add processWillSwap separately from processDidExit. They are currently the same
except processWillSwap doesn't clear the root layer.

* UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h:
* UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm:
(WebKit::TiledCoreAnimationDrawingAreaProxy::attachInWebProcess):

Send a message to the web process to attach the drawing area.

* WebProcess/WebPage/DrawingArea.h:
(WebKit::DrawingArea::attach):
(WebKit::DrawingArea::attachDrawingArea): Deleted.

Rename to be less redundant.

* WebProcess/WebPage/DrawingArea.messages.in:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::reinitializeWebPage):

Don't attach drawing area automatically. It will be done by a message from UI process.

(WebKit::WebPage::setLayerTreeStateIsFrozen):

Layer tree is always frozen in a suspended process (if it exists).

(WebKit::WebPage::didReceivePolicyDecision):

Suspend immediately when receiving policy decision to avoid flash on 'about:blank' loading.

(WebKit::WebPage::didStartPageTransition):
(WebKit::WebPage::didCompletePageTransition):

Notify UI process of transition completion.

(WebKit::WebPage::setIsSuspended):
(WebKit::WebPage::tearDownDrawingAreaForSuspend):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
* WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
(WebKit::TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea):

Don't attach drawing area automatically. It will be done by a message from UI process.

(WebKit::TiledCoreAnimationDrawingArea::attach):
(WebKit::TiledCoreAnimationDrawingArea::attachDrawingArea): Deleted.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitUIProcessCocoaWebViewImplmm">trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessDrawingAreaProxyh">trunk/Source/WebKit/UIProcess/DrawingAreaProxy.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessPageClienth">trunk/Source/WebKit/UIProcess/PageClient.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessSuspendedPageProxycpp">trunk/Source/WebKit/UIProcess/SuspendedPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKitUIProcessSuspendedPageProxyh">trunk/Source/WebKit/UIProcess/SuspendedPageProxy.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessWebPageProxycpp">trunk/Source/WebKit/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKitUIProcessWebPageProxyh">trunk/Source/WebKit/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessWebPageProxymessagesin">trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in</a></li>
<li><a href="#trunkSourceWebKitUIProcessiosPageClientImplIOSh">trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessiosPageClientImplIOSmm">trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessmacPageClientImplMach">trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessmacPageClientImplMacmm">trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessmacTiledCoreAnimationDrawingAreaProxyh">trunk/Source/WebKit/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessmacTiledCoreAnimationDrawingAreaProxymm">trunk/Source/WebKit/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageDrawingAreah">trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageDrawingAreamessagesin">trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.messages.in</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageWebPagecpp">trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageWebPageh">trunk/Source/WebKit/WebProcess/WebPage/WebPage.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPageWebPagemessagesin">trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPagemacTiledCoreAnimationDrawingAreah">trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h</a></li>
<li><a href="#trunkSourceWebKitWebProcessWebPagemacTiledCoreAnimationDrawingAreamm">trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (236256 => 236257)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2018-09-20 11:22:00 UTC (rev 236256)
+++ trunk/Source/WebKit/ChangeLog       2018-09-20 11:49:55 UTC (rev 236257)
</span><span class="lines">@@ -1,3 +1,103 @@
</span><ins>+2018-09-20  Antti Koivisto  <antti@apple.com>
+
+        REGRESSION (PSON): White or Black flash occurs when process swapping on navigation on Mac
+        https://bugs.webkit.org/show_bug.cgi?id=189663
+        <rdar://problem/44184955>
+
+        Reviewed by Geoff Garen and Chris Dumez.
+
+        We need to keep the layer tree of the previous page alive and visible until we have something
+        to render on the new page. With PSON on Mac this means that we should keep displaying the
+        layer tree from the previus process.
+
+        This patch moves the management of 'attaching' the drawing area (Mac only concept) from web process
+        to UI process. This is when we parent the layer tree to the view root layer. It also ensures that
+        the layer tree is not deleted too early on process swap and that it still eventually gets deleted.
+
+        * UIProcess/DrawingAreaProxy.h:
+        (WebKit::DrawingAreaProxy::attachInWebProcess):
+        * UIProcess/SuspendedPageProxy.cpp:
+        (WebKit::messageNamesToIgnoreWhileSuspended):
+        (WebKit::SuspendedPageProxy::tearDownDrawingAreaInWebProcess):
+
+        We no longer tear down drawing area (layer tree) for suspended pages automatically. Send an explicit
+        message for it.
+
+        * UIProcess/SuspendedPageProxy.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::didCompletePageTransition):
+
+        Attach the drawing area if appropriate.
+
+        (WebKit::WebPageProxy::resetStateAfterProcessExited):
+
+        Call PageClien::processWillSwap instead of processDidExit when appropriate.
+
+        (WebKit::WebPageProxy::enterAcceleratedCompositingMode):
+
+        This is called when we have switched to the new layer tree.
+        Tear down the drawing area in the previus process.
+
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/ios/PageClientImplIOS.h:
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::processWillSwap):
+
+        On iOS this just call processDidExit for now.
+
+        * UIProcess/mac/PageClientImplMac.h:
+        * UIProcess/mac/PageClientImplMac.mm:
+        (WebKit::PageClientImpl::processWillSwap):
+        (WebKit::PageClientImpl::processDidExit):
+
+        Add processWillSwap separately from processDidExit. They are currently the same
+        except processWillSwap doesn't clear the root layer.
+
+        * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h:
+        * UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm:
+        (WebKit::TiledCoreAnimationDrawingAreaProxy::attachInWebProcess):
+
+        Send a message to the web process to attach the drawing area.
+
+        * WebProcess/WebPage/DrawingArea.h:
+        (WebKit::DrawingArea::attach):
+        (WebKit::DrawingArea::attachDrawingArea): Deleted.
+
+        Rename to be less redundant.
+
+        * WebProcess/WebPage/DrawingArea.messages.in:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::reinitializeWebPage):
+
+        Don't attach drawing area automatically. It will be done by a message from UI process.
+
+        (WebKit::WebPage::setLayerTreeStateIsFrozen):
+
+        Layer tree is always frozen in a suspended process (if it exists).
+
+        (WebKit::WebPage::didReceivePolicyDecision):
+
+        Suspend immediately when receiving policy decision to avoid flash on 'about:blank' loading.
+
+        (WebKit::WebPage::didStartPageTransition):
+        (WebKit::WebPage::didCompletePageTransition):
+
+        Notify UI process of transition completion.
+
+        (WebKit::WebPage::setIsSuspended):
+        (WebKit::WebPage::tearDownDrawingAreaForSuspend):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/WebPage.messages.in:
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h:
+        * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm:
+        (WebKit::TiledCoreAnimationDrawingArea::TiledCoreAnimationDrawingArea):
+
+        Don't attach drawing area automatically. It will be done by a message from UI process.
+
+        (WebKit::TiledCoreAnimationDrawingArea::attach):
+        (WebKit::TiledCoreAnimationDrawingArea::attachDrawingArea): Deleted.
+
</ins><span class="cx"> 2018-09-20  Tomas Popela  <tpopela@redhat.com>
</span><span class="cx"> 
</span><span class="cx">         [GTK] Always prints in portrait when landscape is requested
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessCocoaWebViewImplmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (236256 => 236257)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm       2018-09-20 11:22:00 UTC (rev 236256)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm  2018-09-20 11:49:55 UTC (rev 236257)
</span><span class="lines">@@ -1460,9 +1460,6 @@
</span><span class="cx"> 
</span><span class="cx">     notifyInputContextAboutDiscardedComposition();
</span><span class="cx"> 
</span><del>-    if (m_layerHostingView)
-        setAcceleratedCompositingRootLayer(nil);
-
</del><span class="cx">     updateRemoteAccessibilityRegistration(false);
</span><span class="cx">     flushPendingMouseEventCallbacks();
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessDrawingAreaProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/DrawingAreaProxy.h (236256 => 236257)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/DrawingAreaProxy.h 2018-09-20 11:22:00 UTC (rev 236256)
+++ trunk/Source/WebKit/UIProcess/DrawingAreaProxy.h    2018-09-20 11:49:55 UTC (rev 236257)
</span><span class="lines">@@ -82,6 +82,8 @@
</span><span class="cx">     void viewExposedRectChangedTimerFired();
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+    virtual void attachInWebProcess() { }
+
</ins><span class="cx">     virtual void updateDebugIndicator() { }
</span><span class="cx"> 
</span><span class="cx">     virtual void waitForDidUpdateActivityState(ActivityStateChangeID) { }
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessPageClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/PageClient.h (236256 => 236257)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/PageClient.h       2018-09-20 11:22:00 UTC (rev 236256)
+++ trunk/Source/WebKit/UIProcess/PageClient.h  2018-09-20 11:49:55 UTC (rev 236257)
</span><span class="lines">@@ -184,6 +184,7 @@
</span><span class="cx">     virtual LayerHostingMode viewLayerHostingMode() { return LayerHostingMode::InProcess; }
</span><span class="cx"> 
</span><span class="cx">     virtual void processDidExit() = 0;
</span><ins>+    virtual void processWillSwap() { processDidExit(); }
</ins><span class="cx">     virtual void didRelaunchProcess() = 0;
</span><span class="cx">     virtual void pageClosed() = 0;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessSuspendedPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/SuspendedPageProxy.cpp (236256 => 236257)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/SuspendedPageProxy.cpp     2018-09-20 11:22:00 UTC (rev 236256)
+++ trunk/Source/WebKit/UIProcess/SuspendedPageProxy.cpp        2018-09-20 11:49:55 UTC (rev 236257)
</span><span class="lines">@@ -54,6 +54,7 @@
</span><span class="cx">         messageNames.get().add("DidDestroyNavigation");
</span><span class="cx">         messageNames.get().add("DidFinishDocumentLoadForFrame");
</span><span class="cx">         messageNames.get().add("DidFinishProgress");
</span><ins>+        messageNames.get().add("DidCompletePageTransition");
</ins><span class="cx">         messageNames.get().add("DidFirstLayoutForFrame");
</span><span class="cx">         messageNames.get().add("DidFirstVisuallyNonEmptyLayoutForFrame");
</span><span class="cx">         messageNames.get().add("DidNavigateWithNavigationData");
</span><span class="lines">@@ -109,6 +110,11 @@
</span><span class="cx">     m_page.suspendedPageClosed(*this);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void SuspendedPageProxy::tearDownDrawingAreaInWebProcess()
+{
+    m_process->send(Messages::WebPage::TearDownDrawingAreaForSuspend(), m_page.pageID());
+}
+
</ins><span class="cx"> void SuspendedPageProxy::didFinishLoad()
</span><span class="cx"> {
</span><span class="cx">     ASSERT(m_process);
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessSuspendedPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/SuspendedPageProxy.h (236256 => 236257)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/SuspendedPageProxy.h       2018-09-20 11:22:00 UTC (rev 236256)
+++ trunk/Source/WebKit/UIProcess/SuspendedPageProxy.h  2018-09-20 11:49:55 UTC (rev 236257)
</span><span class="lines">@@ -49,6 +49,7 @@
</span><span class="cx"> 
</span><span class="cx">     void webProcessDidClose(WebProcessProxy&);
</span><span class="cx">     void destroyWebPageInWebProcess();
</span><ins>+    void tearDownDrawingAreaInWebProcess();
</ins><span class="cx"> 
</span><span class="cx"> #if !LOG_DISABLED
</span><span class="cx">     const char* loggingString() const;
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (236256 => 236257)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp   2018-09-20 11:22:00 UTC (rev 236256)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp      2018-09-20 11:49:55 UTC (rev 236257)
</span><span class="lines">@@ -56,8 +56,8 @@
</span><span class="cx"> #include "AuthenticationDecisionListener.h"
</span><span class="cx"> #include "DataReference.h"
</span><span class="cx"> #include "DownloadProxy.h"
</span><ins>+#include "DrawingAreaMessages.h"
</ins><span class="cx"> #include "DrawingAreaProxy.h"
</span><del>-#include "DrawingAreaProxyMessages.h"
</del><span class="cx"> #include "EventDispatcherMessages.h"
</span><span class="cx"> #include "FrameInfoData.h"
</span><span class="cx"> #include "LoadParameters.h"
</span><span class="lines">@@ -3430,6 +3430,24 @@
</span><span class="cx">     m_pageLoadState.commitChanges();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebPageProxy::didCompletePageTransition(bool isInitialEmptyDocument)
+{
+    // Attach drawing area for the initial empty document only if this is not a process swap.
+    if (isInitialEmptyDocument && m_suspendedPage)
+        return;
+
+#if PLATFORM(MAC)
+    if (!m_drawingArea)
+        return;
+
+    // Drawing area for the suspended page will be torn down when the attach completes.
+    m_drawingArea->attachInWebProcess();
+#else
+    if (m_suspendedPage)
+        m_suspendedPage->tearDownDrawingAreaInWebProcess();
+#endif
+}
+
</ins><span class="cx"> void WebPageProxy::setNetworkRequestsInProgress(bool networkRequestsInProgress)
</span><span class="cx"> {
</span><span class="cx">     auto transaction = m_pageLoadState.transaction();
</span><span class="lines">@@ -6137,7 +6155,11 @@
</span><span class="cx"> 
</span><span class="cx">     m_editorState = EditorState();
</span><span class="cx"> 
</span><del>-    pageClient().processDidExit();
</del><ins>+    if (terminationReason == ProcessTerminationReason::NavigationSwap)
+        pageClient().processWillSwap();
+    else
+        pageClient().processDidExit();
+
</ins><span class="cx">     pageClient().clearAllEditCommands();
</span><span class="cx"> 
</span><span class="cx">     auto resetStateReason = terminationReason == ProcessTerminationReason::NavigationSwap ? ResetStateReason::NavigationSwap : ResetStateReason::WebProcessExited;
</span><span class="lines">@@ -6278,6 +6300,10 @@
</span><span class="cx"> void WebPageProxy::enterAcceleratedCompositingMode(const LayerTreeContext& layerTreeContext)
</span><span class="cx"> {
</span><span class="cx">     pageClient().enterAcceleratedCompositingMode(layerTreeContext);
</span><ins>+
+    // We have completed the page transition and can tear down the layers in the suspended process.
+    if (m_suspendedPage)
+        m_suspendedPage->tearDownDrawingAreaInWebProcess();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPageProxy::exitAcceleratedCompositingMode()
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (236256 => 236257)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebPageProxy.h     2018-09-20 11:22:00 UTC (rev 236256)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h        2018-09-20 11:49:55 UTC (rev 236257)
</span><span class="lines">@@ -1427,6 +1427,7 @@
</span><span class="cx">     void didStartProgress();
</span><span class="cx">     void didChangeProgress(double);
</span><span class="cx">     void didFinishProgress();
</span><ins>+    void didCompletePageTransition(bool isInitialEmptyDocument);
</ins><span class="cx">     void setNetworkRequestsInProgress(bool);
</span><span class="cx"> 
</span><span class="cx">     void hasInsecureContent(WebCore::HasInsecureContent&);
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebPageProxymessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (236256 => 236257)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in   2018-09-20 11:22:00 UTC (rev 236256)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in      2018-09-20 11:49:55 UTC (rev 236257)
</span><span class="lines">@@ -117,6 +117,8 @@
</span><span class="cx">     DidFinishProgress()
</span><span class="cx">     DidStartProgress()
</span><span class="cx"> 
</span><ins>+    DidCompletePageTransition(bool isInitialEmptyDocument)
+
</ins><span class="cx">     SetNetworkRequestsInProgress(bool networkRequestsInProgress)
</span><span class="cx"> 
</span><span class="cx">     # Frame lifetime messages
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessiosPageClientImplIOSh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h (236256 => 236257)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h    2018-09-20 11:22:00 UTC (rev 236256)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h       2018-09-20 11:49:55 UTC (rev 236257)
</span><span class="lines">@@ -65,6 +65,7 @@
</span><span class="cx">     bool isViewVisibleOrOccluded() override;
</span><span class="cx">     bool isVisuallyIdle() override;
</span><span class="cx">     void processDidExit() override;
</span><ins>+    void processWillSwap() override;
</ins><span class="cx">     void didRelaunchProcess() override;
</span><span class="cx">     void pageClosed() override;
</span><span class="cx">     void preferencesDidChange() override;
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessiosPageClientImplIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm (236256 => 236257)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm   2018-09-20 11:22:00 UTC (rev 236256)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm      2018-09-20 11:49:55 UTC (rev 236257)
</span><span class="lines">@@ -209,6 +209,12 @@
</span><span class="cx">     [m_webView _processDidExit];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void PageClientImpl::processWillSwap()
+{
+    // FIXME: It didn't really exit.
+    processDidExit();
+}
+
</ins><span class="cx"> void PageClientImpl::didRelaunchProcess()
</span><span class="cx"> {
</span><span class="cx">     [m_contentView _didRelaunchProcess];
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessmacPageClientImplMach"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h (236256 => 236257)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h    2018-09-20 11:22:00 UTC (rev 236256)
+++ trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h       2018-09-20 11:49:55 UTC (rev 236257)
</span><span class="lines">@@ -79,6 +79,7 @@
</span><span class="cx">     LayerOrView *acceleratedCompositingRootLayer() const override;
</span><span class="cx"> 
</span><span class="cx">     void processDidExit() override;
</span><ins>+    void processWillSwap() override;
</ins><span class="cx">     void pageClosed() override;
</span><span class="cx">     void didRelaunchProcess() override;
</span><span class="cx">     void preferencesDidChange() override;
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessmacPageClientImplMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm (236256 => 236257)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm   2018-09-20 11:22:00 UTC (rev 236256)
+++ trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm      2018-09-20 11:49:55 UTC (rev 236257)
</span><span class="lines">@@ -253,9 +253,16 @@
</span><span class="cx">     return m_impl->colorSpace();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void PageClientImpl::processWillSwap()
+{
+    // FIXME: It didn't really exit.
+    m_impl->processDidExit();
+}
+
</ins><span class="cx"> void PageClientImpl::processDidExit()
</span><span class="cx"> {
</span><span class="cx">     m_impl->processDidExit();
</span><ins>+    m_impl->setAcceleratedCompositingRootLayer(nil);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void PageClientImpl::pageClosed()
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessmacTiledCoreAnimationDrawingAreaProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h (236256 => 236257)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h   2018-09-20 11:22:00 UTC (rev 236256)
+++ trunk/Source/WebKit/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.h      2018-09-20 11:49:55 UTC (rev 236257)
</span><span class="lines">@@ -38,6 +38,8 @@
</span><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     // DrawingAreaProxy
</span><ins>+    void attachInWebProcess() override;
+
</ins><span class="cx">     void deviceScaleFactorDidChange() override;
</span><span class="cx">     void sizeDidChange() override;
</span><span class="cx">     void colorSpaceDidChange() override;
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessmacTiledCoreAnimationDrawingAreaProxymm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm (236256 => 236257)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm  2018-09-20 11:22:00 UTC (rev 236256)
+++ trunk/Source/WebKit/UIProcess/mac/TiledCoreAnimationDrawingAreaProxy.mm     2018-09-20 11:49:55 UTC (rev 236257)
</span><span class="lines">@@ -53,6 +53,11 @@
</span><span class="cx">     m_callbacks.invalidate(CallbackBase::Error::OwnerWasInvalidated);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void TiledCoreAnimationDrawingAreaProxy::attachInWebProcess()
+{
+    m_webPageProxy.process().send(Messages::DrawingArea::Attach(), m_webPageProxy.pageID());
+}
+
</ins><span class="cx"> void TiledCoreAnimationDrawingAreaProxy::deviceScaleFactorDidChange()
</span><span class="cx"> {
</span><span class="cx">     m_webPageProxy.process().send(Messages::DrawingArea::SetDeviceScaleFactor(m_webPageProxy.deviceScaleFactor()), m_webPageProxy.pageID());
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageDrawingAreah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.h (236256 => 236257)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.h     2018-09-20 11:22:00 UTC (rev 236256)
+++ trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.h        2018-09-20 11:49:55 UTC (rev 236257)
</span><span class="lines">@@ -151,7 +151,7 @@
</span><span class="cx">     void displayWasRefreshed();
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    virtual void attachDrawingArea() { };
</del><ins>+    virtual void attach() { };
</ins><span class="cx"> 
</span><span class="cx"> protected:
</span><span class="cx">     DrawingArea(DrawingAreaType, WebPage&);
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageDrawingAreamessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.messages.in (236256 => 236257)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.messages.in   2018-09-20 11:22:00 UTC (rev 236256)
+++ trunk/Source/WebKit/WebProcess/WebPage/DrawingArea.messages.in      2018-09-20 11:49:55 UTC (rev 236257)
</span><span class="lines">@@ -45,7 +45,11 @@
</span><span class="cx">     DestroyNativeSurfaceHandleForCompositing() -> (bool handled)
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-#if PLATFORM(MAC) && ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
</del><ins>+#if PLATFORM(MAC)
+    Attach()
+
+#if ENABLE(WEBPROCESS_WINDOWSERVER_BLOCKING)
</ins><span class="cx">     DisplayWasRefreshed()
</span><span class="cx"> #endif
</span><ins>+#endif
</ins><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageWebPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (236256 => 236257)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp       2018-09-20 11:22:00 UTC (rev 236256)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp  2018-09-20 11:49:55 UTC (rev 236257)
</span><span class="lines">@@ -657,7 +657,6 @@
</span><span class="cx">         m_drawingArea->updatePreferences(parameters.store);
</span><span class="cx">         m_drawingArea->setPaintingEnabled(true);
</span><span class="cx">     }
</span><del>-    m_drawingArea->attachDrawingArea();
</del><span class="cx"> 
</span><span class="cx">     if (m_activityState != parameters.activityState)
</span><span class="cx">         setActivityState(parameters.activityState, ActivityStateChangeAsynchronous, Vector<CallbackID>());
</span><span class="lines">@@ -2215,7 +2214,7 @@
</span><span class="cx">     if (!drawingArea)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    drawingArea->setLayerTreeStateIsFrozen(frozen);
</del><ins>+    drawingArea->setLayerTreeStateIsFrozen(frozen || m_isSuspended);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPage::callVolatilityCompletionHandlers(bool succeeded)
</span><span class="lines">@@ -2833,6 +2832,10 @@
</span><span class="cx">     WebFrame* frame = WebProcess::singleton().webFrame(frameID);
</span><span class="cx">     if (!frame)
</span><span class="cx">         return;
</span><ins>+    if (policyAction == PolicyAction::Suspend) {
+        ASSERT(frame == m_mainFrame);
+        setIsSuspended(true);
+    }
</ins><span class="cx">     frame->didReceivePolicyDecision(listenerID, policyAction, navigationID, downloadID, WTFMove(websitePolicies));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -2846,7 +2849,7 @@
</span><span class="cx"> 
</span><span class="cx"> void WebPage::didStartPageTransition()
</span><span class="cx"> {
</span><del>-    m_drawingArea->setLayerTreeStateIsFrozen(true);
</del><ins>+    setLayerTreeStateIsFrozen(true);
</ins><span class="cx"> 
</span><span class="cx"> #if PLATFORM(MAC)
</span><span class="cx">     bool hasPreviouslyFocusedDueToUserInteraction = m_hasEverFocusedElementDueToUserInteractionSincePageTransition;
</span><span class="lines">@@ -2870,8 +2873,11 @@
</span><span class="cx"> 
</span><span class="cx"> void WebPage::didCompletePageTransition()
</span><span class="cx"> {
</span><del>-    if (m_drawingArea)
-        m_drawingArea->setLayerTreeStateIsFrozen(false);
</del><ins>+    // FIXME: Layer tree freezing should be managed entirely in the UI process side.
+    setLayerTreeStateIsFrozen(false);
+
+    bool isInitialEmptyDocument = !m_mainFrame;
+    send(Messages::WebPageProxy::DidCompletePageTransition(isInitialEmptyDocument));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPage::show()
</span><span class="lines">@@ -6000,10 +6006,17 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     m_isSuspended = suspended;
</span><del>-    if (m_isSuspended)
-        m_drawingArea = nullptr;
</del><ins>+
+    setLayerTreeStateIsFrozen(true);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebPage::tearDownDrawingAreaForSuspend()
+{
+    if (!m_isSuspended)
+        return;
+    m_drawingArea = nullptr;
+}
+
</ins><span class="cx"> void WebPage::frameBecameRemote(uint64_t frameID, GlobalFrameIdentifier&& remoteFrameIdentifier, GlobalWindowIdentifier&& remoteWindowIdentifier)
</span><span class="cx"> {
</span><span class="cx">     RefPtr<WebFrame> frame = WebProcess::singleton().webFrame(frameID);
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageWebPageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (236256 => 236257)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h 2018-09-20 11:22:00 UTC (rev 236256)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h    2018-09-20 11:49:55 UTC (rev 236257)
</span><span class="lines">@@ -1414,6 +1414,7 @@
</span><span class="cx">     void urlSchemeTaskDidComplete(uint64_t handlerIdentifier, uint64_t taskIdentifier, const WebCore::ResourceError&);
</span><span class="cx"> 
</span><span class="cx">     void setIsSuspended(bool);
</span><ins>+    void tearDownDrawingAreaForSuspend();
</ins><span class="cx"> 
</span><span class="cx">     RefPtr<WebImage> snapshotAtSize(const WebCore::IntRect&, const WebCore::IntSize& bitmapSize, SnapshotOptions);
</span><span class="cx">     RefPtr<WebImage> snapshotNode(WebCore::Node&, SnapshotOptions, unsigned maximumPixelCount = std::numeric_limits<unsigned>::max());
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPageWebPagemessagesin"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (236256 => 236257)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in       2018-09-20 11:22:00 UTC (rev 236256)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in  2018-09-20 11:49:55 UTC (rev 236257)
</span><span class="lines">@@ -506,6 +506,7 @@
</span><span class="cx">     URLSchemeTaskDidComplete(uint64_t handlerIdentifier, uint64_t taskIdentifier, WebCore::ResourceError error)
</span><span class="cx"> 
</span><span class="cx">     SetIsSuspended(bool suspended)
</span><ins>+    TearDownDrawingAreaForSuspend();
</ins><span class="cx"> 
</span><span class="cx"> #if HAVE(CFNETWORK_STORAGE_PARTITIONING)
</span><span class="cx">     StorageAccessResponse(bool wasGranted, uint64_t contextId)
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPagemacTiledCoreAnimationDrawingAreah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h (236256 => 236257)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h       2018-09-20 11:22:00 UTC (rev 236256)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.h  2018-09-20 11:49:55 UTC (rev 236257)
</span><span class="lines">@@ -103,7 +103,7 @@
</span><span class="cx">     void addTransactionCallbackID(CallbackID) override;
</span><span class="cx">     void setShouldScaleViewToFitDocument(bool) override;
</span><span class="cx"> 
</span><del>-    void attachDrawingArea() override;
</del><ins>+    void attach() override;
</ins><span class="cx"> 
</span><span class="cx">     void adjustTransientZoom(double scale, WebCore::FloatPoint origin) override;
</span><span class="cx">     void commitTransientZoom(double scale, WebCore::FloatPoint origin) override;
</span></span></pre></div>
<a id="trunkSourceWebKitWebProcessWebPagemacTiledCoreAnimationDrawingAreamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm (236256 => 236257)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm      2018-09-20 11:22:00 UTC (rev 236256)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm 2018-09-20 11:49:55 UTC (rev 236257)
</span><span class="lines">@@ -91,8 +91,6 @@
</span><span class="cx"> 
</span><span class="cx">     updateLayerHostingContext();
</span><span class="cx">     setColorSpace(parameters.colorSpace);
</span><del>-
-    attachDrawingArea();
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TiledCoreAnimationDrawingArea::~TiledCoreAnimationDrawingArea()
</span><span class="lines">@@ -101,7 +99,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-void TiledCoreAnimationDrawingArea::attachDrawingArea()
</del><ins>+void TiledCoreAnimationDrawingArea::attach()
</ins><span class="cx"> {
</span><span class="cx">     LayerTreeContext layerTreeContext;
</span><span class="cx">     layerTreeContext.contextID = m_layerHostingContext->contextID();
</span></span></pre>
</div>
</div>

</body>
</html>