LibWeb: Make a bunch of CSP classes not realm associated

These are not associated with a javascript realm, so to avoid
confusion about which realm these need to be created in, make
all of these objects a GC::Cell, and deal with the fallout.
This commit is contained in:
Shannon Booth 2025-04-26 11:35:51 +12:00 committed by Andreas Kling
commit 8a3c66d8a6
Notes: github-actions[bot] 2025-04-28 10:42:23 +00:00
20 changed files with 91 additions and 92 deletions

View file

@ -3858,9 +3858,9 @@ void Document::set_active_sandboxing_flag_set(HTML::SandboxingFlagSet sandboxing
GC::Ref<HTML::PolicyContainer> Document::policy_container() const
{
auto& realm = this->realm();
auto& heap = this->heap();
if (!m_policy_container) {
m_policy_container = realm.create<HTML::PolicyContainer>(realm);
m_policy_container = heap.allocate<HTML::PolicyContainer>(heap);
}
return *m_policy_container;
}
@ -3873,10 +3873,8 @@ void Document::set_policy_container(GC::Ref<HTML::PolicyContainer> policy_contai
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#snapshotting-source-snapshot-params
GC::Ref<HTML::SourceSnapshotParams> Document::snapshot_source_snapshot_params() const
{
auto& realm = this->realm();
// To snapshot source snapshot params given a Document sourceDocument, return a new source snapshot params with
return realm.create<HTML::SourceSnapshotParams>(
return heap().allocate<HTML::SourceSnapshotParams>(
// has transient activation
// true if sourceDocument's relevant global object has transient activation; otherwise false
as<HTML::Window>(HTML::relevant_global_object(*this)).has_transient_activation(),
@ -3895,7 +3893,7 @@ GC::Ref<HTML::SourceSnapshotParams> Document::snapshot_source_snapshot_params()
// source policy container
// a clone of sourceDocument's policy container
policy_container()->clone(realm));
policy_container()->clone(heap()));
}
// https://html.spec.whatwg.org/multipage/document-sequences.html#descendant-navigables

View file

@ -22,7 +22,6 @@ GC::Ref<DOM::Document> create_document_for_inline_content(GC::Ptr<HTML::Navigabl
{
auto& vm = navigable->vm();
VERIFY(navigable->active_document());
auto& realm = navigable->active_document()->realm();
// 1. Let origin be a new opaque origin.
URL::Origin origin {};
@ -59,7 +58,7 @@ GC::Ref<DOM::Document> create_document_for_inline_content(GC::Ptr<HTML::Navigabl
auto response = Fetch::Infrastructure::Response::create(vm);
response->url_list().append(URL::about_error()); // AD-HOC: https://github.com/whatwg/html/issues/9122
auto navigation_params = vm.heap().allocate<HTML::NavigationParams>();
navigation_params->id = navigation_id;
navigation_params->id = move(navigation_id);
navigation_params->navigable = navigable;
navigation_params->request = nullptr;
navigation_params->response = response;
@ -68,7 +67,7 @@ GC::Ref<DOM::Document> create_document_for_inline_content(GC::Ptr<HTML::Navigabl
navigation_params->coop_enforcement_result = move(coop_enforcement_result);
navigation_params->reserved_environment = {};
navigation_params->origin = move(origin);
navigation_params->policy_container = vm.heap().allocate<HTML::PolicyContainer>(realm);
navigation_params->policy_container = vm.heap().allocate<HTML::PolicyContainer>(vm.heap());
navigation_params->final_sandboxing_flag_set = HTML::SandboxingFlagSet {};
navigation_params->opener_policy = move(coop);
navigation_params->about_base_url = {};