Skip to content

Commit

Permalink
[Site Isolation] Introduce provisional frames to handle load failures…
Browse files Browse the repository at this point in the history
… and JS during navigation

https://bugs.webkit.org/show_bug.cgi?id=273741
rdar://127553870

Reviewed by Brady Eidson.

Until now, to navigate a RemoteFrame we first transitioned it to a LocalFrame then started a load in it.
This worked fine, but it has two fundamental issues.  First, if JS interacts with the Frame between when
the provisional load starts and the server reply is received and the load commits, the JS will be interacting
with a LocalFrame instead of the old RemoteFrame.  Second, if the provisional load fails, we need the original
RemoteFrame to be in the frame tree afterwards.  With main frame provisional load failures we were just
transitioning them back to a new RemoteFrame and that passed existing tests, but with iframes or any
more involved testing we ran into an issue.

To solve this, I give each WebFrame the ability to have a provisional LocalFrame and I use that for loading
instead, then when the load commits I replace the RemoteFrame in the tree with a LocalFrame.  This model allows
us to fix the two issues.

A WebFrame can now have multiple WebCore::Frames, one possibly provisional.  To make this work, I need
WebLocalFrameLoaderClient to not get its LocalFrame from the WebFrame, but have its own reference to its LocalFrame.
To use a non-nullable type (WeakRef<WebCore::LocalFrame>) I made it so that the FrameLoaderClient construction
happens during the constructor of the LocalFrame rather than making the FrameLoaderClient then passing it in
to the LocalFrame constructor.  I did this using ClientCreator.

This makes the frame construction and destruction less symmetric as well as the transitions from remote to local
and local to remote less symmetric, but it is necessary because the provisional state needs to be handled robustly.

I also did a few simple cleanups of code I was touching anyways, such as moving the WebFrame invalidator to
the shared WebFrameLoaderClient from the local and remote clients to reduce duplicate code, removing the
BrowsingContextGroup::remotePageInProcess function that takes a RegistrableDomain because we already have the
WebProcessProxy and don't need to look it up with what is hopefully always the right URL, and using
toWebLocalFrameLoaderClient instead of assuming the client is not an EmptyFrameLoaderClient.

I added some test infrastructure to have HTTPServer never send a response, which will be needed for many
upcoming tests in this area.

* Source/WebKit/CMakeLists.txt:
* Source/WebKit/DerivedSources-input.xcfilelist:
* Source/WebKit/DerivedSources.make:
* Source/WebKit/Shared/ProvisionalFrameCreationParameters.h: Renamed from Source/WebKit/Shared/LocalFrameCreationParameters.h.
* Source/WebKit/Shared/ProvisionalFrameCreationParameters.serialization.in: Renamed from Source/WebKit/Shared/LocalFrameCreationParameters.serialization.in.
* Source/WebKit/UIProcess/BrowsingContextGroup.cpp:
(WebKit::BrowsingContextGroup::takeRemotePageInProcessForProvisionalPage):
* Source/WebKit/UIProcess/BrowsingContextGroup.h:
* Source/WebKit/UIProcess/ProvisionalPageProxy.cpp:
(WebKit::ProvisionalPageProxy::initializeWebPage):
(WebKit::ProvisionalPageProxy::didFailProvisionalLoadForFrame):
* Source/WebKit/UIProcess/WebFrameProxy.cpp:
(WebKit::WebFrameProxy::prepareForProvisionalNavigationInProcess):
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::continueNavigationInNewProcess):
(WebKit::WebPageProxy::webPageIDInProcess const):
(WebKit::WebPageProxy::webPageIDInProcessForDomain const): Deleted.
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:
* Source/WebKit/WebProcess/WebCoreSupport/WebLocalFrameLoaderClient.cpp:
(WebKit::WebLocalFrameLoaderClient::dispatchDidCommitLoad):
* Source/WebKit/WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::coreLocalFrame const):
(WebKit::WebFrame::createProvisionalFrame):
(WebKit::WebFrame::commitProvisionalFrame):
(WebKit::WebFrame::removeFromTree):
(WebKit::WebFrame::transitionToLocal): Deleted.
* Source/WebKit/WebProcess/WebPage/WebFrame.h:
(WebKit::WebFrame::provisionalFrame):
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::createProvisionalFrame):
(WebKit::WebPage::commitProvisionalFrame):
(WebKit::WebPage::loadRequest):
(WebKit::WebPage::transitionFrameToLocal): Deleted.
* Source/WebKit/WebProcess/WebPage/WebPage.h:
* Source/WebKit/WebProcess/WebPage/WebPage.messages.in:
* Tools/TestWebKitAPI/Tests/WebKitCocoa/SiteIsolation.mm:
(TestWebKitAPI::TEST(SiteIsolation, NavigateIframeToProvisionalNavigationFailure)): Deleted.
(TestWebKitAPI::TEST(SiteIsolation, PresentationUpdateAfterCrossSiteNavigation)): Deleted.

