LibWeb: Make TemporaryExecutionContext take a Realm&

This commit is contained in:
Shannon Booth 2024-10-24 20:39:18 +13:00 committed by Andrew Kaster
parent f7a4d94b24
commit cc91473f4d
Notes: github-actions[bot] 2024-11-02 00:56:36 +00:00
34 changed files with 106 additions and 107 deletions

View file

@ -18,7 +18,7 @@ namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/webappapis.html#parse-an-import-map-string
WebIDL::ExceptionOr<ImportMap> parse_import_map_string(JS::Realm& realm, ByteString const& input, URL::URL base_url)
{
HTML::TemporaryExecutionContext execution_context { Bindings::host_defined_environment_settings_object(realm) };
HTML::TemporaryExecutionContext execution_context { realm };
// 1. Let parsed be the result of parsing a JSON string to an Infra value given input.
auto parsed = TRY(Infra::parse_json_string_to_javascript_value(realm, input));

View file

@ -9,20 +9,20 @@
namespace Web::HTML {
TemporaryExecutionContext::TemporaryExecutionContext(EnvironmentSettingsObject& environment_settings, CallbacksEnabled callbacks_enabled)
: m_environment_settings(environment_settings)
TemporaryExecutionContext::TemporaryExecutionContext(JS::Realm& realm, CallbacksEnabled callbacks_enabled)
: m_realm(realm)
, m_callbacks_enabled(callbacks_enabled)
{
prepare_to_run_script(m_environment_settings->realm());
prepare_to_run_script(m_realm);
if (m_callbacks_enabled == CallbacksEnabled::Yes)
prepare_to_run_callback(m_environment_settings->realm());
prepare_to_run_callback(m_realm);
}
TemporaryExecutionContext::~TemporaryExecutionContext()
{
clean_up_after_running_script(m_environment_settings->realm());
clean_up_after_running_script(m_realm);
if (m_callbacks_enabled == CallbacksEnabled::Yes)
clean_up_after_running_callback(m_environment_settings->realm());
clean_up_after_running_callback(m_realm);
}
}

View file

@ -21,11 +21,11 @@ public:
Yes,
};
explicit TemporaryExecutionContext(EnvironmentSettingsObject&, CallbacksEnabled = CallbacksEnabled::No);
explicit TemporaryExecutionContext(JS::Realm&, CallbacksEnabled = CallbacksEnabled::No);
~TemporaryExecutionContext();
private:
JS::NonnullGCPtr<EnvironmentSettingsObject> m_environment_settings;
JS::NonnullGCPtr<JS::Realm> m_realm;
CallbacksEnabled m_callbacks_enabled { CallbacksEnabled::No };
};