Created
November 12, 2023 23:26
-
-
Save awesomekling/e6396ae8bf7188f6955d4dec6e688371 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Userland/Libraries/LibJS/CyclicModule.cpp b/Userland/Libraries/LibJS/CyclicModule.cpp | |
index 4c4cbbc87b..6bcfff1f70 100644 | |
--- a/Userland/Libraries/LibJS/CyclicModule.cpp | |
+++ b/Userland/Libraries/LibJS/CyclicModule.cpp | |
@@ -17,11 +17,11 @@ namespace JS { | |
void GraphLoadingState::visit_edges(Cell::Visitor& visitor) | |
{ | |
+ Base::visit_edges(visitor); | |
visitor.visit(m_promise_capability); | |
for (auto const& visited_module : m_visited) | |
visitor.visit(visited_module); | |
- if (m_host_defined) | |
- m_host_defined->visit_edges(visitor); | |
+ visitor.visit(m_host_defined); | |
} | |
CyclicModule::CyclicModule(Realm& realm, StringView filename, bool has_top_level_await, Vector<ModuleRequest> requested_modules, Script::HostDefined* host_defined) | |
@@ -52,11 +52,11 @@ PromiseCapability& CyclicModule::load_requested_modules(JS::Realm& realm, GCPtr< | |
auto promise_capability = MUST(new_promise_capability(realm.vm(), realm.intrinsics().promise_constructor())); | |
// 3. Let state be the GraphLoadingState Record { [[IsLoading]]: true, [[PendingModulesCount]]: 1, [[Visited]]: « », [[PromiseCapability]]: pc, [[HostDefined]]: hostDefined }. | |
- auto state = GraphLoadingState(); | |
- state.set_is_loading(true); | |
- state.set_pending_module_count(1); | |
- state.set_promise_capability(promise_capability); | |
- state.set_host_defined(host_defined); | |
+ auto state = heap().allocate_without_realm<GraphLoadingState>(); | |
+ state->set_is_loading(true); | |
+ state->set_pending_module_count(1); | |
+ state->set_promise_capability(promise_capability); | |
+ state->set_host_defined(host_defined); | |
// 4. Perform InnerModuleLoading(state, module). | |
inner_module_loading(state); | |
diff --git a/Userland/Libraries/LibJS/CyclicModule.h b/Userland/Libraries/LibJS/CyclicModule.h | |
index fbeae47da5..97e8350d4e 100644 | |
--- a/Userland/Libraries/LibJS/CyclicModule.h | |
+++ b/Userland/Libraries/LibJS/CyclicModule.h | |
@@ -30,10 +30,10 @@ class GraphLoadingState : public Cell { | |
JS_CELL(GraphLoadingState, Cell); | |
public: | |
- struct HostDefined { | |
+ class HostDefined : public Cell { | |
+ JS_CELL(HostDefined, Cell); | |
+ public: | |
virtual ~HostDefined() = default; | |
- | |
- virtual void visit_edges(Cell::Visitor&) { } | |
}; | |
GCPtr<PromiseCapability> promise_capability() { return m_promise_capability; } | |
diff --git a/Userland/Libraries/LibJS/Module.cpp b/Userland/Libraries/LibJS/Module.cpp | |
index fb79aaf2ba..54eb2dc7ee 100644 | |
--- a/Userland/Libraries/LibJS/Module.cpp | |
+++ b/Userland/Libraries/LibJS/Module.cpp | |
@@ -70,7 +70,7 @@ ThrowCompletionOr<u32> Module::inner_module_evaluation(VM& vm, Vector<Module*>&, | |
// FIXME: We currently implement an outdated version of https://tc39.es/proposal-import-attributes, as such it is not possible to | |
// use the exact steps from https://tc39.es/proposal-import-attributes/#sec-HostLoadImportedModule here. | |
// FIXME: Support Realm for referrer. | |
-void finish_loading_imported_module(Realm& realm, ImportedModuleReferrer const& referrer, ModuleRequest const& module_request, ImportedModulePayload& payload, ThrowCompletionOr<NonnullGCPtr<Module>> const& result) | |
+void finish_loading_imported_module(Realm& realm, ImportedModuleReferrer const& referrer, ModuleRequest const& module_request, ImportedModulePayload payload, ThrowCompletionOr<NonnullGCPtr<Module>> const& result) | |
{ | |
dbgln("finish_loading_imported_module"); | |
diff --git a/Userland/Libraries/LibJS/Module.h b/Userland/Libraries/LibJS/Module.h | |
index da14243732..f703c081ae 100644 | |
--- a/Userland/Libraries/LibJS/Module.h | |
+++ b/Userland/Libraries/LibJS/Module.h | |
@@ -113,6 +113,6 @@ private: | |
class CyclicModule; | |
-void finish_loading_imported_module(Realm&, ImportedModuleReferrer const&, ModuleRequest const&, ImportedModulePayload&, ThrowCompletionOr<NonnullGCPtr<Module>> const&); | |
+void finish_loading_imported_module(Realm&, ImportedModuleReferrer const&, ModuleRequest const&, ImportedModulePayload, ThrowCompletionOr<NonnullGCPtr<Module>> const&); | |
} | |
diff --git a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp | |
index 733d68d414..0465486c74 100644 | |
--- a/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp | |
+++ b/Userland/Libraries/LibWeb/Bindings/MainThreadVM.cpp | |
@@ -491,7 +491,7 @@ ErrorOr<void> initialize_main_thread_vm() | |
fetch_client->realm_execution_context(); | |
} | |
- auto on_single_fetch_complete = HTML::create_on_fetch_script_complete(realm.heap(), [&referrer, &realm, &load_state, &module_request, &payload](JS::GCPtr<HTML::Script> const& module_script) -> void { | |
+ auto on_single_fetch_complete = HTML::create_on_fetch_script_complete(realm.heap(), [&referrer, &realm, load_state, &module_request, payload](JS::GCPtr<HTML::Script> const& module_script) -> void { | |
// onSingleFetchComplete given moduleScript is the following algorithm: | |
// 1. Let completion be null. | |
// NOTE: Our JS::Completion does not support non JS::Value types for its [[Value]], a such we | |
diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/Fetching.cpp b/Userland/Libraries/LibWeb/HTML/Scripting/Fetching.cpp | |
index cf289df998..9d77bc84d4 100644 | |
--- a/Userland/Libraries/LibWeb/HTML/Scripting/Fetching.cpp | |
+++ b/Userland/Libraries/LibWeb/HTML/Scripting/Fetching.cpp | |
@@ -694,7 +694,7 @@ void fetch_descendants_of_and_link_a_module_script(JS::Realm& realm, | |
dbgln("Creating a new FetchContext with fetch_client set to {}", &fetch_client); | |
// 3. Let state be Record { [[ParseError]]: null, [[Destination]]: destination, [[PerformFetch]]: null, [[FetchClient]]: fetchClient }. | |
- auto state = FetchContext { {}, destination, {}, fetch_client }; | |
+ auto state = realm.heap().allocate_without_realm<FetchContext>(JS::Value {}, destination, nullptr, fetch_client); | |
// FIXME: 4. If performFetch was given, set state.[[PerformFetch]] to performFetch. | |
@@ -732,8 +732,8 @@ void fetch_descendants_of_and_link_a_module_script(JS::Realm& realm, | |
WebIDL::upon_rejection(loading_promise, [&state, &module_script, on_complete](auto const&) -> WebIDL::ExceptionOr<JS::Value> { | |
// 1. If state.[[ParseError]] is not null, set moduleScript's error to rethrow to state.[[ParseError]] and run | |
// onComplete given moduleScript. | |
- if (state.has_parse_error()) { | |
- module_script.set_error_to_rethrow(state.parse_error()); | |
+ if (state->has_parse_error()) { | |
+ module_script.set_error_to_rethrow(state->parse_error()); | |
on_complete->function()(module_script); | |
} | |
diff --git a/Userland/Libraries/LibWeb/HTML/Scripting/Fetching.h b/Userland/Libraries/LibWeb/HTML/Scripting/Fetching.h | |
index 7d684b01de..c928409bd0 100644 | |
--- a/Userland/Libraries/LibWeb/HTML/Scripting/Fetching.h | |
+++ b/Userland/Libraries/LibWeb/HTML/Scripting/Fetching.h | |
@@ -46,9 +46,7 @@ struct ScriptFetchOptions { | |
// https://html.spec.whatwg.org/multipage/webappapis.html#default-classic-script-fetch-options | |
ScriptFetchOptions default_classic_script_fetch_options(); | |
-class FetchContext final | |
- : public JS::GraphLoadingState::HostDefined | |
- , public JS::Cell { | |
+class FetchContext final : public JS::GraphLoadingState::HostDefined { | |
JS_CELL(FetchContext, JS::GraphLoadingState::HostDefined); | |
public: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment