Source/WebCore:
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Mar 2020 17:56:08 +0000 (17:56 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 12 Mar 2020 17:56:08 +0000 (17:56 +0000)
FrameLoader should own its FrameLoaderClient
https://bugs.webkit.org/show_bug.cgi?id=208918

Reviewed by Geoffrey Garen.

Update Frame/FrameLoader constructors to get a UniqueRef<FrameLoaderClient>.
This makes the lifetime management much clearer and allows some WebKit1/WebKit2 clean-up.

Covered by existing tests.

* loader/EmptyClients.cpp:
(WebCore::pageConfigurationWithEmptyClients):
* loader/EmptyFrameLoaderClient.h:
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::FrameLoader):
(WebCore::FrameLoader::~FrameLoader):
(WebCore::FrameLoader::init):
(WebCore::FrameLoader::initForSynthesizedDocument):
(WebCore::FrameLoader::didExplicitOpen):
(WebCore::FrameLoader::receivedFirstData):
(WebCore::FrameLoader::finishedParsing):
(WebCore::FrameLoader::loadArchive):
(WebCore::FrameLoader::setOpener):
(WebCore::FrameLoader::provisionalLoadStarted):
(WebCore::FrameLoader::loadInSameDocument):
(WebCore::FrameLoader::prepareForLoadStart):
(WebCore::FrameLoader::setupForReplace):
(WebCore::FrameLoader::load):
(WebCore::FrameLoader::loadWithNavigationAction):
(WebCore::FrameLoader::loadWithDocumentLoader):
(WebCore::FrameLoader::willLoadMediaElementURL):
(WebCore::FrameLoader::reloadWithOverrideEncoding):
(WebCore::FrameLoader::reload):
(WebCore::FrameLoader::setDocumentLoader):
(WebCore::FrameLoader::commitProvisionalLoad):
(WebCore::FrameLoader::transitionToCommitted):
(WebCore::FrameLoader::clientRedirectCancelledOrFinished):
(WebCore::FrameLoader::clientRedirected):
(WebCore::FrameLoader::closeOldDataSources):
(WebCore::FrameLoader::willChangeTitle):
(WebCore::FrameLoader::dispatchDidFailProvisionalLoad):
(WebCore::FrameLoader::checkLoadCompleteForThisFrame):
(WebCore::FrameLoader::didReachLayoutMilestone):
(WebCore::FrameLoader::didReachVisuallyNonEmptyState):
(WebCore::FrameLoader::frameLoadCompleted):
(WebCore::FrameLoader::checkLoadComplete):
(WebCore::FrameLoader::userAgent const):
(WebCore::FrameLoader::dispatchOnloadEvents):
(WebCore::FrameLoader::detachViewsAndDocumentLoader):
(WebCore::FrameLoader::receivedMainResourceError):
(WebCore::FrameLoader::continueLoadAfterNavigationPolicy):
(WebCore::FrameLoader::continueLoadAfterNewWindowPolicy):
(WebCore::FrameLoader::loadedResourceFromMemoryCache):
(WebCore::FrameLoader::loadDifferentDocumentItem):
(WebCore::FrameLoader::cancelledError const):
(WebCore::FrameLoader::blockedByContentBlockerError const):
(WebCore::FrameLoader::blockedError const):
(WebCore::FrameLoader::blockedByContentFilterError const):
(WebCore::FrameLoader::connectionProperties):
(WebCore::FrameLoader::dispatchDidClearWindowObjectInWorld):
(WebCore::FrameLoader::dispatchGlobalObjectAvailableInAllWorlds):
(WebCore::FrameLoader::didChangeTitle):
(WebCore::FrameLoader::dispatchDidCommitLoad):
(WebCore::FrameLoader::tellClientAboutPastMemoryCacheLoads):
(WebCore::FrameLoader::completePageTransitionIfNeeded):
* loader/FrameLoader.h:
* loader/FrameLoaderClient.h:
* page/Frame.cpp:
(WebCore::Frame::Frame):
(WebCore::Frame::create):
* page/Frame.h:
* page/Page.cpp:
(WebCore::Page::Page):
* page/PageConfiguration.cpp:
(WebCore::PageConfiguration::PageConfiguration):
* page/PageConfiguration.h:
* workers/service/context/SWContextManager.cpp:
* workers/service/context/SWContextManager.h:

Source/WebKit:
FrameLoader should own its FrameLoaderClient
https://bugs.webkit.org/show_bug.cgi?id=208918

Reviewed by Geoffrey Garen.

Pass a UniqueRef to the PageConfiguration.
Update WebFrameLoaderClient according updated FrameLoaderClient interface.

WebFrame no longer needs to ref/unref itself to keep the loader client alive.
Update WebFrame construction to not need a static_cast at initialization of the main frame.

The ownership is now that a WebCore::FrameLoader owns a FrameLoaderClient who owns a WebFrame.

* WebProcess/Network/WebLoaderStrategy.cpp:
(WebKit::WebLoaderStrategy::tryLoadingUsingURLSchemeHandler):
(WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess):
(WebKit::WebLoaderStrategy::tryLoadingSynchronouslyUsingURLSchemeHandler):
(WebKit::WebLoaderStrategy::loadResourceSynchronously):
(WebKit::WebLoaderStrategy::startPingLoad):
(WebKit::WebLoaderStrategy::preconnectTo):
* WebProcess/Storage/WebSWContextManagerConnection.cpp:
(WebKit::WebSWContextManagerConnection::installServiceWorker):
* WebProcess/Storage/WebSWContextManagerConnection.h:
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::WebFrameLoaderClient):
(WebKit::WebFrameLoaderClient::~WebFrameLoaderClient):
(WebKit::WebFrameLoaderClient::webPageProxyID const):
(WebKit::WebFrameLoaderClient::pageID const):
(WebKit::WebFrameLoaderClient::frameID const):
(WebKit::WebFrameLoaderClient::detachedFromParent2):
(WebKit::WebFrameLoaderClient::assignIdentifierToInitialRequest):
(WebKit::WebFrameLoaderClient::dispatchWillSendRequest):
(WebKit::WebFrameLoaderClient::shouldUseCredentialStorage):
(WebKit::WebFrameLoaderClient::dispatchDidReceiveResponse):
(WebKit::WebFrameLoaderClient::dispatchDidReceiveContentLength):
(WebKit::WebFrameLoaderClient::dispatchDidFinishLoading):
(WebKit::WebFrameLoaderClient::dispatchDidFailLoading):
(WebKit::WebFrameLoaderClient::dispatchDidDispatchOnloadEvents):
(WebKit::WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad):
(WebKit::WebFrameLoaderClient::dispatchDidCancelClientRedirect):
(WebKit::WebFrameLoaderClient::dispatchWillPerformClientRedirect):
(WebKit::WebFrameLoaderClient::dispatchDidChangeLocationWithinPage):
(WebKit::WebFrameLoaderClient::dispatchDidPushStateWithinPage):
(WebKit::WebFrameLoaderClient::dispatchDidReplaceStateWithinPage):
(WebKit::WebFrameLoaderClient::dispatchDidPopStateWithinPage):
(WebKit::WebFrameLoaderClient::dispatchDidStartProvisionalLoad):
(WebKit::WebFrameLoaderClient::dispatchDidReceiveTitle):
(WebKit::WebFrameLoaderClient::dispatchDidCommitLoad):
(WebKit::WebFrameLoaderClient::dispatchDidFailProvisionalLoad):
(WebKit::WebFrameLoaderClient::dispatchDidFailLoad):
(WebKit::WebFrameLoaderClient::dispatchDidFinishDocumentLoad):
(WebKit::WebFrameLoaderClient::dispatchDidFinishLoad):
(WebKit::WebFrameLoaderClient::dispatchDidReachLayoutMilestone):
(WebKit::WebFrameLoaderClient::dispatchDidLayout):
(WebKit::WebFrameLoaderClient::dispatchShow):
(WebKit::WebFrameLoaderClient::dispatchDecidePolicyForResponse):
(WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction):
(WebKit::WebFrameLoaderClient::applyToDocumentLoader):
(WebKit::WebFrameLoaderClient::allowsContentJavaScriptFromMostRecentNavigation const):
(WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
(WebKit::WebFrameLoaderClient::dispatchUnableToImplementPolicy):
(WebKit::WebFrameLoaderClient::dispatchWillSendSubmitEvent):
(WebKit::WebFrameLoaderClient::dispatchWillSubmitForm):
(WebKit::WebFrameLoaderClient::willReplaceMultipartContent):
(WebKit::WebFrameLoaderClient::didReplaceMultipartContent):
(WebKit::WebFrameLoaderClient::didDisplayInsecureContent):
(WebKit::WebFrameLoaderClient::didRunInsecureContent):
(WebKit::WebFrameLoaderClient::didDetectXSS):
(WebKit::WebFrameLoaderClient::cancelledError const):
(WebKit::WebFrameLoaderClient::blockedError const):
(WebKit::WebFrameLoaderClient::blockedByContentBlockerError const):
(WebKit::WebFrameLoaderClient::cannotShowURLError const):
(WebKit::WebFrameLoaderClient::interruptedForPolicyChangeError const):
(WebKit::WebFrameLoaderClient::blockedByContentFilterError const):
(WebKit::WebFrameLoaderClient::cannotShowMIMETypeError const):
(WebKit::WebFrameLoaderClient::fileDoesNotExistError const):
(WebKit::WebFrameLoaderClient::pluginWillHandleLoadError const):
(WebKit::WebFrameLoaderClient::shouldFallBack const):
(WebKit::WebFrameLoaderClient::restoreViewState):
(WebKit::WebFrameLoaderClient::didFinishLoad):
(WebKit::WebFrameLoaderClient::userAgent const):
(WebKit::WebFrameLoaderClient::createPlugin):
(WebKit::WebFrameLoaderClient::webGLPolicyForURL const):
(WebKit::WebFrameLoaderClient::resolveWebGLPolicyForURL const):
(WebKit::WebFrameLoaderClient::objectContentType):
(WebKit::WebFrameLoaderClient::overrideMediaType const):
(WebKit::WebFrameLoaderClient::dispatchDidClearWindowObjectInWorld):
(WebKit::WebFrameLoaderClient::dispatchGlobalObjectAvailable):
(WebKit::WebFrameLoaderClient::willInjectUserScript):
(WebKit::WebFrameLoaderClient::willCacheResponse const):
(WebKit::WebFrameLoaderClient::createNetworkingContext):
* WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
* WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::initWithCoreMainFrame):
(WebKit::WebFrame::createSubframe):
(WebKit::WebFrame::WebFrame):
(WebKit::WebFrame::frameLoaderClient const):
(WebKit::WebFrame::fromCoreFrame):
(WebKit::WebFrame::didReceivePolicyDecision):
* WebProcess/WebPage/WebFrame.h:
(WebKit::WebFrame::create):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::m_processDisplayName):

Source/WebKitLegacy/mac:
FrameLoader should own its FrameLoaderClient
https://bugs.webkit.org/show_bug.cgi?id=208918

Reviewed by Geoffrey Garen.

Update according new Frame/FrameLoader constructors and FrameLoaderClient interface.

* WebCoreSupport/WebFrameLoaderClient.h:
(WebFrameLoaderClient::setWebFrame):
* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::~WebFrameLoaderClient):
(WebFrameLoaderClient::cancelledError const):
(WebFrameLoaderClient::blockedError const):
(WebFrameLoaderClient::blockedByContentBlockerError const):
(WebFrameLoaderClient::cannotShowURLError const):
(WebFrameLoaderClient::interruptedForPolicyChangeError const):
(WebFrameLoaderClient::blockedByContentFilterError const):
(WebFrameLoaderClient::cannotShowMIMETypeError const):
(WebFrameLoaderClient::fileDoesNotExistError const):
(WebFrameLoaderClient::pluginWillHandleLoadError const):
(WebFrameLoaderClient::shouldFallBack const):
(WebFrameLoaderClient::userAgent const):
* WebView/WebFrame.mm:
(+[WebFrame _createFrameWithPage:frameName:frameView:ownerElement:]):
(+[WebFrame _createMainFrameWithPage:frameName:frameView:]):
(+[WebFrame _createMainFrameWithSimpleHTMLDocumentWithPage:frameView:style:]):
* WebView/WebView.mm:
(-[WebView _commonInitializationWithFrameName:groupName:]):
(-[WebView initSimpleHTMLDocumentWithStyle:frame:preferences:groupName:]):

Source/WebKitLegacy/win:
Make sure a preflight fails if response headers are invalid
https://bugs.webkit.org/show_bug.cgi?id=208924

Reviewed by Geoffrey Garen.

* WebCoreSupport/WebFrameLoaderClient.cpp:
(WebFrameLoaderClient::cancelledError const):
(WebFrameLoaderClient::blockedError const):
(WebFrameLoaderClient::blockedByContentBlockerError const):
(WebFrameLoaderClient::cannotShowURLError const):
(WebFrameLoaderClient::interruptedForPolicyChangeError const):
(WebFrameLoaderClient::cannotShowMIMETypeError const):
(WebFrameLoaderClient::fileDoesNotExistError const):
(WebFrameLoaderClient::pluginWillHandleLoadError const):
(WebFrameLoaderClient::shouldFallBack const):
(WebFrameLoaderClient::userAgent const):
(WebFrameLoaderClient::frameLoaderDestroyed): Deleted.
(WebFrameLoaderClient::cancelledError): Deleted.
(WebFrameLoaderClient::blockedError): Deleted.
(WebFrameLoaderClient::blockedByContentBlockerError): Deleted.
(WebFrameLoaderClient::cannotShowURLError): Deleted.
(WebFrameLoaderClient::interruptedForPolicyChangeError): Deleted.
(WebFrameLoaderClient::cannotShowMIMETypeError): Deleted.
(WebFrameLoaderClient::fileDoesNotExistError): Deleted.
(WebFrameLoaderClient::pluginWillHandleLoadError): Deleted.
(WebFrameLoaderClient::shouldFallBack): Deleted.
(WebFrameLoaderClient::userAgent): Deleted.
* WebCoreSupport/WebFrameLoaderClient.h:
* WebFrame.cpp:
(WebFrame::createSubframeWithOwnerElement):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@258339 268f45cc-cd09-0410-ab3c-d52691b4dbfc

32 files changed:
Source/WebCore/ChangeLog
Source/WebCore/loader/EmptyClients.cpp
Source/WebCore/loader/EmptyFrameLoaderClient.h
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/loader/FrameLoader.h
Source/WebCore/loader/FrameLoaderClient.h
Source/WebCore/page/Frame.cpp
Source/WebCore/page/Frame.h
Source/WebCore/page/Page.cpp
Source/WebCore/page/PageConfiguration.cpp
Source/WebCore/page/PageConfiguration.h
Source/WebCore/workers/service/context/SWContextManager.cpp
Source/WebCore/workers/service/context/SWContextManager.h
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp
Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.cpp
Source/WebKit/WebProcess/Storage/WebSWContextManagerConnection.h
Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.h
Source/WebKit/WebProcess/WebPage/WebFrame.cpp
Source/WebKit/WebProcess/WebPage/WebFrame.h
Source/WebKit/WebProcess/WebPage/WebPage.cpp
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.h
Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm
Source/WebKitLegacy/mac/WebView/WebFrame.mm
Source/WebKitLegacy/mac/WebView/WebView.mm
Source/WebKitLegacy/win/ChangeLog
Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.cpp
Source/WebKitLegacy/win/WebCoreSupport/WebFrameLoaderClient.h
Source/WebKitLegacy/win/WebFrame.cpp
Source/WebKitLegacy/win/WebView.cpp

index 5e219b3..b7c2790 100644 (file)
@@ -1,3 +1,84 @@
+2020-03-12  youenn fablet  <youenn@apple.com>
+
+        FrameLoader should own its FrameLoaderClient
+        https://bugs.webkit.org/show_bug.cgi?id=208918
+
+        Reviewed by Geoffrey Garen.
+
+        Update Frame/FrameLoader constructors to get a UniqueRef<FrameLoaderClient>.
+        This makes the lifetime management much clearer and allows some WebKit1/WebKit2 clean-up.
+
+        Covered by existing tests.
+
+        * loader/EmptyClients.cpp:
+        (WebCore::pageConfigurationWithEmptyClients):
+        * loader/EmptyFrameLoaderClient.h:
+        * loader/FrameLoader.cpp:
+        (WebCore::FrameLoader::FrameLoader):
+        (WebCore::FrameLoader::~FrameLoader):
+        (WebCore::FrameLoader::init):
+        (WebCore::FrameLoader::initForSynthesizedDocument):
+        (WebCore::FrameLoader::didExplicitOpen):
+        (WebCore::FrameLoader::receivedFirstData):
+        (WebCore::FrameLoader::finishedParsing):
+        (WebCore::FrameLoader::loadArchive):
+        (WebCore::FrameLoader::setOpener):
+        (WebCore::FrameLoader::provisionalLoadStarted):
+        (WebCore::FrameLoader::loadInSameDocument):
+        (WebCore::FrameLoader::prepareForLoadStart):
+        (WebCore::FrameLoader::setupForReplace):
+        (WebCore::FrameLoader::load):
+        (WebCore::FrameLoader::loadWithNavigationAction):
+        (WebCore::FrameLoader::loadWithDocumentLoader):
+        (WebCore::FrameLoader::willLoadMediaElementURL):
+        (WebCore::FrameLoader::reloadWithOverrideEncoding):
+        (WebCore::FrameLoader::reload):
+        (WebCore::FrameLoader::setDocumentLoader):
+        (WebCore::FrameLoader::commitProvisionalLoad):
+        (WebCore::FrameLoader::transitionToCommitted):
+        (WebCore::FrameLoader::clientRedirectCancelledOrFinished):
+        (WebCore::FrameLoader::clientRedirected):
+        (WebCore::FrameLoader::closeOldDataSources):
+        (WebCore::FrameLoader::willChangeTitle):
+        (WebCore::FrameLoader::dispatchDidFailProvisionalLoad):
+        (WebCore::FrameLoader::checkLoadCompleteForThisFrame):
+        (WebCore::FrameLoader::didReachLayoutMilestone):
+        (WebCore::FrameLoader::didReachVisuallyNonEmptyState):
+        (WebCore::FrameLoader::frameLoadCompleted):
+        (WebCore::FrameLoader::checkLoadComplete):
+        (WebCore::FrameLoader::userAgent const):
+        (WebCore::FrameLoader::dispatchOnloadEvents):
+        (WebCore::FrameLoader::detachViewsAndDocumentLoader):
+        (WebCore::FrameLoader::receivedMainResourceError):
+        (WebCore::FrameLoader::continueLoadAfterNavigationPolicy):
+        (WebCore::FrameLoader::continueLoadAfterNewWindowPolicy):
+        (WebCore::FrameLoader::loadedResourceFromMemoryCache):
+        (WebCore::FrameLoader::loadDifferentDocumentItem):
+        (WebCore::FrameLoader::cancelledError const):
+        (WebCore::FrameLoader::blockedByContentBlockerError const):
+        (WebCore::FrameLoader::blockedError const):
+        (WebCore::FrameLoader::blockedByContentFilterError const):
+        (WebCore::FrameLoader::connectionProperties):
+        (WebCore::FrameLoader::dispatchDidClearWindowObjectInWorld):
+        (WebCore::FrameLoader::dispatchGlobalObjectAvailableInAllWorlds):
+        (WebCore::FrameLoader::didChangeTitle):
+        (WebCore::FrameLoader::dispatchDidCommitLoad):
+        (WebCore::FrameLoader::tellClientAboutPastMemoryCacheLoads):
+        (WebCore::FrameLoader::completePageTransitionIfNeeded):
+        * loader/FrameLoader.h:
+        * loader/FrameLoaderClient.h:
+        * page/Frame.cpp:
+        (WebCore::Frame::Frame):
+        (WebCore::Frame::create):
+        * page/Frame.h:
+        * page/Page.cpp:
+        (WebCore::Page::Page):
+        * page/PageConfiguration.cpp:
+        (WebCore::PageConfiguration::PageConfiguration):
+        * page/PageConfiguration.h:
+        * workers/service/context/SWContextManager.cpp:
+        * workers/service/context/SWContextManager.h:
+
 2020-03-11  Simon Fraser  <simon.fraser@apple.com>
 
         REGRESSION (r254054): finance.google.com watch list renders initially then disappears for 5+ seconds before reappearing
index 12d52bd..01ff208 100644 (file)
@@ -597,6 +597,7 @@ PageConfiguration pageConfigurationWithEmptyClients(PAL::SessionID sessionID)
         adoptRef(*new EmptyBackForwardClient),
         CookieJar::create(adoptRef(*new EmptyStorageSessionProvider)),
         makeUniqueRef<EmptyProgressTrackerClient>(),
+        makeUniqueRef<EmptyFrameLoaderClient>(),
         makeUniqueRef<EmptyMediaRecorderProvider>()
     };
 
@@ -620,9 +621,6 @@ PageConfiguration pageConfigurationWithEmptyClients(PAL::SessionID sessionID)
     static NeverDestroyed<EmptyInspectorClient> dummyInspectorClient;
     pageConfiguration.inspectorClient = &dummyInspectorClient.get();
 
-    static NeverDestroyed<EmptyFrameLoaderClient> dummyFrameLoaderClient;
-    pageConfiguration.loaderClientForMainFrame = &dummyFrameLoaderClient.get();
-
     pageConfiguration.diagnosticLoggingClient = makeUnique<EmptyDiagnosticLoggingClient>();
 
     pageConfiguration.applicationCacheStorage = ApplicationCacheStorage::create({ }, { });
