1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:28:11 +00:00

LibWeb: Let Document have a direct GCPtr to its containing Web::Page

With this change, Document now always has a Web::Page. This means we no
longer rely on the breakable link between Document and BrowsingContext
to find a relevant Web::Page.

Fixes #22290
This commit is contained in:
Andreas Kling 2023-12-15 13:43:39 +01:00
parent b2b5297997
commit 70193c0009
12 changed files with 35 additions and 10 deletions

View file

@ -29,7 +29,7 @@ void WindowEnvironmentSettingsObject::visit_edges(JS::Cell::Visitor& visitor)
}
// https://html.spec.whatwg.org/multipage/window-object.html#set-up-a-window-environment-settings-object
void WindowEnvironmentSettingsObject::setup(AK::URL const& creation_url, NonnullOwnPtr<JS::ExecutionContext> execution_context, Optional<Environment> reserved_environment, AK::URL top_level_creation_url, Origin top_level_origin)
void WindowEnvironmentSettingsObject::setup(Page& page, AK::URL const& creation_url, NonnullOwnPtr<JS::ExecutionContext> execution_context, Optional<Environment> reserved_environment, AK::URL top_level_creation_url, Origin top_level_origin)
{
// 1. Let realm be the value of execution context's Realm component.
auto realm = execution_context->realm;
@ -74,7 +74,7 @@ void WindowEnvironmentSettingsObject::setup(AK::URL const& creation_url, Nonnull
// 7. Set realm's [[HostDefined]] field to settings object.
// Non-Standard: We store the ESO next to the web intrinsics in a custom HostDefined object
auto intrinsics = realm->heap().allocate<Bindings::Intrinsics>(*realm, *realm);
auto host_defined = make<Bindings::HostDefined>(settings_object, intrinsics);
auto host_defined = make<Bindings::HostDefined>(settings_object, intrinsics, page);
realm->set_host_defined(move(host_defined));
// Non-Standard: We cannot fully initialize window object until *after* the we set up

View file

@ -16,7 +16,7 @@ class WindowEnvironmentSettingsObject final : public EnvironmentSettingsObject {
JS_DECLARE_ALLOCATOR(WindowEnvironmentSettingsObject);
public:
static void setup(AK::URL const& creation_url, NonnullOwnPtr<JS::ExecutionContext>, Optional<Environment>, AK::URL top_level_creation_url, Origin top_level_origin);
static void setup(Page&, AK::URL const& creation_url, NonnullOwnPtr<JS::ExecutionContext>, Optional<Environment>, AK::URL top_level_creation_url, Origin top_level_origin);
virtual ~WindowEnvironmentSettingsObject() override;

View file

@ -11,7 +11,7 @@ namespace Web::HTML {
JS_DEFINE_ALLOCATOR(WorkerEnvironmentSettingsObject);
JS::NonnullGCPtr<WorkerEnvironmentSettingsObject> WorkerEnvironmentSettingsObject::setup(NonnullOwnPtr<JS::ExecutionContext> execution_context /* FIXME: null or an environment reservedEnvironment, a URL topLevelCreationURL, and an origin topLevelOrigin */)
JS::NonnullGCPtr<WorkerEnvironmentSettingsObject> WorkerEnvironmentSettingsObject::setup(JS::NonnullGCPtr<Page> page, NonnullOwnPtr<JS::ExecutionContext> execution_context /* FIXME: null or an environment reservedEnvironment, a URL topLevelCreationURL, and an origin topLevelOrigin */)
{
auto realm = execution_context->realm;
VERIFY(realm);
@ -22,7 +22,7 @@ JS::NonnullGCPtr<WorkerEnvironmentSettingsObject> WorkerEnvironmentSettingsObjec
settings_object->target_browsing_context = nullptr;
auto intrinsics = realm->heap().allocate<Bindings::Intrinsics>(*realm, *realm);
auto host_defined = make<Bindings::HostDefined>(settings_object, intrinsics);
auto host_defined = make<Bindings::HostDefined>(settings_object, intrinsics, page);
realm->set_host_defined(move(host_defined));
// Non-Standard: We cannot fully initialize worker object until *after* the we set up

View file

@ -24,7 +24,7 @@ public:
{
}
static JS::NonnullGCPtr<WorkerEnvironmentSettingsObject> setup(NonnullOwnPtr<JS::ExecutionContext> execution_context /* FIXME: null or an environment reservedEnvironment, a URL topLevelCreationURL, and an origin topLevelOrigin */);
static JS::NonnullGCPtr<WorkerEnvironmentSettingsObject> setup(JS::NonnullGCPtr<Page> page, NonnullOwnPtr<JS::ExecutionContext> execution_context /* FIXME: null or an environment reservedEnvironment, a URL topLevelCreationURL, and an origin topLevelOrigin */);
virtual ~WorkerEnvironmentSettingsObject() override = default;