Canonical link: https://commits.webkit.org/278444@main
  • Loading branch information
achristensen07 committed May 7, 2024
1 parent d8da684 commit 6b90cc5
Show file tree
Hide file tree
Showing 46 changed files with 361 additions and 264 deletions.
21 changes: 18 additions & 3 deletions Source/WebCore/history/BackForwardController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ void BackForwardController::goBackOrForward(int distance)
if (!historyItem)
return;

protectedPage()->goToItem(*historyItem, FrameLoadType::IndexedBackForward, ShouldTreatAsContinuingLoad::No);
Ref page { protectedPage() };
RefPtr localMainFrame = dynamicDowncast<LocalFrame>(page->mainFrame());
if (!localMainFrame)
return;

page->goToItem(*localMainFrame, *historyItem, FrameLoadType::IndexedBackForward, ShouldTreatAsContinuingLoad::No);
}

bool BackForwardController::goBack()
Expand All @@ -105,7 +110,12 @@ bool BackForwardController::goBack()
if (!historyItem)
return false;

protectedPage()->goToItem(*historyItem, FrameLoadType::Back, ShouldTreatAsContinuingLoad::No);
Ref page { protectedPage() };
RefPtr localMainFrame = dynamicDowncast<LocalFrame>(page->mainFrame());
if (!localMainFrame)
return false;

page->goToItem(*localMainFrame, *historyItem, FrameLoadType::Back, ShouldTreatAsContinuingLoad::No);
return true;
}

Expand All @@ -115,7 +125,12 @@ bool BackForwardController::goForward()
if (!historyItem)
return false;

protectedPage()->goToItem(*historyItem, FrameLoadType::Forward, ShouldTreatAsContinuingLoad::No);
Ref page { protectedPage() };
RefPtr localMainFrame = dynamicDowncast<LocalFrame>(page->mainFrame());
if (!localMainFrame)
return false;

page->goToItem(*localMainFrame, *historyItem, FrameLoadType::Forward, ShouldTreatAsContinuingLoad::No);
return true;
}

