Changeset 242697 in webkit
- Timestamp:
- Mar 10, 2019, 8:41:13 PM (7 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 10 edited
-
ChangeLog (modified) (1 diff)
-
UIProcess/API/APINavigationAction.h (modified) (3 diffs)
-
UIProcess/API/APIUIClient.h (modified) (1 diff)
-
UIProcess/API/C/WKPage.cpp (modified) (3 diffs)
-
UIProcess/API/glib/WebKitUIClient.cpp (modified) (1 diff)
-
UIProcess/Cocoa/NavigationState.mm (modified) (4 diffs)
-
UIProcess/Cocoa/UIDelegate.h (modified) (1 diff)
-
UIProcess/Cocoa/UIDelegate.mm (modified) (4 diffs)
-
UIProcess/WebPageProxy.cpp (modified) (3 diffs)
-
UIProcess/WebPageProxy.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r242696 r242697 1 2019-03-10 Jiewen Tan <jiewen_tan@apple.com> 2 3 Optimizing loads when creating new pages 4 https://bugs.webkit.org/show_bug.cgi?id=195516 5 <rdar://problem/48738086> 6 7 Reviewed by Darin Adler. 8 9 This patch adds hooks in WebPageProxy::createNewPage to optimize loads, and moves the creationParameters 10 of API::NavigationAction from UI clients to WebPageProxy::createNewPage. Also, we now pass the whole 11 API::NavigationAction to the load optimizer instead of the request within. 12 13 * UIProcess/API/APINavigationAction.h: 14 * UIProcess/API/APIUIClient.h: 15 (API::UIClient::createNewPage): 16 * UIProcess/API/C/WKPage.cpp: 17 (WKPageSetPageUIClient): 18 * UIProcess/API/glib/WebKitUIClient.cpp: 19 * UIProcess/Cocoa/NavigationState.mm: 20 (WebKit::tryOptimizingLoad): 21 (WebKit::tryInterceptNavigation): 22 (WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction): 23 * UIProcess/Cocoa/UIDelegate.h: 24 * UIProcess/Cocoa/UIDelegate.mm: 25 (WebKit::UIDelegate::UIClient::createNewPage): 26 * UIProcess/WebPageProxy.cpp: 27 (WebKit::WebPageProxy::decidePolicyForNavigationAction): 28 (WebKit::tryOptimizingLoad): 29 (WebKit::WebPageProxy::createNewPage): 30 * UIProcess/WebPageProxy.h: 31 1 32 2019-03-10 Tim Horton <timothy_horton@apple.com> 2 33 -
trunk/Source/WebKit/UIProcess/API/APINavigationAction.h
r241000 r242697 34 34 #include <wtf/URL.h> 35 35 36 #if USE(APPLE_INTERNAL_SDK) 37 #include <WebKitAdditions/APINavigationActionAdditions.h> 38 #endif 39 36 40 namespace API { 37 41 … … 66 70 Navigation* mainFrameNavigation() const { return m_mainFrameNavigation.get(); } 67 71 72 #if HAVE(LOAD_OPTIMIZER) 73 APINAVIGATIONACTION_LOADOPTIMIZER_ADDITIONS_1 74 #endif 75 68 76 private: 69 77 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) … … 93 101 94 102 bool m_shouldOpenAppLinks; 103 #if HAVE(LOAD_OPTIMIZER) 104 APINAVIGATIONACTION_LOADOPTIMIZER_ADDITIONS_2 105 #endif 95 106 96 107 RefPtr<UserInitiatedAction> m_userInitiatedAction; -
trunk/Source/WebKit/UIProcess/API/APIUIClient.h
r242664 r242697 74 74 virtual ~UIClient() { } 75 75 76 virtual void createNewPage(WebKit::WebPageProxy&, Ref<FrameInfo>&&, WebCore::ResourceRequest&&, WebCore::WindowFeatures&&, WebKit::NavigationActionData&&, CompletionHandler<void(RefPtr<WebKit::WebPageProxy>&&)>&& completionHandler) { completionHandler(nullptr); }76 virtual void createNewPage(WebKit::WebPageProxy&, WebCore::WindowFeatures&&, Ref<API::NavigationAction>&&, CompletionHandler<void(RefPtr<WebKit::WebPageProxy>&&)>&& completionHandler) { completionHandler(nullptr); } 77 77 virtual void showPage(WebKit::WebPageProxy*) { } 78 78 virtual void fullscreenMayReturnToInline(WebKit::WebPageProxy*) { } -
trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp
r242664 r242697 1475 1475 1476 1476 private: 1477 void createNewPage(WebPageProxy& page, Ref<API::FrameInfo>&& sourceFrameInfo, WebCore::ResourceRequest&& resourceRequest, WebCore::WindowFeatures&& windowFeatures, NavigationActionData&& navigationActionData, CompletionHandler<void(RefPtr<WebPageProxy>&&)>&& completionHandler) final1477 void createNewPage(WebPageProxy& page, WebCore::WindowFeatures&& windowFeatures, Ref<API::NavigationAction>&& navigationAction, CompletionHandler<void(RefPtr<WebPageProxy>&&)>&& completionHandler) final 1478 1478 { 1479 1479 if (m_client.createNewPage) { … … 1481 1481 configuration->setRelatedPage(&page); 1482 1482 1483 auto userInitiatedActivity = page.process().userInitiatedActivity(navigationActionData.userGestureTokenIdentifier);1484 bool shouldOpenAppLinks = !hostsAreEqual(sourceFrameInfo->request().url(), resourceRequest.url());1485 auto apiNavigationAction = API::NavigationAction::create(WTFMove(navigationActionData), sourceFrameInfo.ptr(), nullptr, WTF::nullopt, WTFMove(resourceRequest), URL(), shouldOpenAppLinks, WTFMove(userInitiatedActivity));1486 1487 1483 auto apiWindowFeatures = API::WindowFeatures::create(windowFeatures); 1488 1484 1489 return completionHandler(adoptRef(toImpl(m_client.createNewPage(toAPI(&page), toAPI(configuration.ptr()), toAPI( apiNavigationAction.ptr()), toAPI(apiWindowFeatures.ptr()), m_client.base.clientInfo))));1485 return completionHandler(adoptRef(toImpl(m_client.createNewPage(toAPI(&page), toAPI(configuration.ptr()), toAPI(navigationAction.ptr()), toAPI(apiWindowFeatures.ptr()), m_client.base.clientInfo)))); 1490 1486 } 1491 1487 … … 1511 1507 1512 1508 if (m_client.createNewPage_deprecatedForUseWithV1) { 1513 Ref<API::URLRequest> request = API::URLRequest::create( resourceRequest);1514 return completionHandler(adoptRef(toImpl(m_client.createNewPage_deprecatedForUseWithV1(toAPI(&page), toAPI(request.ptr()), toAPI(featuresMap.ptr()), toAPI(navigationAction Data.modifiers), toAPI(navigationActionData.mouseButton), m_client.base.clientInfo))));1509 Ref<API::URLRequest> request = API::URLRequest::create(navigationAction->request()); 1510 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)))); 1515 1511 } 1516 1512 1517 1513 ASSERT(m_client.createNewPage_deprecatedForUseWithV0); 1518 return completionHandler(adoptRef(toImpl(m_client.createNewPage_deprecatedForUseWithV0(toAPI(&page), toAPI(featuresMap.ptr()), toAPI(navigationAction Data.modifiers), toAPI(navigationActionData.mouseButton), m_client.base.clientInfo))));1514 return completionHandler(adoptRef(toImpl(m_client.createNewPage_deprecatedForUseWithV0(toAPI(&page), toAPI(featuresMap.ptr()), toAPI(navigationAction->modifiers()), toAPI(navigationAction->mouseButton()), m_client.base.clientInfo)))); 1519 1515 } 1520 1516 -
trunk/Source/WebKit/UIProcess/API/glib/WebKitUIClient.cpp
r241000 r242697 51 51 52 52 private: 53 void createNewPage(WebPageProxy& page, Ref<API::FrameInfo>&& frameInfo, WebCore::ResourceRequest&& resourceRequest, WebCore::WindowFeatures&& windowFeatures, NavigationActionData&& navigationActionData, CompletionHandler<void(RefPtr<WebPageProxy>&&)>&& completionHandler) final 54 { 55 auto userInitiatedActivity = page.process().userInitiatedActivity(navigationActionData.userGestureTokenIdentifier); 56 WebKitNavigationAction navigationAction(API::NavigationAction::create(WTFMove(navigationActionData), frameInfo.ptr(), nullptr, WTF::nullopt, WTFMove(resourceRequest), URL { }, false, WTFMove(userInitiatedActivity))); 53 void createNewPage(WebPageProxy& page, WebCore::WindowFeatures&& windowFeatures, Ref<API::NavigationAction>&& apiNavigationAction, CompletionHandler<void(RefPtr<WebPageProxy>&&)>&& completionHandler) final 54 { 55 WebKitNavigationAction navigationAction(WTFMove(apiNavigationAction)); 57 56 completionHandler(webkitWebViewCreateNewPage(m_webView, windowFeatures, &navigationAction)); 58 57 } -
trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm
r242339 r242697 468 468 469 469 #if !USE(APPLE_INTERNAL_SDK) 470 static void tryOptimizingLoad( const WebCore::ResourceRequest&, WebPageProxy&, Function<void(bool)>&& completionHandler)470 static void tryOptimizingLoad(Ref<API::NavigationAction>&&, WebPageProxy&, Function<void(bool)>&& completionHandler) 471 471 { 472 472 completionHandler(false); … … 478 478 #if HAVE(APP_LINKS) 479 479 if (navigationAction->shouldOpenAppLinks()) { 480 auto* localCompletionHandler = new WTF::Function<void (bool)>([request = navigationAction->request().isolatedCopy(), weakPage = makeWeakPtr(page), completionHandler = WTFMove(completionHandler)] (bool success) mutable { 480 auto url = navigationAction->request().url(); 481 auto* localCompletionHandler = new WTF::Function<void (bool)>([navigationAction = WTFMove(navigationAction), weakPage = makeWeakPtr(page), completionHandler = WTFMove(completionHandler)] (bool success) mutable { 481 482 ASSERT(RunLoop::isMain()); 482 483 if (!success && weakPage) { 483 tryOptimizingLoad( request, *weakPage, WTFMove(completionHandler));484 tryOptimizingLoad(WTFMove(navigationAction), *weakPage, WTFMove(completionHandler)); 484 485 return; 485 486 } 486 487 completionHandler(success); 487 488 }); 488 [LSAppLink openWithURL: navigationAction->request().url()completionHandler:[localCompletionHandler](BOOL success, NSError *) {489 [LSAppLink openWithURL:url completionHandler:[localCompletionHandler](BOOL success, NSError *) { 489 490 dispatch_async(dispatch_get_main_queue(), [localCompletionHandler, success] { 490 491 (*localCompletionHandler)(success); … … 496 497 #endif 497 498 498 tryOptimizingLoad( navigationAction->request(), page, WTFMove(completionHandler));499 tryOptimizingLoad(WTFMove(navigationAction), page, WTFMove(completionHandler)); 499 500 } 500 501 … … 588 589 break; 589 590 case _WKNavigationActionPolicyAllowWithoutTryingAppLink: 590 tryOptimizingLoad( navigationAction->request(), webPageProxy, [localListener = WTFMove(localListener), websitePolicies = WTFMove(apiWebsitePolicies)] (bool optimizedLoad) {591 tryOptimizingLoad(WTFMove(navigationAction), webPageProxy, [localListener = WTFMove(localListener), websitePolicies = WTFMove(apiWebsitePolicies)] (bool optimizedLoad) { 591 592 if (optimizedLoad) { 592 593 localListener->ignore(); -
trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.h
r242664 r242697 80 80 private: 81 81 // API::UIClient 82 void createNewPage(Web PageProxy&, Ref<API::FrameInfo>&&, WebCore::ResourceRequest&&, WebCore::WindowFeatures&&, NavigationActionData&&, CompletionHandler<void(RefPtr<WebPageProxy>&&)>&&) final;82 void createNewPage(WebKit::WebPageProxy&, WebCore::WindowFeatures&&, Ref<API::NavigationAction>&&, CompletionHandler<void(RefPtr<WebPageProxy>&&)>&&) final; 83 83 void close(WebPageProxy*) final; 84 84 void fullscreenMayReturnToInline(WebPageProxy*) final; -
trunk/Source/WebKit/UIProcess/Cocoa/UIDelegate.mm
r242664 r242697 229 229 } 230 230 231 void UIDelegate::UIClient::createNewPage(Web PageProxy& page, Ref<API::FrameInfo>&& sourceFrameInfo, WebCore::ResourceRequest&& request, WebCore::WindowFeatures&& windowFeatures, NavigationActionData&& navigationActionData, CompletionHandler<void(RefPtr<WebPageProxy>&&)>&& completionHandler)231 void UIDelegate::UIClient::createNewPage(WebKit::WebPageProxy&, WebCore::WindowFeatures&& windowFeatures, Ref<API::NavigationAction>&& navigationAction, CompletionHandler<void(RefPtr<WebPageProxy>&&)>&& completionHandler) 232 232 { 233 233 auto delegate = m_uiDelegate.m_delegate.get(); … … 237 237 [configuration _setRelatedWebView:m_uiDelegate.m_webView]; 238 238 239 auto userInitiatedActivity = page.process().userInitiatedActivity(navigationActionData.userGestureTokenIdentifier);240 bool shouldOpenAppLinks = !hostsAreEqual(sourceFrameInfo->request().url(), request.url());241 auto apiNavigationAction = API::NavigationAction::create(WTFMove(navigationActionData), sourceFrameInfo.ptr(), nullptr, WTF::nullopt, WTFMove(request), URL(), shouldOpenAppLinks, WTFMove(userInitiatedActivity));242 243 239 auto apiWindowFeatures = API::WindowFeatures::create(windowFeatures); 244 240 … … 246 242 auto checker = CompletionHandlerCallChecker::create(delegate.get(), @selector(_webView:createWebViewWithConfiguration:forNavigationAction:windowFeatures:completionHandler:)); 247 243 248 [(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 {244 [(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 { 249 245 if (checker->completionHandlerHasBeenCalled()) 250 246 return; … … 266 262 return completionHandler(nullptr); 267 263 268 RetainPtr<WKWebView> webView = [delegate webView:m_uiDelegate.m_webView createWebViewWithConfiguration:configuration.get() forNavigationAction:wrapper( apiNavigationAction) windowFeatures:wrapper(apiWindowFeatures)];264 RetainPtr<WKWebView> webView = [delegate webView:m_uiDelegate.m_webView createWebViewWithConfiguration:configuration.get() forNavigationAction:wrapper(navigationAction) windowFeatures:wrapper(apiWindowFeatures)]; 269 265 if (!webView) 270 266 return completionHandler(nullptr); -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r242696 r242697 4603 4603 auto navigationAction = API::NavigationAction::create(WTFMove(navigationActionData), sourceFrameInfo.get(), destinationFrameInfo.ptr(), WTF::nullopt, WTFMove(request), originalRequest.url(), shouldOpenAppLinks, WTFMove(userInitiatedActivity), mainFrameNavigation); 4604 4604 4605 #if HAVE(LOAD_OPTIMIZER) 4606 WEBPAGEPROXY_LOADOPTIMIZER_ADDITIONS_3 4607 #endif 4608 4605 4609 m_navigationClient->decidePolicyForNavigationAction(*this, WTFMove(navigationAction), WTFMove(listener), process->transformHandlesToObjects(userData.object()).get()); 4606 4610 } 4607 4611 4608 4612 m_shouldSuppressAppLinksInNextNavigationPolicyDecision = false; 4613 4614 #if HAVE(LOAD_OPTIMIZER) 4615 WEBPAGEPROXY_LOADOPTIMIZER_ADDITIONS_4 4616 #endif 4609 4617 } 4610 4618 … … 4892 4900 // UIClient 4893 4901 4902 using NewPageCallback = CompletionHandler<void(RefPtr<WebPageProxy>&&)>; 4903 using UIClientCallback = Function<void(Ref<API::NavigationAction>&&, NewPageCallback&&)>; 4904 static void tryOptimizingLoad(Ref<API::NavigationAction>&& navigationAction, WebPageProxy& page, NewPageCallback&& newPageCallback, UIClientCallback&& uiClientCallback) 4905 { 4906 #if HAVE(LOAD_OPTIMIZER) 4907 WEBPAGEPROXY_LOADOPTIMIZER_ADDITIONS_6 4908 #else 4909 ASSERT_UNUSED(page, page.pageID()); 4910 uiClientCallback(WTFMove(navigationAction), WTFMove(newPageCallback)); 4911 #endif 4912 } 4913 4894 4914 void WebPageProxy::createNewPage(const FrameInfoData& originatingFrameInfoData, uint64_t originatingPageID, ResourceRequest&& request, WindowFeatures&& windowFeatures, NavigationActionData&& navigationActionData, Messages::WebPageProxy::CreateNewPage::DelayedReply&& reply) 4895 4915 { 4896 4916 MESSAGE_CHECK(m_process, m_process->webFrame(originatingFrameInfoData.frameID)); 4897 4917 auto originatingFrameInfo = API::FrameInfo::create(originatingFrameInfoData, m_process->webPage(originatingPageID)); 4898 4899 4918 auto mainFrameURL = m_mainFrame->url(); 4900 4901 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 { 4919 auto completionHandler = [this, protectedThis = makeRef(*this), mainFrameURL, request, reply = WTFMove(reply)] (RefPtr<WebPageProxy> newPage) mutable { 4902 4920 if (!newPage) { 4903 4921 reply(0, WTF::nullopt); … … 4911 4929 WebsiteDataStore::cloneSessionData(*this, *newPage); 4912 4930 newPage->m_shouldSuppressAppLinksInNextNavigationPolicyDecision = hostsAreEqual(URL({ }, mainFrameURL), request.url()); 4931 4932 #if HAVE(LOAD_OPTIMIZER) 4933 WEBPAGEPROXY_LOADOPTIMIZER_ADDITIONS_5 4934 #endif 4935 }; 4936 4937 auto userInitiatedActivity = m_process->userInitiatedActivity(navigationActionData.userGestureTokenIdentifier); 4938 bool shouldOpenAppLinks = !hostsAreEqual(originatingFrameInfo->request().url(), request.url()); 4939 auto navigationAction = API::NavigationAction::create(WTFMove(navigationActionData), originatingFrameInfo.ptr(), nullptr, WTF::nullopt, WTFMove(request), URL(), shouldOpenAppLinks, WTFMove(userInitiatedActivity)); 4940 4941 tryOptimizingLoad(WTFMove(navigationAction), *this, WTFMove(completionHandler), [this, protectedThis = makeRef(*this), windowFeatures = WTFMove(windowFeatures)] (Ref<API::NavigationAction>&& navigationAction, CompletionHandler<void(RefPtr<WebPageProxy>&&)>&& completionHandler) mutable { 4942 m_uiClient->createNewPage(*this, WTFMove(windowFeatures), WTFMove(navigationAction), WTFMove(completionHandler)); 4913 4943 }); 4914 4944 } -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r242696 r242697 136 136 #endif 137 137 138 #if USE(APPLE_INTERNAL_SDK) 139 #include <WebKitAdditions/WebPageProxyAdditions.h> 140 #endif 141 138 142 #if ENABLE(MEDIA_SESSION) 139 143 namespace WebCore { … … 1481 1485 void webViewDidMoveToWindow(); 1482 1486 1487 #if HAVE(LOAD_OPTIMIZER) 1488 WEBPAGEPROXY_LOADOPTIMIZER_ADDITIONS_1 1489 #endif 1490 1483 1491 // IPC::MessageReceiver 1484 1492 // Implemented in generated WebPageProxyMessageReceiver.cpp … … 2188 2196 bool m_shouldSuppressAppLinksInNextNavigationPolicyDecision { false }; 2189 2197 2198 #if HAVE(LOAD_OPTIMIZER) 2199 WEBPAGEPROXY_LOADOPTIMIZER_ADDITIONS_2 2200 #endif 2201 2190 2202 Deque<NativeWebMouseEvent> m_mouseEventQueue; 2191 2203 Deque<NativeWebKeyboardEvent> m_keyEventQueue;
Note:
See TracChangeset
for help on using the changeset viewer.