1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 16:37:47 +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

@ -14,9 +14,10 @@
namespace Web::Bindings {
struct HostDefined : public JS::Realm::HostDefined {
HostDefined(JS::NonnullGCPtr<HTML::EnvironmentSettingsObject> eso, JS::NonnullGCPtr<Intrinsics> intrinsics)
HostDefined(JS::NonnullGCPtr<HTML::EnvironmentSettingsObject> eso, JS::NonnullGCPtr<Intrinsics> intrinsics, JS::NonnullGCPtr<Page> page)
: environment_settings_object(eso)
, intrinsics(intrinsics)
, page(page)
{
}
virtual ~HostDefined() override = default;
@ -24,6 +25,7 @@ struct HostDefined : public JS::Realm::HostDefined {
JS::NonnullGCPtr<HTML::EnvironmentSettingsObject> environment_settings_object;
JS::NonnullGCPtr<Intrinsics> intrinsics;
JS::NonnullGCPtr<Page> page;
};
[[nodiscard]] inline HTML::EnvironmentSettingsObject& host_defined_environment_settings_object(JS::Realm& realm)
@ -31,4 +33,9 @@ struct HostDefined : public JS::Realm::HostDefined {
return *verify_cast<HostDefined>(realm.host_defined())->environment_settings_object;
}
[[nodiscard]] inline Page& host_defined_page(JS::Realm& realm)
{
return *verify_cast<HostDefined>(realm.host_defined())->page;
}
}