Expand Down
4 changes: 3 additions & 1 deletion Source/WebCore/loader/EmptyClients.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,9 @@ PageConfiguration pageConfigurationWithEmptyClients(std::optional<PageIdentifier
adoptRef(*new EmptyBackForwardClient),
CookieJar::create(adoptRef(*new EmptyStorageSessionProvider)),
makeUniqueRef<EmptyProgressTrackerClient>(),
UniqueRef<LocalFrameLoaderClient>(makeUniqueRef<EmptyFrameLoaderClient>()),
CompletionHandler<UniqueRef<LocalFrameLoaderClient>(LocalFrame&)> { [] (auto&) {
return makeUniqueRef<EmptyFrameLoaderClient>();
} },
FrameIdentifier::generate(),
nullptr,
makeUniqueRef<DummySpeechRecognitionProvider>(),
Expand Down
10 changes: 7 additions & 3 deletions Source/WebCore/loader/NavigationScheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,13 @@ class ScheduledHistoryNavigation : public ScheduledNavigation {
void fire(Frame& frame) override
{
// If the destination HistoryItem is no longer in the back/forward list, then we don't proceed.
if (!frame.page()->backForward().containsItem(m_historyItem))
RefPtr page { frame.page() };
if (!page || !page->backForward().containsItem(m_historyItem))
return;

UserGestureIndicator gestureIndicator(userGestureToForward());

if (frame.page()->backForward().currentItem() == m_historyItem.ptr()) {
if (page->backForward().currentItem() == m_historyItem.ptr()) {
// Special case for go(0) from a frame -> reload only the frame
// To follow Firefox and IE's behavior, history reload can only navigate the self frame.
if (RefPtr localFrame = dynamicDowncast<LocalFrame>(frame))
Expand All @@ -304,7 +305,10 @@ class ScheduledHistoryNavigation : public ScheduledNavigation {

// go(i!=0) from a frame navigates into the history of the frame only,
// in both IE and NS (but not in Mozilla). We can't easily do that.
frame.protectedPage()->goToItem(m_historyItem, FrameLoadType::IndexedBackForward, ShouldTreatAsContinuingLoad::No);
RefPtr localMainFrame = dynamicDowncast<LocalFrame>(page->mainFrame());
if (!localMainFrame)
return;
page->goToItem(*localMainFrame, m_historyItem, FrameLoadType::IndexedBackForward, ShouldTreatAsContinuingLoad::No);
}

private:
Expand Down
16 changes: 8 additions & 8 deletions Source/WebCore/page/LocalFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ static const LocalFrame& rootFrame(const LocalFrame& frame)
return frame;
}

LocalFrame::LocalFrame(Page& page, UniqueRef<LocalFrameLoaderClient>&& frameLoaderClient, FrameIdentifier identifier, HTMLFrameOwnerElement* ownerElement, Frame* parent, Frame* opener)
LocalFrame::LocalFrame(Page& page, ClientCreator&& clientCreator, FrameIdentifier identifier, HTMLFrameOwnerElement* ownerElement, Frame* parent, Frame* opener)
: Frame(page, identifier, FrameType::Local, ownerElement, parent, opener)
, m_loader(makeUniqueRef<FrameLoader>(*this, WTFMove(frameLoaderClient)))
, m_loader(makeUniqueRef<FrameLoader>(*this, clientCreator(*this)))
, m_script(makeUniqueRef<ScriptController>(*this))
, m_pageZoomFactor(parentPageZoomFactor(this))
, m_textZoomFactor(parentTextZoomFactor(this))
Expand Down Expand Up @@ -191,19 +191,19 @@ void LocalFrame::init()
checkedLoader()->init();
}

Ref<LocalFrame> LocalFrame::createMainFrame(Page& page, UniqueRef<LocalFrameLoaderClient>&& client, FrameIdentifier identifier, Frame* opener)
Ref<LocalFrame> LocalFrame::createMainFrame(Page& page, ClientCreator&& clientCreator, FrameIdentifier identifier, Frame* opener)
{
return adoptRef(*new LocalFrame(page, WTFMove(client), identifier, nullptr, nullptr, opener));
return adoptRef(*new LocalFrame(page, WTFMove(clientCreator), identifier, nullptr, nullptr, opener));
}

Ref<LocalFrame> LocalFrame::createSubframe(Page& page, UniqueRef<LocalFrameLoaderClient>&& client, FrameIdentifier identifier, HTMLFrameOwnerElement& ownerElement)
Ref<LocalFrame> LocalFrame::createSubframe(Page& page, ClientCreator&& clientCreator, FrameIdentifier identifier, HTMLFrameOwnerElement& ownerElement)
{
return adoptRef(*new LocalFrame(page, WTFMove(client), identifier, &ownerElement, ownerElement.document().frame(), nullptr));
return adoptRef(*new LocalFrame(page, WTFMove(clientCreator), identifier, &ownerElement, ownerElement.document().frame(), nullptr));
}

Ref<LocalFrame> LocalFrame::createSubframeHostedInAnotherProcess(Page& page, UniqueRef<LocalFrameLoaderClient>&& client, FrameIdentifier identifier, Frame& parent)
Ref<LocalFrame> LocalFrame::createSubframeHostedInAnotherProcess(Page& page, ClientCreator&& clientCreator, FrameIdentifier identifier, Frame& parent)
{
return adoptRef(*new LocalFrame(page, WTFMove(client), identifier, nullptr, &parent, nullptr));
return adoptRef(*new LocalFrame(page, WTFMove(clientCreator), identifier, nullptr, &parent, nullptr));
}

LocalFrame::~LocalFrame()
Expand Down
9 changes: 5 additions & 4 deletions Source/WebCore/page/LocalFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@ using NodeQualifier = Function<Node* (const HitTestResult&, Node* terminationNod

class LocalFrame final : public Frame {
public:
WEBCORE_EXPORT static Ref<LocalFrame> createMainFrame(Page&, UniqueRef<LocalFrameLoaderClient>&&, FrameIdentifier, Frame* opener);
WEBCORE_EXPORT static Ref<LocalFrame> createSubframe(Page&, UniqueRef<LocalFrameLoaderClient>&&, FrameIdentifier, HTMLFrameOwnerElement&);
WEBCORE_EXPORT static Ref<LocalFrame> createSubframeHostedInAnotherProcess(Page&, UniqueRef<LocalFrameLoaderClient>&&, FrameIdentifier, Frame& parent);
using ClientCreator = CompletionHandler<UniqueRef<LocalFrameLoaderClient>(LocalFrame&)>;
WEBCORE_EXPORT static Ref<LocalFrame> createMainFrame(Page&, ClientCreator&&, FrameIdentifier, Frame* opener);
WEBCORE_EXPORT static Ref<LocalFrame> createSubframe(Page&, ClientCreator&&, FrameIdentifier, HTMLFrameOwnerElement&);
WEBCORE_EXPORT static Ref<LocalFrame> createSubframeHostedInAnotherProcess(Page&, ClientCreator&&, FrameIdentifier, Frame& parent);

WEBCORE_EXPORT void init();
#if PLATFORM(IOS_FAMILY)
Expand Down Expand Up @@ -322,7 +323,7 @@ class LocalFrame final : public Frame {
private:
friend class NavigationDisabler;

LocalFrame(Page&, UniqueRef<LocalFrameLoaderClient>&&, FrameIdentifier, HTMLFrameOwnerElement*, Frame* parent, Frame* opener);
LocalFrame(Page&, ClientCreator&&, FrameIdentifier, HTMLFrameOwnerElement*, Frame* parent, Frame* opener);

void dropChildren();

Expand Down
28 changes: 11 additions & 17 deletions Source/WebCore/page/Page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,13 @@ static constexpr OptionSet<ActivityState> pageInitialActivityState()
return { ActivityState::IsVisible, ActivityState::IsInWindow };
}

static Ref<Frame> createMainFrame(Page& page, std::variant<UniqueRef<LocalFrameLoaderClient>, UniqueRef<RemoteFrameClient>>&& client, RefPtr<Frame> mainFrameOpener, FrameIdentifier identifier)
static Ref<Frame> createMainFrame(Page& page, PageConfiguration::ClientCreatorForMainFrame&& clientCreator, RefPtr<Frame> mainFrameOpener, FrameIdentifier identifier)
{
page.relaxAdoptionRequirement();
return switchOn(WTFMove(client), [&] (UniqueRef<LocalFrameLoaderClient>&& localFrameClient) -> Ref<Frame> {
return LocalFrame::createMainFrame(page, WTFMove(localFrameClient), identifier, mainFrameOpener.get());
}, [&] (UniqueRef<RemoteFrameClient>&& remoteFrameClient) -> Ref<Frame> {
return RemoteFrame::createMainFrame(page, WTFMove(remoteFrameClient), identifier, mainFrameOpener.get());
return switchOn(WTFMove(clientCreator), [&] (CompletionHandler<UniqueRef<LocalFrameLoaderClient>(LocalFrame&)>&& localFrameClientCreator) -> Ref<Frame> {
return LocalFrame::createMainFrame(page, WTFMove(localFrameClientCreator), identifier, mainFrameOpener.get());
}, [&] (CompletionHandler<UniqueRef<RemoteFrameClient>(RemoteFrame&)>&& remoteFrameClientCreator) -> Ref<Frame> {
return RemoteFrame::createMainFrame(page, WTFMove(remoteFrameClientCreator), identifier, mainFrameOpener.get());
});
}

Expand Down Expand Up @@ -327,7 +327,7 @@ Page::Page(PageConfiguration&& pageConfiguration)
, m_progress(makeUniqueRef<ProgressTracker>(*this, WTFMove(pageConfiguration.progressTrackerClient)))
, m_backForwardController(makeUniqueRef<BackForwardController>(*this, WTFMove(pageConfiguration.backForwardClient)))
, m_editorClient(WTFMove(pageConfiguration.editorClient))
, m_mainFrame(createMainFrame(*this, WTFMove(pageConfiguration.clientForMainFrame), WTFMove(pageConfiguration.mainFrameOpener), pageConfiguration.mainFrameIdentifier))
, m_mainFrame(createMainFrame(*this, WTFMove(pageConfiguration.clientCreatorForMainFrame), WTFMove(pageConfiguration.mainFrameOpener), pageConfiguration.mainFrameIdentifier))
, m_validationMessageClient(WTFMove(pageConfiguration.validationMessageClient))
, m_diagnosticLoggingClient(WTFMove(pageConfiguration.diagnosticLoggingClient))
, m_performanceLoggingClient(WTFMove(pageConfiguration.performanceLoggingClient))
Expand Down Expand Up @@ -750,22 +750,16 @@ void Page::setOpenedByDOM()
m_openedByDOM = true;
}

void Page::goToItem(HistoryItem& item, FrameLoadType type, ShouldTreatAsContinuingLoad shouldTreatAsContinuingLoad)
void Page::goToItem(LocalFrame& localMainFrame, HistoryItem& item, FrameLoadType type, ShouldTreatAsContinuingLoad shouldTreatAsContinuingLoad)
{
// stopAllLoaders may end up running onload handlers, which could cause further history traversals that may lead to the passed in HistoryItem
// being deref()-ed. Make sure we can still use it with HistoryController::goToItem later.
Ref protectedItem { item };

RefPtr localMainFrame = dynamicDowncast<LocalFrame>(m_mainFrame);
if (!localMainFrame)
return;

if (localMainFrame->checkedHistory()->shouldStopLoadingForHistoryItem(item)) {
if (localMainFrame)
localMainFrame->checkedLoader()->stopAllLoadersAndCheckCompleteness();
}

localMainFrame->checkedHistory()->goToItem(item, type, shouldTreatAsContinuingLoad);
ASSERT(localMainFrame.isMainFrame());
if (localMainFrame.checkedHistory()->shouldStopLoadingForHistoryItem(item))
localMainFrame.checkedLoader()->stopAllLoadersAndCheckCompleteness();
localMainFrame.checkedHistory()->goToItem(item, type, shouldTreatAsContinuingLoad);
}

void Page::setGroupName(const String& name)
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/page/Page.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ class Page : public RefCounted<Page>, public Supplementable<Page>, public CanMak
bool openedByDOMWithOpener() const { return m_openedByDOMWithOpener; }
void setOpenedByDOMWithOpener(bool value) { m_openedByDOMWithOpener = value; }

WEBCORE_EXPORT void goToItem(HistoryItem&, FrameLoadType, ShouldTreatAsContinuingLoad);
WEBCORE_EXPORT void goToItem(LocalFrame& localMainFrame, HistoryItem&, FrameLoadType, ShouldTreatAsContinuingLoad);

WEBCORE_EXPORT void setGroupName(const String&);
WEBCORE_EXPORT const String& groupName() const;
Expand Down
4 changes: 2 additions & 2 deletions Source/WebCore/page/PageConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ PageConfiguration::PageConfiguration(
Ref<BackForwardClient>&& backForwardClient,
Ref<CookieJar>&& cookieJar,
UniqueRef<ProgressTrackerClient>&& progressTrackerClient,
std::variant<UniqueRef<LocalFrameLoaderClient>, UniqueRef<RemoteFrameClient>>&& clientForMainFrame,
ClientCreatorForMainFrame&& clientCreatorForMainFrame,
FrameIdentifier mainFrameIdentifier,
RefPtr<Frame>&& mainFrameOpener,
UniqueRef<SpeechRecognitionProvider>&& speechRecognitionProvider,
Expand Down Expand Up @@ -115,7 +115,7 @@ PageConfiguration::PageConfiguration(
, progressTrackerClient(WTFMove(progressTrackerClient))
, backForwardClient(WTFMove(backForwardClient))
, cookieJar(WTFMove(cookieJar))
, clientForMainFrame(WTFMove(clientForMainFrame))
, clientCreatorForMainFrame(WTFMove(clientCreatorForMainFrame))
, mainFrameIdentifier(WTFMove(mainFrameIdentifier))
, mainFrameOpener(WTFMove(mainFrameOpener))
, cacheStorageProvider(WTFMove(cacheStorageProvider))
Expand Down
8 changes: 6 additions & 2 deletions Source/WebCore/page/PageConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "PageIdentifier.h"
#include "ShouldRelaxThirdPartyCookieBlocking.h"
#include <pal/SessionID.h>
#include <wtf/CompletionHandler.h>
#include <wtf/Forward.h>
#include <wtf/HashSet.h>
#include <wtf/Noncopyable.h>
Expand Down Expand Up @@ -74,6 +75,7 @@ class PaymentCoordinatorClient;
class PerformanceLoggingClient;
class PluginInfoProvider;
class ProgressTrackerClient;
class RemoteFrame;
class RemoteFrameClient;
class ScreenOrientationManager;
class SocketProvider;
Expand All @@ -91,6 +93,8 @@ class PageConfiguration {
WTF_MAKE_NONCOPYABLE(PageConfiguration); WTF_MAKE_FAST_ALLOCATED;
public:

using ClientCreatorForMainFrame = std::variant<CompletionHandler<UniqueRef<LocalFrameLoaderClient>(LocalFrame&)>, CompletionHandler<UniqueRef<RemoteFrameClient>(RemoteFrame&)>>;

WEBCORE_EXPORT PageConfiguration(
std::optional<PageIdentifier>,
PAL::SessionID,
Expand All @@ -102,7 +106,7 @@ class PageConfiguration {
Ref<BackForwardClient>&&,
Ref<CookieJar>&&,
UniqueRef<ProgressTrackerClient>&&,
std::variant<UniqueRef<LocalFrameLoaderClient>, UniqueRef<RemoteFrameClient>>&&,
ClientCreatorForMainFrame&&,
FrameIdentifier mainFrameIdentifier,
RefPtr<Frame>&& mainFrameOpener,
UniqueRef<SpeechRecognitionProvider>&&,
Expand Down Expand Up @@ -154,7 +158,7 @@ class PageConfiguration {
Ref<CookieJar> cookieJar;
std::unique_ptr<ValidationMessageClient> validationMessageClient;

std::variant<UniqueRef<LocalFrameLoaderClient>, UniqueRef<RemoteFrameClient>> clientForMainFrame;
ClientCreatorForMainFrame clientCreatorForMainFrame;

FrameIdentifier mainFrameIdentifier;
RefPtr<Frame> mainFrameOpener;
Expand Down
17 changes: 9 additions & 8 deletions Source/WebCore/page/RemoteFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,29 @@
#include "RemoteDOMWindow.h"
#include "RemoteFrameClient.h"
#include "RemoteFrameView.h"
#include <wtf/CompletionHandler.h>

namespace WebCore {

Ref<RemoteFrame> RemoteFrame::createMainFrame(Page& page, UniqueRef<RemoteFrameClient>&& client, FrameIdentifier identifier, Frame* opener)
Ref<RemoteFrame> RemoteFrame::createMainFrame(Page& page, ClientCreator&& clientCreator, FrameIdentifier identifier, Frame* opener)
{
return adoptRef(*new RemoteFrame(page, WTFMove(client), identifier, nullptr, nullptr, std::nullopt, opener));
return adoptRef(*new RemoteFrame(page, WTFMove(clientCreator), identifier, nullptr, nullptr, std::nullopt, opener));
}

Ref<RemoteFrame> RemoteFrame::createSubframe(Page& page, UniqueRef<RemoteFrameClient>&& client, FrameIdentifier identifier, Frame& parent)
Ref<RemoteFrame> RemoteFrame::createSubframe(Page& page, ClientCreator&& clientCreator, FrameIdentifier identifier, Frame& parent)
{
return adoptRef(*new RemoteFrame(page, WTFMove(client), identifier, nullptr, &parent, std::nullopt, nullptr));
return adoptRef(*new RemoteFrame(page, WTFMove(clientCreator), identifier, nullptr, &parent, std::nullopt, nullptr));
}

Ref<RemoteFrame> RemoteFrame::createSubframeWithContentsInAnotherProcess(Page& page, UniqueRef<RemoteFrameClient>&& client, FrameIdentifier identifier, HTMLFrameOwnerElement& ownerElement, std::optional<LayerHostingContextIdentifier> layerHostingContextIdentifier)
Ref<RemoteFrame> RemoteFrame::createSubframeWithContentsInAnotherProcess(Page& page, ClientCreator&& clientCreator, FrameIdentifier identifier, HTMLFrameOwnerElement& ownerElement, std::optional<LayerHostingContextIdentifier> layerHostingContextIdentifier)
{
return adoptRef(*new RemoteFrame(page, WTFMove(client), identifier, &ownerElement, ownerElement.document().frame(), layerHostingContextIdentifier, nullptr));
return adoptRef(*new RemoteFrame(page, WTFMove(clientCreator), identifier, &ownerElement, ownerElement.document().frame(), layerHostingContextIdentifier, nullptr));
}

RemoteFrame::RemoteFrame(Page& page, UniqueRef<RemoteFrameClient>&& client, FrameIdentifier frameID, HTMLFrameOwnerElement* ownerElement, Frame* parent, Markable<LayerHostingContextIdentifier> layerHostingContextIdentifier, Frame* opener)
RemoteFrame::RemoteFrame(Page& page, ClientCreator&& clientCreator, FrameIdentifier frameID, HTMLFrameOwnerElement* ownerElement, Frame* parent, Markable<LayerHostingContextIdentifier> layerHostingContextIdentifier, Frame* opener)
: Frame(page, frameID, FrameType::Remote, ownerElement, parent, opener)
, m_window(RemoteDOMWindow::create(*this, GlobalWindowIdentifier { Process::identifier(), WindowIdentifier::generate() }))
, m_client(WTFMove(client))
, m_client(clientCreator(*this))
, m_layerHostingContextIdentifier(layerHostingContextIdentifier)
{
setView(RemoteFrameView::create(*this));
Expand Down
9 changes: 5 additions & 4 deletions Source/WebCore/page/RemoteFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ enum class RenderAsTextFlag : uint16_t;

class RemoteFrame final : public Frame {
public:
WEBCORE_EXPORT static Ref<RemoteFrame> createMainFrame(Page&, UniqueRef<RemoteFrameClient>&&, FrameIdentifier, Frame* opener);
WEBCORE_EXPORT static Ref<RemoteFrame> createSubframe(Page&, UniqueRef<RemoteFrameClient>&&, FrameIdentifier, Frame& parent);
WEBCORE_EXPORT static Ref<RemoteFrame> createSubframeWithContentsInAnotherProcess(Page&, UniqueRef<RemoteFrameClient>&&, FrameIdentifier, HTMLFrameOwnerElement&, std::optional<LayerHostingContextIdentifier>);
using ClientCreator = CompletionHandler<UniqueRef<RemoteFrameClient>(RemoteFrame&)>;
WEBCORE_EXPORT static Ref<RemoteFrame> createMainFrame(Page&, ClientCreator&&, FrameIdentifier, Frame* opener);
WEBCORE_EXPORT static Ref<RemoteFrame> createSubframe(Page&, ClientCreator&&, FrameIdentifier, Frame& parent);
WEBCORE_EXPORT static Ref<RemoteFrame> createSubframeWithContentsInAnotherProcess(Page&, ClientCreator&&, FrameIdentifier, HTMLFrameOwnerElement&, std::optional<LayerHostingContextIdentifier>);
~RemoteFrame();

RemoteDOMWindow& window() const;
Expand All @@ -69,7 +70,7 @@ class RemoteFrame final : public Frame {
String customUserAgentAsSiteSpecificQuirks() const final;

private:
WEBCORE_EXPORT explicit RemoteFrame(Page&, UniqueRef<RemoteFrameClient>&&, FrameIdentifier, HTMLFrameOwnerElement*, Frame* parent, Markable<LayerHostingContextIdentifier>, Frame* opener);
WEBCORE_EXPORT explicit RemoteFrame(Page&, ClientCreator&&, FrameIdentifier, HTMLFrameOwnerElement*, Frame* parent, Markable<LayerHostingContextIdentifier>, Frame* opener);

void frameDetached() final;
bool preventsParentFromBeingComplete() const final;
Expand Down
Loading

0 comments on commit 6b90cc5

Please sign in to comment.