WebKit Bugzilla
Attachment 356294 Details for
Bug 192272
: Add WKWebProcessPlugInLoadDelegate SPI willStartProvisionalLoadForFrame with a completion handler
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-192272-20181130221542.patch (text/plain), 62.70 KB, created by
Alex Christensen
on 2018-11-30 22:15:43 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Alex Christensen
Created:
2018-11-30 22:15:43 PST
Size:
62.70 KB
patch
obsolete
>Index: Source/WebCore/ChangeLog >=================================================================== >--- Source/WebCore/ChangeLog (revision 238774) >+++ Source/WebCore/ChangeLog (working copy) >@@ -1,3 +1,21 @@ >+2018-11-30 Alex Christensen <achristensen@webkit.org> >+ >+ Add WKWebProcessPlugInLoadDelegate SPI willStartProvisionalLoadForFrame with a completion handler >+ https://bugs.webkit.org/show_bug.cgi?id=192272 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ This is needed for rdar://problem/45910057 >+ Covered by an API test. >+ >+ * loader/EmptyFrameLoaderClient.h: >+ * loader/FrameLoader.cpp: >+ (WebCore::FrameLoader::prepareForLoadStart): >+ (WebCore::FrameLoader::continueLoadAfterNavigationPolicy): >+ (WebCore::FrameLoader::loadProvisionalItemFromCachedPage): >+ * loader/FrameLoader.h: >+ * loader/FrameLoaderClient.h: >+ > 2018-11-30 Alex Christensen <achristensen@webkit.org> > > Fix Windows build. >Index: Source/WebCore/loader/EmptyFrameLoaderClient.h >=================================================================== >--- Source/WebCore/loader/EmptyFrameLoaderClient.h (revision 238771) >+++ Source/WebCore/loader/EmptyFrameLoaderClient.h (working copy) >@@ -81,7 +81,7 @@ class WEBCORE_EXPORT EmptyFrameLoaderCli > void dispatchDidReplaceStateWithinPage() final { } > void dispatchDidPopStateWithinPage() final { } > void dispatchWillClose() final { } >- void dispatchDidStartProvisionalLoad() final { } >+ void dispatchDidStartProvisionalLoad(CompletionHandler<void()>&& completionHandler) final { completionHandler(); } > void dispatchDidReceiveTitle(const StringWithDirection&) final { } > void dispatchDidCommitLoad(std::optional<HasInsecureContent>) final { } > void dispatchDidFailProvisionalLoad(const ResourceError&) final { } >Index: Source/WebCore/loader/FrameLoader.cpp >=================================================================== >--- Source/WebCore/loader/FrameLoader.cpp (revision 238771) >+++ Source/WebCore/loader/FrameLoader.cpp (working copy) >@@ -1204,19 +1204,20 @@ void FrameLoader::started() > frame->loader().m_isComplete = false; > } > >-void FrameLoader::prepareForLoadStart() >+void FrameLoader::prepareForLoadStart(CompletionHandler<void()>&& completionHandler) > { > RELEASE_LOG_IF_ALLOWED("prepareForLoadStart: Starting frame load (frame = %p, main = %d)", &m_frame, m_frame.isMainFrame()); > > m_progressTracker->progressStarted(); >- m_client.dispatchDidStartProvisionalLoad(); >- >- if (AXObjectCache::accessibilityEnabled()) { >- if (AXObjectCache* cache = m_frame.document()->existingAXObjectCache()) { >- AXObjectCache::AXLoadingEvent loadingEvent = loadType() == FrameLoadType::Reload ? AXObjectCache::AXLoadingReloaded : AXObjectCache::AXLoadingStarted; >- cache->frameLoadingEventNotification(&m_frame, loadingEvent); >+ m_client.dispatchDidStartProvisionalLoad([this, protectedFrame = makeRef(m_frame), completionHandler = WTFMove(completionHandler)] () mutable { >+ if (AXObjectCache::accessibilityEnabled()) { >+ if (AXObjectCache* cache = m_frame.document()->existingAXObjectCache()) { >+ AXObjectCache::AXLoadingEvent loadingEvent = loadType() == FrameLoadType::Reload ? AXObjectCache::AXLoadingReloaded : AXObjectCache::AXLoadingStarted; >+ cache->frameLoadingEventNotification(&m_frame, loadingEvent); >+ } > } >- } >+ completionHandler(); >+ }); > } > > void FrameLoader::setupForReplace() >@@ -3345,37 +3346,38 @@ void FrameLoader::continueLoadAfterNavig > diagnosticLoggingClient.logDiagnosticMessageWithResult(DiagnosticLoggingKeys::pageCacheKey(), DiagnosticLoggingKeys::retrievalKey(), DiagnosticLoggingResultFail, ShouldSample::Yes); > } > >- CompletionHandler<void()> completionHandler = [this, shouldContinue] { >+ CompletionHandler<void()> completionHandler = [this, protectedFrame = makeRef(m_frame), shouldContinue] () mutable { > if (!m_provisionalDocumentLoader) > return; > >- prepareForLoadStart(); >- >- // The load might be cancelled inside of prepareForLoadStart(), nulling out the m_provisionalDocumentLoader, >- // so we need to null check it again. >- if (!m_provisionalDocumentLoader) { >- RELEASE_LOG_IF_ALLOWED("dispatchWillSubmitForm completionHandler: Frame load canceled (frame = %p, main = %d)", &m_frame, m_frame.isMainFrame()); >- return; >- } >- >- DocumentLoader* activeDocLoader = activeDocumentLoader(); >- if (activeDocLoader && activeDocLoader->isLoadingMainResource()) { >- RELEASE_LOG_IF_ALLOWED("dispatchWillSubmitForm completionHandler: Main frame already being loaded (frame = %p, main = %d)", &m_frame, m_frame.isMainFrame()); >- return; >- } >- >- m_loadingFromCachedPage = false; >+ prepareForLoadStart([this, protectedFrame = WTFMove(protectedFrame), shouldContinue] { > >- // We handle suspension by navigating forward to about:blank, which leaves us setup to navigate back to resume. >- if (shouldContinue == ShouldContinue::ForSuspension) { >- // Make sure we do a standard load to about:blank instead of reusing whatever the load type was on process swap. >- // For example, using a Back/Forward load to load about blank would cause the current HistoryItem's url to be >- // overwritten with 'about:blank', which we do not want. >- m_loadType = FrameLoadType::Standard; >- m_provisionalDocumentLoader->willContinueMainResourceLoadAfterRedirect({ WTF::blankURL() }); >- } >+ // The load might be cancelled inside of prepareForLoadStart(), nulling out the m_provisionalDocumentLoader, >+ // so we need to null check it again. >+ if (!m_provisionalDocumentLoader) { >+ RELEASE_LOG_IF_ALLOWED("dispatchWillSubmitForm completionHandler: Frame load canceled (frame = %p, main = %d)", &m_frame, m_frame.isMainFrame()); >+ return; >+ } >+ >+ DocumentLoader* activeDocLoader = activeDocumentLoader(); >+ if (activeDocLoader && activeDocLoader->isLoadingMainResource()) { >+ RELEASE_LOG_IF_ALLOWED("dispatchWillSubmitForm completionHandler: Main frame already being loaded (frame = %p, main = %d)", &m_frame, m_frame.isMainFrame()); >+ return; >+ } >+ >+ m_loadingFromCachedPage = false; >+ >+ // We handle suspension by navigating forward to about:blank, which leaves us setup to navigate back to resume. >+ if (shouldContinue == ShouldContinue::ForSuspension) { >+ // Make sure we do a standard load to about:blank instead of reusing whatever the load type was on process swap. >+ // For example, using a Back/Forward load to load about blank would cause the current HistoryItem's url to be >+ // overwritten with 'about:blank', which we do not want. >+ m_loadType = FrameLoadType::Standard; >+ m_provisionalDocumentLoader->willContinueMainResourceLoadAfterRedirect({ WTF::blankURL() }); >+ } > >- m_provisionalDocumentLoader->startLoadingMainResource(shouldContinue); >+ m_provisionalDocumentLoader->startLoadingMainResource(shouldContinue); >+ }); > }; > > if (!formState) { >@@ -3518,20 +3520,20 @@ bool FrameLoader::shouldInterruptLoadFor > > void FrameLoader::loadProvisionalItemFromCachedPage() > { >- DocumentLoader* provisionalLoader = provisionalDocumentLoader(); >- LOG(PageCache, "WebCorePageCache: Loading provisional DocumentLoader %p with URL '%s' from CachedPage", provisionalDocumentLoader(), provisionalDocumentLoader()->url().stringCenterEllipsizedToLength().utf8().data()); >- >- prepareForLoadStart(); >- >- m_loadingFromCachedPage = true; >- >- // Should have timing data from previous time(s) the page was shown. >- ASSERT(provisionalLoader->timing().startTime()); >- provisionalLoader->resetTiming(); >- provisionalLoader->timing().markStartTime(); >+ prepareForLoadStart([this, protectedFrame = makeRef(m_frame)] { >+ DocumentLoader* provisionalLoader = provisionalDocumentLoader(); >+ LOG(PageCache, "WebCorePageCache: Loading provisional DocumentLoader %p with URL '%s' from CachedPage", provisionalDocumentLoader(), provisionalDocumentLoader()->url().stringCenterEllipsizedToLength().utf8().data()); > >- provisionalLoader->setCommitted(true); >- commitProvisionalLoad(); >+ m_loadingFromCachedPage = true; >+ >+ // Should have timing data from previous time(s) the page was shown. >+ ASSERT(provisionalLoader->timing().startTime()); >+ provisionalLoader->resetTiming(); >+ provisionalLoader->timing().markStartTime(); >+ >+ provisionalLoader->setCommitted(true); >+ commitProvisionalLoad(); >+ }); > } > > bool FrameLoader::shouldTreatURLAsSameAsCurrent(const URL& url) const >Index: Source/WebCore/loader/FrameLoader.h >=================================================================== >--- Source/WebCore/loader/FrameLoader.h (revision 238771) >+++ Source/WebCore/loader/FrameLoader.h (working copy) >@@ -387,7 +387,7 @@ private: > > void loadInSameDocument(const URL&, SerializedScriptValue* stateObject, bool isNewNavigation); > >- void prepareForLoadStart(); >+ void prepareForLoadStart(CompletionHandler<void()>&&); > void provisionalLoadStarted(); > > void willTransitionToCommitted(); >Index: Source/WebCore/loader/FrameLoaderClient.h >=================================================================== >--- Source/WebCore/loader/FrameLoaderClient.h (revision 238771) >+++ Source/WebCore/loader/FrameLoaderClient.h (working copy) >@@ -173,7 +173,7 @@ public: > virtual void dispatchDidPopStateWithinPage() = 0; > virtual void dispatchWillClose() = 0; > virtual void dispatchDidReceiveIcon() { } >- virtual void dispatchDidStartProvisionalLoad() = 0; >+ virtual void dispatchDidStartProvisionalLoad(CompletionHandler<void()>&&) = 0; > virtual void dispatchDidReceiveTitle(const StringWithDirection&) = 0; > virtual void dispatchDidCommitLoad(std::optional<HasInsecureContent>) = 0; > virtual void dispatchDidFailProvisionalLoad(const ResourceError&) = 0; >Index: Source/WebKit/ChangeLog >=================================================================== >--- Source/WebKit/ChangeLog (revision 238771) >+++ Source/WebKit/ChangeLog (working copy) >@@ -1,3 +1,68 @@ >+2018-11-30 Alex Christensen <achristensen@webkit.org> >+ >+ Add WKWebProcessPlugInLoadDelegate SPI willStartProvisionalLoadForFrame with a completion handler >+ https://bugs.webkit.org/show_bug.cgi?id=192272 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * WebProcess/InjectedBundle/API/APIInjectedBundlePageLoaderClient.h: >+ (API::InjectedBundle::PageLoaderClient::didStartProvisionalLoadForFrame): >+ * WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInLoadDelegate.h: >+ * WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm: >+ (ResourceLoadClient::ResourceLoadClient): >+ (ResourceLoadClient::loadDelegate const): >+ (ResourceLoadClient::pluginContextController const): >+ (PageLoaderClient::PageLoaderClient): >+ (PageLoaderClient::loadDelegate const): >+ (PageLoaderClient::pluginContextController const): >+ (PageLoaderClient::didStartProvisionalLoadForFrame): >+ (PageLoaderClient::didReceiveServerRedirectForProvisionalLoadForFrame): >+ (PageLoaderClient::didFinishLoadForFrame): >+ (PageLoaderClient::globalObjectIsAvailableForFrame): >+ (PageLoaderClient::didRemoveFrameFromHierarchy): >+ (PageLoaderClient::didCommitLoadForFrame): >+ (PageLoaderClient::didFinishDocumentLoadForFrame): >+ (PageLoaderClient::didFailProvisionalLoadWithErrorForFrame): >+ (PageLoaderClient::didFailLoadWithErrorForFrame): >+ (PageLoaderClient::didSameDocumentNavigationForFrame): >+ (PageLoaderClient::didLayoutForFrame): >+ (PageLoaderClient::didReachLayoutMilestone): >+ (PageLoaderClient::didFirstVisuallyNonEmptyLayoutForFrame): >+ (PageLoaderClient::didHandleOnloadEventsForFrame): >+ (PageLoaderClient::userAgentForURL const): >+ (ResourceLoadClient::willSendRequestForFrame): >+ (ResourceLoadClient::didInitiateLoadForResource): >+ (ResourceLoadClient::didFinishLoadForResource): >+ (ResourceLoadClient::didFailLoadForResource): >+ (-[WKWebProcessPlugInBrowserContextController setLoadDelegate:]): >+ (didStartProvisionalLoadForFrame): Deleted. >+ (didReceiveServerRedirectForProvisionalLoadForFrame): Deleted. >+ (didFinishLoadForFrame): Deleted. >+ (globalObjectIsAvailableForFrame): Deleted. >+ (didRemoveFrameFromHierarchy): Deleted. >+ (didCommitLoadForFrame): Deleted. >+ (didFinishDocumentLoadForFrame): Deleted. >+ (didFailProvisionalLoadWithErrorForFrame): Deleted. >+ (didFailLoadWithErrorForFrame): Deleted. >+ (didSameDocumentNavigationForFrame): Deleted. >+ (didLayoutForFrame): Deleted. >+ (didReachLayoutMilestone): Deleted. >+ (didFirstVisuallyNonEmptyLayoutForFrame): Deleted. >+ (didHandleOnloadEventsForFrame): Deleted. >+ (userAgentForURL): Deleted. >+ (setUpPageLoaderClient): Deleted. >+ (willSendRequestForFrame): Deleted. >+ (didInitiateLoadForResource): Deleted. >+ (didFinishLoadForResource): Deleted. >+ (didFailLoadForResource): Deleted. >+ (setUpResourceLoadClient): Deleted. >+ * WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp: >+ (WebKit::InjectedBundlePageLoaderClient::didStartProvisionalLoadForFrame): >+ * WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h: >+ * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp: >+ (WebKit::WebFrameLoaderClient::dispatchDidStartProvisionalLoad): >+ * WebProcess/WebCoreSupport/WebFrameLoaderClient.h: >+ > 2018-11-30 Alex Christensen <achristensen@webkit.org> > > Move URL from WebCore to WTF >Index: Source/WebKit/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp >=================================================================== >--- Source/WebKit/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp (revision 238771) >+++ Source/WebKit/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp (working copy) >@@ -81,14 +81,14 @@ void InjectedBundlePageLoaderClient::wil > m_client.willLoadDataRequest(toAPI(&page), toAPI(request), toAPI(data.get()), toAPI(MIMEType.impl()), toAPI(encodingName.impl()), toURLRef(unreachableURL.string().impl()), toAPI(userData), m_client.base.clientInfo); > } > >-void InjectedBundlePageLoaderClient::didStartProvisionalLoadForFrame(WebPage& page, WebFrame& frame, RefPtr<API::Object>& userData) >+void InjectedBundlePageLoaderClient::didStartProvisionalLoadForFrame(WebPage& page, WebFrame& frame, CompletionHandler<void(RefPtr<API::Object>&&)>&& completionHandler) > { > if (!m_client.didStartProvisionalLoadForFrame) >- return; >+ return completionHandler(nullptr); > > WKTypeRef userDataToPass = nullptr; > m_client.didStartProvisionalLoadForFrame(toAPI(&page), toAPI(&frame), &userDataToPass, m_client.base.clientInfo); >- userData = adoptRef(toImpl(userDataToPass)); >+ completionHandler(adoptRef(toImpl(userDataToPass))); > } > > void InjectedBundlePageLoaderClient::didReceiveServerRedirectForProvisionalLoadForFrame(WebPage& page, WebFrame& frame, RefPtr<API::Object>& userData) >Index: Source/WebKit/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h >=================================================================== >--- Source/WebKit/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h (revision 238771) >+++ Source/WebKit/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h (working copy) >@@ -49,7 +49,7 @@ public: > void willLoadURLRequest(WebPage&, const WebCore::ResourceRequest&, API::Object*) override; > void willLoadDataRequest(WebPage&, const WebCore::ResourceRequest&, WebCore::SharedBuffer*, const WTF::String&, const WTF::String&, const URL&, API::Object*) override; > >- void didStartProvisionalLoadForFrame(WebPage&, WebFrame&, RefPtr<API::Object>&) override; >+ void didStartProvisionalLoadForFrame(WebPage&, WebFrame&, CompletionHandler<void(RefPtr<API::Object>&&)>&&) override; > void didReceiveServerRedirectForProvisionalLoadForFrame(WebPage&, WebFrame&, RefPtr<API::Object>&) override; > void didFailProvisionalLoadWithErrorForFrame(WebPage&, WebFrame&, const WebCore::ResourceError&, RefPtr<API::Object>&) override; > void didCommitLoadForFrame(WebPage&, WebFrame&, RefPtr<API::Object>&) override; >Index: Source/WebKit/WebProcess/InjectedBundle/API/APIInjectedBundlePageLoaderClient.h >=================================================================== >--- Source/WebKit/WebProcess/InjectedBundle/API/APIInjectedBundlePageLoaderClient.h (revision 238771) >+++ Source/WebKit/WebProcess/InjectedBundle/API/APIInjectedBundlePageLoaderClient.h (working copy) >@@ -27,6 +27,7 @@ > > #include "SameDocumentNavigationType.h" > #include <WebCore/LayoutMilestone.h> >+#include <wtf/CompletionHandler.h> > #include <wtf/Forward.h> > #include <wtf/WallTime.h> > #include <wtf/text/WTFString.h> >@@ -57,7 +58,7 @@ public: > virtual void willLoadURLRequest(WebKit::WebPage&, const WebCore::ResourceRequest&, API::Object*) { } > virtual void willLoadDataRequest(WebKit::WebPage&, const WebCore::ResourceRequest&, WebCore::SharedBuffer*, const WTF::String&, const WTF::String&, const WTF::URL&, API::Object*) { } > >- virtual void didStartProvisionalLoadForFrame(WebKit::WebPage&, WebKit::WebFrame&, RefPtr<API::Object>&) { } >+ virtual void didStartProvisionalLoadForFrame(WebKit::WebPage&, WebKit::WebFrame&, CompletionHandler<void(RefPtr<API::Object>&&)>&& completionHandler) { completionHandler(nullptr); } > virtual void didReceiveServerRedirectForProvisionalLoadForFrame(WebKit::WebPage&, WebKit::WebFrame&, RefPtr<API::Object>&) { } > virtual void didFailProvisionalLoadWithErrorForFrame(WebKit::WebPage&, WebKit::WebFrame&, const WebCore::ResourceError&, RefPtr<API::Object>&) { } > virtual void didCommitLoadForFrame(WebKit::WebPage&, WebKit::WebFrame&, RefPtr<API::Object>&) { } >Index: Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInLoadDelegate.h >=================================================================== >--- Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInLoadDelegate.h (revision 238771) >+++ Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInLoadDelegate.h (working copy) >@@ -37,6 +37,7 @@ > // Frame loading > > - (void)webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController*)controller didStartProvisionalLoadForFrame:(WKWebProcessPlugInFrame *)frame; >+- (void)webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController*)controller willStartProvisionalLoadForFrame:(WKWebProcessPlugInFrame *)frame completionHandler:(void(^)(void))completionHandler; > - (void)webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController*)controller didReceiveServerRedirectForProvisionalLoadForFrame:(WKWebProcessPlugInFrame *)frame; > - (void)webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController*)controller didCommitLoadForFrame:(WKWebProcessPlugInFrame *)frame; > - (void)webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController*)controller didFinishDocumentLoadForFrame:(WKWebProcessPlugInFrame *)frame; >Index: Source/WebKit/WebProcess/InjectedBundle/API/glib/WebKitWebPage.cpp >=================================================================== >--- Source/WebKit/WebProcess/InjectedBundle/API/glib/WebKitWebPage.cpp (revision 238771) >+++ Source/WebKit/WebProcess/InjectedBundle/API/glib/WebKitWebPage.cpp (working copy) >@@ -170,11 +170,12 @@ private: > return documentLoader->url().string().utf8(); > } > >- void didStartProvisionalLoadForFrame(WebPage&, WebFrame& frame, RefPtr<API::Object>&) override >+ void didStartProvisionalLoadForFrame(WebPage&, WebFrame& frame, CompletionHandler<void(RefPtr<API::Object>&&)>&& completionHandler) override > { > if (!frame.isMainFrame()) >- return; >+ return completionHandler(nullptr); > webkitWebPageSetURI(m_webPage, getDocumentLoaderURL(frame.coreFrame()->loader().provisionalDocumentLoader())); >+ completionHandler(nullptr); > } > > void didReceiveServerRedirectForProvisionalLoadForFrame(WebPage&, WebFrame& frame, RefPtr<API::Object>&) override >Index: Source/WebKit/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm >=================================================================== >--- Source/WebKit/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm (revision 238771) >+++ Source/WebKit/WebProcess/InjectedBundle/API/mac/WKWebProcessPlugInBrowserContextController.mm (working copy) >@@ -29,6 +29,7 @@ > #if WK_API_ENABLED > > #import "APIData.h" >+#import "CompletionHandlerCallChecker.h" > #import "RemoteObjectRegistry.h" > #import "RemoteObjectRegistryMessages.h" > #import "WKBrowsingContextHandleInternal.h" >@@ -64,12 +65,66 @@ > #import <WebCore/HTMLFormElement.h> > #import <WebCore/HTMLInputElement.h> > #import <pal/spi/cocoa/NSKeyedArchiverSPI.h> >+#import <wtf/BlockPtr.h> > #import <wtf/WeakObjCPtr.h> > > @interface NSObject (WKDeprecatedDelegateMethods) > - (void)webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController *)controller didSameDocumentNavigationForFrame:(WKWebProcessPlugInFrame *)frame; > @end > >+class ResourceLoadClient : public API::InjectedBundle::ResourceLoadClient { >+public: >+ explicit ResourceLoadClient(WKWebProcessPlugInBrowserContextController *controller, id <WKWebProcessPlugInLoadDelegate> delegate) >+ : m_controller(controller) >+ , m_delegate(delegate) { } >+ >+ void didInitiateLoadForResource(WebKit::WebPage&, WebKit::WebFrame&, uint64_t identifier, const WebCore::ResourceRequest&, bool) override; >+ void willSendRequestForFrame(WebKit::WebPage&, WebKit::WebFrame&, uint64_t identifier, WebCore::ResourceRequest&, const WebCore::ResourceResponse&) override; >+ void didFinishLoadForResource(WebKit::WebPage&, WebKit::WebFrame&, uint64_t identifier) override; >+ void didFailLoadForResource(WebKit::WebPage&, WebKit::WebFrame&, uint64_t identifier, const WebCore::ResourceError&) override; >+ >+private: >+ id <WKWebProcessPlugInLoadDelegate> loadDelegate() const { return m_delegate.get().get(); } >+ WKWebProcessPlugInBrowserContextController *pluginContextController() const { return m_controller.get().get(); } >+ >+ WeakObjCPtr<WKWebProcessPlugInBrowserContextController> m_controller; >+ WeakObjCPtr<id <WKWebProcessPlugInLoadDelegate>> m_delegate; >+}; >+ >+class PageLoaderClient : public API::InjectedBundle::PageLoaderClient { >+public: >+ explicit PageLoaderClient(WKWebProcessPlugInBrowserContextController *controller, id <WKWebProcessPlugInLoadDelegate> delegate) >+ : m_controller(controller) >+ , m_delegate(delegate) { } >+ >+ void didStartProvisionalLoadForFrame(WebKit::WebPage&, WebKit::WebFrame&, CompletionHandler<void(RefPtr<API::Object>&&)>&&) override; >+ void didReceiveServerRedirectForProvisionalLoadForFrame(WebKit::WebPage&, WebKit::WebFrame&, RefPtr<API::Object>&) override; >+ void didFailProvisionalLoadWithErrorForFrame(WebKit::WebPage&, WebKit::WebFrame&, const WebCore::ResourceError&, RefPtr<API::Object>&) override; >+ void didCommitLoadForFrame(WebKit::WebPage&, WebKit::WebFrame&, RefPtr<API::Object>&) override; >+ void didFinishDocumentLoadForFrame(WebKit::WebPage&, WebKit::WebFrame&, RefPtr<API::Object>&) override; >+ void didFinishLoadForFrame(WebKit::WebPage&, WebKit::WebFrame&, RefPtr<API::Object>&) override; >+ void didFailLoadWithErrorForFrame(WebKit::WebPage&, WebKit::WebFrame&, const WebCore::ResourceError&, RefPtr<API::Object>&) override; >+ void didSameDocumentNavigationForFrame(WebKit::WebPage&, WebKit::WebFrame&, WebKit::SameDocumentNavigationType, RefPtr<API::Object>&) override; >+ void didRemoveFrameFromHierarchy(WebKit::WebPage&, WebKit::WebFrame&, RefPtr<API::Object>&) override; >+ >+ void didFirstVisuallyNonEmptyLayoutForFrame(WebKit::WebPage&, WebKit::WebFrame&, RefPtr<API::Object>&) override; >+ void didLayoutForFrame(WebKit::WebPage&, WebKit::WebFrame&) override; >+ void didReachLayoutMilestone(WebKit::WebPage&, OptionSet<WebCore::LayoutMilestone>, RefPtr<API::Object>&) override; >+ >+ void didHandleOnloadEventsForFrame(WebKit::WebPage&, WebKit::WebFrame&) override; >+ >+ void globalObjectIsAvailableForFrame(WebKit::WebPage&, WebKit::WebFrame&, WebCore::DOMWrapperWorld&) override; >+ >+ WTF::String userAgentForURL(WebKit::WebFrame&, const URL&) const override; >+ >+private: >+ id <WKWebProcessPlugInLoadDelegate> loadDelegate() const { return m_delegate.get().get(); } >+ WKWebProcessPlugInBrowserContextController *pluginContextController() const { return m_controller.get().get(); } >+ >+ WeakObjCPtr<WKWebProcessPlugInBrowserContextController> m_controller; >+ WeakObjCPtr<id <WKWebProcessPlugInLoadDelegate>> m_delegate; >+}; >+ > @implementation WKWebProcessPlugInBrowserContextController { > API::ObjectStorage<WebKit::WebPage> _page; > WeakObjCPtr<id <WKWebProcessPlugInLoadDelegate>> _loadDelegate; >@@ -79,254 +134,164 @@ - (void)webProcessPlugInBrowserContextCo > RetainPtr<_WKRemoteObjectRegistry> _remoteObjectRegistry; > } > >-static void didStartProvisionalLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userDataRef, const void *clientInfo) >+void PageLoaderClient::didStartProvisionalLoadForFrame(WebKit::WebPage&, WebKit::WebFrame& frame, CompletionHandler<void(RefPtr<API::Object>&&)>&& completionHandler) > { >- auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; >- auto loadDelegate = pluginContextController->_loadDelegate.get(); >- >- if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:didStartProvisionalLoadForFrame:)]) >- [loadDelegate webProcessPlugInBrowserContextController:pluginContextController didStartProvisionalLoadForFrame:wrapper(*WebKit::toImpl(frame))]; >+ if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:didStartProvisionalLoadForFrame:)]) { >+ [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() didStartProvisionalLoadForFrame:wrapper(frame)]; >+ completionHandler(nullptr); >+ return; >+ } >+ SEL selector = @selector(webProcessPlugInBrowserContextController:willStartProvisionalLoadForFrame:completionHandler:); >+ if ([loadDelegate() respondsToSelector:selector]) { >+ auto checker = WebKit::CompletionHandlerCallChecker::create(loadDelegate(), selector); >+ [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() willStartProvisionalLoadForFrame:wrapper(frame) completionHandler:BlockPtr<void()>::fromCallable([completionHandler = WTFMove(completionHandler), checker = WTFMove(checker)] () mutable { >+ if (checker->completionHandlerHasBeenCalled()) >+ return; >+ checker->didCallCompletionHandler(); >+ completionHandler(nullptr); >+ }).get()]; >+ return; >+ } >+ completionHandler(nullptr); > } > >-static void didReceiveServerRedirectForProvisionalLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef *userDataRef, const void *clientInfo) >+void PageLoaderClient::didReceiveServerRedirectForProvisionalLoadForFrame(WebKit::WebPage&, WebKit::WebFrame& frame, RefPtr<API::Object>&) > { >- auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; >- auto loadDelegate = pluginContextController->_loadDelegate.get(); >- >- if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:didReceiveServerRedirectForProvisionalLoadForFrame:)]) >- [loadDelegate webProcessPlugInBrowserContextController:pluginContextController didReceiveServerRedirectForProvisionalLoadForFrame:wrapper(*WebKit::toImpl(frame))]; >+ if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:didReceiveServerRedirectForProvisionalLoadForFrame:)]) >+ [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() didReceiveServerRedirectForProvisionalLoadForFrame:wrapper(frame)]; > } > >-static void didFinishLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo) >+void PageLoaderClient::didFinishLoadForFrame(WebKit::WebPage&, WebKit::WebFrame& frame, RefPtr<API::Object>&) > { >- auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; >- auto loadDelegate = pluginContextController->_loadDelegate.get(); >- >- if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:didFinishLoadForFrame:)]) >- [loadDelegate webProcessPlugInBrowserContextController:pluginContextController didFinishLoadForFrame:wrapper(*WebKit::toImpl(frame))]; >+ if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:didFinishLoadForFrame:)]) >+ [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() didFinishLoadForFrame:wrapper(frame)]; > } > >-static void globalObjectIsAvailableForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKBundleScriptWorldRef scriptWorld, const void* clientInfo) >+void PageLoaderClient::globalObjectIsAvailableForFrame(WebKit::WebPage&, WebKit::WebFrame& frame, WebCore::DOMWrapperWorld& scriptWorld) > { >- auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; >- auto loadDelegate = pluginContextController->_loadDelegate.get(); >- >- if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:globalObjectIsAvailableForFrame:inScriptWorld:)]) >- [loadDelegate webProcessPlugInBrowserContextController:pluginContextController globalObjectIsAvailableForFrame:wrapper(*WebKit::toImpl(frame)) inScriptWorld:wrapper(*WebKit::toImpl(scriptWorld))]; >+ if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:globalObjectIsAvailableForFrame:inScriptWorld:)]) >+ [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() globalObjectIsAvailableForFrame:wrapper(frame) inScriptWorld:API::wrapper(WebKit::InjectedBundleScriptWorld::getOrCreate(scriptWorld))]; > } > >-static void didRemoveFrameFromHierarchy(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void* clientInfo) >+void PageLoaderClient::didRemoveFrameFromHierarchy(WebKit::WebPage&, WebKit::WebFrame& frame, RefPtr<API::Object>&) > { >- auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; >- auto loadDelegate = pluginContextController->_loadDelegate.get(); >- >- if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:didRemoveFrameFromHierarchy:)]) >- [loadDelegate webProcessPlugInBrowserContextController:pluginContextController didRemoveFrameFromHierarchy:wrapper(*WebKit::toImpl(frame))]; >+ if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:didRemoveFrameFromHierarchy:)]) >+ [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() didRemoveFrameFromHierarchy:wrapper(frame)]; > } > >-static void didCommitLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo) >+void PageLoaderClient::didCommitLoadForFrame(WebKit::WebPage&, WebKit::WebFrame& frame, RefPtr<API::Object>&) > { >- auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; >- auto loadDelegate = pluginContextController->_loadDelegate.get(); >- >- if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:didCommitLoadForFrame:)]) >- [loadDelegate webProcessPlugInBrowserContextController:pluginContextController didCommitLoadForFrame:wrapper(*WebKit::toImpl(frame))]; >+ if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:didCommitLoadForFrame:)]) >+ [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() didCommitLoadForFrame:wrapper(frame)]; > } > >-static void didFinishDocumentLoadForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo) >+void PageLoaderClient::didFinishDocumentLoadForFrame(WebKit::WebPage&, WebKit::WebFrame& frame, RefPtr<API::Object>&) > { >- auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; >- auto loadDelegate = pluginContextController->_loadDelegate.get(); >- >- if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:didFinishDocumentLoadForFrame:)]) >- [loadDelegate webProcessPlugInBrowserContextController:pluginContextController didFinishDocumentLoadForFrame:wrapper(*WebKit::toImpl(frame))]; >+ if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:didFinishDocumentLoadForFrame:)]) >+ [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() didFinishDocumentLoadForFrame:wrapper(frame)]; > } > >-static void didFailProvisionalLoadWithErrorForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKErrorRef wkError, WKTypeRef* userData, const void *clientInfo) >+void PageLoaderClient::didFailProvisionalLoadWithErrorForFrame(WebKit::WebPage&, WebKit::WebFrame& frame, const WebCore::ResourceError& error, RefPtr<API::Object>&) > { >- auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; >- auto loadDelegate = pluginContextController->_loadDelegate.get(); >- >- if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:didFailProvisionalLoadWithErrorForFrame:error:)]) >- [loadDelegate webProcessPlugInBrowserContextController:pluginContextController didFailProvisionalLoadWithErrorForFrame:wrapper(*WebKit::toImpl(frame)) error:wrapper(*WebKit::toImpl(wkError))]; >+ if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:didFailProvisionalLoadWithErrorForFrame:error:)]) >+ [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() didFailProvisionalLoadWithErrorForFrame:wrapper(frame) error:error]; > } > >-static void didFailLoadWithErrorForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKErrorRef wkError, WKTypeRef* userData, const void *clientInfo) >+void PageLoaderClient::didFailLoadWithErrorForFrame(WebKit::WebPage&, WebKit::WebFrame& frame, const WebCore::ResourceError& error, RefPtr<API::Object>&) > { >- auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; >- auto loadDelegate = pluginContextController->_loadDelegate.get(); >- >- if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:didFailLoadWithErrorForFrame:error:)]) >- [loadDelegate webProcessPlugInBrowserContextController:pluginContextController didFailLoadWithErrorForFrame:wrapper(*WebKit::toImpl(frame)) error:wrapper(*WebKit::toImpl(wkError))]; >+ if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:didFailLoadWithErrorForFrame:error:)]) >+ [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() didFailLoadWithErrorForFrame:wrapper(frame) error:error]; > } > >-static void didSameDocumentNavigationForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKSameDocumentNavigationType type, WKTypeRef* userData, const void *clientInfo) >+void PageLoaderClient::didSameDocumentNavigationForFrame(WebKit::WebPage&, WebKit::WebFrame& frame, WebKit::SameDocumentNavigationType type, RefPtr<API::Object>&) > { >- auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; >- auto loadDelegate = pluginContextController->_loadDelegate.get(); >- >- if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:didSameDocumentNavigation:forFrame:)]) >- [loadDelegate webProcessPlugInBrowserContextController:pluginContextController didSameDocumentNavigation:toWKSameDocumentNavigationType(WebKit::toSameDocumentNavigationType(type)) forFrame:wrapper(*WebKit::toImpl(frame))]; >+ if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:didSameDocumentNavigation:forFrame:)]) >+ [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() didSameDocumentNavigation:toWKSameDocumentNavigationType(type) forFrame:wrapper(frame)]; > else { > // FIXME: Remove this once clients switch to implementing the above delegate method. >- if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:didSameDocumentNavigationForFrame:)]) >- [(NSObject *)loadDelegate webProcessPlugInBrowserContextController:pluginContextController didSameDocumentNavigationForFrame:wrapper(*WebKit::toImpl(frame))]; >+ if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:didSameDocumentNavigationForFrame:)]) >+ [(NSObject *)loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() didSameDocumentNavigationForFrame:wrapper(frame)]; > } > } > >-static void didLayoutForFrame(WKBundlePageRef page, WKBundleFrameRef frame, const void* clientInfo) >-{ >- auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; >- auto loadDelegate = pluginContextController->_loadDelegate.get(); >- >- if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:didLayoutForFrame:)]) >- [loadDelegate webProcessPlugInBrowserContextController:pluginContextController didLayoutForFrame:wrapper(*WebKit::toImpl(frame))]; >-} >- >-static void didReachLayoutMilestone(WKBundlePageRef page, WKLayoutMilestones milestones, WKTypeRef* userData, const void *clientInfo) >+void PageLoaderClient::didLayoutForFrame(WebKit::WebPage&, WebKit::WebFrame& frame) > { >- auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; >- auto loadDelegate = pluginContextController->_loadDelegate.get(); >- >- if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:renderingProgressDidChange:)]) >- [loadDelegate webProcessPlugInBrowserContextController:pluginContextController renderingProgressDidChange:renderingProgressEvents(WebKit::toLayoutMilestones(milestones))]; >+ if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:didLayoutForFrame:)]) >+ [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() didLayoutForFrame:wrapper(frame)]; > } > >-static void didFirstVisuallyNonEmptyLayoutForFrame(WKBundlePageRef page, WKBundleFrameRef frame, WKTypeRef* userData, const void *clientInfo) >+void PageLoaderClient::didReachLayoutMilestone(WebKit::WebPage&, OptionSet<WebCore::LayoutMilestone> milestones, RefPtr<API::Object>&) > { >- auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; >- auto loadDelegate = pluginContextController->_loadDelegate.get(); >- >- if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:didFirstVisuallyNonEmptyLayoutForFrame:)]) >- [loadDelegate webProcessPlugInBrowserContextController:pluginContextController didFirstVisuallyNonEmptyLayoutForFrame:wrapper(*WebKit::toImpl(frame))]; >+ if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:renderingProgressDidChange:)]) >+ [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() renderingProgressDidChange:renderingProgressEvents(milestones)]; > } > >-static void didHandleOnloadEventsForFrame(WKBundlePageRef page, WKBundleFrameRef frame, const void* clientInfo) >+void PageLoaderClient::didFirstVisuallyNonEmptyLayoutForFrame(WebKit::WebPage&, WebKit::WebFrame& frame, RefPtr<API::Object>&) > { >- auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; >- auto loadDelegate = pluginContextController->_loadDelegate.get(); >- >- if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:didHandleOnloadEventsForFrame:)]) >- [loadDelegate webProcessPlugInBrowserContextController:pluginContextController didHandleOnloadEventsForFrame:wrapper(*WebKit::toImpl(frame))]; >+ if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:didFirstVisuallyNonEmptyLayoutForFrame:)]) >+ [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() didFirstVisuallyNonEmptyLayoutForFrame:wrapper(frame)]; > } > >-static WKStringRef userAgentForURL(WKBundleFrameRef frame, WKURLRef url, const void* clientInfo) >+void PageLoaderClient::didHandleOnloadEventsForFrame(WebKit::WebPage&, WebKit::WebFrame& frame) > { >- auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; >- auto loadDelegate = pluginContextController->_loadDelegate.get(); >- >- if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:frame:userAgentForURL:)]) { >- WKWebProcessPlugInFrame *newFrame = wrapper(*WebKit::toImpl(frame)); >- NSString *string = [loadDelegate webProcessPlugInBrowserContextController:pluginContextController frame:newFrame userAgentForURL:wrapper(*WebKit::toImpl(url))]; >- if (!string) >- return nullptr; >- >- return WKStringCreateWithCFString((__bridge CFStringRef)string); >- } >- >- return nullptr; >+ if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:didHandleOnloadEventsForFrame:)]) >+ [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() didHandleOnloadEventsForFrame:wrapper(frame)]; > } > >-static void setUpPageLoaderClient(WKWebProcessPlugInBrowserContextController *contextController, WebKit::WebPage& page) >+WTF::String PageLoaderClient::userAgentForURL(WebKit::WebFrame& frame, const URL& url) const > { >- WKBundlePageLoaderClientV9 client; >- memset(&client, 0, sizeof(client)); >- >- client.base.version = 8; >- client.base.clientInfo = (__bridge void*)contextController; >- client.didStartProvisionalLoadForFrame = didStartProvisionalLoadForFrame; >- client.didReceiveServerRedirectForProvisionalLoadForFrame = didReceiveServerRedirectForProvisionalLoadForFrame; >- client.didCommitLoadForFrame = didCommitLoadForFrame; >- client.didFinishDocumentLoadForFrame = didFinishDocumentLoadForFrame; >- client.didFailProvisionalLoadWithErrorForFrame = didFailProvisionalLoadWithErrorForFrame; >- client.didFailLoadWithErrorForFrame = didFailLoadWithErrorForFrame; >- client.didSameDocumentNavigationForFrame = didSameDocumentNavigationForFrame; >- client.didFinishLoadForFrame = didFinishLoadForFrame; >- client.globalObjectIsAvailableForFrame = globalObjectIsAvailableForFrame; >- client.didRemoveFrameFromHierarchy = didRemoveFrameFromHierarchy; >- client.didHandleOnloadEventsForFrame = didHandleOnloadEventsForFrame; >- client.didFirstVisuallyNonEmptyLayoutForFrame = didFirstVisuallyNonEmptyLayoutForFrame; >- client.userAgentForURL = userAgentForURL; >- >- client.didLayoutForFrame = didLayoutForFrame; >- client.didLayout = didReachLayoutMilestone; >- >- WKBundlePageSetPageLoaderClient(toAPI(&page), &client.base); >+ if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:frame:userAgentForURL:)]) >+ return [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() frame:wrapper(frame) userAgentForURL:url]; >+ return { }; > } > >-static WKURLRequestRef willSendRequestForFrame(WKBundlePageRef, WKBundleFrameRef frame, uint64_t resourceIdentifier, WKURLRequestRef request, WKURLResponseRef redirectResponse, const void* clientInfo) >+void ResourceLoadClient::willSendRequestForFrame(WebKit::WebPage&, WebKit::WebFrame& frame, uint64_t resourceIdentifier, WebCore::ResourceRequest& request, const WebCore::ResourceResponse& redirectResponse) > { >- auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; >- auto loadDelegate = pluginContextController->_loadDelegate.get(); >+ if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:frame:willSendRequestForResource:request:redirectResponse:)]) { >+ RetainPtr<NSURLRequest> originalRequest = request.nsURLRequest(WebCore::HTTPBodyUpdatePolicy::DoNotUpdateHTTPBody); >+ RetainPtr<NSURLRequest> substituteRequest = [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() frame:wrapper(frame) willSendRequestForResource:resourceIdentifier >+ request:originalRequest.get() redirectResponse:redirectResponse.nsURLResponse()]; > >- if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:frame:willSendRequestForResource:request:redirectResponse:)]) { >- NSURLRequest *originalRequest = wrapper(*WebKit::toImpl(request)); >- RetainPtr<NSURLRequest> substituteRequest = [loadDelegate webProcessPlugInBrowserContextController:pluginContextController frame:wrapper(*WebKit::toImpl(frame)) willSendRequestForResource:resourceIdentifier >- request:originalRequest redirectResponse:WebKit::toImpl(redirectResponse)->resourceResponse().nsURLResponse()]; >- >- if (substituteRequest != originalRequest) >- return substituteRequest ? WKURLRequestCreateWithNSURLRequest(substituteRequest.get()) : nullptr; >- } else if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:frame:willSendRequest:redirectResponse:)]) { >- NSURLRequest *originalRequest = wrapper(*WebKit::toImpl(request)); >- RetainPtr<NSURLRequest> substituteRequest = [loadDelegate webProcessPlugInBrowserContextController:pluginContextController frame:wrapper(*WebKit::toImpl(frame)) willSendRequest:originalRequest >- redirectResponse:WebKit::toImpl(redirectResponse)->resourceResponse().nsURLResponse()]; >+ if (substituteRequest != originalRequest) { >+ request = substituteRequest.get(); >+ return; >+ } >+ } else if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:frame:willSendRequest:redirectResponse:)]) { >+ RetainPtr<NSURLRequest> originalRequest = request.nsURLRequest(WebCore::HTTPBodyUpdatePolicy::DoNotUpdateHTTPBody); >+ RetainPtr<NSURLRequest> substituteRequest = [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() frame:wrapper(frame) willSendRequest:originalRequest.get() >+ redirectResponse:redirectResponse.nsURLResponse()]; > >- if (substituteRequest != originalRequest) >- return substituteRequest ? WKURLRequestCreateWithNSURLRequest(substituteRequest.get()) : nullptr; >+ if (substituteRequest != originalRequest) { >+ request = substituteRequest.get(); >+ return; >+ } > } >- >- WKRetain(request); >- return request; > } > >-static void didInitiateLoadForResource(WKBundlePageRef, WKBundleFrameRef frame, uint64_t resourceIdentifier, WKURLRequestRef request, bool pageIsProvisionallyLoading, const void* clientInfo) >+void ResourceLoadClient::didInitiateLoadForResource(WebKit::WebPage&, WebKit::WebFrame& frame, uint64_t resourceIdentifier, const WebCore::ResourceRequest& request, bool pageIsProvisionallyLoading) > { >- auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; >- auto loadDelegate = pluginContextController->_loadDelegate.get(); >- >- if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:frame:didInitiateLoadForResource:request:pageIsProvisionallyLoading:)]) { >- [loadDelegate webProcessPlugInBrowserContextController:pluginContextController frame:wrapper(*WebKit::toImpl(frame)) didInitiateLoadForResource:resourceIdentifier request:wrapper(*WebKit::toImpl(request)) >+ if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:frame:didInitiateLoadForResource:request:pageIsProvisionallyLoading:)]) { >+ [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() frame:wrapper(frame) didInitiateLoadForResource:resourceIdentifier request:request.nsURLRequest(WebCore::HTTPBodyUpdatePolicy::DoNotUpdateHTTPBody) > pageIsProvisionallyLoading:pageIsProvisionallyLoading]; >- } else if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:frame:didInitiateLoadForResource:request:)]) { >- [loadDelegate webProcessPlugInBrowserContextController:pluginContextController frame:wrapper(*WebKit::toImpl(frame)) didInitiateLoadForResource:resourceIdentifier request:wrapper(*WebKit::toImpl(request))]; >+ } else if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:frame:didInitiateLoadForResource:request:)]) { >+ [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() frame:wrapper(frame) didInitiateLoadForResource:resourceIdentifier request:request.nsURLRequest(WebCore::HTTPBodyUpdatePolicy::DoNotUpdateHTTPBody)]; > } > } > >-static void didFinishLoadForResource(WKBundlePageRef, WKBundleFrameRef frame, uint64_t resourceIdentifier, const void* clientInfo) >+void ResourceLoadClient::didFinishLoadForResource(WebKit::WebPage&, WebKit::WebFrame& frame, uint64_t resourceIdentifier) > { >- auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; >- auto loadDelegate = pluginContextController->_loadDelegate.get(); >- >- if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:frame:didFinishLoadForResource:)]) { >- [loadDelegate webProcessPlugInBrowserContextController:pluginContextController frame:wrapper(*WebKit::toImpl(frame)) didFinishLoadForResource:resourceIdentifier]; >+ if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:frame:didFinishLoadForResource:)]) { >+ [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() frame:wrapper(frame) didFinishLoadForResource:resourceIdentifier]; > } > } > >-static void didFailLoadForResource(WKBundlePageRef, WKBundleFrameRef frame, uint64_t resourceIdentifier, WKErrorRef error, const void* clientInfo) >+void ResourceLoadClient::didFailLoadForResource(WebKit::WebPage&, WebKit::WebFrame& frame, uint64_t resourceIdentifier, const WebCore::ResourceError& error) > { >- auto pluginContextController = (__bridge WKWebProcessPlugInBrowserContextController *)clientInfo; >- auto loadDelegate = pluginContextController->_loadDelegate.get(); >- >- if ([loadDelegate respondsToSelector:@selector(webProcessPlugInBrowserContextController:frame:didFailLoadForResource:error:)]) { >- [loadDelegate webProcessPlugInBrowserContextController:pluginContextController frame:wrapper(*WebKit::toImpl(frame)) didFailLoadForResource:resourceIdentifier error:wrapper(*WebKit::toImpl(error))]; >+ if ([loadDelegate() respondsToSelector:@selector(webProcessPlugInBrowserContextController:frame:didFailLoadForResource:error:)]) { >+ [loadDelegate() webProcessPlugInBrowserContextController:pluginContextController() frame:wrapper(frame) didFailLoadForResource:resourceIdentifier error:error]; > } > } > >-static void setUpResourceLoadClient(WKWebProcessPlugInBrowserContextController *contextController, WebKit::WebPage& page) >-{ >- WKBundlePageResourceLoadClientV1 client; >- memset(&client, 0, sizeof(client)); >- >- client.base.version = 1; >- client.base.clientInfo = (__bridge void*) contextController; >- client.willSendRequestForFrame = willSendRequestForFrame; >- client.didInitiateLoadForResource = didInitiateLoadForResource; >- client.didFinishLoadForResource = didFinishLoadForResource; >- client.didFailLoadForResource = didFailLoadForResource; >- >- WKBundlePageSetResourceLoadClient(toAPI(&page), &client.base); >-} >- > - (id <WKWebProcessPlugInLoadDelegate>)loadDelegate > { > return _loadDelegate.getAutoreleased(); >@@ -337,11 +302,11 @@ - (void)setLoadDelegate:(id <WKWebProces > _loadDelegate = loadDelegate; > > if (loadDelegate) { >- setUpPageLoaderClient(self, *_page); >- setUpResourceLoadClient(self, *_page); >+ _page->setInjectedBundlePageLoaderClient(std::make_unique<PageLoaderClient>(self, loadDelegate)); >+ _page->setInjectedBundleResourceLoadClient(std::make_unique<ResourceLoadClient>(self, loadDelegate)); > } else { >- WKBundlePageSetPageLoaderClient(toAPI(_page.get()), nullptr); >- WKBundlePageSetResourceLoadClient(toAPI(_page.get()), nullptr); >+ _page->setInjectedBundlePageLoaderClient(nullptr); >+ _page->setInjectedBundleResourceLoadClient(nullptr); > } > } > >Index: Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp >=================================================================== >--- Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (revision 238771) >+++ Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (working copy) >@@ -457,11 +457,11 @@ void WebFrameLoaderClient::dispatchWillC > notImplemented(); > } > >-void WebFrameLoaderClient::dispatchDidStartProvisionalLoad() >+void WebFrameLoaderClient::dispatchDidStartProvisionalLoad(CompletionHandler<void()>&& completionHandler) > { > WebPage* webPage = m_frame->page(); > if (!webPage) >- return; >+ return completionHandler(); > > #if ENABLE(FULLSCREEN_API) > Element* documentElement = m_frame->coreFrame()->document()->documentElement(); >@@ -473,16 +473,13 @@ void WebFrameLoaderClient::dispatchDidSt > webPage->sandboxExtensionTracker().didStartProvisionalLoad(m_frame); > > WebDocumentLoader& provisionalLoader = static_cast<WebDocumentLoader&>(*m_frame->coreFrame()->loader().provisionalDocumentLoader()); >- auto& url = provisionalLoader.url(); >- RefPtr<API::Object> userData; > > // Notify the bundle client. >- webPage->injectedBundleLoaderClient().didStartProvisionalLoadForFrame(*webPage, *m_frame, userData); >- >- auto& unreachableURL = provisionalLoader.unreachableURL(); >- >- // Notify the UIProcess. >- webPage->send(Messages::WebPageProxy::DidStartProvisionalLoadForFrame(m_frame->frameID(), provisionalLoader.navigationID(), url, unreachableURL, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get()))); >+ webPage->injectedBundleLoaderClient().didStartProvisionalLoadForFrame(*webPage, *m_frame, [completionHandler = WTFMove(completionHandler), webPage = makeRef(*webPage), url = provisionalLoader.url(), unreachableURL = provisionalLoader.unreachableURL(), frameID = m_frame->frameID(), navigationID = provisionalLoader.navigationID()] (RefPtr<API::Object>&& userData) mutable { >+ // Notify the UIProcess. >+ webPage->send(Messages::WebPageProxy::DidStartProvisionalLoadForFrame(frameID, navigationID, url, unreachableURL, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get()))); >+ completionHandler(); >+ }); > } > > static constexpr unsigned maxTitleLength = 1000; // Closest power of 10 above the W3C recommendation for Title length. >Index: Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h >=================================================================== >--- Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h (revision 238771) >+++ Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h (working copy) >@@ -109,7 +109,7 @@ private: > void dispatchDidReplaceStateWithinPage() final; > void dispatchDidPopStateWithinPage() final; > void dispatchWillClose() final; >- void dispatchDidStartProvisionalLoad() final; >+ void dispatchDidStartProvisionalLoad(CompletionHandler<void()>&&) final; > void dispatchDidReceiveTitle(const WebCore::StringWithDirection&) final; > void dispatchDidCommitLoad(std::optional<WebCore::HasInsecureContent>) final; > void dispatchDidFailProvisionalLoad(const WebCore::ResourceError&) final; >Index: Source/WebKitLegacy/mac/ChangeLog >=================================================================== >--- Source/WebKitLegacy/mac/ChangeLog (revision 238771) >+++ Source/WebKitLegacy/mac/ChangeLog (working copy) >@@ -1,3 +1,14 @@ >+2018-11-30 Alex Christensen <achristensen@webkit.org> >+ >+ Add WKWebProcessPlugInLoadDelegate SPI willStartProvisionalLoadForFrame with a completion handler >+ https://bugs.webkit.org/show_bug.cgi?id=192272 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * WebCoreSupport/WebFrameLoaderClient.h: >+ * WebCoreSupport/WebFrameLoaderClient.mm: >+ (WebFrameLoaderClient::dispatchDidStartProvisionalLoad): >+ > 2018-11-30 Alex Christensen <achristensen@webkit.org> > > Move URL from WebCore to WTF >Index: Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.h >=================================================================== >--- Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.h (revision 238771) >+++ Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.h (working copy) >@@ -114,7 +114,7 @@ private: > void dispatchDidPopStateWithinPage() final; > > void dispatchWillClose() final; >- void dispatchDidStartProvisionalLoad() final; >+ void dispatchDidStartProvisionalLoad(CompletionHandler<void()>&&) final; > void dispatchDidReceiveTitle(const WebCore::StringWithDirection&) final; > void dispatchDidCommitLoad(std::optional<WebCore::HasInsecureContent>) final; > void dispatchDidFailProvisionalLoad(const WebCore::ResourceError&) final; >Index: Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm >=================================================================== >--- Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm (revision 238771) >+++ Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm (working copy) >@@ -666,7 +666,7 @@ void WebFrameLoaderClient::dispatchWillC > #endif > } > >-void WebFrameLoaderClient::dispatchDidStartProvisionalLoad() >+void WebFrameLoaderClient::dispatchDidStartProvisionalLoad(CompletionHandler<void()>&& completionHandler) > { > ASSERT(!m_webFrame->_private->provisionalURL); > m_webFrame->_private->provisionalURL = core(m_webFrame.get())->loader().provisionalDocumentLoader()->url().string(); >@@ -683,6 +683,7 @@ void WebFrameLoaderClient::dispatchDidSt > WebFrameLoadDelegateImplementationCache* implementations = WebViewGetFrameLoadDelegateImplementations(webView); > if (implementations->didStartProvisionalLoadForFrameFunc) > CallFrameLoadDelegate(implementations->didStartProvisionalLoadForFrameFunc, webView, @selector(webView:didStartProvisionalLoadForFrame:), m_webFrame.get()); >+ completionHandler(); > } > > static constexpr unsigned maxTitleLength = 1000; // Closest power of 10 above the W3C recommendation for Title length. >Index: Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.cpp >=================================================================== >--- Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.cpp (revision 238771) >+++ Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.cpp (working copy) >@@ -419,12 +419,13 @@ void WebFrameLoaderClient::dispatchWillC > frameLoadDelegate->willCloseFrame(webView, m_webFrame); > } > >-void WebFrameLoaderClient::dispatchDidStartProvisionalLoad() >+void WebFrameLoaderClient::dispatchDidStartProvisionalLoad(CompletionHandler<void()>&& completionHandler) > { > WebView* webView = m_webFrame->webView(); > COMPtr<IWebFrameLoadDelegate> frameLoadDelegate; > if (SUCCEEDED(webView->frameLoadDelegate(&frameLoadDelegate))) > frameLoadDelegate->didStartProvisionalLoadForFrame(webView, m_webFrame); >+ completionHandler(); > } > > void WebFrameLoaderClient::dispatchDidReceiveTitle(const StringWithDirection& title) >Index: Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.h >=================================================================== >--- Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.h (revision 238774) >+++ Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.h (working copy) >@@ -91,7 +91,7 @@ public: > void dispatchDidReplaceStateWithinPage() override; > void dispatchDidPopStateWithinPage() override; > void dispatchWillClose() override; >- void dispatchDidStartProvisionalLoad() override; >+ void dispatchDidStartProvisionalLoad(CompletionHandler<void()>&&) override; > void dispatchDidReceiveTitle(const WebCore::StringWithDirection&) override; > void dispatchDidCommitLoad(std::optional<WebCore::HasInsecureContent>) override; > void dispatchDidFailProvisionalLoad(const WebCore::ResourceError&) override; >Index: Tools/ChangeLog >=================================================================== >--- Tools/ChangeLog (revision 238771) >+++ Tools/ChangeLog (working copy) >@@ -1,3 +1,14 @@ >+2018-11-30 Alex Christensen <achristensen@webkit.org> >+ >+ Add WKWebProcessPlugInLoadDelegate SPI willStartProvisionalLoadForFrame with a completion handler >+ https://bugs.webkit.org/show_bug.cgi?id=192272 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * TestWebKitAPI/Tests/WebKitCocoa/ParserYieldTokenPlugIn.mm: >+ (-[ParserYieldTokenPlugIn webProcessPlugInBrowserContextController:willStartProvisionalLoadForFrame:completionHandler:]): >+ (-[ParserYieldTokenPlugIn webProcessPlugInBrowserContextController:didCommitLoadForFrame:]): >+ > 2018-11-30 Alex Christensen <achristensen@webkit.org> > > Move URL from WebCore to WTF >Index: Tools/TestWebKitAPI/Tests/WebKitCocoa/ParserYieldTokenPlugIn.mm >=================================================================== >--- Tools/TestWebKitAPI/Tests/WebKitCocoa/ParserYieldTokenPlugIn.mm (revision 238771) >+++ Tools/TestWebKitAPI/Tests/WebKitCocoa/ParserYieldTokenPlugIn.mm (working copy) >@@ -37,6 +37,8 @@ > #import <WebKit/_WKRemoteObjectRegistry.h> > #import <wtf/RetainPtr.h> > >+static bool willStartProvisionalLoadForFrameCalled = false; >+ > @interface ParserYieldTokenPlugIn : NSObject <WKWebProcessPlugIn, WKWebProcessPlugInLoadDelegate, ParserYieldTokenTestBundle> > @end > >@@ -64,8 +66,16 @@ - (void)releaseDocumentParserToken > --_numberOfTokensToTakeAfterComittingLoad; > } > >+- (void)webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController*)controller willStartProvisionalLoadForFrame:(WKWebProcessPlugInFrame *)frame completionHandler:(void(^)(void))completionHandler >+{ >+ willStartProvisionalLoadForFrameCalled = true; >+ completionHandler(); >+} >+ > - (void)webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController *)controller didCommitLoadForFrame:(WKWebProcessPlugInFrame *)frame > { >+ ASSERT(willStartProvisionalLoadForFrameCalled); >+ > _loadCommitted = YES; > while (_numberOfTokensToTakeAfterComittingLoad) { > [self takeDocumentParserTokenAfterCommittingLoad];
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 192272
:
356279
|
356287
|
356294
|
360758