index 1d9f113..aee77e3 100644 (file)
@@ -37,8 +37,6 @@ namespace WebCore {
 class WEBCORE_EXPORT EmptyFrameLoaderClient : public FrameLoaderClient {
     Ref<DocumentLoader> createDocumentLoader(const ResourceRequest&, const SubstituteData&) override;
 
-    void frameLoaderDestroyed() override { }
-
     Optional<FrameIdentifier> frameID() const override { return WTF::nullopt; }
     Optional<PageIdentifier> pageID() const override { return WTF::nullopt; }
 
@@ -126,20 +124,20 @@ class WEBCORE_EXPORT EmptyFrameLoaderClient : public FrameLoaderClient {
     void committedLoad(DocumentLoader*, const char*, int) final { }
     void finishedLoading(DocumentLoader*) final { }
 
-    ResourceError cancelledError(const ResourceRequest&) final { return { ResourceError::Type::Cancellation }; }
-    ResourceError blockedError(const ResourceRequest&) final { return { }; }
-    ResourceError blockedByContentBlockerError(const ResourceRequest&) final { return { }; }
-    ResourceError cannotShowURLError(const ResourceRequest&) final { return { }; }
-    ResourceError interruptedForPolicyChangeError(const ResourceRequest&) final { return { }; }
+    ResourceError cancelledError(const ResourceRequest&) const final { return { ResourceError::Type::Cancellation }; }
+    ResourceError blockedError(const ResourceRequest&) const final { return { }; }
+    ResourceError blockedByContentBlockerError(const ResourceRequest&) const final { return { }; }
+    ResourceError cannotShowURLError(const ResourceRequest&) const final { return { }; }
+    ResourceError interruptedForPolicyChangeError(const ResourceRequest&) const final { return { }; }
 #if ENABLE(CONTENT_FILTERING)
-    ResourceError blockedByContentFilterError(const ResourceRequest&) final { return { }; }
+    ResourceError blockedByContentFilterError(const ResourceRequest&) const final { return { }; }
 #endif
 
-    ResourceError cannotShowMIMETypeError(const ResourceResponse&) final { return { }; }
-    ResourceError fileDoesNotExistError(const ResourceResponse&) final { return { }; }
-    ResourceError pluginWillHandleLoadError(const ResourceResponse&) final { return { }; }
+    ResourceError cannotShowMIMETypeError(const ResourceResponse&) const final { return { }; }
+    ResourceError fileDoesNotExistError(const ResourceResponse&) const final { return { }; }
+    ResourceError pluginWillHandleLoadError(const ResourceResponse&) const final { return { }; }
 
-    bool shouldFallBack(const ResourceError&) final { return false; }
+    bool shouldFallBack(const ResourceError&) const final { return false; }
 
     bool canHandleRequest(const ResourceRequest&) const final { return false; }
     bool canShowMIMEType(const String&) const final { return false; }
@@ -156,7 +154,7 @@ class WEBCORE_EXPORT EmptyFrameLoaderClient : public FrameLoaderClient {
     void updateCachedDocumentLoader(DocumentLoader&) final { }
     void setTitle(const StringWithDirection&, const URL&) final { }
 
-    String userAgent(const URL&) override { return emptyString(); }
+    String userAgent(const URL&) const override { return emptyString(); }
 
     void savePlatformDataToCachedFrame(CachedFrame*) final { }
     void transitionToCommittedFromCachedFrame(CachedFrame*) final { }
index 0f4a528..f278e51 100644 (file)
@@ -291,9 +291,9 @@ private:
     bool m_inProgress;
 };
 
-FrameLoader::FrameLoader(Frame& frame, FrameLoaderClient& client)
+FrameLoader::FrameLoader(Frame& frame, UniqueRef<FrameLoaderClient>&& client)
     : m_frame(frame)
-    , m_client(client)
+    , m_client(WTFMove(client))
     , m_policyChecker(makeUnique<PolicyChecker>(frame))
     , m_history(makeUnique<HistoryController>(frame))
     , m_notifier(frame)
@@ -325,8 +325,6 @@ FrameLoader::~FrameLoader()
     setOpener(nullptr);
     detachFromAllOpenedFrames();
 
-    m_client.frameLoaderDestroyed();
-
     if (m_networkingContext)
         m_networkingContext->invalidate();
 }
@@ -341,7 +339,7 @@ void FrameLoader::detachFromAllOpenedFrames()
 void FrameLoader::init()
 {
     // This somewhat odd set of steps gives the frame an initial empty document.
-    setPolicyDocumentLoader(m_client.createDocumentLoader(ResourceRequest(URL({ }, emptyString())), SubstituteData()).ptr());
+    setPolicyDocumentLoader(m_client->createDocumentLoader(ResourceRequest(URL({ }, emptyString())), SubstituteData()).ptr());
     setProvisionalDocumentLoader(m_policyDocumentLoader.get());
     m_provisionalDocumentLoader->startLoadingMainResource();
 
@@ -349,7 +347,7 @@ void FrameLoader::init()
     m_frame.document()->cancelParsing();
     m_stateMachine.advanceTo(FrameLoaderStateMachine::DisplayingInitialEmptyDocument);
 
-    m_networkingContext = m_client.createNetworkingContext();
+    m_networkingContext = m_client->createNetworkingContext();
     m_progressTracker = makeUnique<FrameProgressTracker>(m_frame);
 }
 
@@ -358,7 +356,7 @@ void FrameLoader::initForSynthesizedDocument(const URL&)
     // FIXME: We need to initialize the document URL to the specified URL. Currently the URL is empty and hence
     // FrameLoader::checkCompleted() will overwrite the URL of the document to be activeDocumentLoader()->documentURL().
 
-    auto loader = m_client.createDocumentLoader(ResourceRequest(URL({ }, emptyString())), SubstituteData());
+    auto loader = m_client->createDocumentLoader(ResourceRequest(URL({ }, emptyString())), SubstituteData());
     loader->attachToFrame(m_frame);
     loader->setResponse(ResourceResponse(URL(), "text/html"_s, 0, String()));
     loader->setCommitted(true);
@@ -367,14 +365,14 @@ void FrameLoader::initForSynthesizedDocument(const URL&)
     m_stateMachine.advanceTo(FrameLoaderStateMachine::DisplayingInitialEmptyDocument);
     m_stateMachine.advanceTo(FrameLoaderStateMachine::DisplayingInitialEmptyDocumentPostCommit);
     m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad);
-    m_client.transitionToCommittedForNewPage();
+    m_client->transitionToCommittedForNewPage();
 
     m_didCallImplicitClose = true;
     m_isComplete = true;
     m_state = FrameStateComplete;
     m_needsClear = true;
 
-    m_networkingContext = m_client.createNetworkingContext();
+    m_networkingContext = m_client->createNetworkingContext();
     m_progressTracker = makeUnique<FrameProgressTracker>(m_frame);
 }
 
@@ -612,7 +610,7 @@ void FrameLoader::didExplicitOpen()
         m_stateMachine.advanceTo(FrameLoaderStateMachine::DisplayingInitialEmptyDocumentPostCommit);
 
     if (auto* document = m_frame.document())
-        m_client.dispatchDidExplicitOpen(document->url(), document->contentType());
+        m_client->dispatchDidExplicitOpen(document->url(), document->contentType());
     
     // Prevent window.open(url) -- eg window.open("about:blank") -- from blowing away results
     // from a subsequent window.document.open / window.document.write call. 
@@ -718,7 +716,7 @@ void FrameLoader::receivedFirstData()
     auto& documentLoader = *m_documentLoader;
     auto& title = documentLoader.title();
     if (!title.string.isNull())
-        m_client.dispatchDidReceiveTitle(title);
+        m_client->dispatchDidReceiveTitle(title);
 
     ASSERT(m_frame.document());
     auto& document = *m_frame.document();
@@ -803,7 +801,7 @@ void FrameLoader::finishedParsing()
     // Null-checking the FrameView indicates whether or not we're in the destructor.
     RefPtr<Frame> protector = m_frame.view() ? &m_frame : 0;
 
-    m_client.dispatchDidFinishDocumentLoad();
+    m_client->dispatchDidFinishDocumentLoad();
 
     scrollToFragmentWithParentBoundary(m_frame.document()->url());
 
@@ -1008,7 +1006,7 @@ void FrameLoader::loadArchive(Ref<Archive>&& archive)
     
     ResourceRequest request(mainResource->url());
 
-    auto documentLoader = m_client.createDocumentLoader(request, substituteData);
+    auto documentLoader = m_client->createDocumentLoader(request, substituteData);
     documentLoader->setArchive(WTFMove(archive));
     load(documentLoader.get());
 }
