<!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>[242760] 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/242760">242760</a></dd>
<dt>Author</dt> <dd>jiewen_tan@apple.com</dd>
<dt>Date</dt> <dd>2019-03-11 17:57:53 -0700 (Mon, 11 Mar 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>Optimizing loads when creating new pages
https://bugs.webkit.org/show_bug.cgi?id=195516
<rdar://problem/48738086>

Reviewed by Darin Adler.

This patch adds hooks in WebPageProxy::createNewPage to optimize loads, and moves the creationParameters
of API::NavigationAction from UI clients to WebPageProxy::createNewPage. Also, we now pass the whole
API::NavigationAction to the load optimizer instead of the request within.

* UIProcess/API/APINavigationAction.h:
* UIProcess/API/APIUIClient.h:
(API::UIClient::createNewPage):
* UIProcess/API/C/WKPage.cpp:
(WKPageSetPageUIClient):
* UIProcess/API/glib/WebKitUIClient.cpp:
* UIProcess/Cocoa/NavigationState.mm:
(WebKit::tryOptimizingLoad):
(WebKit::tryInterceptNavigation):
(WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction):
* UIProcess/Cocoa/UIDelegate.h:
* UIProcess/Cocoa/UIDelegate.mm:
(WebKit::UIDelegate::UIClient::createNewPage):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::decidePolicyForNavigationAction):
(WebKit::tryOptimizingLoad):
(WebKit::WebPageProxy::createNewPage):
* UIProcess/WebPageProxy.h:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPIAPINavigationActionh">trunk/Source/WebKit/UIProcess/API/APINavigationAction.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPIAPIUIClienth">trunk/Source/WebKit/UIProcess/API/APIUIClient.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICWKPagecpp">trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPIglibWebKitUIClientcpp">trunk/Source/WebKit/UIProcess/API/glib/WebKitUIClient.cpp</a></li>
<li><a href="#trunkSourceWebKitUIProcessCocoaNavigationStatemm">trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessCocoaUIDelegateh">trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessCocoaUIDelegatemm">trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm</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>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (242759 => 242760)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2019-03-12 00:46:41 UTC (rev 242759)
+++ trunk/Source/WebKit/ChangeLog       2019-03-12 00:57:53 UTC (rev 242760)
</span><span class="lines">@@ -1,3 +1,34 @@
</span><ins>+2019-03-09  Jiewen Tan  <jiewen_tan@apple.com>
+
+        Optimizing loads when creating new pages
+        https://bugs.webkit.org/show_bug.cgi?id=195516
+        <rdar://problem/48738086>
+
+        Reviewed by Darin Adler.
+
+        This patch adds hooks in WebPageProxy::createNewPage to optimize loads, and moves the creationParameters
+        of API::NavigationAction from UI clients to WebPageProxy::createNewPage. Also, we now pass the whole
+        API::NavigationAction to the load optimizer instead of the request within.
+
+        * UIProcess/API/APINavigationAction.h:
+        * UIProcess/API/APIUIClient.h:
+        (API::UIClient::createNewPage):
+        * UIProcess/API/C/WKPage.cpp:
+        (WKPageSetPageUIClient):
+        * UIProcess/API/glib/WebKitUIClient.cpp:
+        * UIProcess/Cocoa/NavigationState.mm:
+        (WebKit::tryOptimizingLoad):
+        (WebKit::tryInterceptNavigation):
+        (WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction):
+        * UIProcess/Cocoa/UIDelegate.h:
+        * UIProcess/Cocoa/UIDelegate.mm:
+        (WebKit::UIDelegate::UIClient::createNewPage):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::decidePolicyForNavigationAction):
+        (WebKit::tryOptimizingLoad):
+        (WebKit::WebPageProxy::createNewPage):
+        * UIProcess/WebPageProxy.h:
+
</ins><span class="cx"> 2019-03-11  Dean Jackson  <dino@apple.com>
</span><span class="cx"> 
</span><span class="cx">         [iOS] Implement a faster click detection that intercepts double-tap-to-zoom if possible
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPIAPINavigationActionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/APINavigationAction.h (242759 => 242760)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/APINavigationAction.h  2019-03-12 00:46:41 UTC (rev 242759)
+++ trunk/Source/WebKit/UIProcess/API/APINavigationAction.h     2019-03-12 00:57:53 UTC (rev 242760)
</span><span class="lines">@@ -33,6 +33,10 @@
</span><span class="cx"> #include <WebCore/ResourceRequest.h>
</span><span class="cx"> #include <wtf/URL.h>
</span><span class="cx"> 
</span><ins>+#if USE(APPLE_INTERNAL_SDK)
+#include <WebKitAdditions/APINavigationActionAdditions.h>
+#endif
+
</ins><span class="cx"> namespace API {
</span><span class="cx"> 
</span><span class="cx"> class NavigationAction final : public ObjectImpl<Object::Type::NavigationAction> {
</span><span class="lines">@@ -65,6 +69,10 @@
</span><span class="cx"> 
</span><span class="cx">     Navigation* mainFrameNavigation() const { return m_mainFrameNavigation.get(); }
</span><span class="cx"> 
</span><ins>+#if HAVE(LOAD_OPTIMIZER)
+APINAVIGATIONACTION_LOADOPTIMIZER_ADDITIONS_1
+#endif
+
</ins><span class="cx"> private:
</span><span class="cx">     NavigationAction(WebKit::NavigationActionData&& navigationActionData, API::FrameInfo* sourceFrame, API::FrameInfo* targetFrame, Optional<WTF::String> targetFrameName, WebCore::ResourceRequest&& request, const WTF::URL& originalURL, bool shouldOpenAppLinks, RefPtr<UserInitiatedAction>&& userInitiatedAction, API::Navigation* mainFrameNavigation)
</span><span class="cx">         : m_sourceFrame(sourceFrame)
</span><span class="lines">@@ -92,6 +100,9 @@
</span><span class="cx">     WTF::URL m_originalURL;
</span><span class="cx"> 
</span><span class="cx">     bool m_shouldOpenAppLinks;
</span><ins>+#if HAVE(LOAD_OPTIMIZER)
+APINAVIGATIONACTION_LOADOPTIMIZER_ADDITIONS_2
+#endif
</ins><span class="cx"> 
</span><span class="cx">     RefPtr<UserInitiatedAction> m_userInitiatedAction;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPIAPIUIClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/APIUIClient.h (242759 => 242760)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/APIUIClient.h  2019-03-12 00:46:41 UTC (rev 242759)
+++ trunk/Source/WebKit/UIProcess/API/APIUIClient.h     2019-03-12 00:57:53 UTC (rev 242760)
</span><span class="lines">@@ -73,7 +73,7 @@
</span><span class="cx"> public:
</span><span class="cx">     virtual ~UIClient() { }
</span><span class="cx"> 
</span><del>-    virtual void createNewPage(WebKit::WebPageProxy&, Ref<FrameInfo>&&, WebCore::ResourceRequest&&, WebCore::WindowFeatures&&, WebKit::NavigationActionData&&, CompletionHandler<void(RefPtr<WebKit::WebPageProxy>&&)>&& completionHandler) { completionHandler(nullptr); }
</del><ins>+    virtual void createNewPage(WebKit::WebPageProxy&, WebCore::WindowFeatures&&, Ref<API::NavigationAction>&&, CompletionHandler<void(RefPtr<WebKit::WebPageProxy>&&)>&& completionHandler) { completionHandler(nullptr); }
</ins><span class="cx">     virtual void showPage(WebKit::WebPageProxy*) { }
</span><span class="cx">     virtual void fullscreenMayReturnToInline(WebKit::WebPageProxy*) { }
</span><span class="cx">     virtual void didEnterFullscreen(WebKit::WebPageProxy*) { }
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICWKPagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp (242759 => 242760)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp   2019-03-12 00:46:41 UTC (rev 242759)
+++ trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp      2019-03-12 00:57:53 UTC (rev 242760)
</span><span class="lines">@@ -1474,19 +1474,15 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">     private:
</span><del>-        void createNewPage(WebPageProxy& page, Ref<API::FrameInfo>&& sourceFrameInfo, WebCore::ResourceRequest&& resourceRequest, WebCore::WindowFeatures&& windowFeatures, NavigationActionData&& navigationActionData, CompletionHandler<void(RefPtr<WebPageProxy>&&)>&& completionHandler) final
</del><ins>+        void createNewPage(WebPageProxy& page, WebCore::WindowFeatures&& windowFeatures, Ref<API::NavigationAction>&& navigationAction, CompletionHandler<void(RefPtr<WebPageProxy>&&)>&& completionHandler) final
</ins><span class="cx">         {
</span><span class="cx">             if (m_client.createNewPage) {
</span><span class="cx">                 auto configuration = page.configuration().copy();
</span><span class="cx">                 configuration->setRelatedPage(&page);
</span><span class="cx"> 
</span><del>-                auto userInitiatedActivity = page.process().userInitiatedActivity(navigationActionData.userGestureTokenIdentifier);
-                bool shouldOpenAppLinks = !hostsAreEqual(sourceFrameInfo->request().url(), resourceRequest.url());
-                auto apiNavigationAction = API::NavigationAction::create(WTFMove(navigationActionData), sourceFrameInfo.ptr(), nullptr, WTF::nullopt, WTFMove(resourceRequest), URL(), shouldOpenAppLinks, WTFMove(userInitiatedActivity));
-
</del><span class="cx">                 auto apiWindowFeatures = API::WindowFeatures::create(windowFeatures);
</span><span class="cx"> 
</span><del>-                return completionHandler(adoptRef(toImpl(m_client.createNewPage(toAPI(&page), toAPI(configuration.ptr()), toAPI(apiNavigationAction.ptr()), toAPI(apiWindowFeatures.ptr()), m_client.base.clientInfo))));
</del><ins>+                return completionHandler(adoptRef(toImpl(m_client.createNewPage(toAPI(&page), toAPI(configuration.ptr()), toAPI(navigationAction.ptr()), toAPI(apiWindowFeatures.ptr()), m_client.base.clientInfo))));
</ins><span class="cx">             }
</span><span class="cx">         
</span><span class="cx">             if (m_client.createNewPage_deprecatedForUseWithV1 || m_client.createNewPage_deprecatedForUseWithV0) {
</span><span class="lines">@@ -1510,12 +1506,12 @@
</span><span class="cx">                 Ref<API::Dictionary> featuresMap = API::Dictionary::create(WTFMove(map));
</span><span class="cx"> 
</span><span class="cx">                 if (m_client.createNewPage_deprecatedForUseWithV1) {
</span><del>-                    Ref<API::URLRequest> request = API::URLRequest::create(resourceRequest);
-                    return completionHandler(adoptRef(toImpl(m_client.createNewPage_deprecatedForUseWithV1(toAPI(&page), toAPI(request.ptr()), toAPI(featuresMap.ptr()), toAPI(navigationActionData.modifiers), toAPI(navigationActionData.mouseButton), m_client.base.clientInfo))));
</del><ins>+                    Ref<API::URLRequest> request = API::URLRequest::create(navigationAction->request());
+                    return completionHandler(adoptRef(toImpl(m_client.createNewPage_deprecatedForUseWithV1(toAPI(&page), toAPI(request.ptr()), toAPI(featuresMap.ptr()), toAPI(navigationAction->modifiers()), toAPI(navigationAction->mouseButton()), m_client.base.clientInfo))));
</ins><span class="cx">                 }
</span><span class="cx">     
</span><span class="cx">                 ASSERT(m_client.createNewPage_deprecatedForUseWithV0);
</span><del>-                return completionHandler(adoptRef(toImpl(m_client.createNewPage_deprecatedForUseWithV0(toAPI(&page), toAPI(featuresMap.ptr()), toAPI(navigationActionData.modifiers), toAPI(navigationActionData.mouseButton), m_client.base.clientInfo))));
</del><ins>+                return completionHandler(adoptRef(toImpl(m_client.createNewPage_deprecatedForUseWithV0(toAPI(&page), toAPI(featuresMap.ptr()), toAPI(navigationAction->modifiers()), toAPI(navigationAction->mouseButton()), m_client.base.clientInfo))));
</ins><span class="cx">             }
</span><span class="cx"> 
</span><span class="cx">             completionHandler(nullptr);
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPIglibWebKitUIClientcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/glib/WebKitUIClient.cpp (242759 => 242760)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/glib/WebKitUIClient.cpp        2019-03-12 00:46:41 UTC (rev 242759)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitUIClient.cpp   2019-03-12 00:57:53 UTC (rev 242760)
</span><span class="lines">@@ -50,10 +50,9 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    void createNewPage(WebPageProxy& page, Ref<API::FrameInfo>&& frameInfo, WebCore::ResourceRequest&& resourceRequest, WebCore::WindowFeatures&& windowFeatures, NavigationActionData&& navigationActionData, CompletionHandler<void(RefPtr<WebPageProxy>&&)>&& completionHandler) final
</del><ins>+    void createNewPage(WebPageProxy& page, WebCore::WindowFeatures&& windowFeatures, Ref<API::NavigationAction>&& apiNavigationAction, CompletionHandler<void(RefPtr<WebPageProxy>&&)>&& completionHandler) final
</ins><span class="cx">     {
</span><del>-        auto userInitiatedActivity = page.process().userInitiatedActivity(navigationActionData.userGestureTokenIdentifier);
-        WebKitNavigationAction navigationAction(API::NavigationAction::create(WTFMove(navigationActionData), frameInfo.ptr(), nullptr, WTF::nullopt, WTFMove(resourceRequest), URL { }, false, WTFMove(userInitiatedActivity)));
</del><ins>+        WebKitNavigationAction navigationAction(WTFMove(apiNavigationAction));
</ins><span class="cx">         completionHandler(webkitWebViewCreateNewPage(m_webView, windowFeatures, &navigationAction));
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessCocoaNavigationStatemm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm (242759 => 242760)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm   2019-03-12 00:46:41 UTC (rev 242759)
+++ trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm      2019-03-12 00:57:53 UTC (rev 242760)
</span><span class="lines">@@ -467,7 +467,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if !USE(APPLE_INTERNAL_SDK)
</span><del>-static void tryOptimizingLoad(const WebCore::ResourceRequest&, WebPageProxy&, Function<void(bool)>&& completionHandler)
</del><ins>+static void tryOptimizingLoad(Ref<API::NavigationAction>&&, WebPageProxy&, Function<void(bool)>&& completionHandler)
</ins><span class="cx"> {
</span><span class="cx">     completionHandler(false);
</span><span class="cx"> }
</span><span class="lines">@@ -477,15 +477,16 @@
</span><span class="cx"> {
</span><span class="cx"> #if HAVE(APP_LINKS)
</span><span class="cx">     if (navigationAction->shouldOpenAppLinks()) {
</span><del>-        auto* localCompletionHandler = new WTF::Function<void (bool)>([request = navigationAction->request().isolatedCopy(), weakPage = makeWeakPtr(page), completionHandler = WTFMove(completionHandler)] (bool success) mutable {
</del><ins>+        auto url = navigationAction->request().url();
+        auto* localCompletionHandler = new WTF::Function<void (bool)>([navigationAction = WTFMove(navigationAction), weakPage = makeWeakPtr(page), completionHandler = WTFMove(completionHandler)] (bool success) mutable {
</ins><span class="cx">             ASSERT(RunLoop::isMain());
</span><span class="cx">             if (!success && weakPage) {
</span><del>-                tryOptimizingLoad(request, *weakPage, WTFMove(completionHandler));
</del><ins>+                tryOptimizingLoad(WTFMove(navigationAction), *weakPage, WTFMove(completionHandler));
</ins><span class="cx">                 return;
</span><span class="cx">             }
</span><span class="cx">             completionHandler(success);
</span><span class="cx">         });
</span><del>-        [LSAppLink openWithURL:navigationAction->request().url() completionHandler:[localCompletionHandler](BOOL success, NSError *) {
</del><ins>+        [LSAppLink openWithURL:url completionHandler:[localCompletionHandler](BOOL success, NSError *) {
</ins><span class="cx">             dispatch_async(dispatch_get_main_queue(), [localCompletionHandler, success] {
</span><span class="cx">                 (*localCompletionHandler)(success);
</span><span class="cx">                 delete localCompletionHandler;
</span><span class="lines">@@ -495,7 +496,7 @@
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    tryOptimizingLoad(navigationAction->request(), page, WTFMove(completionHandler));
</del><ins>+    tryOptimizingLoad(WTFMove(navigationAction), page, WTFMove(completionHandler));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void NavigationState::NavigationClient::decidePolicyForNavigationAction(WebPageProxy& webPageProxy, Ref<API::NavigationAction>&& navigationAction, Ref<WebFramePolicyListenerProxy>&& listener, API::Object* userInfo)
</span><span class="lines">@@ -587,7 +588,7 @@
</span><span class="cx">             localListener->download();
</span><span class="cx">             break;
</span><span class="cx">         case _WKNavigationActionPolicyAllowWithoutTryingAppLink:
</span><del>-            tryOptimizingLoad(navigationAction->request(), webPageProxy, [localListener = WTFMove(localListener), websitePolicies = WTFMove(apiWebsitePolicies)] (bool optimizedLoad) {
</del><ins>+            tryOptimizingLoad(WTFMove(navigationAction), webPageProxy, [localListener = WTFMove(localListener), websitePolicies = WTFMove(apiWebsitePolicies)] (bool optimizedLoad) {
</ins><span class="cx">                 if (optimizedLoad) {
</span><span class="cx">                     localListener->ignore();
</span><span class="cx">                     return;
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessCocoaUIDelegateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h (242759 => 242760)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h 2019-03-12 00:46:41 UTC (rev 242759)
+++ trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h    2019-03-12 00:57:53 UTC (rev 242760)
</span><span class="lines">@@ -79,7 +79,7 @@
</span><span class="cx"> 
</span><span class="cx">     private:
</span><span class="cx">         // API::UIClient
</span><del>-        void createNewPage(WebPageProxy&, Ref<API::FrameInfo>&&, WebCore::ResourceRequest&&, WebCore::WindowFeatures&&, NavigationActionData&&, CompletionHandler<void(RefPtr<WebPageProxy>&&)>&&) final;
</del><ins>+        void createNewPage(WebKit::WebPageProxy&, WebCore::WindowFeatures&&, Ref<API::NavigationAction>&&, CompletionHandler<void(RefPtr<WebPageProxy>&&)>&&) final;
</ins><span class="cx">         void close(WebPageProxy*) final;
</span><span class="cx">         void fullscreenMayReturnToInline(WebPageProxy*) final;
</span><span class="cx">         void didEnterFullscreen(WebPageProxy*) final;
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessCocoaUIDelegatemm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm (242759 => 242760)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm        2019-03-12 00:46:41 UTC (rev 242759)
+++ trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm   2019-03-12 00:57:53 UTC (rev 242760)
</span><span class="lines">@@ -228,7 +228,7 @@
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void UIDelegate::UIClient::createNewPage(WebPageProxy& page, Ref<API::FrameInfo>&& sourceFrameInfo, WebCore::ResourceRequest&& request, WebCore::WindowFeatures&& windowFeatures, NavigationActionData&& navigationActionData, CompletionHandler<void(RefPtr<WebPageProxy>&&)>&& completionHandler)
</del><ins>+void UIDelegate::UIClient::createNewPage(WebKit::WebPageProxy&, WebCore::WindowFeatures&& windowFeatures, Ref<API::NavigationAction>&& navigationAction, CompletionHandler<void(RefPtr<WebPageProxy>&&)>&& completionHandler)
</ins><span class="cx"> {
</span><span class="cx">     auto delegate = m_uiDelegate.m_delegate.get();
</span><span class="cx">     ASSERT(delegate);
</span><span class="lines">@@ -236,16 +236,12 @@
</span><span class="cx">     auto configuration = adoptNS([m_uiDelegate.m_webView->_configuration copy]);
</span><span class="cx">     [configuration _setRelatedWebView:m_uiDelegate.m_webView];
</span><span class="cx"> 
</span><del>-    auto userInitiatedActivity = page.process().userInitiatedActivity(navigationActionData.userGestureTokenIdentifier);
-    bool shouldOpenAppLinks = !hostsAreEqual(sourceFrameInfo->request().url(), request.url());
-    auto apiNavigationAction = API::NavigationAction::create(WTFMove(navigationActionData), sourceFrameInfo.ptr(), nullptr, WTF::nullopt, WTFMove(request), URL(), shouldOpenAppLinks, WTFMove(userInitiatedActivity));
-
</del><span class="cx">     auto apiWindowFeatures = API::WindowFeatures::create(windowFeatures);
</span><span class="cx"> 
</span><span class="cx">     if (m_uiDelegate.m_delegateMethods.webViewCreateWebViewWithConfigurationForNavigationActionWindowFeaturesAsync) {
</span><span class="cx">         auto checker = CompletionHandlerCallChecker::create(delegate.get(), @selector(_webView:createWebViewWithConfiguration:forNavigationAction:windowFeatures:completionHandler:));
</span><span class="cx"> 
</span><del>-        [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView createWebViewWithConfiguration:configuration.get() forNavigationAction:wrapper(apiNavigationAction) windowFeatures:wrapper(apiWindowFeatures) completionHandler:makeBlockPtr([completionHandler = WTFMove(completionHandler), checker = WTFMove(checker), relatedWebView = RetainPtr<WKWebView>(m_uiDelegate.m_webView)] (WKWebView *webView) mutable {
</del><ins>+        [(id <WKUIDelegatePrivate>)delegate _webView:m_uiDelegate.m_webView createWebViewWithConfiguration:configuration.get() forNavigationAction:wrapper(navigationAction) windowFeatures:wrapper(apiWindowFeatures) completionHandler:makeBlockPtr([completionHandler = WTFMove(completionHandler), checker = WTFMove(checker), relatedWebView = RetainPtr<WKWebView>(m_uiDelegate.m_webView)] (WKWebView *webView) mutable {
</ins><span class="cx">             if (checker->completionHandlerHasBeenCalled())
</span><span class="cx">                 return;
</span><span class="cx">             checker->didCallCompletionHandler();
</span><span class="lines">@@ -265,7 +261,7 @@
</span><span class="cx">     if (!m_uiDelegate.m_delegateMethods.webViewCreateWebViewWithConfigurationForNavigationActionWindowFeatures)
</span><span class="cx">         return completionHandler(nullptr);
</span><span class="cx"> 
</span><del>-    RetainPtr<WKWebView> webView = [delegate webView:m_uiDelegate.m_webView createWebViewWithConfiguration:configuration.get() forNavigationAction:wrapper(apiNavigationAction) windowFeatures:wrapper(apiWindowFeatures)];
</del><ins>+    RetainPtr<WKWebView> webView = [delegate webView:m_uiDelegate.m_webView createWebViewWithConfiguration:configuration.get() forNavigationAction:wrapper(navigationAction) windowFeatures:wrapper(apiWindowFeatures)];
</ins><span class="cx">     if (!webView)
</span><span class="cx">         return completionHandler(nullptr);
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (242759 => 242760)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp   2019-03-12 00:46:41 UTC (rev 242759)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp      2019-03-12 00:57:53 UTC (rev 242760)
</span><span class="lines">@@ -4607,10 +4607,18 @@
</span><span class="cx"> 
</span><span class="cx">         auto navigationAction = API::NavigationAction::create(WTFMove(navigationActionData), sourceFrameInfo.get(), destinationFrameInfo.ptr(), WTF::nullopt, WTFMove(request), originalRequest.url(), shouldOpenAppLinks, WTFMove(userInitiatedActivity), mainFrameNavigation);
</span><span class="cx"> 
</span><ins>+#if HAVE(LOAD_OPTIMIZER)
+WEBPAGEPROXY_LOADOPTIMIZER_ADDITIONS_3
+#endif
+
</ins><span class="cx">         m_navigationClient->decidePolicyForNavigationAction(*this, WTFMove(navigationAction), WTFMove(listener), process->transformHandlesToObjects(userData.object()).get());
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     m_shouldSuppressAppLinksInNextNavigationPolicyDecision = false;
</span><ins>+
+#if HAVE(LOAD_OPTIMIZER)
+WEBPAGEPROXY_LOADOPTIMIZER_ADDITIONS_4
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> WebPageProxy* WebPageProxy::nonEphemeralWebPageProxy()
</span><span class="lines">@@ -4896,14 +4904,24 @@
</span><span class="cx"> 
</span><span class="cx"> // UIClient
</span><span class="cx"> 
</span><ins>+using NewPageCallback = CompletionHandler<void(RefPtr<WebPageProxy>&&)>;
+using UIClientCallback = Function<void(Ref<API::NavigationAction>&&, NewPageCallback&&)>;
+static void tryOptimizingLoad(Ref<API::NavigationAction>&& navigationAction, WebPageProxy& page, NewPageCallback&& newPageCallback, UIClientCallback&& uiClientCallback)
+{
+#if HAVE(LOAD_OPTIMIZER)
+WEBPAGEPROXY_LOADOPTIMIZER_ADDITIONS_6
+#else
+    ASSERT_UNUSED(page, page.pageID());
+    uiClientCallback(WTFMove(navigationAction), WTFMove(newPageCallback));
+#endif
+}
+
</ins><span class="cx"> void WebPageProxy::createNewPage(const FrameInfoData& originatingFrameInfoData, uint64_t originatingPageID, ResourceRequest&& request, WindowFeatures&& windowFeatures, NavigationActionData&& navigationActionData, Messages::WebPageProxy::CreateNewPage::DelayedReply&& reply)
</span><span class="cx"> {
</span><span class="cx">     MESSAGE_CHECK(m_process, m_process->webFrame(originatingFrameInfoData.frameID));
</span><span class="cx">     auto originatingFrameInfo = API::FrameInfo::create(originatingFrameInfoData, m_process->webPage(originatingPageID));
</span><del>-
</del><span class="cx">     auto mainFrameURL = m_mainFrame->url();
</span><del>-
-    m_uiClient->createNewPage(*this, WTFMove(originatingFrameInfo), WTFMove(request), WTFMove(windowFeatures), WTFMove(navigationActionData), [this, protectedThis = makeRef(*this), mainFrameURL, request, reply = WTFMove(reply)] (RefPtr<WebPageProxy> newPage) mutable {
</del><ins>+    auto completionHandler = [this, protectedThis = makeRef(*this), mainFrameURL, request, reply = WTFMove(reply)] (RefPtr<WebPageProxy> newPage) mutable {
</ins><span class="cx">         if (!newPage) {
</span><span class="cx">             reply(0, WTF::nullopt);
</span><span class="cx">             return;
</span><span class="lines">@@ -4915,6 +4933,18 @@
</span><span class="cx"> 
</span><span class="cx">         WebsiteDataStore::cloneSessionData(*this, *newPage);
</span><span class="cx">         newPage->m_shouldSuppressAppLinksInNextNavigationPolicyDecision = hostsAreEqual(URL({ }, mainFrameURL), request.url());
</span><ins>+
+#if HAVE(LOAD_OPTIMIZER)
+WEBPAGEPROXY_LOADOPTIMIZER_ADDITIONS_5
+#endif
+    };
+
+    auto userInitiatedActivity = m_process->userInitiatedActivity(navigationActionData.userGestureTokenIdentifier);
+    bool shouldOpenAppLinks = !hostsAreEqual(originatingFrameInfo->request().url(), request.url());
+    auto navigationAction = API::NavigationAction::create(WTFMove(navigationActionData), originatingFrameInfo.ptr(), nullptr, WTF::nullopt, WTFMove(request), URL(), shouldOpenAppLinks, WTFMove(userInitiatedActivity));
+
+    tryOptimizingLoad(WTFMove(navigationAction), *this, WTFMove(completionHandler), [this, protectedThis = makeRef(*this), windowFeatures = WTFMove(windowFeatures)] (Ref<API::NavigationAction>&& navigationAction, CompletionHandler<void(RefPtr<WebPageProxy>&&)>&& completionHandler) mutable {
+        m_uiClient->createNewPage(*this, WTFMove(windowFeatures), WTFMove(navigationAction), WTFMove(completionHandler));
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx">     
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (242759 => 242760)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebPageProxy.h     2019-03-12 00:46:41 UTC (rev 242759)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h        2019-03-12 00:57:53 UTC (rev 242760)
</span><span class="lines">@@ -135,6 +135,10 @@
</span><span class="cx"> #include <WebCore/WebMediaSessionManagerClient.h>
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><ins>+#if USE(APPLE_INTERNAL_SDK)
+#include <WebKitAdditions/WebPageProxyAdditions.h>
+#endif
+
</ins><span class="cx"> #if ENABLE(MEDIA_SESSION)
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> class MediaSessionMetadata;
</span><span class="lines">@@ -1481,6 +1485,10 @@
</span><span class="cx">     void removeObserver(WebViewDidMoveToWindowObserver&);
</span><span class="cx">     void webViewDidMoveToWindow();
</span><span class="cx"> 
</span><ins>+#if HAVE(LOAD_OPTIMIZER)
+WEBPAGEPROXY_LOADOPTIMIZER_ADDITIONS_1
+#endif
+
</ins><span class="cx">     // IPC::MessageReceiver
</span><span class="cx">     // Implemented in generated WebPageProxyMessageReceiver.cpp
</span><span class="cx">     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
</span><span class="lines">@@ -2188,6 +2196,10 @@
</span><span class="cx">     WebCore::ResourceRequest m_decidePolicyForResponseRequest;
</span><span class="cx">     bool m_shouldSuppressAppLinksInNextNavigationPolicyDecision { false };
</span><span class="cx"> 
</span><ins>+#if HAVE(LOAD_OPTIMIZER)
+WEBPAGEPROXY_LOADOPTIMIZER_ADDITIONS_2
+#endif
+
</ins><span class="cx">     Deque<NativeWebMouseEvent> m_mouseEventQueue;
</span><span class="cx">     Deque<NativeWebKeyboardEvent> m_keyEventQueue;
</span><span class="cx">     Deque<NativeWebWheelEvent> m_wheelEventQueue;
</span></span></pre>
</div>
</div>

</body>
</html>