@@ -1053,7 +1051,7 @@ Frame* FrameLoader::opener()
 void FrameLoader::setOpener(Frame* opener)
 {
     if (m_opener && !opener)
-        m_client.didDisownOpener();
+        m_client->didDisownOpener();
 
     if (m_opener) {
         // When setOpener is called in ~FrameLoader, opener's m_frameLoader is already cleared.
@@ -1085,7 +1083,7 @@ void FrameLoader::provisionalLoadStarted()
     if (m_stateMachine.firstLayoutDone())
         m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad);
     m_frame.navigationScheduler().cancel(NewLoadInProgress::Yes);
-    m_client.provisionalLoadStarted();
+    m_client->provisionalLoadStarted();
 
     if (m_frame.isMainFrame()) {
         tracePoint(MainResourceLoadDidStartProvisional);
@@ -1182,18 +1180,18 @@ void FrameLoader::loadInSameDocument(const URL& url, SerializedScriptValue* stat
         checkLoadComplete();
     }
 
-    m_client.dispatchDidNavigateWithinPage();
+    m_client->dispatchDidNavigateWithinPage();
 
     m_frame.document()->statePopped(stateObject ? Ref<SerializedScriptValue> { *stateObject } : SerializedScriptValue::nullValue());
-    m_client.dispatchDidPopStateWithinPage();
+    m_client->dispatchDidPopStateWithinPage();
     
     if (hashChange) {
         m_frame.document()->enqueueHashchangeEvent(oldURL, url);
-        m_client.dispatchDidChangeLocationWithinPage();
+        m_client->dispatchDidChangeLocationWithinPage();
     }
     
     // FrameLoaderClient::didFinishLoad() tells the internal load delegate the load finished with no error
-    m_client.didFinishLoad();
+    m_client->didFinishLoad();
 }
 
 bool FrameLoader::isComplete() const
@@ -1226,7 +1224,7 @@ void FrameLoader::prepareForLoadStart()
     FRAMELOADER_RELEASE_LOG_IF_ALLOWED(ResourceLoading, "prepareForLoadStart: Starting frame load");
 
     m_progressTracker->progressStarted();
-    m_client.dispatchDidStartProvisionalLoad();
+    m_client->dispatchDidStartProvisionalLoad();
 
     if (AXObjectCache::accessibilityEnabled()) {
         if (AXObjectCache* cache = m_frame.document()->existingAXObjectCache()) {
@@ -1238,7 +1236,7 @@ void FrameLoader::prepareForLoadStart()
 
 void FrameLoader::setupForReplace()
 {
-    m_client.revertToProvisionalState(m_documentLoader.get());
+    m_client->revertToProvisionalState(m_documentLoader.get());
     setState(FrameStateProvisional);
     m_provisionalDocumentLoader = m_documentLoader;
     FRAMELOADER_RELEASE_LOG_IF_ALLOWED(ResourceLoading, "setupForReplace: Setting provisional document loader (m_provisionalDocumentLoader=%p)", m_provisionalDocumentLoader.get());
@@ -1481,7 +1479,7 @@ void FrameLoader::load(FrameLoadRequest&& request)
     if (!request.hasSubstituteData())
         request.setSubstituteData(defaultSubstituteDataForURL(request.resourceRequest().url()));
 
-    Ref<DocumentLoader> loader = m_client.createDocumentLoader(request.resourceRequest(), request.substituteData());
+    Ref<DocumentLoader> loader = m_client->createDocumentLoader(request.resourceRequest(), request.substituteData());
     loader->setAllowsWebArchiveForMainFrame(request.isRequestFromClientOrUserInput());
     loader->setAllowsDataURLsForMainFrame(request.isRequestFromClientOrUserInput());
     addSameSiteInfoToRequestIfNeeded(loader->request());
@@ -1503,7 +1501,7 @@ void FrameLoader::loadWithNavigationAction(const ResourceRequest& request, Navig
 {
     FRAMELOADER_RELEASE_LOG_IF_ALLOWED(ResourceLoading, "loadWithNavigationAction: frame load started");
 
-    Ref<DocumentLoader> loader = m_client.createDocumentLoader(request, defaultSubstituteDataForURL(request.url()));
+    Ref<DocumentLoader> loader = m_client->createDocumentLoader(request, defaultSubstituteDataForURL(request.url()));
     loader->setDownloadAttribute(downloadAttribute);
     applyShouldOpenExternalURLsPolicyToNewDocumentLoader(m_frame, loader, action.initiatedByMainFrame(), action.shouldOpenExternalURLsPolicy());
 
@@ -1567,7 +1565,7 @@ void FrameLoader::loadWithDocumentLoader(DocumentLoader* loader, FrameLoadType t
 
     CompletionHandlerCallingScope completionHandlerCaller(WTFMove(completionHandler));
 
-    ASSERT(m_client.hasWebView());
+    ASSERT(m_client->hasWebView());
 
     // Unfortunately the view must be non-nil, this is ultimately due
     // to parser requiring a FrameView.  We should fix this dependency.
@@ -1699,7 +1697,7 @@ bool FrameLoader::willLoadMediaElementURL(URL& url, Node& initiatorNode)
     // MobileStore depends on the iOS 4.0 era client delegate method because webView:resource:willSendRequest:redirectResponse:fromDataSource
     // doesn't let them tell when a load request is coming from a media element. See <rdar://problem/8266916> for more details.
     if (IOSApplication::isMobileStore())
-        return m_client.shouldLoadMediaElementURL(url);
+        return m_client->shouldLoadMediaElementURL(url);
 #endif
 
     ResourceRequest request(url);
@@ -1752,7 +1750,7 @@ void FrameLoader::reloadWithOverrideEncoding(const String& encoding)
     // We should ask the user for confirmation in this case.
     request.setCachePolicy(ResourceRequestCachePolicy::ReturnCacheDataElseLoad);
 
-    Ref<DocumentLoader> loader = m_client.createDocumentLoader(request, defaultSubstituteDataForURL(request.url()));
+    Ref<DocumentLoader> loader = m_client->createDocumentLoader(request, defaultSubstituteDataForURL(request.url()));
     applyShouldOpenExternalURLsPolicyToNewDocumentLoader(m_frame, loader, InitiatedByMainFrame::Unknown, m_documentLoader->shouldOpenExternalURLsPolicyToPropagate());
 
     setPolicyDocumentLoader(loader.ptr());
@@ -1782,7 +1780,7 @@ void FrameLoader::reload(OptionSet<ReloadOption> options)
 
     // Create a new document loader for the reload, this will become m_documentLoader eventually,
     // but first it has to be the "policy" document loader, and then the "provisional" document loader.
-    Ref<DocumentLoader> loader = m_client.createDocumentLoader(initialRequest, defaultSubstituteDataForURL(initialRequest.url()));
+    Ref<DocumentLoader> loader = m_client->createDocumentLoader(initialRequest, defaultSubstituteDataForURL(initialRequest.url()));
     loader->setAllowsWebArchiveForMainFrame(m_documentLoader->allowsWebArchiveForMainFrame());
     loader->setAllowsDataURLsForMainFrame(m_documentLoader->allowsDataURLsForMainFrame());
     applyShouldOpenExternalURLsPolicyToNewDocumentLoader(m_frame, loader, InitiatedByMainFrame::Unknown, m_documentLoader->shouldOpenExternalURLsPolicyToPropagate());
@@ -1944,7 +1942,7 @@ void FrameLoader::setDocumentLoader(DocumentLoader* loader)
     ASSERT(loader != m_documentLoader);
     ASSERT(!loader || loader->frameLoader() == this);
 
-    m_client.prepareForDataSourceReplacement();
+    m_client->prepareForDataSourceReplacement();
     detachChildren();
 
     // detachChildren() can trigger this frame's unload event, and therefore
@@ -2044,7 +2042,7 @@ void FrameLoader::commitProvisionalLoad()
         closeOldDataSources();
 
     if (!cachedPage && !m_stateMachine.creatingInitialEmptyDocument())
-        m_client.makeRepresentation(pdl.get());
+        m_client->makeRepresentation(pdl.get());
 
     transitionToCommitted(cachedPage.get());
 
@@ -2093,7 +2091,7 @@ void FrameLoader::commitProvisionalLoad()
 
         auto& title = m_documentLoader->title();
         if (!title.string.isNull())
-            m_client.dispatchDidReceiveTitle(title);
+            m_client->dispatchDidReceiveTitle(title);
 
         // Send remaining notifications for the main resource.
         notifier().sendRemainingDelegateMessages(m_documentLoader.get(), mainResourceIdentifier, mainResourceRequest, ResourceResponse(),
@@ -2117,7 +2115,7 @@ void FrameLoader::commitProvisionalLoad()
 
         // Force a layout to update view size and thereby update scrollbars.
 #if PLATFORM(IOS_FAMILY)
-        if (!m_client.forceLayoutOnRestoreFromBackForwardCache())
+        if (!m_client->forceLayoutOnRestoreFromBackForwardCache())
             m_frame.view()->forceLayout();
 #else
         m_frame.view()->forceLayout();
@@ -2144,7 +2142,7 @@ void FrameLoader::commitProvisionalLoad()
 
 void FrameLoader::transitionToCommitted(CachedPage* cachedPage)
 {
-    ASSERT(m_client.hasWebView());
+    ASSERT(m_client->hasWebView());
     ASSERT(m_state == FrameStateProvisional);
 
     if (m_state != FrameStateProvisional)
@@ -2155,7 +2153,7 @@ void FrameLoader::transitionToCommitted(CachedPage* cachedPage)
             scrollAnimator->cancelAnimations();
     }
 
-    m_client.setCopiesOnScroll();
+    m_client->setCopiesOnScroll();
     history().updateForCommit();
 
     // The call to closeURL() invokes the unload event handler, which can execute arbitrary
@@ -2209,9 +2207,9 @@ void FrameLoader::transitionToCommitted(CachedPage* cachedPage)
                 DocumentLoader* cachedDocumentLoader = cachedPage->documentLoader();
                 ASSERT(cachedDocumentLoader);
                 cachedDocumentLoader->attachToFrame(m_frame);
-                m_client.transitionToCommittedFromCachedFrame(cachedPage->cachedMainFrame());
+                m_client->transitionToCommittedFromCachedFrame(cachedPage->cachedMainFrame());
             } else
-                m_client.transitionToCommittedForNewPage();
+                m_client->transitionToCommittedForNewPage();
         }
         break;
 
@@ -2221,19 +2219,19 @@ void FrameLoader::transitionToCommitted(CachedPage* cachedPage)
     case FrameLoadType::Same:
     case FrameLoadType::Replace:
         history().updateForReload();
-        m_client.transitionToCommittedForNewPage();
+        m_client->transitionToCommittedForNewPage();
         break;
 
     case FrameLoadType::Standard:
         history().updateForStandardLoad();
         if (m_frame.view())
             m_frame.view()->setScrollbarsSuppressed(true);
-        m_client.transitionToCommittedForNewPage();
+        m_client->transitionToCommittedForNewPage();
         break;
 
     case FrameLoadType::RedirectWithLockedBackForwardList:
         history().updateForRedirectWithLockedBackForwardList();
-        m_client.transitionToCommittedForNewPage();
+        m_client->transitionToCommittedForNewPage();
         break;
     }
 
@@ -2254,7 +2252,7 @@ void FrameLoader::clientRedirectCancelledOrFinished(NewLoadInProgress newLoadInP
     // Note that -webView:didCancelClientRedirectForFrame: is called on the frame load delegate even if
     // the redirect succeeded.  We should either rename this API, or add a new method, like
     // -webView:didFinishClientRedirectForFrame:
-    m_client.dispatchDidCancelClientRedirect();
+    m_client->dispatchDidCancelClientRedirect();
 
     if (newLoadInProgress == NewLoadInProgress::No)
         m_quickRedirectComing = false;
@@ -2264,7 +2262,7 @@ void FrameLoader::clientRedirectCancelledOrFinished(NewLoadInProgress newLoadInP
 
 void FrameLoader::clientRedirected(const URL& url, double seconds, WallTime fireDate, LockBackForwardList lockBackForwardList)
 {
-    m_client.dispatchWillPerformClientRedirect(url, seconds, fireDate, lockBackForwardList);
+    m_client->dispatchWillPerformClientRedirect(url, seconds, fireDate, lockBackForwardList);
     
     // Remember that we sent a redirect notification to the frame load delegate so that when we commit
     // the next provisional load, we can send a corresponding -webView:didCancelClientRedirectForFrame:
@@ -2296,9 +2294,9 @@ void FrameLoader::closeOldDataSources()
         child->loader().closeOldDataSources();
     
     if (m_documentLoader)
-        m_client.dispatchWillClose();
+        m_client->dispatchWillClose();
 
-    m_client.setMainFrameDocumentReady(false); // stop giving out the actual DOMDocument to observers
+    m_client->setMainFrameDocumentReady(false); // stop giving out the actual DOMDocument to observers
 }
 
 void FrameLoader::willRestoreFromCachedPage()
@@ -2413,7 +2411,7 @@ bool FrameLoader::subframeIsLoading() const
 
 void FrameLoader::willChangeTitle(DocumentLoader* loader)
 {
-    m_client.willChangeTitle(loader);
+    m_client->willChangeTitle(loader);
 }
 
 FrameLoadType FrameLoader::loadType() const
@@ -2485,7 +2483,7 @@ void FrameLoader::dispatchDidFailProvisionalLoad(DocumentLoader& provisionalDocu
     }
 #endif
 
-    m_client.dispatchDidFailProvisionalLoad(error, willContinueLoading);
+    m_client->dispatchDidFailProvisionalLoad(error, willContinueLoading);
 
 #if ENABLE(CONTENT_FILTERING)
     if (contentFilterWillContinueLoading)
@@ -2497,7 +2495,7 @@ void FrameLoader::dispatchDidFailProvisionalLoad(DocumentLoader& provisionalDocu
 
 void FrameLoader::checkLoadCompleteForThisFrame()
 {
-    ASSERT(m_client.hasWebView());
+    ASSERT(m_client->hasWebView());
 
     // FIXME: Should this check be done in checkLoadComplete instead of here?
     // FIXME: Why does this one check need to be repeated here, and not the many others from checkCompleted?
@@ -2570,7 +2568,7 @@ void FrameLoader::checkLoadCompleteForThisFrame()
             // Maybe there are bugs because of that, or extra work we can skip because
             // the new page is ready.
 
-            m_client.forceLayoutForNonHTML();
+            m_client->forceLayoutForNonHTML();
              
             // If the user had a scroll point, scroll to it, overriding the anchor point if any.
             if (m_frame.page()) {
@@ -2595,7 +2593,7 @@ void FrameLoader::checkLoadCompleteForThisFrame()
             AXObjectCache::AXLoadingEvent loadingEvent;
             if (!error.isNull()) {
                 FRAMELOADER_RELEASE_LOG_IF_ALLOWED(ResourceLoading, "checkLoadCompleteForThisFrame: Finished frame load with error (isTimeout = %d, isCancellation = %d, errorCode = %d)", error.isTimeout(), error.isCancellation(), error.errorCode());
-                m_client.dispatchDidFailLoad(error);
+                m_client->dispatchDidFailLoad(error);
                 loadingEvent = AXObjectCache::AXLoadingFailed;
             } else {
                 FRAMELOADER_RELEASE_LOG_IF_ALLOWED(ResourceLoading, "checkLoadCompleteForThisFrame: Finished frame load");
@@ -2604,13 +2602,13 @@ void FrameLoader::checkLoadCompleteForThisFrame()
                 if (m_frame.settings().dataDetectorTypes() != DataDetectorTypeNone && document) {
                     if (auto* documentElement = document->documentElement()) {
                         RefPtr<Range> documentRange = makeRange(firstPositionInNode(documentElement), lastPositionInNode(documentElement));
-                        m_frame.setDataDetectionResults(DataDetection::detectContentInRange(documentRange, m_frame.settings().dataDetectorTypes(), m_client.dataDetectionContext()));
+                        m_frame.setDataDetectionResults(DataDetection::detectContentInRange(documentRange, m_frame.settings().dataDetectorTypes(), m_client->dataDetectionContext()));
                         if (m_frame.isMainFrame())
-                            m_client.dispatchDidFinishDataDetection(m_frame.dataDetectionResults());
+                            m_client->dispatchDidFinishDataDetection(m_frame.dataDetectionResults());
                     }
                 }
 #endif
-                m_client.dispatchDidFinishLoad();
+                m_client->dispatchDidFinishLoad();
                 loadingEvent = AXObjectCache::AXLoadingFinished;
             }
 
@@ -2668,7 +2666,7 @@ void FrameLoader::didReachLayoutMilestone(OptionSet<LayoutMilestone> milestones)
 {
     ASSERT(m_frame.isMainFrame());
 
-    m_client.dispatchDidReachLayoutMilestone(milestones);
+    m_client->dispatchDidReachLayoutMilestone(milestones);
 }
 
 void FrameLoader::didFirstLayout()
@@ -2690,14 +2688,14 @@ void FrameLoader::didFirstLayout()
 void FrameLoader::didReachVisuallyNonEmptyState()
 {
     ASSERT(m_frame.isMainFrame());
-    m_client.dispatchDidReachVisuallyNonEmptyState();
+    m_client->dispatchDidReachVisuallyNonEmptyState();
 }
 
 void FrameLoader::frameLoadCompleted()
 {
     // Note: Can be called multiple times.
 
-    m_client.frameLoadCompleted();
+    m_client->frameLoadCompleted();
 
     history().updateForFrameLoadCompleted();
 
@@ -2756,7 +2754,7 @@ void FrameLoader::checkLoadComplete()
     if (!m_frame.page())
         return;
 
-    ASSERT(m_client.hasWebView());
+    ASSERT(m_client->hasWebView());
     
     // FIXME: Always traversing the entire frame tree is a bit inefficient, but 
     // is currently needed in order to null out the previous history item for all frames.
@@ -2798,7 +2796,7 @@ String FrameLoader::userAgent(const URL& url) const
     if (!userAgent.isEmpty())
         return userAgent;
 
-    return m_client.userAgent(url);
+    return m_client->userAgent(url);
 }
 
 String FrameLoader::navigatorPlatform() const
@@ -2813,7 +2811,7 @@ String FrameLoader::navigatorPlatform() const
 
 void FrameLoader::dispatchOnloadEvents()
 {
-    m_client.dispatchDidDispatchOnloadEvents();
+    m_client->dispatchDidDispatchOnloadEvents();
 
     if (documentLoader())
         documentLoader()->dispatchOnloadEvents();
@@ -2871,9 +2869,9 @@ void FrameLoader::detachFromParent()
 
 void FrameLoader::detachViewsAndDocumentLoader()
 {
-    m_client.detachedFromParent2();
+    m_client->detachedFromParent2();
     setDocumentLoader(nullptr);
-    m_client.detachedFromParent3();
+    m_client->detachedFromParent3();
 }
     
 void FrameLoader::addExtraFieldsToSubresourceRequest(ResourceRequest& request)
@@ -3172,7 +3170,7 @@ void FrameLoader::receivedMainResourceError(const ResourceError& error)
     // FIXME: Don't want to do this if an entirely new load is going, so should check
     // that both data sources on the frame are either this or nil.
     stop();
-    if (m_client.shouldFallBack(error))
+    if (m_client->shouldFallBack(error))
         handleFallbackContent();
 
     if (m_state == FrameStateProvisional && m_provisionalDocumentLoader) {
@@ -3551,7 +3549,7 @@ void FrameLoader::continueLoadAfterNavigationPolicy(const ResourceRequest& reque
         return;
     }
 
-    m_client.dispatchWillSubmitForm(*formState, WTFMove(completionHandler));
+    m_client->dispatchWillSubmitForm(*formState, WTFMove(completionHandler));
 }
 
 void FrameLoader::continueLoadAfterNewWindowPolicy(const ResourceRequest& request,
@@ -3561,7 +3559,7 @@ void FrameLoader::continueLoadAfterNewWindowPolicy(const ResourceRequest& reques
         return;
 
     Ref<Frame> frame(m_frame);
-    RefPtr<Frame> mainFrame = m_client.dispatchCreatePage(action);
+    RefPtr<Frame> mainFrame = m_client->dispatchCreatePage(action);
     if (!mainFrame)
         return;
 
@@ -3573,7 +3571,7 @@ void FrameLoader::continueLoadAfterNewWindowPolicy(const ResourceRequest& reques
         mainFrame->tree().setName(frameName);
 
     mainFrame->page()->setOpenedByDOM();
-    mainFrame->loader().m_client.dispatchShow();
+    mainFrame->loader().m_client->dispatchShow();
     if (openerPolicy == NewFrameOpenerPolicy::Allow) {
         mainFrame->loader().setOpener(frame.ptr());
         mainFrame->document()->setReferrerPolicy(frame->document()->referrerPolicy());
@@ -3624,7 +3622,7 @@ void FrameLoader::loadedResourceFromMemoryCache(CachedResource& resource, Resour
         return;
     }
 
-    if (m_client.dispatchDidLoadResourceFromMemoryCache(m_documentLoader.get(), newRequest, resource.response(), resource.encodedSize())) {
+    if (m_client->dispatchDidLoadResourceFromMemoryCache(m_documentLoader.get(), newRequest, resource.response(), resource.encodedSize())) {
         InspectorInstrumentation::didLoadResourceFromMemoryCache(*page, m_documentLoader.get(), &resource);
         m_documentLoader->didTellClientAboutLoad(resource.url());
         return;
@@ -3776,7 +3774,7 @@ void FrameLoader::loadDifferentDocumentItem(HistoryItem& item, HistoryItem* from
 
     if (CachedPage* cachedPage = BackForwardCache::singleton().get(item, m_frame.page())) {
         auto documentLoader = cachedPage->documentLoader();
-        m_client.updateCachedDocumentLoader(*documentLoader);
+        m_client->updateCachedDocumentLoader(*documentLoader);
 
         auto action = NavigationAction { *m_frame.document(), documentLoader->request(), initiatedByMainFrame, loadType, false };
         action.setTargetBackForwardItem(item);
@@ -3909,19 +3907,19 @@ void FrameLoader::retryAfterFailedCacheOnlyMainResourceLoad()
 
 ResourceError FrameLoader::cancelledError(const ResourceRequest& request) const
 {
-    ResourceError error = m_client.cancelledError(request);
+    ResourceError error = m_client->cancelledError(request);
     error.setType(ResourceError::Type::Cancellation);
     return error;
 }
 
 ResourceError FrameLoader::blockedByContentBlockerError(const ResourceRequest& request) const
 {
-    return m_client.blockedByContentBlockerError(request);
+    return m_client->blockedByContentBlockerError(request);
 }
 
 ResourceError FrameLoader::blockedError(const ResourceRequest& request) const
 {
-    ResourceError error = m_client.blockedError(request);
+    ResourceError error = m_client->blockedError(request);
     error.setType(ResourceError::Type::Cancellation);
     return error;
 }
@@ -3929,7 +3927,7 @@ ResourceError FrameLoader::blockedError(const ResourceRequest& request) const
 #if ENABLE(CONTENT_FILTERING)
 ResourceError FrameLoader::blockedByContentFilterError(const ResourceRequest& request) const
 {
-    ResourceError error = m_client.blockedByContentFilterError(request);
+    ResourceError error = m_client->blockedByContentFilterError(request);
     error.setType(ResourceError::Type::General);
     return error;
 }
@@ -3938,7 +3936,7 @@ ResourceError FrameLoader::blockedByContentFilterError(const ResourceRequest& re
 #if PLATFORM(IOS_FAMILY)
 RetainPtr<CFDictionaryRef> FrameLoader::connectionProperties(ResourceLoader* loader)
 {
-    return m_client.connectionProperties(loader->documentLoader(), loader->identifier());
+    return m_client->connectionProperties(loader->documentLoader(), loader->identifier());
 }
 #endif
 
@@ -3972,7 +3970,7 @@ void FrameLoader::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld& world)
     if (!m_frame.script().canExecuteScripts(NotAboutToExecuteScript) || !m_frame.windowProxy().existingJSWindowProxy(world))
         return;
 
-    m_client.dispatchDidClearWindowObjectInWorld(world);
+    m_client->dispatchDidClearWindowObjectInWorld(world);
 
     if (Page* page = m_frame.page())
         page->inspectorController().didClearWindowObjectInWorld(m_frame, world);
@@ -3985,7 +3983,7 @@ void FrameLoader::dispatchGlobalObjectAvailableInAllWorlds()
     Vector<Ref<DOMWrapperWorld>> worlds;
     ScriptController::getAllWorlds(worlds);
     for (auto& world : worlds)
-        m_client.dispatchGlobalObjectAvailable(world);
+        m_client->dispatchGlobalObjectAvailable(world);
 }
 
 SandboxFlags FrameLoader::effectiveSandboxFlags() const
@@ -4000,15 +3998,15 @@ SandboxFlags FrameLoader::effectiveSandboxFlags() const
 
 void FrameLoader::didChangeTitle(DocumentLoader* loader)
 {
-    m_client.didChangeTitle(loader);
+    m_client->didChangeTitle(loader);
 
     if (loader == m_documentLoader) {
         // Must update the entries in the back-forward list too.
         history().setCurrentItemTitle(loader->title());
         // This must go through the WebFrame because it has the right notion of the current b/f item.
-        m_client.setTitle(loader->title(), loader->urlForHistory());
-        m_client.setMainFrameDocumentReady(true); // update observers with new DOMDocument
-        m_client.dispatchDidReceiveTitle(loader->title());
+        m_client->setTitle(loader->title(), loader->urlForHistory());
+        m_client->setMainFrameDocumentReady(true); // update observers with new DOMDocument
+        m_client->dispatchDidReceiveTitle(loader->title());
     }
 
 #if ENABLE(REMOTE_INSPECTOR)
@@ -4022,7 +4020,7 @@ void FrameLoader::dispatchDidCommitLoad(Optional<HasInsecureContent> initialHasI
     if (m_stateMachine.creatingInitialEmptyDocument())
         return;
 
-    m_client.dispatchDidCommitLoad(initialHasInsecureContent, initialUsedLegacyTLS);
+    m_client->dispatchDidCommitLoad(initialHasInsecureContent, initialUsedLegacyTLS);
 
     if (m_frame.isMainFrame()) {
         m_frame.page()->resetSeenPlugins();
@@ -4059,7 +4057,7 @@ void FrameLoader::tellClientAboutPastMemoryCacheLoads()
             continue;
 
         ResourceRequest request(resource->url());
-        m_client.dispatchDidLoadResourceFromMemoryCache(m_documentLoader.get(), request, resource->response(), resource->encodedSize());
+        m_client->dispatchDidLoadResourceFromMemoryCache(m_documentLoader.get(), request, resource->response(), resource->encodedSize());
     }
 }
 
@@ -4076,7 +4074,7 @@ void FrameLoader::loadProgressingStatusChanged()
 
 void FrameLoader::completePageTransitionIfNeeded()
 {
-    m_client.completePageTransitionIfNeeded();
+    m_client->completePageTransitionIfNeeded();
 }
 
 void FrameLoader::clearTestingOverrides()
index 6a16766..4301bb2 100644 (file)
@@ -52,6 +52,7 @@
 #include <wtf/HashSet.h>
 #include <wtf/OptionSet.h>
 #include <wtf/Optional.h>
+#include <wtf/UniqueRef.h>
 #include <wtf/WallTime.h>
 
 namespace WebCore {
@@ -102,7 +103,7 @@ class FrameLoader final {
     WTF_MAKE_FAST_ALLOCATED;
     WTF_MAKE_NONCOPYABLE(FrameLoader);
 public:
-    FrameLoader(Frame&, FrameLoaderClient&);
+    FrameLoader(Frame&, UniqueRef<FrameLoaderClient>&&);
     ~FrameLoader();
 
     WEBCORE_EXPORT void init();
@@ -227,7 +228,8 @@ public:
     static void addHTTPUpgradeInsecureRequestsIfNeeded(ResourceRequest&);
     static void addSameSiteInfoToRequestIfNeeded(ResourceRequest&, const Document* initiator = nullptr);
 
-    FrameLoaderClient& client() const { return m_client; }
+    const FrameLoaderClient& client() const { return m_client.get(); }
+    FrameLoaderClient& client() { return m_client.get(); }
 
     WEBCORE_EXPORT Optional<PageIdentifier> pageID() const;
     WEBCORE_EXPORT Optional<FrameIdentifier> frameID() const;
@@ -424,7 +426,7 @@ private:
     bool shouldTreatCurrentLoadAsContinuingLoad() const { return m_currentLoadContinuingState != LoadContinuingState::NotContinuing; }
 
     Frame& m_frame;
-    FrameLoaderClient& m_client;
+    UniqueRef<FrameLoaderClient> m_client;
 
     const std::unique_ptr<PolicyChecker> m_policyChecker;
     const std::unique_ptr<HistoryController> m_history;
index 841bb24..aba662d 100644 (file)
@@ -120,8 +120,6 @@ public:
 
     virtual ~FrameLoaderClient() = default;
 
-    virtual void frameLoaderDestroyed() = 0;
-
     virtual bool hasWebView() const = 0; // mainly for assertions
 
     virtual void makeRepresentation(DocumentLoader*) = 0;
@@ -238,20 +236,20 @@ public:
     virtual void didRunInsecureContent(SecurityOrigin&, const URL&) = 0;
     virtual void didDetectXSS(const URL&, bool didBlockEntirePage) = 0;
 
-    virtual ResourceError cancelledError(const ResourceRequest&) = 0;
-    virtual ResourceError blockedError(const ResourceRequest&) = 0;
-    virtual ResourceError blockedByContentBlockerError(const ResourceRequest&) = 0;
-    virtual ResourceError cannotShowURLError(const ResourceRequest&) = 0;
-    virtual ResourceError interruptedForPolicyChangeError(const ResourceRequest&) = 0;
+    virtual ResourceError cancelledError(const ResourceRequest&) const = 0;
+    virtual ResourceError blockedError(const ResourceRequest&) const = 0;
+    virtual ResourceError blockedByContentBlockerError(const ResourceRequest&) const = 0;
+    virtual ResourceError cannotShowURLError(const ResourceRequest&) const = 0;
+    virtual ResourceError interruptedForPolicyChangeError(const ResourceRequest&) const = 0;
 #if ENABLE(CONTENT_FILTERING)
-    virtual ResourceError blockedByContentFilterError(const ResourceRequest&) = 0;
+    virtual ResourceError blockedByContentFilterError(const ResourceRequest&) const = 0;
 #endif
 
-    virtual ResourceError cannotShowMIMETypeError(const ResourceResponse&) = 0;
-    virtual ResourceError fileDoesNotExistError(const ResourceResponse&) = 0;
-    virtual ResourceError pluginWillHandleLoadError(const ResourceResponse&) = 0;
+    virtual ResourceError cannotShowMIMETypeError(const ResourceResponse&) const = 0;
+    virtual ResourceError fileDoesNotExistError(const ResourceResponse&) const = 0;
+    virtual ResourceError pluginWillHandleLoadError(const ResourceResponse&) const = 0;
 
-    virtual bool shouldFallBack(const ResourceError&) = 0;
+    virtual bool shouldFallBack(const ResourceError&) const = 0;
 
     virtual bool canHandleRequest(const ResourceRequest&) const = 0;
     virtual bool canShowMIMEType(const String& MIMEType) const = 0;
@@ -270,7 +268,7 @@ public:
     virtual void updateCachedDocumentLoader(DocumentLoader&) = 0;
     virtual void setTitle(const StringWithDirection&, const URL&) = 0;
 
-    virtual String userAgent(const URL&) = 0;
+    virtual String userAgent(const URL&) const = 0;
 
     virtual String overrideContentSecurityPolicy() const { return String(); }
     
index bc741bc..9b5aa40 100644 (file)
@@ -143,12 +143,12 @@ static inline float parentTextZoomFactor(Frame* frame)
     return parent->textZoomFactor();
 }
 
-Frame::Frame(Page& page, HTMLFrameOwnerElement* ownerElement, FrameLoaderClient& frameLoaderClient)
+Frame::Frame(Page& page, HTMLFrameOwnerElement* ownerElement, UniqueRef<FrameLoaderClient>&& frameLoaderClient)
     : m_mainFrame(ownerElement ? page.mainFrame() : *this)
     , m_page(&page)
     , m_settings(&page.settings())
     , m_treeNode(*this, parentFromOwnerElement(ownerElement))
-    , m_loader(makeUniqueRef<FrameLoader>(*this, frameLoaderClient))
+    , m_loader(makeUniqueRef<FrameLoader>(*this, WTFMove(frameLoaderClient)))
     , m_navigationScheduler(makeUniqueRef<NavigationScheduler>(*this))
     , m_ownerElement(ownerElement)
     , m_script(makeUniqueRef<ScriptController>(*this))
@@ -182,11 +182,10 @@ void Frame::init()
     m_loader->init();
 }
 
-Ref<Frame> Frame::create(Page* page, HTMLFrameOwnerElement* ownerElement, FrameLoaderClient* client)
+Ref<Frame> Frame::create(Page* page, HTMLFrameOwnerElement* ownerElement, UniqueRef<FrameLoaderClient>&& client)
 {
     ASSERT(page);
-    ASSERT(client);
-    return adoptRef(*new Frame(*page, ownerElement, *client));
+    return adoptRef(*new Frame(*page, ownerElement, WTFMove(client)));
 }
 
 Frame::~Frame()
index 9a4cfd9..6fdfa68 100644 (file)
@@ -126,7 +126,7 @@ typedef unsigned LayerTreeFlags;
 // FIXME: Rename Frame to LocalFrame and AbstractFrame to Frame.
 class Frame final : public AbstractFrame {
 public:
-    WEBCORE_EXPORT static Ref<Frame> create(Page*, HTMLFrameOwnerElement*, FrameLoaderClient*);
+    WEBCORE_EXPORT static Ref<Frame> create(Page*, HTMLFrameOwnerElement*, UniqueRef<FrameLoaderClient>&&);
 
     WEBCORE_EXPORT void init();
 #if PLATFORM(IOS_FAMILY)
@@ -307,7 +307,7 @@ public:
 private:
     friend class NavigationDisabler;
 
-    Frame(Page&, HTMLFrameOwnerElement*, FrameLoaderClient&);
+    Frame(Page&, HTMLFrameOwnerElement*, UniqueRef<FrameLoaderClient>&&);
 
     void dropChildren();
 
index a383a1c..bbe0ae5 100644 (file)
@@ -229,7 +229,7 @@ Page::Page(PageConfiguration&& pageConfiguration)
     , m_settings(Settings::create(this))
     , m_progress(makeUnique<ProgressTracker>(WTFMove(pageConfiguration.progressTrackerClient)))
     , m_backForwardController(makeUnique<BackForwardController>(*this, WTFMove(pageConfiguration.backForwardClient)))
-    , m_mainFrame(Frame::create(this, nullptr, pageConfiguration.loaderClientForMainFrame))
+    , m_mainFrame(Frame::create(this, nullptr, WTFMove(pageConfiguration.loaderClientForMainFrame)))
     , m_editorClient(WTFMove(pageConfiguration.editorClient))
     , m_plugInClient(WTFMove(pageConfiguration.plugInClient))
     , m_validationMessageClient(WTFMove(pageConfiguration.validationMessageClient))
index 338f4e7..c971765 100644 (file)
@@ -56,7 +56,7 @@
 
 namespace WebCore {
 
-PageConfiguration::PageConfiguration(PAL::SessionID sessionID, UniqueRef<EditorClient>&& editorClient, Ref<SocketProvider>&& socketProvider, UniqueRef<LibWebRTCProvider>&& libWebRTCProvider, Ref<CacheStorageProvider>&& cacheStorageProvider, Ref<BackForwardClient>&& backForwardClient, Ref<CookieJar>&& cookieJar, UniqueRef<ProgressTrackerClient>&& progressTrackerClient, UniqueRef<MediaRecorderProvider>&& mediaRecorderProvider)
+PageConfiguration::PageConfiguration(PAL::SessionID sessionID, UniqueRef<EditorClient>&& editorClient, Ref<SocketProvider>&& socketProvider, UniqueRef<LibWebRTCProvider>&& libWebRTCProvider, Ref<CacheStorageProvider>&& cacheStorageProvider, Ref<BackForwardClient>&& backForwardClient, Ref<CookieJar>&& cookieJar, UniqueRef<ProgressTrackerClient>&& progressTrackerClient, UniqueRef<FrameLoaderClient>&& loaderClientForMainFrame, UniqueRef<MediaRecorderProvider>&& mediaRecorderProvider)
     : sessionID(sessionID)
     , editorClient(WTFMove(editorClient))
     , socketProvider(WTFMove(socketProvider))
@@ -64,6 +64,7 @@ PageConfiguration::PageConfiguration(PAL::SessionID sessionID, UniqueRef<EditorC
     , progressTrackerClient(WTFMove(progressTrackerClient))
     , backForwardClient(WTFMove(backForwardClient))
     , cookieJar(WTFMove(cookieJar))
+    , loaderClientForMainFrame(WTFMove(loaderClientForMainFrame))
     , cacheStorageProvider(WTFMove(cacheStorageProvider))
     , mediaRecorderProvider(WTFMove(mediaRecorderProvider))
 {
index abd85a1..369f063 100644 (file)
@@ -71,7 +71,7 @@ class SpeechSynthesisClient;
 class PageConfiguration {
     WTF_MAKE_NONCOPYABLE(PageConfiguration); WTF_MAKE_FAST_ALLOCATED;
 public:
-    WEBCORE_EXPORT PageConfiguration(PAL::SessionID, UniqueRef<EditorClient>&&, Ref<SocketProvider>&&, UniqueRef<LibWebRTCProvider>&&, Ref<CacheStorageProvider>&&, Ref<BackForwardClient>&&, Ref<CookieJar>&&, UniqueRef<ProgressTrackerClient>&&, UniqueRef<MediaRecorderProvider>&&);
+    WEBCORE_EXPORT PageConfiguration(PAL::SessionID, UniqueRef<EditorClient>&&, Ref<SocketProvider>&&, UniqueRef<LibWebRTCProvider>&&, Ref<CacheStorageProvider>&&, Ref<BackForwardClient>&&, Ref<CookieJar>&&, UniqueRef<ProgressTrackerClient>&&, UniqueRef<FrameLoaderClient>&&, UniqueRef<MediaRecorderProvider>&&);
     WEBCORE_EXPORT ~PageConfiguration();
     PageConfiguration(PageConfiguration&&);
 
@@ -104,7 +104,7 @@ public:
     Ref<BackForwardClient> backForwardClient;
     Ref<CookieJar> cookieJar;
     std::unique_ptr<ValidationMessageClient> validationMessageClient;
-    FrameLoaderClient* loaderClientForMainFrame { nullptr };
+    UniqueRef<FrameLoaderClient> loaderClientForMainFrame;
     std::unique_ptr<DiagnosticLoggingClient> diagnosticLoggingClient;
     std::unique_ptr<PerformanceLoggingClient> performanceLoggingClient;
 #if ENABLE(WEBGL)
index 19132da..19eedea 100644 (file)
@@ -182,17 +182,6 @@ void SWContextManager::stopAllServiceWorkers()
         stopWorker(serviceWorker, workerTerminationTimeout, [] { });
 }
 
-void SWContextManager::addServiceWorkerFrameLoaderClient(std::unique_ptr<FrameLoaderClient>&& client)
-{
-    m_serviceWorkerFrameLoaderClients.add(WTFMove(client));
-}
-
-void SWContextManager::removeServiceWorkerFrameLoaderClient(FrameLoaderClient& client)
-{
-    ASSERT(m_serviceWorkerFrameLoaderClients.contains(&client));
-    m_serviceWorkerFrameLoaderClients.remove(&client);
-}
-
 } // namespace WebCore
 
 #endif
index c6f2b0a..829b9e4 100644 (file)
@@ -37,7 +37,6 @@
 
 namespace WebCore {
 
-class FrameLoaderClient;
 class SerializedScriptValue;
 class ServiceWorkerGlobalScope;
 
@@ -103,9 +102,6 @@ public:
 
     WEBCORE_EXPORT void stopAllServiceWorkers();
 
-    WEBCORE_EXPORT void addServiceWorkerFrameLoaderClient(std::unique_ptr<FrameLoaderClient>&&);
-    WEBCORE_EXPORT void removeServiceWorkerFrameLoaderClient(FrameLoaderClient&);
-
     static constexpr Seconds workerTerminationTimeout { 10_s };
     static constexpr Seconds syncWorkerTerminationTimeout { 100_ms }; // Only used by layout tests.
 
@@ -130,7 +126,6 @@ private:
         Timer m_timeoutTimer;
     };
     HashMap<ServiceWorkerIdentifier, std::unique_ptr<ServiceWorkerTerminationRequest>> m_pendingServiceWorkerTerminationRequests;
-    HashSet<std::unique_ptr<FrameLoaderClient>> m_serviceWorkerFrameLoaderClients;
 };
 
 } // namespace WebCore
index 38fa8dc..b9770a2 100644 (file)
@@ -1,3 +1,109 @@
+2020-03-12  youenn fablet  <youenn@apple.com>
+
+        FrameLoader should own its FrameLoaderClient
+        https://bugs.webkit.org/show_bug.cgi?id=208918
+
+        Reviewed by Geoffrey Garen.
+
+        Pass a UniqueRef to the PageConfiguration.
+        Update WebFrameLoaderClient according updated FrameLoaderClient interface.
+
+        WebFrame no longer needs to ref/unref itself to keep the loader client alive.
+        Update WebFrame construction to not need a static_cast at initialization of the main frame.
+
+        The ownership is now that a WebCore::FrameLoader owns a FrameLoaderClient who owns a WebFrame.
+
+        * WebProcess/Network/WebLoaderStrategy.cpp:
+        (WebKit::WebLoaderStrategy::tryLoadingUsingURLSchemeHandler):
+        (WebKit::WebLoaderStrategy::scheduleLoadFromNetworkProcess):
+        (WebKit::WebLoaderStrategy::tryLoadingSynchronouslyUsingURLSchemeHandler):
+        (WebKit::WebLoaderStrategy::loadResourceSynchronously):
+        (WebKit::WebLoaderStrategy::startPingLoad):
+        (WebKit::WebLoaderStrategy::preconnectTo):
+        * WebProcess/Storage/WebSWContextManagerConnection.cpp:
+        (WebKit::WebSWContextManagerConnection::installServiceWorker):
+        * WebProcess/Storage/WebSWContextManagerConnection.h:
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebKit::WebFrameLoaderClient::WebFrameLoaderClient):
+        (WebKit::WebFrameLoaderClient::~WebFrameLoaderClient):
+        (WebKit::WebFrameLoaderClient::webPageProxyID const):
+        (WebKit::WebFrameLoaderClient::pageID const):
+        (WebKit::WebFrameLoaderClient::frameID const):
+        (WebKit::WebFrameLoaderClient::detachedFromParent2):
+        (WebKit::WebFrameLoaderClient::assignIdentifierToInitialRequest):
+        (WebKit::WebFrameLoaderClient::dispatchWillSendRequest):
+        (WebKit::WebFrameLoaderClient::shouldUseCredentialStorage):
+        (WebKit::WebFrameLoaderClient::dispatchDidReceiveResponse):
+        (WebKit::WebFrameLoaderClient::dispatchDidReceiveContentLength):
+        (WebKit::WebFrameLoaderClient::dispatchDidFinishLoading):
+        (WebKit::WebFrameLoaderClient::dispatchDidFailLoading):
+        (WebKit::WebFrameLoaderClient::dispatchDidDispatchOnloadEvents):
+        (WebKit::WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad):
+        (WebKit::WebFrameLoaderClient::dispatchDidCancelClientRedirect):
+        (WebKit::WebFrameLoaderClient::dispatchWillPerformClientRedirect):
+        (WebKit::WebFrameLoaderClient::dispatchDidChangeLocationWithinPage):
+        (WebKit::WebFrameLoaderClient::dispatchDidPushStateWithinPage):
+        (WebKit::WebFrameLoaderClient::dispatchDidReplaceStateWithinPage):
+        (WebKit::WebFrameLoaderClient::dispatchDidPopStateWithinPage):
+        (WebKit::WebFrameLoaderClient::dispatchDidStartProvisionalLoad):
+        (WebKit::WebFrameLoaderClient::dispatchDidReceiveTitle):
+        (WebKit::WebFrameLoaderClient::dispatchDidCommitLoad):
+        (WebKit::WebFrameLoaderClient::dispatchDidFailProvisionalLoad):
+        (WebKit::WebFrameLoaderClient::dispatchDidFailLoad):
+        (WebKit::WebFrameLoaderClient::dispatchDidFinishDocumentLoad):
+        (WebKit::WebFrameLoaderClient::dispatchDidFinishLoad):
+        (WebKit::WebFrameLoaderClient::dispatchDidReachLayoutMilestone):
+        (WebKit::WebFrameLoaderClient::dispatchDidLayout):
+        (WebKit::WebFrameLoaderClient::dispatchShow):
+        (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForResponse):
+        (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction):
+        (WebKit::WebFrameLoaderClient::applyToDocumentLoader):
+        (WebKit::WebFrameLoaderClient::allowsContentJavaScriptFromMostRecentNavigation const):
+        (WebKit::WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction):
+        (WebKit::WebFrameLoaderClient::dispatchUnableToImplementPolicy):
+        (WebKit::WebFrameLoaderClient::dispatchWillSendSubmitEvent):
+        (WebKit::WebFrameLoaderClient::dispatchWillSubmitForm):
+        (WebKit::WebFrameLoaderClient::willReplaceMultipartContent):
+        (WebKit::WebFrameLoaderClient::didReplaceMultipartContent):
+        (WebKit::WebFrameLoaderClient::didDisplayInsecureContent):
+        (WebKit::WebFrameLoaderClient::didRunInsecureContent):
+        (WebKit::WebFrameLoaderClient::didDetectXSS):
+        (WebKit::WebFrameLoaderClient::cancelledError const):
+        (WebKit::WebFrameLoaderClient::blockedError const):
+        (WebKit::WebFrameLoaderClient::blockedByContentBlockerError const):
+        (WebKit::WebFrameLoaderClient::cannotShowURLError const):
+        (WebKit::WebFrameLoaderClient::interruptedForPolicyChangeError const):
+        (WebKit::WebFrameLoaderClient::blockedByContentFilterError const):
+        (WebKit::WebFrameLoaderClient::cannotShowMIMETypeError const):
+        (WebKit::WebFrameLoaderClient::fileDoesNotExistError const):
+        (WebKit::WebFrameLoaderClient::pluginWillHandleLoadError const):
+        (WebKit::WebFrameLoaderClient::shouldFallBack const):
+        (WebKit::WebFrameLoaderClient::restoreViewState):
+        (WebKit::WebFrameLoaderClient::didFinishLoad):
+        (WebKit::WebFrameLoaderClient::userAgent const):
+        (WebKit::WebFrameLoaderClient::createPlugin):
+        (WebKit::WebFrameLoaderClient::webGLPolicyForURL const):
+        (WebKit::WebFrameLoaderClient::resolveWebGLPolicyForURL const):
+        (WebKit::WebFrameLoaderClient::objectContentType):
+        (WebKit::WebFrameLoaderClient::overrideMediaType const):
+        (WebKit::WebFrameLoaderClient::dispatchDidClearWindowObjectInWorld):
+        (WebKit::WebFrameLoaderClient::dispatchGlobalObjectAvailable):
+        (WebKit::WebFrameLoaderClient::willInjectUserScript):
+        (WebKit::WebFrameLoaderClient::willCacheResponse const):
+        (WebKit::WebFrameLoaderClient::createNetworkingContext):
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
+        * WebProcess/WebPage/WebFrame.cpp:
+        (WebKit::WebFrame::initWithCoreMainFrame):
+        (WebKit::WebFrame::createSubframe):
+        (WebKit::WebFrame::WebFrame):
+        (WebKit::WebFrame::frameLoaderClient const):
+        (WebKit::WebFrame::fromCoreFrame):
+        (WebKit::WebFrame::didReceivePolicyDecision):
+        * WebProcess/WebPage/WebFrame.h:
+        (WebKit::WebFrame::create):
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::m_processDisplayName):
+
 2020-03-12  Brent Fulgham  <bfulgham@apple.com>
 
         Drop unused LogGlobalDiagnosticMessageWithValue IPC message
index 446eb53..5a369f5 100644 (file)
@@ -243,11 +243,8 @@ bool WebLoaderStrategy::tryLoadingUsingURLSchemeHandler(ResourceLoader& resource
     if (!webFrameLoaderClient)
         return false;
 
-    auto* webFrame = webFrameLoaderClient->webFrame();
-    if (!webFrame)
-        return false;
-
-    auto* webPage = webFrame->page();
+    auto& webFrame = webFrameLoaderClient->webFrame();
+    auto* webPage = webFrame.page();
     if (!webPage)
         return false;
 
@@ -258,7 +255,7 @@ bool WebLoaderStrategy::tryLoadingUsingURLSchemeHandler(ResourceLoader& resource
     LOG(NetworkScheduling, "(WebProcess) WebLoaderStrategy::scheduleLoad, URL '%s' will be handled by a UIProcess URL scheme handler.", resourceLoader.url().string().utf8().data());
     WEBLOADERSTRATEGY_RELEASE_LOG_IF_ALLOWED("tryLoadingUsingURLSchemeHandler: URL will be handled by a UIProcess URL scheme handler");
 
-    handler->startNewTask(resourceLoader, *webFrame);
+    handler->startNewTask(resourceLoader, webFrame);
     return true;
 }
 
@@ -330,7 +327,7 @@ void WebLoaderStrategy::scheduleLoadFromNetworkProcess(ResourceLoader& resourceL
     }
     
     auto* webFrameLoaderClient = frame ? toWebFrameLoaderClient(frame->loader().client()) : nullptr;
-    auto* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : nullptr;
+    auto* webFrame = webFrameLoaderClient ? &webFrameLoaderClient->webFrame() : nullptr;
     auto* webPage = webFrame ? webFrame->page() : nullptr;
     if (webPage)
         loadParameters.isNavigatingToAppBoundDomain = webPage->isNavigatingToAppBoundDomain();
@@ -533,7 +530,7 @@ static bool shouldClearReferrerOnHTTPSToHTTPRedirect(Frame* frame)
 Optional<WebLoaderStrategy::SyncLoadResult> WebLoaderStrategy::tryLoadingSynchronouslyUsingURLSchemeHandler(FrameLoader& frameLoader, ResourceLoadIdentifier identifier, const ResourceRequest& request)
 {
     auto* webFrameLoaderClient = toWebFrameLoaderClient(frameLoader.client());
-    auto* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : nullptr;
+    auto* webFrame = webFrameLoaderClient ? &webFrameLoaderClient->webFrame() : nullptr;
     auto* webPage = webFrame ? webFrame->page() : nullptr;
     if (!webPage)
         return WTF::nullopt;
@@ -553,7 +550,7 @@ Optional<WebLoaderStrategy::SyncLoadResult> WebLoaderStrategy::tryLoadingSynchro
 void WebLoaderStrategy::loadResourceSynchronously(FrameLoader& frameLoader, unsigned long resourceLoadIdentifier, const ResourceRequest& request, ClientCredentialPolicy clientCredentialPolicy,  const FetchOptions& options, const HTTPHeaderMap& originalRequestHeaders, ResourceError& error, ResourceResponse& response, Vector<char>& data)
 {
     auto* webFrameLoaderClient = toWebFrameLoaderClient(frameLoader.client());
-    auto* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : nullptr;
+    auto* webFrame = webFrameLoaderClient ? &webFrameLoaderClient->webFrame() : nullptr;
     auto* webPage = webFrame ? webFrame->page() : nullptr;
     auto* page = webPage ? webPage->corePage() : nullptr;
 
@@ -686,7 +683,7 @@ void WebLoaderStrategy::startPingLoad(Frame& frame, ResourceRequest& request, co
     addParametersShared(&frame, loadParameters);
     
     auto* webFrameLoaderClient = toWebFrameLoaderClient(frame.loader().client());
-    auto* webFrame = webFrameLoaderClient ? webFrameLoaderClient->webFrame() : nullptr;
+    auto* webFrame = webFrameLoaderClient ? &webFrameLoaderClient->webFrame() : nullptr;
     auto* webPage = webFrame ? webFrame->page() : nullptr;
     if (webPage)
         loadParameters.isNavigatingToAppBoundDomain = webPage->isNavigatingToAppBoundDomain();
@@ -718,18 +715,14 @@ void WebLoaderStrategy::preconnectTo(FrameLoader& frameLoader, const URL& url, S
         completionHandler(internalError(url));
         return;
     }
-    auto* webFrame = webFrameLoaderClient->webFrame();
-    if (!webFrame) {
-        completionHandler(internalError(url));
-        return;
-    }
-    auto* webPage = webFrame->page();
+    auto& webFrame = webFrameLoaderClient->webFrame();
+    auto* webPage = webFrame.page();
     if (!webPage) {
         completionHandler(internalError(url));
         return;
     }
 
-    preconnectTo(ResourceRequest { url }, *webPage, *webFrame, storedCredentialsPolicy, WTFMove(completionHandler));
+    preconnectTo(ResourceRequest { url }, *webPage, webFrame, storedCredentialsPolicy, WTFMove(completionHandler));
 }
 
 void WebLoaderStrategy::preconnectTo(WebCore::ResourceRequest&& request, WebPage& webPage, WebFrame& webFrame, WebCore::StoredCredentialsPolicy storedCredentialsPolicy, PreconnectCompletionHandler&& completionHandler)
index bd44fc5..9c0b569 100644 (file)
@@ -73,14 +73,6 @@ using namespace PAL;
 using namespace WebCore;
 
 
-ServiceWorkerFrameLoaderClient& ServiceWorkerFrameLoaderClient::create(WebPageProxyIdentifier webPageProxyID, PageIdentifier pageID, FrameIdentifier frameID, const String& userAgent)
-{
-    auto frameLoaderClient = std::unique_ptr<ServiceWorkerFrameLoaderClient>(new ServiceWorkerFrameLoaderClient(webPageProxyID, pageID, frameID, userAgent));
-    auto& client = *frameLoaderClient;
-    SWContextManager::singleton().addServiceWorkerFrameLoaderClient(WTFMove(frameLoaderClient));
-    return client;
-}
-
 ServiceWorkerFrameLoaderClient::ServiceWorkerFrameLoaderClient(WebPageProxyIdentifier webPageProxyID, PageIdentifier pageID, FrameIdentifier frameID, const String& userAgent)
     : m_webPageProxyID(webPageProxyID)
     , m_pageID(pageID)
@@ -89,11 +81,6 @@ ServiceWorkerFrameLoaderClient::ServiceWorkerFrameLoaderClient(WebPageProxyIdent
 {
 }
 
-void ServiceWorkerFrameLoaderClient::frameLoaderDestroyed()
-{
-    SWContextManager::singleton().removeServiceWorkerFrameLoaderClient(*this);
-}
-
 Ref<DocumentLoader> ServiceWorkerFrameLoaderClient::createDocumentLoader(const ResourceRequest& request, const SubstituteData& substituteData)
 {
     return WebDocumentLoader::create(request, substituteData);
@@ -162,7 +149,7 @@ void WebSWContextManagerConnection::installServiceWorker(const ServiceWorkerCont
     if (effectiveUserAgent.isNull())
         effectiveUserAgent = m_userAgent;
 
-    pageConfiguration.loaderClientForMainFrame = &ServiceWorkerFrameLoaderClient::create(m_webPageProxyID, m_pageID, FrameIdentifier::generate(), effectiveUserAgent);
+    pageConfiguration.loaderClientForMainFrame = makeUniqueRef<ServiceWorkerFrameLoaderClient>(m_webPageProxyID, m_pageID, FrameIdentifier::generate(), effectiveUserAgent);
 
     auto serviceWorkerThreadProxy = ServiceWorkerThreadProxy::create(WTFMove(pageConfiguration), data, WTFMove(effectiveUserAgent), WebProcess::singleton().cacheStorageProvider(), m_storageBlockingPolicy);
     SWContextManager::singleton().registerServiceWorkerThreadForInstall(WTFMove(serviceWorkerThreadProxy));
index ec1e83a..6d8c876 100644 (file)
@@ -117,26 +117,22 @@ private:
 
 class ServiceWorkerFrameLoaderClient final : public WebCore::EmptyFrameLoaderClient {
 public:
-    static ServiceWorkerFrameLoaderClient& create(WebPageProxyIdentifier, WebCore::PageIdentifier, WebCore::FrameIdentifier, const String& userAgent);
+    ServiceWorkerFrameLoaderClient(WebPageProxyIdentifier, WebCore::PageIdentifier, WebCore::FrameIdentifier, const String& userAgent);
 
     WebPageProxyIdentifier webPageProxyID() const { return m_webPageProxyID; }
 
     void setUserAgent(String&& userAgent) { m_userAgent = WTFMove(userAgent); }
 
 private:
-    ServiceWorkerFrameLoaderClient(WebPageProxyIdentifier, WebCore::PageIdentifier, WebCore::FrameIdentifier, const String& userAgent);
-
     Ref<WebCore::DocumentLoader> createDocumentLoader(const WebCore::ResourceRequest&, const WebCore::SubstituteData&) final;
 
-    void frameLoaderDestroyed() final;
-
     Optional<WebCore::PageIdentifier> pageID() const final { return m_pageID; }
     Optional<WebCore::FrameIdentifier> frameID() const final { return m_frameID; }
 
     bool shouldUseCredentialStorage(WebCore::DocumentLoader*, unsigned long) final { return true; }
     bool isServiceWorkerFrameLoaderClient() const final { return true; }
 
-    String userAgent(const URL&) final { return m_userAgent; }
+    String userAgent(const URL&) const final { return m_userAgent; }
 
     WebPageProxyIdentifier m_webPageProxyID;
     WebCore::PageIdentifier m_pageID;
index 77806b2..bb4c609 100644 (file)
@@ -98,9 +98,9 @@
 #include <wtf/ProcessPrivilege.h>
 
 #define PREFIX_PARAMETERS "%p - [webFrame=%p, webFrameID=%" PRIu64 ", webPage=%p, webPageID=%" PRIu64 "] WebFrameLoaderClient::"
-#define WEBFRAME (webFrame())
-#define WEBFRAMEID (WEBFRAME ? WEBFRAME->frameID().toUInt64() : 0)
-#define WEBPAGE (WEBFRAME ? WEBFRAME->page() : nullptr)
+#define WEBFRAME (&webFrame())
+#define WEBFRAMEID (webFrame().frameID().toUInt64())
+#define WEBPAGE (webFrame().page())
 #define WEBPAGEID (WEBPAGE ? WEBPAGE->identifier().toUInt64() : 0)
 
 #define WEBFRAMELOADERCLIENT_RELEASE_LOG(channel, fmt, ...) RELEASE_LOG(channel, PREFIX_PARAMETERS fmt, this, WEBFRAME, WEBFRAMEID, WEBPAGE, WEBPAGEID, ##__VA_ARGS__)
 namespace WebKit {
 using namespace WebCore;
 
-WebFrameLoaderClient::WebFrameLoaderClient()
-    : m_frame(0)
-    , m_hasSentResponseToPluginView(false)
-    , m_didCompletePageTransition(false)
-    , m_frameHasCustomContentProvider(false)
-    , m_frameCameFromBackForwardCache(false)
+WebFrameLoaderClient::WebFrameLoaderClient(Ref<WebFrame>&& frame)
+    : m_frame(WTFMove(frame))
 {
 }
 
 WebFrameLoaderClient::~WebFrameLoaderClient()
 {
+    m_frame->invalidate();
 }
 
 Optional<WebPageProxyIdentifier> WebFrameLoaderClient::webPageProxyID() const
 {
-    if (m_frame && m_frame->page())
+    if (m_frame->page())
         return m_frame->page()->webPageProxyIdentifier();
 
     return WTF::nullopt;
@@ -133,7 +130,7 @@ Optional<WebPageProxyIdentifier> WebFrameLoaderClient::webPageProxyID() const
 
 Optional<PageIdentifier> WebFrameLoaderClient::pageID() const
 {
-    if (m_frame && m_frame->page())
+    if (m_frame->page())
         return m_frame->page()->identifier();
 
     return WTF::nullopt;
@@ -141,10 +138,7 @@ Optional<PageIdentifier> WebFrameLoaderClient::pageID() const
 
 Optional<FrameIdentifier> WebFrameLoaderClient::frameID() const
 {
-    if (m_frame)
-        return m_frame->frameID();
-
-    return WTF::nullopt;
+    return m_frame->frameID();
 }
 
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
@@ -166,14 +160,6 @@ void WebFrameLoaderClient::addLoadedRegistrableDomain(RegistrableDomain&& domain
 
 #endif
 
-void WebFrameLoaderClient::frameLoaderDestroyed()
-{
-    m_frame->invalidate();
-
-    // Balances explicit ref() in WebFrame::create().
-    m_frame->deref();
-}
-
 bool WebFrameLoaderClient::hasHTMLView() const
 {
     return !m_frameHasCustomContentProvider;
@@ -216,7 +202,7 @@ void WebFrameLoaderClient::detachedFromParent2()
     RefPtr<API::Object> userData;
 
     // Notify the bundle client.
-    webPage->injectedBundleLoaderClient().didRemoveFrameFromHierarchy(*webPage, *m_frame, userData);
+    webPage->injectedBundleLoaderClient().didRemoveFrameFromHierarchy(*webPage, m_frame, userData);
 }
 
 void WebFrameLoaderClient::detachedFromParent3()
@@ -234,7 +220,7 @@ void WebFrameLoaderClient::assignIdentifierToInitialRequest(unsigned long identi
     if (FrameLoader* frameLoader = loader ? loader->frameLoader() : nullptr)
         pageIsProvisionallyLoading = frameLoader->provisionalDocumentLoader() == loader;
 
-    webPage->injectedBundleResourceLoadClient().didInitiateLoadForResource(*webPage, *m_frame, identifier, request, pageIsProvisionallyLoading);
+    webPage->injectedBundleResourceLoadClient().didInitiateLoadForResource(*webPage, m_frame, identifier, request, pageIsProvisionallyLoading);
     webPage->addResourceRequest(identifier, request);
 }
 
@@ -247,7 +233,7 @@ void WebFrameLoaderClient::dispatchWillSendRequest(DocumentLoader*, unsigned lon
     // The API can return a completely new request. We should ensure that at least the requester
     // is kept, so that if this is a main resource load it's still considered as such.
     auto requester = request.requester();
-    webPage->injectedBundleResourceLoadClient().willSendRequestForFrame(*webPage, *m_frame, identifier, request, redirectResponse);
+    webPage->injectedBundleResourceLoadClient().willSendRequestForFrame(*webPage, m_frame, identifier, request, redirectResponse);
     if (!request.isNull())
         request.setRequester(requester);
 }
@@ -258,7 +244,7 @@ bool WebFrameLoaderClient::shouldUseCredentialStorage(DocumentLoader*, unsigned
     if (!webPage)
         return true;
 
-    return webPage->injectedBundleResourceLoadClient().shouldUseCredentialStorage(*webPage, *m_frame, identifier);
+    return webPage->injectedBundleResourceLoadClient().shouldUseCredentialStorage(*webPage, m_frame, identifier);
 }
 
 void WebFrameLoaderClient::dispatchDidReceiveAuthenticationChallenge(DocumentLoader*, unsigned long, const AuthenticationChallenge&)
@@ -281,7 +267,7 @@ void WebFrameLoaderClient::dispatchDidReceiveResponse(DocumentLoader*, unsigned
     if (!webPage)
         return;
 
-    webPage->injectedBundleResourceLoadClient().didReceiveResponseForResource(*webPage, *m_frame, identifier, response);
+    webPage->injectedBundleResourceLoadClient().didReceiveResponseForResource(*webPage, m_frame, identifier, response);
 }
 
 void WebFrameLoaderClient::dispatchDidReceiveContentLength(DocumentLoader*, unsigned long identifier, int dataLength)
@@ -290,7 +276,7 @@ void WebFrameLoaderClient::dispatchDidReceiveContentLength(DocumentLoader*, unsi
     if (!webPage)
         return;
 
-    webPage->injectedBundleResourceLoadClient().didReceiveContentLengthForResource(*webPage, *m_frame, identifier, dataLength);
+    webPage->injectedBundleResourceLoadClient().didReceiveContentLengthForResource(*webPage, m_frame, identifier, dataLength);
 }
 
 #if ENABLE(DATA_DETECTION)
@@ -309,7 +295,7 @@ void WebFrameLoaderClient::dispatchDidFinishLoading(DocumentLoader*, unsigned lo
     if (!webPage)
         return;
 
-    webPage->injectedBundleResourceLoadClient().didFinishLoadForResource(*webPage, *m_frame, identifier);
+    webPage->injectedBundleResourceLoadClient().didFinishLoadForResource(*webPage, m_frame, identifier);
     webPage->removeResourceRequest(identifier);
 }
 
@@ -319,7 +305,7 @@ void WebFrameLoaderClient::dispatchDidFailLoading(DocumentLoader*, unsigned long
     if (!webPage)
         return;
 
-    webPage->injectedBundleResourceLoadClient().didFailLoadForResource(*webPage, *m_frame, identifier, error);
+    webPage->injectedBundleResourceLoadClient().didFailLoadForResource(*webPage, m_frame, identifier, error);
     webPage->removeResourceRequest(identifier);
 }
 
@@ -336,7 +322,7 @@ void WebFrameLoaderClient::dispatchDidDispatchOnloadEvents()
         return;
 
     // Notify the bundle client.
-    webPage->injectedBundleLoaderClient().didHandleOnloadEventsForFrame(*webPage, *m_frame);
+    webPage->injectedBundleLoaderClient().didHandleOnloadEventsForFrame(*webPage, m_frame);
 }
 
 void WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad()
@@ -356,7 +342,7 @@ void WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad()
     LOG(Loading, "WebProcess %i - dispatchDidReceiveServerRedirectForProvisionalLoad to request url %s", getCurrentProcessID(), documentLoader->request().url().string().utf8().data());
 
     // Notify the bundle client.
-    webPage->injectedBundleLoaderClient().didReceiveServerRedirectForProvisionalLoadForFrame(*webPage, *m_frame, userData);
+    webPage->injectedBundleLoaderClient().didReceiveServerRedirectForProvisionalLoadForFrame(*webPage, m_frame, userData);
 
     // Notify the UIProcess.
     webPage->send(Messages::WebPageProxy::DidReceiveServerRedirectForProvisionalLoadForFrame(m_frame->frameID(), documentLoader->navigationID(), documentLoader->request(), UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
@@ -379,7 +365,7 @@ void WebFrameLoaderClient::dispatchDidCancelClientRedirect()
         return;
 
     // Notify the bundle client.
-    webPage->injectedBundleLoaderClient().didCancelClientRedirectForFrame(*webPage, *m_frame);
+    webPage->injectedBundleLoaderClient().didCancelClientRedirectForFrame(*webPage, m_frame);
 
     // Notify the UIProcess.
     webPage->send(Messages::WebPageProxy::DidCancelClientRedirectForFrame(m_frame->frameID()));
@@ -392,7 +378,7 @@ void WebFrameLoaderClient::dispatchWillPerformClientRedirect(const URL& url, dou
         return;
 
     // Notify the bundle client.
-    webPage->injectedBundleLoaderClient().willPerformClientRedirectForFrame(*webPage, *m_frame, url, interval, fireDate);
+    webPage->injectedBundleLoaderClient().willPerformClientRedirectForFrame(*webPage, m_frame, url, interval, fireDate);
 
     // Notify the UIProcess.
     webPage->send(Messages::WebPageProxy::WillPerformClientRedirectForFrame(m_frame->frameID(), url.string(), interval, lockBackForwardList));
@@ -409,7 +395,7 @@ void WebFrameLoaderClient::dispatchDidChangeLocationWithinPage()
     auto navigationID = static_cast<WebDocumentLoader&>(*m_frame->coreFrame()->loader().documentLoader()).navigationID();
 
     // Notify the bundle client.
-    webPage->injectedBundleLoaderClient().didSameDocumentNavigationForFrame(*webPage, *m_frame, SameDocumentNavigationAnchorNavigation, userData);
+    webPage->injectedBundleLoaderClient().didSameDocumentNavigationForFrame(*webPage, m_frame, SameDocumentNavigationAnchorNavigation, userData);
 
     // Notify the UIProcess.
     webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), navigationID, SameDocumentNavigationAnchorNavigation, m_frame->coreFrame()->document()->url(), UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
@@ -453,7 +439,7 @@ void WebFrameLoaderClient::dispatchDidPushStateWithinPage()
     auto navigationID = static_cast<WebDocumentLoader&>(*m_frame->coreFrame()->loader().documentLoader()).navigationID();
 
     // Notify the bundle client.
-    webPage->injectedBundleLoaderClient().didSameDocumentNavigationForFrame(*webPage, *m_frame, SameDocumentNavigationSessionStatePush, userData);
+    webPage->injectedBundleLoaderClient().didSameDocumentNavigationForFrame(*webPage, m_frame, SameDocumentNavigationSessionStatePush, userData);
 
     // Notify the UIProcess.
     webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), navigationID, SameDocumentNavigationSessionStatePush, m_frame->coreFrame()->document()->url(), UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
@@ -470,7 +456,7 @@ void WebFrameLoaderClient::dispatchDidReplaceStateWithinPage()
     auto navigationID = static_cast<WebDocumentLoader&>(*m_frame->coreFrame()->loader().documentLoader()).navigationID();
 
     // Notify the bundle client.
-    webPage->injectedBundleLoaderClient().didSameDocumentNavigationForFrame(*webPage, *m_frame, SameDocumentNavigationSessionStateReplace, userData);
+    webPage->injectedBundleLoaderClient().didSameDocumentNavigationForFrame(*webPage, m_frame, SameDocumentNavigationSessionStateReplace, userData);
 
     // Notify the UIProcess.
     webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), navigationID, SameDocumentNavigationSessionStateReplace, m_frame->coreFrame()->document()->url(), UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
@@ -487,7 +473,7 @@ void WebFrameLoaderClient::dispatchDidPopStateWithinPage()
     auto navigationID = static_cast<WebDocumentLoader&>(*m_frame->coreFrame()->loader().documentLoader()).navigationID();
 
     // Notify the bundle client.
-    webPage->injectedBundleLoaderClient().didSameDocumentNavigationForFrame(*webPage, *m_frame, SameDocumentNavigationSessionStatePop, userData);
+    webPage->injectedBundleLoaderClient().didSameDocumentNavigationForFrame(*webPage, m_frame, SameDocumentNavigationSessionStatePop, userData);
 
     // Notify the UIProcess.
     webPage->send(Messages::WebPageProxy::DidSameDocumentNavigationForFrame(m_frame->frameID(), navigationID, SameDocumentNavigationSessionStatePop, m_frame->coreFrame()->document()->url(), UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
@@ -521,14 +507,14 @@ void WebFrameLoaderClient::dispatchDidStartProvisionalLoad()
 #endif
 
     webPage->findController().hideFindUI();
-    webPage->sandboxExtensionTracker().didStartProvisionalLoad(m_frame);
+    webPage->sandboxExtensionTracker().didStartProvisionalLoad(m_frame.ptr());
 
     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);
+    webPage->injectedBundleLoaderClient().didStartProvisionalLoadForFrame(*webPage, m_frame, userData);
 
     auto& unreachableURL = provisionalLoader.unreachableURL();
 
@@ -550,7 +536,7 @@ void WebFrameLoaderClient::dispatchDidReceiveTitle(const StringWithDirection& ti
 
     // Notify the bundle client.
     // FIXME: Use direction of title.
-    webPage->injectedBundleLoaderClient().didReceiveTitleForFrame(*webPage, truncatedTitle.string, *m_frame, userData);
+    webPage->injectedBundleLoaderClient().didReceiveTitleForFrame(*webPage, truncatedTitle.string, m_frame, userData);
 
     // Notify the UIProcess.
     webPage->send(Messages::WebPageProxy::DidReceiveTitleForFrame(m_frame->frameID(), truncatedTitle.string, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
@@ -566,9 +552,9 @@ void WebFrameLoaderClient::dispatchDidCommitLoad(Optional<HasInsecureContent> ha
     RefPtr<API::Object> userData;
 
     // Notify the bundle client.
-    webPage->injectedBundleLoaderClient().didCommitLoadForFrame(*webPage, *m_frame, userData);
+    webPage->injectedBundleLoaderClient().didCommitLoadForFrame(*webPage, m_frame, userData);
 
-    webPage->sandboxExtensionTracker().didCommitProvisionalLoad(m_frame);
+    webPage->sandboxExtensionTracker().didCommitProvisionalLoad(m_frame.ptr());
 
     bool usedLegacyTLS = documentLoader.response().usedLegacyTLS();
     if (!usedLegacyTLS && usedLegacyTLSFromPageCache)
@@ -576,7 +562,7 @@ void WebFrameLoaderClient::dispatchDidCommitLoad(Optional<HasInsecureContent> ha
     
     // Notify the UIProcess.
     webPage->send(Messages::WebPageProxy::DidCommitLoadForFrame(m_frame->frameID(), m_frame->info(), documentLoader.request(), documentLoader.navigationID(), documentLoader.response().mimeType(), m_frameHasCustomContentProvider, static_cast<uint32_t>(m_frame->coreFrame()->loader().loadType()), valueOrCompute(documentLoader.response().certificateInfo(), [] { return CertificateInfo(); }), usedLegacyTLS, m_frame->coreFrame()->document()->isPluginDocument(), hasInsecureContent, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
-    webPage->didCommitLoad(m_frame);
+    webPage->didCommitLoad(m_frame.ptr());
 }
 
 void WebFrameLoaderClient::dispatchDidFailProvisionalLoad(const ResourceError& error, WillContinueLoading willContinueLoading)
@@ -590,9 +576,9 @@ void WebFrameLoaderClient::dispatchDidFailProvisionalLoad(const ResourceError& e
     RefPtr<API::Object> userData;
 
     // Notify the bundle client.
-    webPage->injectedBundleLoaderClient().didFailProvisionalLoadWithErrorForFrame(*webPage, *m_frame, error, userData);
+    webPage->injectedBundleLoaderClient().didFailProvisionalLoadWithErrorForFrame(*webPage, m_frame, error, userData);
 
-    webPage->sandboxExtensionTracker().didFailProvisionalLoad(m_frame);
+    webPage->sandboxExtensionTracker().didFailProvisionalLoad(m_frame.ptr());
 
     // FIXME: This is gross. This is necessary because if the client calls WKBundlePageStopLoading() from within the didFailProvisionalLoadWithErrorForFrame
     // injected bundle client call, that will cause the provisional DocumentLoader to be disconnected from the Frame, and didDistroyNavigation message
@@ -615,7 +601,7 @@ void WebFrameLoaderClient::dispatchDidFailProvisionalLoad(const ResourceError& e
 
     // If we have a load listener, notify it.
     if (WebFrame::LoadListener* loadListener = m_frame->loadListener())
-        loadListener->didFailLoad(m_frame, error.isCancellation());
+        loadListener->didFailLoad(m_frame.ptr(), error.isCancellation());
 }
 
 void WebFrameLoaderClient::dispatchDidFailLoad(const ResourceError& error)
@@ -632,14 +618,14 @@ void WebFrameLoaderClient::dispatchDidFailLoad(const ResourceError& error)
     auto navigationID = documentLoader.navigationID();
 
     // Notify the bundle client.
-    webPage->injectedBundleLoaderClient().didFailLoadWithErrorForFrame(*webPage, *m_frame, error, userData);
+    webPage->injectedBundleLoaderClient().didFailLoadWithErrorForFrame(*webPage, m_frame, error, userData);
 
     // Notify the UIProcess.
     webPage->send(Messages::WebPageProxy::DidFailLoadForFrame(m_frame->frameID(), m_frame->info(), documentLoader.request(), navigationID, error, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
 
     // If we have a load listener, notify it.
     if (WebFrame::LoadListener* loadListener = m_frame->loadListener())
-        loadListener->didFailLoad(m_frame, error.isCancellation());
+        loadListener->didFailLoad(m_frame.ptr(), error.isCancellation());
 }
 
 void WebFrameLoaderClient::dispatchDidFinishDocumentLoad()
@@ -653,12 +639,12 @@ void WebFrameLoaderClient::dispatchDidFinishDocumentLoad()
     auto navigationID = static_cast<WebDocumentLoader&>(*m_frame->coreFrame()->loader().documentLoader()).navigationID();
 
     // Notify the bundle client.
-    webPage->injectedBundleLoaderClient().didFinishDocumentLoadForFrame(*webPage, *m_frame, userData);
+    webPage->injectedBundleLoaderClient().didFinishDocumentLoadForFrame(*webPage, m_frame, userData);
 
     // Notify the UIProcess.
     webPage->send(Messages::WebPageProxy::DidFinishDocumentLoadForFrame(m_frame->frameID(), navigationID, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
 
-    webPage->didFinishDocumentLoad(*m_frame);
+    webPage->didFinishDocumentLoad(m_frame);
 }
 
 void WebFrameLoaderClient::dispatchDidFinishLoad()
@@ -673,16 +659,16 @@ void WebFrameLoaderClient::dispatchDidFinishLoad()
     auto navigationID = documentLoader.navigationID();
 
     // Notify the bundle client.
-    webPage->injectedBundleLoaderClient().didFinishLoadForFrame(*webPage, *m_frame, userData);
+    webPage->injectedBundleLoaderClient().didFinishLoadForFrame(*webPage, m_frame, userData);
 
     // Notify the UIProcess.
     webPage->send(Messages::WebPageProxy::DidFinishLoadForFrame(m_frame->frameID(), m_frame->info(), documentLoader.request(), navigationID, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
 
     // If we have a load listener, notify it.
     if (WebFrame::LoadListener* loadListener = m_frame->loadListener())
-        loadListener->didFinishLoad(m_frame);
+        loadListener->didFinishLoad(m_frame.ptr());
 
-    webPage->didFinishLoad(*m_frame);
+    webPage->didFinishLoad(m_frame);
 }
 
 void WebFrameLoaderClient::completePageTransitionIfNeeded()
@@ -712,12 +698,12 @@ void WebFrameLoaderClient::dispatchDidReachLayoutMilestone(OptionSet<WebCore::La
 
         // FIXME: We should consider removing the old didFirstLayout API since this is doing double duty with the
         // new didLayout API.
-        webPage->injectedBundleLoaderClient().didFirstLayoutForFrame(*webPage, *m_frame, userData);
+        webPage->injectedBundleLoaderClient().didFirstLayoutForFrame(*webPage, m_frame, userData);
         webPage->send(Messages::WebPageProxy::DidFirstLayoutForFrame(m_frame->frameID(), UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
 
 #if USE(COORDINATED_GRAPHICS)
         // Make sure viewport properties are dispatched on the main frame by the time the first layout happens.
-        ASSERT(!webPage->useFixedLayout() || m_frame != m_frame->page()->mainWebFrame() || m_frame->coreFrame()->document()->didDispatchViewportPropertiesChanged());
+        ASSERT(!webPage->useFixedLayout() || m_frame.ptr() != m_frame->page()->mainWebFrame() || m_frame->coreFrame()->document()->didDispatchViewportPropertiesChanged());
 #endif
     }
 
@@ -751,7 +737,7 @@ void WebFrameLoaderClient::dispatchDidReachLayoutMilestone(OptionSet<WebCore::La
         ASSERT(!m_frame->isMainFrame() || webPage->corePage()->settings().suppressesIncrementalRendering() || m_didCompletePageTransition);
         // FIXME: We should consider removing the old didFirstVisuallyNonEmptyLayoutForFrame API since this is doing double duty with the new didLayout API.
         WEBFRAMELOADERCLIENT_RELEASE_LOG(Layout, "dispatchDidReachLayoutMilestone: dispatching DidFirstVisuallyNonEmptyLayoutForFrame");
-        webPage->injectedBundleLoaderClient().didFirstVisuallyNonEmptyLayoutForFrame(*webPage, *m_frame, userData);
+        webPage->injectedBundleLoaderClient().didFirstVisuallyNonEmptyLayoutForFrame(*webPage, m_frame, userData);
         webPage->send(Messages::WebPageProxy::DidFirstVisuallyNonEmptyLayoutForFrame(m_frame->frameID(), UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
     }
 }
@@ -771,7 +757,7 @@ void WebFrameLoaderClient::dispatchDidLayout()
         return;
 
     // Notify the bundle client.
-    webPage->injectedBundleLoaderClient().didLayoutForFrame(*webPage, *m_frame);
+    webPage->injectedBundleLoaderClient().didLayoutForFrame(*webPage, m_frame);
 
     webPage->recomputeShortCircuitHorizontalWheelEventsState();
 
@@ -782,7 +768,7 @@ void WebFrameLoaderClient::dispatchDidLayout()
     // NOTE: Unlike the other layout notifications, this does not notify the
     // the UIProcess for every call.
 
-    if (m_frame == m_frame->page()->mainWebFrame()) {
+    if (m_frame.ptr() == m_frame->page()->mainWebFrame()) {
         // FIXME: Remove at the soonest possible time.
         webPage->send(Messages::WebPageProxy::SetRenderTreeSize(webPage->renderTreeSize()));
         webPage->mainFrameDidLayout();
@@ -807,7 +793,7 @@ Frame* WebFrameLoaderClient::dispatchCreatePage(const NavigationAction& navigati
 
 void WebFrameLoaderClient::dispatchShow()
 {
-    WebPage* webPage = m_frame->page();
+    auto* webPage = m_frame->page();
     if (!webPage)
         return;
 
@@ -816,7 +802,7 @@ void WebFrameLoaderClient::dispatchShow()
 
 void WebFrameLoaderClient::dispatchDecidePolicyForResponse(const ResourceResponse& response, const ResourceRequest& request, WebCore::PolicyCheckIdentifier identifier, const String& downloadAttribute, FramePolicyFunction&& function)
 {
-    WebPage* webPage = m_frame ? m_frame->page() : nullptr;
+    auto* webPage = m_frame->page();
     if (!webPage) {
         WEBFRAMELOADERCLIENT_RELEASE_LOG(Network, "dispatchDecidePolicyForResponse: ignoring because there's no web page");
         function(PolicyAction::Ignore, identifier);
@@ -832,7 +818,7 @@ void WebFrameLoaderClient::dispatchDecidePolicyForResponse(const ResourceRespons
     RefPtr<API::Object> userData;
 
     // Notify the bundle client.
-    WKBundlePagePolicyAction policy = webPage->injectedBundlePolicyClient().decidePolicyForResponse(webPage, m_frame, response, request, userData);
+    WKBundlePagePolicyAction policy = webPage->injectedBundlePolicyClient().decidePolicyForResponse(webPage, m_frame.ptr(), response, request, userData);
     if (policy == WKBundlePagePolicyActionUse) {
         WEBFRAMELOADERCLIENT_RELEASE_LOG(Network, "dispatchDecidePolicyForResponse: continuing because injected bundle says so");
         function(PolicyAction::Use, identifier);
@@ -841,11 +827,11 @@ void WebFrameLoaderClient::dispatchDecidePolicyForResponse(const ResourceRespons
 
     bool canShowResponse = webPage->canShowResponse(response);
 
-    WebCore::Frame* coreFrame = m_frame->coreFrame();
+    auto* coreFrame = m_frame->coreFrame();
     auto* policyDocumentLoader = coreFrame ? coreFrame->loader().provisionalDocumentLoader() : nullptr;
     auto navigationID = policyDocumentLoader ? static_cast<WebDocumentLoader&>(*policyDocumentLoader).navigationID() : 0;
-    
-    Ref<WebFrame> protector(*m_frame);
+
+    auto protector = m_frame.copyRef();
     uint64_t listenerID = m_frame->setUpPolicyListener(identifier, WTFMove(function), WebFrame::ForNavigationAction::No);
     if (!webPage->send(Messages::WebPageProxy::DecidePolicyForResponse(m_frame->frameID(), m_frame->info(), identifier, navigationID, response, request, canShowResponse, downloadAttribute, listenerID, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())))) {
         WEBFRAMELOADERCLIENT_RELEASE_LOG(Network, "dispatchDecidePolicyForResponse: ignoring because WebPageProxy::DecidePolicyForResponse failed");
@@ -856,7 +842,7 @@ void WebFrameLoaderClient::dispatchDecidePolicyForResponse(const ResourceRespons
 void WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction(const NavigationAction& navigationAction, const ResourceRequest& request,
     FormState* formState, const String& frameName, WebCore::PolicyCheckIdentifier identifier, FramePolicyFunction&& function)
 {
-    WebPage* webPage = m_frame ? m_frame->page() : nullptr;
+    auto* webPage = m_frame->page();
     if (!webPage) {
         function(PolicyAction::Ignore, identifier);
         return;
@@ -864,10 +850,10 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction(const Navigati
 
     RefPtr<API::Object> userData;
 
-    auto action = InjectedBundleNavigationAction::create(m_frame, navigationAction, formState);
+    auto action = InjectedBundleNavigationAction::create(m_frame.ptr(), navigationAction, formState);
 
     // Notify the bundle client.
-    WKBundlePagePolicyAction policy = webPage->injectedBundlePolicyClient().decidePolicyForNewWindowAction(webPage, m_frame, action.ptr(), request, frameName, userData);
+    WKBundlePagePolicyAction policy = webPage->injectedBundlePolicyClient().decidePolicyForNewWindowAction(webPage, m_frame.ptr(), action.ptr(), request, frameName, userData);
     if (policy == WKBundlePagePolicyActionUse) {
         function(PolicyAction::Use, identifier);
         return;
@@ -892,8 +878,6 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNewWindowAction(const Navigati
 
 void WebFrameLoaderClient::applyToDocumentLoader(WebsitePoliciesData&& websitePolicies)
 {
-    if (!m_frame)
-        return;
     auto* coreFrame = m_frame->coreFrame();
     if (!coreFrame)
         return;
@@ -910,14 +894,14 @@ void WebFrameLoaderClient::applyToDocumentLoader(WebsitePoliciesData&& websitePo
 
 WebCore::AllowsContentJavaScript WebFrameLoaderClient::allowsContentJavaScriptFromMostRecentNavigation() const
 {
-    WebPage* webPage = m_frame ? m_frame->page() : nullptr;
+    auto* webPage = m_frame->page();
     return webPage ? webPage->allowsContentJavaScriptFromMostRecentNavigation() : WebCore::AllowsContentJavaScript::No;
 }
 
 void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(const NavigationAction& navigationAction, const ResourceRequest& request, const ResourceResponse& redirectResponse,
     FormState* formState, PolicyDecisionMode policyDecisionMode, WebCore::PolicyCheckIdentifier requestIdentifier, FramePolicyFunction&& function)
 {
-    WebPage* webPage = m_frame ? m_frame->page() : nullptr;
+    auto* webPage = m_frame->page();
     if (!webPage) {
         function(PolicyAction::Ignore, requestIdentifier);
         return;
@@ -933,10 +917,10 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(const Navigat
 
     RefPtr<API::Object> userData;
 
-    Ref<InjectedBundleNavigationAction> action = InjectedBundleNavigationAction::create(m_frame, navigationAction, formState);
+    Ref<InjectedBundleNavigationAction> action = InjectedBundleNavigationAction::create(m_frame.ptr(), navigationAction, formState);
 
     // Notify the bundle client.
-    WKBundlePagePolicyAction policy = webPage->injectedBundlePolicyClient().decidePolicyForNavigationAction(webPage, m_frame, action.ptr(), request, userData);
+    WKBundlePagePolicyAction policy = webPage->injectedBundlePolicyClient().decidePolicyForNavigationAction(webPage, m_frame.ptr(), action.ptr(), request, userData);
     if (policy == WKBundlePagePolicyActionUse) {
         function(PolicyAction::Use, requestIdentifier);
         return;
@@ -992,7 +976,7 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(const Navigat
     navigationActionData.lockBackForwardList = navigationAction.lockBackForwardList();
     navigationActionData.adClickAttribution = navigationAction.adClickAttribution();
 
-    WebCore::Frame* coreFrame = m_frame->coreFrame();
+    auto* coreFrame = m_frame->coreFrame();
     if (!coreFrame)
         return function(PolicyAction::Ignore, requestIdentifier);
     WebDocumentLoader* documentLoader = static_cast<WebDocumentLoader*>(coreFrame->loader().policyDocumentLoader());
@@ -1007,7 +991,7 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(const Navigat
     navigationActionData.clientRedirectSourceForHistory = documentLoader->clientRedirectSourceForHistory();
 
     // Notify the UIProcess.
-    Ref<WebFrame> protect(*m_frame);
+    auto protector = makeRef(*coreFrame);
 
     if (policyDecisionMode == PolicyDecisionMode::Synchronous) {
         PolicyDecision policyDecision;
@@ -1040,7 +1024,7 @@ void WebFrameLoaderClient::dispatchUnableToImplementPolicy(const ResourceError&
     RefPtr<API::Object> userData;
 
     // Notify the bundle client.
-    webPage->injectedBundlePolicyClient().unableToImplementPolicy(webPage, m_frame, error, userData);
+    webPage->injectedBundlePolicyClient().unableToImplementPolicy(webPage, m_frame.ptr(), error, userData);
 
     // Notify the UIProcess.
     webPage->send(Messages::WebPageProxy::UnableToImplementPolicy(m_frame->frameID(), error, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
@@ -1058,7 +1042,7 @@ void WebFrameLoaderClient::dispatchWillSendSubmitEvent(Ref<FormState>&& formStat
     auto* sourceFrame = WebFrame::fromCoreFrame(*formState->sourceDocument().frame());
     ASSERT(sourceFrame);
 
-    webPage->injectedBundleFormClient().willSendSubmitEvent(webPage, &form, m_frame, sourceFrame, formState->textFieldValues());
+    webPage->injectedBundleFormClient().willSendSubmitEvent(webPage, &form, m_frame.ptr(), sourceFrame, formState->textFieldValues());
 }
 
 void WebFrameLoaderClient::dispatchWillSubmitForm(FormState& formState, CompletionHandler<void()>&& completionHandler)
@@ -1081,7 +1065,7 @@ void WebFrameLoaderClient::dispatchWillSubmitForm(FormState& formState, Completi
     auto& values = formState.textFieldValues();
 
     RefPtr<API::Object> userData;
-    webPage->injectedBundleFormClient().willSubmitForm(webPage, &form, m_frame, sourceFrame, values, userData);
+    webPage->injectedBundleFormClient().willSubmitForm(webPage, &form, m_frame.ptr(), sourceFrame, values, userData);
 
     uint64_t listenerID = m_frame->setUpWillSubmitFormListener(WTFMove(completionHandler));
 
@@ -1128,7 +1112,7 @@ void WebFrameLoaderClient::willReplaceMultipartContent()
     WebPage* webPage = m_frame->page();
     if (!webPage)
         return;
-    webPage->willReplaceMultipartContent(*m_frame);
+    webPage->willReplaceMultipartContent(m_frame);
 }
 
 void WebFrameLoaderClient::didReplaceMultipartContent()
@@ -1136,7 +1120,7 @@ void WebFrameLoaderClient::didReplaceMultipartContent()
     WebPage* webPage = m_frame->page();
     if (!webPage)
         return;
-    webPage->didReplaceMultipartContent(*m_frame);
+    webPage->didReplaceMultipartContent(m_frame);
 }
 
 void WebFrameLoaderClient::committedLoad(DocumentLoader* loader, const char* data, int length)
@@ -1253,7 +1237,7 @@ void WebFrameLoaderClient::didDisplayInsecureContent()
 
     RefPtr<API::Object> userData;
 
-    webPage->injectedBundleLoaderClient().didDisplayInsecureContentForFrame(*webPage, *m_frame, userData);
+    webPage->injectedBundleLoaderClient().didDisplayInsecureContentForFrame(*webPage, m_frame, userData);
 
     webPage->send(Messages::WebPageProxy::DidDisplayInsecureContentForFrame(m_frame->frameID(), UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
 }
@@ -1266,7 +1250,7 @@ void WebFrameLoaderClient::didRunInsecureContent(SecurityOrigin&, const URL&)
 
     RefPtr<API::Object> userData;
 
-    webPage->injectedBundleLoaderClient().didRunInsecureContentForFrame(*webPage, *m_frame, userData);
+    webPage->injectedBundleLoaderClient().didRunInsecureContentForFrame(*webPage, m_frame, userData);
 
     webPage->send(Messages::WebPageProxy::DidRunInsecureContentForFrame(m_frame->frameID(), UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
 }
@@ -1279,59 +1263,59 @@ void WebFrameLoaderClient::didDetectXSS(const URL&, bool)
 
     RefPtr<API::Object> userData;
 
-    webPage->injectedBundleLoaderClient().didDetectXSSForFrame(*webPage, *m_frame, userData);
+    webPage->injectedBundleLoaderClient().didDetectXSSForFrame(*webPage, m_frame, userData);
 
     webPage->send(Messages::WebPageProxy::DidDetectXSSForFrame(m_frame->frameID(), UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
 }
 
-ResourceError WebFrameLoaderClient::cancelledError(const ResourceRequest& request)
+ResourceError WebFrameLoaderClient::cancelledError(const ResourceRequest& request) const
 {
     return WebKit::cancelledError(request);
 }
 
-ResourceError WebFrameLoaderClient::blockedError(const ResourceRequest& request)
+ResourceError WebFrameLoaderClient::blockedError(const ResourceRequest& request) const
 {
     return WebKit::blockedError(request);
 }
 
-ResourceError WebFrameLoaderClient::blockedByContentBlockerError(const ResourceRequest& request)
+ResourceError WebFrameLoaderClient::blockedByContentBlockerError(const ResourceRequest& request) const
 {
     return WebKit::blockedByContentBlockerError(request);
 }
 
-ResourceError WebFrameLoaderClient::cannotShowURLError(const ResourceRequest& request)
+ResourceError WebFrameLoaderClient::cannotShowURLError(const ResourceRequest& request) const
 {
     return WebKit::cannotShowURLError(request);
 }
 
-ResourceError WebFrameLoaderClient::interruptedForPolicyChangeError(const ResourceRequest& request)
+ResourceError WebFrameLoaderClient::interruptedForPolicyChangeError(const ResourceRequest& request) const
 {
     return WebKit::interruptedForPolicyChangeError(request);
 }
 
 #if ENABLE(CONTENT_FILTERING)
-ResourceError WebFrameLoaderClient::blockedByContentFilterError(const ResourceRequest& request)
+ResourceError WebFrameLoaderClient::blockedByContentFilterError(const ResourceRequest& request) const
 {
     return WebKit::blockedByContentFilterError(request);
 }
 #endif
 
-ResourceError WebFrameLoaderClient::cannotShowMIMETypeError(const ResourceResponse& response)
+ResourceError WebFrameLoaderClient::cannotShowMIMETypeError(const ResourceResponse& response) const
 {
     return WebKit::cannotShowMIMETypeError(response);
 }
 
-ResourceError WebFrameLoaderClient::fileDoesNotExistError(const ResourceResponse& response)
+ResourceError WebFrameLoaderClient::fileDoesNotExistError(const ResourceResponse& response) const
 {
     return WebKit::fileDoesNotExistError(response);
 }
 
-ResourceError WebFrameLoaderClient::pluginWillHandleLoadError(const ResourceResponse& response)
+ResourceError WebFrameLoaderClient::pluginWillHandleLoadError(const ResourceResponse& response) const
 {
     return WebKit::pluginWillHandleLoadError(response);
 }
 
-bool WebFrameLoaderClient::shouldFallBack(const ResourceError& error)
+bool WebFrameLoaderClient::shouldFallBack(const ResourceError& error) const
 {
     static NeverDestroyed<const ResourceError> cancelledError(this->cancelledError(ResourceRequest()));
     static NeverDestroyed<const ResourceError> pluginWillHandleLoadError(this->pluginWillHandleLoadError(ResourceResponse()));
@@ -1413,7 +1397,7 @@ void WebFrameLoaderClient::restoreViewState()
 
     // FIXME: This should not be necessary. WebCore should be correctly invalidating
     // the view on restores from the back/forward cache.
-    if (m_frame->page() && m_frame == m_frame->page()->mainWebFrame())
+    if (m_frame->page() && m_frame.ptr() == m_frame->page()->mainWebFrame())
         m_frame->page()->drawingArea()->setNeedsDisplay();
 #endif
 }
@@ -1434,7 +1418,7 @@ void WebFrameLoaderClient::didFinishLoad()
 {
     // If we have a load listener, notify it.
     if (WebFrame::LoadListener* loadListener = m_frame->loadListener())
-        loadListener->didFinishLoad(m_frame);
+        loadListener->didFinishLoad(m_frame.ptr());
 }
 
 void WebFrameLoaderClient::prepareForDataSourceReplacement()
@@ -1462,7 +1446,7 @@ void WebFrameLoaderClient::setTitle(const StringWithDirection& title, const URL&
     webPage->send(Messages::WebPageProxy::DidUpdateHistoryTitle(title.string, url.string(), m_frame->frameID()));
 }
 
-String WebFrameLoaderClient::userAgent(const URL& url)
+String WebFrameLoaderClient::userAgent(const URL& url) const
 {
     auto* webPage = m_frame->page();
     if (!webPage)
@@ -1635,7 +1619,7 @@ RefPtr<Widget> WebFrameLoaderClient::createPlugin(const IntSize&, HTMLPlugInElem
 #endif
 
 #if ENABLE(NETSCAPE_PLUGIN_API)
-    auto plugin = m_frame->page()->createPlugin(m_frame, &pluginElement, parameters, parameters.mimeType);
+    auto plugin = m_frame->page()->createPlugin(m_frame.ptr(), &pluginElement, parameters, parameters.mimeType);
     if (!plugin)
         return nullptr;
 
@@ -1656,7 +1640,7 @@ void WebFrameLoaderClient::redirectDataToPlugin(Widget& pluginWidget)
 WebCore::WebGLLoadPolicy WebFrameLoaderClient::webGLPolicyForURL(const URL& url) const
 {
     if (auto* webPage = m_frame->page())
-        return webPage->webGLPolicyForURL(m_frame, url);
+        return webPage->webGLPolicyForURL(m_frame.ptr(), url);
 
     return WebGLAllowCreation;
 }
@@ -1664,7 +1648,7 @@ WebCore::WebGLLoadPolicy WebFrameLoaderClient::webGLPolicyForURL(const URL& url)
 WebCore::WebGLLoadPolicy WebFrameLoaderClient::resolveWebGLPolicyForURL(const URL& url) const
 {
     if (auto* webPage = m_frame->page())
-        return webPage->resolveWebGLPolicyForURL(m_frame, url);
+        return webPage->resolveWebGLPolicyForURL(m_frame.ptr(), url);
 
     return WebGLAllowCreation;
 }
@@ -1733,7 +1717,7 @@ ObjectContentType WebFrameLoaderClient::objectContentType(const URL& url, const
         return ObjectContentType::Image;
 
     if (WebPage* webPage = m_frame->page()) {
-        auto allowedPluginTypes = webFrame()->coreFrame()->loader().subframeLoader().allowPlugins()
+        auto allowedPluginTypes = webFrame().coreFrame()->loader().subframeLoader().allowPlugins()
             ? PluginData::AllPlugins : PluginData::OnlyApplicationPlugins;
         if (webPage->corePage()->pluginData().supportsMimeType(mimeType, allowedPluginTypes))
             return ObjectContentType::PlugIn;
@@ -1753,10 +1737,8 @@ ObjectContentType WebFrameLoaderClient::objectContentType(const URL& url, const
 
 String WebFrameLoaderClient::overrideMediaType() const
 {
-    if (m_frame) {
-        if (auto* page = m_frame->page())
-            return page->overriddenMediaType();
-    }
+    if (auto* page = m_frame->page())
+        return page->overriddenMediaType();
 
     return String();
 }
@@ -1767,11 +1749,11 @@ void WebFrameLoaderClient::dispatchDidClearWindowObjectInWorld(DOMWrapperWorld&
     if (!webPage)
         return;
 
-    webPage->injectedBundleLoaderClient().didClearWindowObjectForFrame(*webPage, *m_frame, world);
+    webPage->injectedBundleLoaderClient().didClearWindowObjectForFrame(*webPage, m_frame, world);
 
     WebAutomationSessionProxy* automationSessionProxy = WebProcess::singleton().automationSessionProxy();
     if (automationSessionProxy && world.isNormal())
-        automationSessionProxy->didClearWindowObjectForFrame(*m_frame);
+        automationSessionProxy->didClearWindowObjectForFrame(m_frame);
 }
 
 void WebFrameLoaderClient::dispatchGlobalObjectAvailable(DOMWrapperWorld& world)
@@ -1780,7 +1762,7 @@ void WebFrameLoaderClient::dispatchGlobalObjectAvailable(DOMWrapperWorld& world)
     if (!webPage)
         return;
     
-    webPage->injectedBundleLoaderClient().globalObjectIsAvailableForFrame(*webPage, *m_frame, world);
+    webPage->injectedBundleLoaderClient().globalObjectIsAvailableForFrame(*webPage, m_frame, world);
 }
 
 void WebFrameLoaderClient::willInjectUserScript(DOMWrapperWorld& world)
@@ -1789,7 +1771,7 @@ void WebFrameLoaderClient::willInjectUserScript(DOMWrapperWorld& world)
     if (!webPage)
         return;
 
-    webPage->injectedBundleLoaderClient().willInjectUserScriptForFrame(*webPage, *m_frame, world);
+    webPage->injectedBundleLoaderClient().willInjectUserScriptForFrame(*webPage, m_frame, world);
 }
 
 void WebFrameLoaderClient::dispatchWillDisconnectDOMWindowExtensionFromGlobalObject(WebCore::DOMWindowExtension* extension)
@@ -1836,7 +1818,7 @@ void WebFrameLoaderClient::willCacheResponse(DocumentLoader*, unsigned long iden
     if (!webPage)
         return completionHandler(response);
 
-    return completionHandler(webPage->injectedBundleResourceLoadClient().shouldCacheResponse(*webPage, *m_frame, identifier) ? response : nil);
+    return completionHandler(webPage->injectedBundleResourceLoadClient().shouldCacheResponse(*webPage, m_frame, identifier) ? response : nil);
 }
 
 NSDictionary *WebFrameLoaderClient::dataDetectionContext()
@@ -1880,7 +1862,7 @@ bool WebFrameLoaderClient::shouldForceUniversalAccessFromLocalURL(const URL& url
 Ref<FrameNetworkingContext> WebFrameLoaderClient::createNetworkingContext()
 {
     ASSERT(!hasProcessPrivilege(ProcessPrivilege::CanAccessRawCookies));
-    return WebFrameNetworkingContext::create(m_frame);
+    return WebFrameNetworkingContext::create(m_frame.ptr());
 }
 
 #if ENABLE(CONTENT_FILTERING)
index 6c894f0..b058e62 100644 (file)
@@ -37,11 +37,10 @@ struct WebsitePoliciesData;
     
 class WebFrameLoaderClient final : public WebCore::FrameLoaderClient {
 public:
-    WebFrameLoaderClient();
+    explicit WebFrameLoaderClient(Ref<WebFrame>&&);
     ~WebFrameLoaderClient();
 
-    void setWebFrame(WebFrame* webFrame) { m_frame = webFrame; }
-    WebFrame* webFrame() const { return m_frame; }
+    WebFrame& webFrame() const { return m_frame.get(); }
 
     bool frameHasCustomContentProvider() const { return m_frameHasCustomContentProvider; }
 
@@ -67,8 +66,6 @@ public:
     WebCore::AllowsContentJavaScript allowsContentJavaScriptFromMostRecentNavigation() const final;
 
 private:
-    void frameLoaderDestroyed() final;
-
     bool hasHTMLView() const final;
     bool hasWebView() const final;
     
@@ -166,20 +163,20 @@ private:
     void didRunInsecureContent(WebCore::SecurityOrigin&, const URL&) final;
     void didDetectXSS(const URL&, bool didBlockEntirePage) final;
 
-    WebCore::ResourceError cancelledError(const WebCore::ResourceRequest&) final;
-    WebCore::ResourceError blockedError(const WebCore::ResourceRequest&) final;
-    WebCore::ResourceError blockedByContentBlockerError(const WebCore::ResourceRequest&) final;
-    WebCore::ResourceError cannotShowURLError(const WebCore::ResourceRequest&) final;
-    WebCore::ResourceError interruptedForPolicyChangeError(const WebCore::ResourceRequest&) final;
+    WebCore::ResourceError cancelledError(const WebCore::ResourceRequest&) const final;
+    WebCore::ResourceError blockedError(const WebCore::ResourceRequest&) const final;
+    WebCore::ResourceError blockedByContentBlockerError(const WebCore::ResourceRequest&) const final;
+    WebCore::ResourceError cannotShowURLError(const WebCore::ResourceRequest&) const final;
+    WebCore::ResourceError interruptedForPolicyChangeError(const WebCore::ResourceRequest&) const final;
 #if ENABLE(CONTENT_FILTERING)
-    WebCore::ResourceError blockedByContentFilterError(const WebCore::ResourceRequest&) final;
+    WebCore::ResourceError blockedByContentFilterError(const WebCore::ResourceRequest&) const final;
 #endif
     
-    WebCore::ResourceError cannotShowMIMETypeError(const WebCore::ResourceResponse&) final;
-    WebCore::ResourceError fileDoesNotExistError(const WebCore::ResourceResponse&) final;
-    WebCore::ResourceError pluginWillHandleLoadError(const WebCore::ResourceResponse&) final;
+    WebCore::ResourceError cannotShowMIMETypeError(const WebCore::ResourceResponse&) const final;
+    WebCore::ResourceError fileDoesNotExistError(const WebCore::ResourceResponse&) const final;
+    WebCore::ResourceError pluginWillHandleLoadError(const WebCore::ResourceResponse&) const final;
     
-    bool shouldFallBack(const WebCore::ResourceError&) final;
+    bool shouldFallBack(const WebCore::ResourceError&) const final;
     
     bool canHandleRequest(const WebCore::ResourceRequest&) const final;
     bool canShowMIMEType(const String& MIMEType) const final;
@@ -199,7 +196,7 @@ private:
 
     void setTitle(const WebCore::StringWithDirection&, const URL&) final;
     
-    String userAgent(const URL&) final;
+    String userAgent(const URL&) const final;
 
     String overrideContentSecurityPolicy() const final;
 
@@ -280,12 +277,12 @@ private:
     void finishedLoadingApplicationManifest(uint64_t, const Optional<WebCore::ApplicationManifest>&) final;
 #endif
 
-    WebFrame* m_frame;
+    Ref<WebFrame> m_frame;
     RefPtr<PluginView> m_pluginView;
-    bool m_hasSentResponseToPluginView;
-    bool m_didCompletePageTransition;
-    bool m_frameHasCustomContentProvider;
-    bool m_frameCameFromBackForwardCache;
+    bool m_hasSentResponseToPluginView { false };
+    bool m_didCompletePageTransition { false };
+    bool m_frameHasCustomContentProvider { false };
+    bool m_frameCameFromBackForwardCache { false };
     bool m_useIconLoadingClient { false };
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
     Optional<FrameSpecificStorageAccessIdentifier> m_frameSpecificStorageAccessIdentifier;
index cf678fa..21bd375 100644 (file)
@@ -102,23 +102,21 @@ static uint64_t generateListenerID()
     return uniqueListenerID++;
 }
 
-Ref<WebFrame> WebFrame::createWithCoreMainFrame(WebPage* page, WebCore::Frame* coreFrame)
+void WebFrame::initWithCoreMainFrame(WebPage& page, Frame& coreFrame)
 {
-    auto frame = create(std::unique_ptr<WebFrameLoaderClient>(static_cast<WebFrameLoaderClient*>(&coreFrame->loader().client())));
-    page->send(Messages::WebPageProxy::DidCreateMainFrame(frame->frameID()));
+    page.send(Messages::WebPageProxy::DidCreateMainFrame(frameID()));
 
-    frame->m_coreFrame = coreFrame;
-    frame->m_coreFrame->tree().setName(String());
-    frame->m_coreFrame->init();
-    return frame;
+    m_coreFrame = &coreFrame;
+    m_coreFrame->tree().setName(String());
+    m_coreFrame->init();
 }
 
 Ref<WebFrame> WebFrame::createSubframe(WebPage* page, const String& frameName, HTMLFrameOwnerElement* ownerElement)
 {
-    auto frame = create(makeUnique<WebFrameLoaderClient>());
+    auto frame = create();
     page->send(Messages::WebPageProxy::DidCreateSubframe(frame->frameID()));
 
-    auto coreFrame = Frame::create(page->corePage(), ownerElement, frame->m_frameLoaderClient.get());
+    auto coreFrame = Frame::create(page->corePage(), ownerElement, makeUniqueRef<WebFrameLoaderClient>(frame.get()));
     frame->m_coreFrame = coreFrame.ptr();
 
     coreFrame->tree().setName(frameName);
@@ -131,21 +129,9 @@ Ref<WebFrame> WebFrame::createSubframe(WebPage* page, const String& frameName, H
     return frame;
 }
 
-Ref<WebFrame> WebFrame::create(std::unique_ptr<WebFrameLoaderClient> frameLoaderClient)
-{
-    auto frame = adoptRef(*new WebFrame(WTFMove(frameLoaderClient)));
-
-    // Add explict ref() that will be balanced in WebFrameLoaderClient::frameLoaderDestroyed().
-    frame->ref();
-
-    return frame;
-}
-
-WebFrame::WebFrame(std::unique_ptr<WebFrameLoaderClient> frameLoaderClient)
-    : m_frameLoaderClient(WTFMove(frameLoaderClient))
-    , m_frameID(FrameIdentifier::generate())
+WebFrame::WebFrame()
+    : m_frameID(FrameIdentifier::generate())
 {
-    m_frameLoaderClient->setWebFrame(this);
     WebProcess::singleton().addWebFrame(m_frameID, this);
 
 #ifndef NDEBUG
@@ -153,6 +139,11 @@ WebFrame::WebFrame(std::unique_ptr<WebFrameLoaderClient> frameLoaderClient)
 #endif
 }
 
+WebFrameLoaderClient* WebFrame::frameLoaderClient() const
+{
+    return m_coreFrame ? static_cast<WebFrameLoaderClient*>(&m_coreFrame->loader().client()) : nullptr;
+}
+
 WebFrame::~WebFrame()
 {
     ASSERT(!m_coreFrame);
@@ -183,7 +174,7 @@ WebFrame* WebFrame::fromCoreFrame(const Frame& frame)
     if (!webFrameLoaderClient)
         return nullptr;
 
-    return webFrameLoaderClient->webFrame();
+    return &webFrameLoaderClient->webFrame();
 }
 
 FrameInfoData WebFrame::info() const
@@ -268,11 +259,11 @@ void WebFrame::didReceivePolicyDecision(uint64_t listenerID, PolicyDecision&& po
 
     invalidatePolicyListener();
 
-    if (forNavigationAction && m_frameLoaderClient && policyDecision.websitePoliciesData) {
+    if (forNavigationAction && frameLoaderClient() && policyDecision.websitePoliciesData) {
         ASSERT(page());
         if (page())
             page()->setAllowsContentJavaScriptFromMostRecentNavigation(policyDecision.websitePoliciesData->allowsContentJavaScript);
-        m_frameLoaderClient->applyToDocumentLoader(WTFMove(*policyDecision.websitePoliciesData));
+        frameLoaderClient()->applyToDocumentLoader(WTFMove(*policyDecision.websitePoliciesData));
     }
 
     m_policyDownloadID = policyDecision.downloadID;
index 363cbbc..da02921 100644 (file)
@@ -65,10 +65,12 @@ struct WebsitePoliciesData;
 
 class WebFrame : public API::ObjectImpl<API::Object::Type::BundleFrame> {
 public:
-    static Ref<WebFrame> createWithCoreMainFrame(WebPage*, WebCore::Frame*);
+    static Ref<WebFrame> create() { return adoptRef(*new WebFrame); }
     static Ref<WebFrame> createSubframe(WebPage*, const String& frameName, WebCore::HTMLFrameOwnerElement*);
     ~WebFrame();
 
+    void initWithCoreMainFrame(WebPage&, WebCore::Frame&);
+
     // Called when the FrameLoaderClient (and therefore the WebCore::Frame) is being torn down.
     void invalidate();
 
@@ -169,11 +171,10 @@ public:
     void setFirstLayerTreeTransactionIDAfterDidCommitLoad(TransactionID transactionID) { m_firstLayerTreeTransactionIDAfterDidCommitLoad = transactionID; }
 #endif
 
-    WebFrameLoaderClient* frameLoaderClient() const { return m_frameLoaderClient.get(); }
+    WebFrameLoaderClient* frameLoaderClient() const;
 
 private:
-    static Ref<WebFrame> create(std::unique_ptr<WebFrameLoaderClient>);
-    explicit WebFrame(std::unique_ptr<WebFrameLoaderClient>);
+    WebFrame();
 
     WebCore::Frame* m_coreFrame { nullptr };
 
@@ -184,7 +185,6 @@ private:
     HashMap<uint64_t, CompletionHandler<void()>> m_willSubmitFormCompletionHandlers;
     DownloadID m_policyDownloadID { 0 };
 
-    std::unique_ptr<WebFrameLoaderClient> m_frameLoaderClient;
     LoadListener* m_loadListener { nullptr };
     
     WebCore::FrameIdentifier m_frameID;
index 648fc21..aef2859 100644 (file)
@@ -467,7 +467,8 @@ WebPage::WebPage(PageIdentifier pageID, WebPageCreationParameters&& parameters)
     ASSERT(m_identifier);
 
     m_pageGroup = WebProcess::singleton().webPageGroup(parameters.pageGroupData);
-
+    m_mainFrame = WebFrame::create();
+    
     PageConfiguration pageConfiguration(
         WebProcess::singleton().sessionID(),
         makeUniqueRef<WebEditorClient>(this),
@@ -477,6 +478,7 @@ WebPage::WebPage(PageIdentifier pageID, WebPageCreationParameters&& parameters)
         WebBackForwardListProxy::create(*this),
         WebProcess::singleton().cookieJar(),
         makeUniqueRef<WebProgressTrackerClient>(*this),
+        makeUniqueRef<WebFrameLoaderClient>(*m_mainFrame),
         makeUniqueRef<MediaRecorderProvider>()
     );
     pageConfiguration.chromeClient = new WebChromeClient(*this);
@@ -492,7 +494,6 @@ WebPage::WebPage(PageIdentifier pageID, WebPageCreationParameters&& parameters)
 #endif
 
     pageConfiguration.plugInClient = makeUnique<WebPlugInClient>(*this);
-    pageConfiguration.loaderClientForMainFrame = new WebFrameLoaderClient;
     pageConfiguration.diagnosticLoggingClient = makeUnique<WebDiagnosticLoggingClient>(*this);
     pageConfiguration.performanceLoggingClient = makeUnique<WebPerformanceLoggingClient>(*this);
 
@@ -572,7 +573,9 @@ WebPage::WebPage(PageIdentifier pageID, WebPageCreationParameters&& parameters)
     // in modern WebKit.
     m_page->settings().setBackForwardCacheExpirationInterval(Seconds::infinity());
 
-    m_mainFrame = WebFrame::createWithCoreMainFrame(this, &m_page->mainFrame());
+    m_mainFrame->initWithCoreMainFrame(*this, m_page->mainFrame());
+
+
     m_drawingArea->updatePreferences(parameters.store);
 
     setBackgroundExtendsBeyondPage(parameters.backgroundExtendsBeyondPage);
index ffd8885..03d1f97 100644 (file)
@@ -1,3 +1,35 @@
+2020-03-12  youenn fablet  <youenn@apple.com>
+
+        FrameLoader should own its FrameLoaderClient
+        https://bugs.webkit.org/show_bug.cgi?id=208918
+
+        Reviewed by Geoffrey Garen.
+
+        Update according new Frame/FrameLoader constructors and FrameLoaderClient interface.
+
+        * WebCoreSupport/WebFrameLoaderClient.h:
+        (WebFrameLoaderClient::setWebFrame):
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        (WebFrameLoaderClient::~WebFrameLoaderClient):
+        (WebFrameLoaderClient::cancelledError const):
+        (WebFrameLoaderClient::blockedError const):
+        (WebFrameLoaderClient::blockedByContentBlockerError const):
+        (WebFrameLoaderClient::cannotShowURLError const):
+        (WebFrameLoaderClient::interruptedForPolicyChangeError const):
+        (WebFrameLoaderClient::blockedByContentFilterError const):
+        (WebFrameLoaderClient::cannotShowMIMETypeError const):
+        (WebFrameLoaderClient::fileDoesNotExistError const):
+        (WebFrameLoaderClient::pluginWillHandleLoadError const):
+        (WebFrameLoaderClient::shouldFallBack const):
+        (WebFrameLoaderClient::userAgent const):
+        * WebView/WebFrame.mm:
+        (+[WebFrame _createFrameWithPage:frameName:frameView:ownerElement:]):
+        (+[WebFrame _createMainFrameWithPage:frameName:frameView:]):
+        (+[WebFrame _createMainFrameWithSimpleHTMLDocumentWithPage:frameView:style:]):
+        * WebView/WebView.mm:
+        (-[WebView _commonInitializationWithFrameName:groupName:]):
+        (-[WebView initSimpleHTMLDocumentWithStyle:frame:preferences:groupName:]):
+
 2020-03-08  Darin Adler  <darin@apple.com>
 
         Make TextIterator::range return a SimpleRange
index aeb2b5d..7190b8c 100644 (file)
@@ -54,13 +54,13 @@ class ResourceRequest;
 
 class WebFrameLoaderClient : public WebCore::FrameLoaderClient {
 public:
-    WebFrameLoaderClient(WebFrame* = 0);
+    explicit WebFrameLoaderClient(WebFrame* = nullptr);
+    ~WebFrameLoaderClient();
 
-    void setWebFrame(WebFrame* webFrame) { m_webFrame = webFrame; }
+    void setWebFrame(WebFrame& webFrame) { m_webFrame = &webFrame; }
     WebFrame* webFrame() const { return m_webFrame.get(); }
 
 private:
-    void frameLoaderDestroyed() final;
     bool hasWebView() const final; // mainly for assertions
 
     Optional<WebCore::PageIdentifier> pageID() const final;
@@ -160,22 +160,22 @@ private:
     void didRunInsecureContent(WebCore::SecurityOrigin&, const URL&) final;
     void didDetectXSS(const URL&, bool didBlockEntirePage) final;
 
-    WebCore::ResourceError cancelledError(const WebCore::ResourceRequest&) final;
-    WebCore::ResourceError blockedError(const WebCore::ResourceRequest&) final;
-    WebCore::ResourceError blockedByContentBlockerError(const WebCore::ResourceRequest&) final;
-    WebCore::ResourceError cannotShowURLError(const WebCore::ResourceRequest&) final;
-    WebCore::ResourceError interruptedForPolicyChangeError(const WebCore::ResourceRequest&) final;
+    WebCore::ResourceError cancelledError(const WebCore::ResourceRequest&) const final;
+    WebCore::ResourceError blockedError(const WebCore::ResourceRequest&) const final;
+    WebCore::ResourceError blockedByContentBlockerError(const WebCore::ResourceRequest&) const final;
+    WebCore::ResourceError cannotShowURLError(const WebCore::ResourceRequest&) const final;
+    WebCore::ResourceError interruptedForPolicyChangeError(const WebCore::ResourceRequest&) const final;
 #if ENABLE(CONTENT_FILTERING)
-    WebCore::ResourceError blockedByContentFilterError(const WebCore::ResourceRequest&) final;
+    WebCore::ResourceError blockedByContentFilterError(const WebCore::ResourceRequest&) const final;
 #endif
 
-    WebCore::ResourceError cannotShowMIMETypeError(const WebCore::ResourceResponse&) final;
-    WebCore::ResourceError fileDoesNotExistError(const WebCore::ResourceResponse&) final;
-    WebCore::ResourceError pluginWillHandleLoadError(const WebCore::ResourceResponse&) final;
+    WebCore::ResourceError cannotShowMIMETypeError(const WebCore::ResourceResponse&) const final;
+    WebCore::ResourceError fileDoesNotExistError(const WebCore::ResourceResponse&) const final;
+    WebCore::ResourceError pluginWillHandleLoadError(const WebCore::ResourceResponse&) const final;
 
-    bool shouldFallBack(const WebCore::ResourceError&) final;
+    bool shouldFallBack(const WebCore::ResourceError&) const final;
 
-    WTF::String userAgent(const URL&) final;
+    WTF::String userAgent(const URL&) const final;
     
     void savePlatformDataToCachedFrame(WebCore::CachedFrame*) final;
     void transitionToCommittedFromCachedFrame(WebCore::CachedFrame*) final;
index 43c6a79..43d7050 100644 (file)
@@ -217,10 +217,9 @@ Optional<WebCore::FrameIdentifier> WebFrameLoaderClient::frameID() const
     return WTF::nullopt;
 }
 
-void WebFrameLoaderClient::frameLoaderDestroyed()
+WebFrameLoaderClient::~WebFrameLoaderClient()
 {
     [m_webFrame.get() _clearCoreFrame];
-    delete this;
 }
 
 bool WebFrameLoaderClient::hasWebView() const
@@ -1133,49 +1132,49 @@ void WebFrameLoaderClient::didDetectXSS(const URL& insecureURL, bool didBlockEnt
     }
 }
 
-WebCore::ResourceError WebFrameLoaderClient::cancelledError(const WebCore::ResourceRequest& request)
+WebCore::ResourceError WebFrameLoaderClient::cancelledError(const WebCore::ResourceRequest& request) const
 {
     return [NSError _webKitErrorWithDomain:NSURLErrorDomain code:NSURLErrorCancelled URL:request.url()];
 }
     
-WebCore::ResourceError WebFrameLoaderClient::blockedError(const WebCore::ResourceRequest& request)
+WebCore::ResourceError WebFrameLoaderClient::blockedError(const WebCore::ResourceRequest& request) const
 {
     return [NSError _webKitErrorWithDomain:WebKitErrorDomain code:WebKitErrorCannotUseRestrictedPort URL:request.url()];
 }
 
-WebCore::ResourceError WebFrameLoaderClient::blockedByContentBlockerError(const WebCore::ResourceRequest& request)
+WebCore::ResourceError WebFrameLoaderClient::blockedByContentBlockerError(const WebCore::ResourceRequest& request) const
 {
     RELEASE_ASSERT_NOT_REACHED(); // Content blockers are not enabled in WebKit1.
 }
 
-WebCore::ResourceError WebFrameLoaderClient::cannotShowURLError(const WebCore::ResourceRequest& request)
+WebCore::ResourceError WebFrameLoaderClient::cannotShowURLError(const WebCore::ResourceRequest& request) const
 {
     return [NSError _webKitErrorWithDomain:WebKitErrorDomain code:WebKitErrorCannotShowURL URL:request.url()];
 }
 
-WebCore::ResourceError WebFrameLoaderClient::interruptedForPolicyChangeError(const WebCore::ResourceRequest& request)
+WebCore::ResourceError WebFrameLoaderClient::interruptedForPolicyChangeError(const WebCore::ResourceRequest& request) const
 {
     return [NSError _webKitErrorWithDomain:WebKitErrorDomain code:WebKitErrorFrameLoadInterruptedByPolicyChange URL:request.url()];
 }
 
 #if ENABLE(CONTENT_FILTERING)
-WebCore::ResourceError WebFrameLoaderClient::blockedByContentFilterError(const WebCore::ResourceRequest& request)
+WebCore::ResourceError WebFrameLoaderClient::blockedByContentFilterError(const WebCore::ResourceRequest& request) const
 {
     return [NSError _webKitErrorWithDomain:WebKitErrorDomain code:WebKitErrorFrameLoadBlockedByContentFilter URL:request.url()];
 }
 #endif
 
-WebCore::ResourceError WebFrameLoaderClient::cannotShowMIMETypeError(const WebCore::ResourceResponse& response)
+WebCore::ResourceError WebFrameLoaderClient::cannotShowMIMETypeError(const WebCore::ResourceResponse& response) const
 {
     return [NSError _webKitErrorWithDomain:NSURLErrorDomain code:WebKitErrorCannotShowMIMEType URL:response.url()];
 }
 
-WebCore::ResourceError WebFrameLoaderClient::fileDoesNotExistError(const WebCore::ResourceResponse& response)
+WebCore::ResourceError WebFrameLoaderClient::fileDoesNotExistError(const WebCore::ResourceResponse& response) const
 {
     return [NSError _webKitErrorWithDomain:NSURLErrorDomain code:NSURLErrorFileDoesNotExist URL:response.url()];    
 }
 
-WebCore::ResourceError WebFrameLoaderClient::pluginWillHandleLoadError(const WebCore::ResourceResponse& response)
+WebCore::ResourceError WebFrameLoaderClient::pluginWillHandleLoadError(const WebCore::ResourceResponse& response) const
 {
     NSError *error = [[NSError alloc] _initWithPluginErrorCode:WebKitErrorPlugInWillHandleLoad
                                                     contentURL:response.url()
@@ -1185,7 +1184,7 @@ WebCore::ResourceError WebFrameLoaderClient::pluginWillHandleLoadError(const Web
     return [error autorelease];
 }
 
-bool WebFrameLoaderClient::shouldFallBack(const WebCore::ResourceError& error)
+bool WebFrameLoaderClient::shouldFallBack(const WebCore::ResourceError& error) const
 {
     // FIXME: Needs to check domain.
     // FIXME: WebKitErrorPlugInWillHandleLoad is a workaround for the cancel we do to prevent
@@ -1533,7 +1532,7 @@ RetainPtr<WebFramePolicyListener> WebFrameLoaderClient::setUpPolicyListener(WebC
     return policyListener;
 }
 
-String WebFrameLoaderClient::userAgent(const URL& url)
+String WebFrameLoaderClient::userAgent(const URL& url) const
 {
     WebView *webView = getWebView(m_webFrame.get());
     ASSERT(webView);
index bf2ae28..eb9268c 100644 (file)
@@ -305,7 +305,7 @@ WebView *getWebView(WebFrame *webFrame)
     WebView *webView = kit(page);
 
     WebFrame *frame = [[self alloc] _initWithWebFrameView:frameView webView:webView];
-    auto coreFrame = WebCore::Frame::create(page, ownerElement, new WebFrameLoaderClient(frame));
+    auto coreFrame = WebCore::Frame::create(page, ownerElement, makeUniqueRef<WebFrameLoaderClient>(frame));
     [frame release];
     frame->_private->coreFrame = coreFrame.ptr();
 
@@ -328,7 +328,7 @@ WebView *getWebView(WebFrame *webFrame)
 
     WebFrame *frame = [[self alloc] _initWithWebFrameView:frameView webView:webView];
     frame->_private->coreFrame = &page->mainFrame();
-    static_cast<WebFrameLoaderClient&>(page->mainFrame().loader().client()).setWebFrame(frame);
+    static_cast<WebFrameLoaderClient&>(page->mainFrame().loader().client()).setWebFrame(*frame);
     [frame release];
 
     page->mainFrame().tree().setName(name);
@@ -356,7 +356,7 @@ static NSURL *createUniqueWebDataURL();
     
     WebFrame *frame = [[self alloc] _initWithWebFrameView:frameView webView:webView];
     frame->_private->coreFrame = &page->mainFrame();
-    static_cast<WebFrameLoaderClient&>(page->mainFrame().loader().client()).setWebFrame(frame);
+    static_cast<WebFrameLoaderClient&>(page->mainFrame().loader().client()).setWebFrame(*frame);
     [frame release];
 
     frame->_private->coreFrame->initWithSimpleHTMLDocument(style, createUniqueWebDataURL());
index cb3379a..bd36755 100644 (file)
@@ -1443,6 +1443,7 @@ static void WebKitInitializeGamepadProviderIfNecessary()
         BackForwardList::create(self),
         WebCore::CookieJar::create(storageProvider.copyRef()),
         makeUniqueRef<WebProgressTrackerClient>(self),
+        makeUniqueRef<WebFrameLoaderClient>(),
         makeUniqueRef<WebCore::MediaRecorderProvider>()
     );
 #if !PLATFORM(IOS_FAMILY)
@@ -1465,7 +1466,6 @@ static void WebKitInitializeGamepadProviderIfNecessary()
 #endif
 
     pageConfiguration.alternativeTextClient = makeUnique<WebAlternativeTextClient>(self);
-    pageConfiguration.loaderClientForMainFrame = new WebFrameLoaderClient;
     pageConfiguration.applicationCacheStorage = &webApplicationCacheStorage();
     pageConfiguration.databaseProvider = &WebDatabaseProvider::singleton();
     pageConfiguration.pluginInfoProvider = &WebPluginInfoProvider::singleton();
@@ -1714,6 +1714,7 @@ static void WebKitInitializeGamepadProviderIfNecessary()
         BackForwardList::create(self),
         WebCore::CookieJar::create(storageProvider.copyRef()),
         makeUniqueRef<WebProgressTrackerClient>(self),
+        makeUniqueRef<WebFrameLoaderClient>(),
         makeUniqueRef<WebCore::MediaRecorderProvider>()
     );
     pageConfiguration.chromeClient = new WebChromeClientIOS(self);
@@ -1726,7 +1727,6 @@ static void WebKitInitializeGamepadProviderIfNecessary()
 #endif
 
     pageConfiguration.inspectorClient = new WebInspectorClient(self);
-    pageConfiguration.loaderClientForMainFrame = new WebFrameLoaderClient;
     pageConfiguration.applicationCacheStorage = &webApplicationCacheStorage();
     pageConfiguration.databaseProvider = &WebDatabaseProvider::singleton();
     pageConfiguration.storageNamespaceProvider = &_private->group->storageNamespaceProvider();
index 40419a9..f989806 100644 (file)
@@ -1,3 +1,36 @@
+2020-03-12  youenn fablet  <youenn@apple.com>
+
+        Make sure a preflight fails if response headers are invalid
+        https://bugs.webkit.org/show_bug.cgi?id=208924
+
+        Reviewed by Geoffrey Garen.
+
+        * WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebFrameLoaderClient::cancelledError const):
+        (WebFrameLoaderClient::blockedError const):
+        (WebFrameLoaderClient::blockedByContentBlockerError const):
+        (WebFrameLoaderClient::cannotShowURLError const):
+        (WebFrameLoaderClient::interruptedForPolicyChangeError const):
+        (WebFrameLoaderClient::cannotShowMIMETypeError const):
+        (WebFrameLoaderClient::fileDoesNotExistError const):
+        (WebFrameLoaderClient::pluginWillHandleLoadError const):
+        (WebFrameLoaderClient::shouldFallBack const):
+        (WebFrameLoaderClient::userAgent const):
+        (WebFrameLoaderClient::frameLoaderDestroyed): Deleted.
+        (WebFrameLoaderClient::cancelledError): Deleted.
+        (WebFrameLoaderClient::blockedError): Deleted.
+        (WebFrameLoaderClient::blockedByContentBlockerError): Deleted.
+        (WebFrameLoaderClient::cannotShowURLError): Deleted.
+        (WebFrameLoaderClient::interruptedForPolicyChangeError): Deleted.
+        (WebFrameLoaderClient::cannotShowMIMETypeError): Deleted.
+        (WebFrameLoaderClient::fileDoesNotExistError): Deleted.
+        (WebFrameLoaderClient::pluginWillHandleLoadError): Deleted.
+        (WebFrameLoaderClient::shouldFallBack): Deleted.
+        (WebFrameLoaderClient::userAgent): Deleted.
+        * WebCoreSupport/WebFrameLoaderClient.h:
+        * WebFrame.cpp:
+        (WebFrame::createSubframeWithOwnerElement):
+
 2020-03-09  Don Olmstead  <don.olmstead@sony.com>
 
         Remove obsolete feature flags
index 9de3268..6222820 100644 (file)
@@ -119,10 +119,6 @@ WebFrameLoaderClient::~WebFrameLoaderClient()
 {
 }
 
-void WebFrameLoaderClient::frameLoaderDestroyed()
-{
-}
-
 Optional<WebCore::PageIdentifier> WebFrameLoaderClient::pageID() const
 {
     return WTF::nullopt;
@@ -785,49 +781,49 @@ void WebFrameLoaderClient::didDetectXSS(const URL&, bool)
     // FIXME: propogate call into the private delegate.
 }
 
-ResourceError WebFrameLoaderClient::cancelledError(const ResourceRequest& request)
+ResourceError WebFrameLoaderClient::cancelledError(const ResourceRequest& request) const
 {
     // FIXME: Need ChickenCat to include CFNetwork/CFURLError.h to get these values
     // Alternatively, we could create our own error domain/codes.
     return ResourceError(String(WebURLErrorDomain), -999, request.url(), String("Cancelled"));
 }
 
-ResourceError WebFrameLoaderClient::blockedError(const ResourceRequest& request)
+ResourceError WebFrameLoaderClient::blockedError(const ResourceRequest& request) const
 {
     return ResourceError(String(WebKitErrorDomain), WebKitErrorCannotUseRestrictedPort, request.url(), WEB_UI_STRING("Not allowed to use restricted network port", "WebKitErrorCannotUseRestrictedPort description"));
 }
 
-ResourceError WebFrameLoaderClient::blockedByContentBlockerError(const ResourceRequest& request)
+ResourceError WebFrameLoaderClient::blockedByContentBlockerError(const ResourceRequest& request) const
 {
     RELEASE_ASSERT_NOT_REACHED(); // Content Blockers are not enabled for WK1.
 }
 
-ResourceError WebFrameLoaderClient::cannotShowURLError(const ResourceRequest& request)
+ResourceError WebFrameLoaderClient::cannotShowURLError(const ResourceRequest& request) const
 {
     return ResourceError(String(WebKitErrorDomain), WebKitErrorCannotShowURL, request.url(), WEB_UI_STRING("The URL can\xE2\x80\x99t be shown", "WebKitErrorCannotShowURL description"));
 }
 
-ResourceError WebFrameLoaderClient::interruptedForPolicyChangeError(const ResourceRequest& request)
+ResourceError WebFrameLoaderClient::interruptedForPolicyChangeError(const ResourceRequest& request) const
 {
     return ResourceError(String(WebKitErrorDomain), WebKitErrorFrameLoadInterruptedByPolicyChange, request.url(), WEB_UI_STRING("Frame load interrupted", "WebKitErrorFrameLoadInterruptedByPolicyChange description"));
 }
 
-ResourceError WebFrameLoaderClient::cannotShowMIMETypeError(const ResourceResponse& response)
+ResourceError WebFrameLoaderClient::cannotShowMIMETypeError(const ResourceResponse& response) const
 {
     return ResourceError(String(), WebKitErrorCannotShowMIMEType, response.url(), WEB_UI_STRING("Content with specified MIME type can\xE2\x80\x99t be shown", "WebKitErrorCannotShowMIMEType description"));
 }
 
-ResourceError WebFrameLoaderClient::fileDoesNotExistError(const ResourceResponse& response)
+ResourceError WebFrameLoaderClient::fileDoesNotExistError(const ResourceResponse& response) const
 {
     return ResourceError(String(WebURLErrorDomain), -1100, response.url(), String("File does not exist."));
 }
 
-ResourceError WebFrameLoaderClient::pluginWillHandleLoadError(const ResourceResponse& response)
+ResourceError WebFrameLoaderClient::pluginWillHandleLoadError(const ResourceResponse& response) const
 {
     return ResourceError(String(WebKitErrorDomain), WebKitErrorPlugInWillHandleLoad, response.url(), WEB_UI_STRING("Plug-in handled load", "WebKitErrorPlugInWillHandleLoad description"));
 }
 
-bool WebFrameLoaderClient::shouldFallBack(const ResourceError& error)
+bool WebFrameLoaderClient::shouldFallBack(const ResourceError& error) const
 {
     if (error.errorCode() == WebURLErrorCancelled && error.domain() == String(WebURLErrorDomain))
         return false;
@@ -979,7 +975,7 @@ void WebFrameLoaderClient::dispatchDidBecomeFrameset(bool)
 {
 }
 
-String WebFrameLoaderClient::userAgent(const URL& url)
+String WebFrameLoaderClient::userAgent(const URL& url) const
 {
     return m_webFrame->webView()->userAgentForKURL(url);
 }
index 7a2ace3..d3a73a5 100644 (file)
@@ -58,7 +58,6 @@ public:
 
     Ref<WebCore::FrameNetworkingContext> createNetworkingContext() override;
 
-    void frameLoaderDestroyed() override;
     void makeRepresentation(WebCore::DocumentLoader*) override;
     void forceLayoutForNonHTML() override;
 
@@ -137,18 +136,18 @@ public:
     void didRunInsecureContent(WebCore::SecurityOrigin&, const URL&) override;
     void didDetectXSS(const URL&, bool didBlockEntirePage) override;
 
-    WebCore::ResourceError cancelledError(const WebCore::ResourceRequest&) override;
-    WebCore::ResourceError blockedError(const WebCore::ResourceRequest&) override;
-    WebCore::ResourceError blockedByContentBlockerError(const WebCore::ResourceRequest&) override;
-    WebCore::ResourceError cannotShowURLError(const WebCore::ResourceRequest&) override;
-    WebCore::ResourceError interruptedForPolicyChangeError(const WebCore::ResourceRequest&) override;
-    WebCore::ResourceError cannotShowMIMETypeError(const WebCore::ResourceResponse&) override;
-    WebCore::ResourceError fileDoesNotExistError(const WebCore::ResourceResponse&) override;
-    WebCore::ResourceError pluginWillHandleLoadError(const WebCore::ResourceResponse&) override;
+    WebCore::ResourceError cancelledError(const WebCore::ResourceRequest&) const override;
+    WebCore::ResourceError blockedError(const WebCore::ResourceRequest&) const override;
+    WebCore::ResourceError blockedByContentBlockerError(const WebCore::ResourceRequest&) const override;
+    WebCore::ResourceError cannotShowURLError(const WebCore::ResourceRequest&) const override;
+    WebCore::ResourceError interruptedForPolicyChangeError(const WebCore::ResourceRequest&) const override;
+    WebCore::ResourceError cannotShowMIMETypeError(const WebCore::ResourceResponse&) const override;
+    WebCore::ResourceError fileDoesNotExistError(const WebCore::ResourceResponse&) const override;
+    WebCore::ResourceError pluginWillHandleLoadError(const WebCore::ResourceResponse&) const override;
 
-    bool shouldFallBack(const WebCore::ResourceError&) override;
+    bool shouldFallBack(const WebCore::ResourceError&) const override;
 
-    WTF::String userAgent(const URL&) override;
+    WTF::String userAgent(const URL&) const override;
 
     Ref<WebCore::DocumentLoader> createDocumentLoader(const WebCore::ResourceRequest&, const WebCore::SubstituteData&) override;
     void updateCachedDocumentLoader(WebCore::DocumentLoader&) override { }
index c778e22..368d7ce 100644 (file)
@@ -1082,7 +1082,7 @@ Ref<Frame> WebFrame::createSubframeWithOwnerElement(IWebView* webView, Page* pag
     d->webView->viewWindow(&viewWindow);
 
     this->AddRef(); // We release this ref in frameLoaderDestroyed()
-    auto frame = Frame::create(page, ownerElement, new WebFrameLoaderClient(this));
+    auto frame = Frame::create(page, ownerElement, makeUniqueRef<WebFrameLoaderClient>(this));
     d->frame = frame.ptr();
     return frame;
 }
index 4fd175b..d7053ec 100644 (file)
@@ -3116,6 +3116,8 @@ HRESULT WebView::initWithFrame(RECT frame, _In_ BSTR frameName, _In_ BSTR groupN
     m_inspectorClient = new WebInspectorClient(this);
 
     auto storageProvider = PageStorageSessionProvider::create();
+
+    WebFrame* webFrame = WebFrame::createInstance();
     PageConfiguration configuration(
         PAL::SessionID::defaultSessionID(),
         makeUniqueRef<WebEditorClient>(this),
@@ -3125,13 +3127,13 @@ HRESULT WebView::initWithFrame(RECT frame, _In_ BSTR frameName, _In_ BSTR groupN
         BackForwardList::create(),
         CookieJar::create(storageProvider.copyRef()),
         makeUniqueRef<WebProgressTrackerClient>(),
+        makeUniqueRef<WebFrameLoaderClient>(webFrame),
         makeUniqueRef<MediaRecorderProvider>()
     );
     configuration.chromeClient = new WebChromeClient(this);
     configuration.contextMenuClient = new WebContextMenuClient(this);
     configuration.dragClient = makeUnique<WebDragClient>(this);
     configuration.inspectorClient = m_inspectorClient;
-    configuration.loaderClientForMainFrame = new WebFrameLoaderClient;
     configuration.applicationCacheStorage = &WebApplicationCache::storage();
     configuration.databaseProvider = &WebDatabaseProvider::singleton();
     configuration.storageNamespaceProvider = &m_webViewGroup->storageNamespaceProvider();
@@ -3151,7 +3153,6 @@ HRESULT WebView::initWithFrame(RECT frame, _In_ BSTR frameName, _In_ BSTR groupN
             m_page->settings().setFTPDirectoryTemplatePath(toString(path));
     }
 
-    WebFrame* webFrame = WebFrame::createInstance();
     webFrame->initWithWebView(this, m_page);
     static_cast<WebFrameLoaderClient&>(m_page->mainFrame().loader().client()).setWebFrame(webFrame);
     static_cast<WebProgressTrackerClient&>(m_page->progress().client()).setWebFrame(webFrame);