mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibWeb: Implement prepare_to_run_script on a Realm&
Making further progress porting away from depending on the EnvironmentSettingObject.
This commit is contained in:
parent
d6fdaf6b26
commit
8dffd8e7d6
Notes:
github-actions[bot]
2024-11-01 19:16:18 +00:00
Author: https://github.com/shannonbooth
Commit: 8dffd8e7d6
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1932
Reviewed-by: https://github.com/ADKaster ✅
10 changed files with 40 additions and 36 deletions
|
@ -88,8 +88,8 @@ JS::Completion ClassicScript::run(RethrowErrors rethrow_errors)
|
|||
if (can_run_script(realm) == RunScriptDecision::DoNotRun)
|
||||
return JS::normal_completion({});
|
||||
|
||||
// 3. Prepare to run script given settings.
|
||||
settings.prepare_to_run_script();
|
||||
// 3. Prepare to run script given realm.
|
||||
prepare_to_run_script(realm);
|
||||
|
||||
// 4. Let evaluationStatus be null.
|
||||
JS::Completion evaluation_status;
|
||||
|
|
|
@ -123,12 +123,15 @@ RunScriptDecision can_run_script(JS::Realm const& realm)
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#prepare-to-run-script
|
||||
void EnvironmentSettingsObject::prepare_to_run_script()
|
||||
// https://whatpr.org/html/9893/b8ea975...df5706b/webappapis.html#prepare-to-run-script
|
||||
void prepare_to_run_script(JS::Realm& realm)
|
||||
{
|
||||
// 1. Push settings's realm execution context onto the JavaScript execution context stack; it is now the running JavaScript execution context.
|
||||
global_object().vm().push_execution_context(realm_execution_context());
|
||||
// 1. Push realms's execution context onto the JavaScript execution context stack; it is now the running JavaScript execution context.
|
||||
realm.global_object().vm().push_execution_context(execution_context_of_realm(realm));
|
||||
|
||||
// FIXME: 2. Add settings to the currently running task's script evaluation environment settings object set.
|
||||
// FIXME: 2. If realm is a principal realm, then:
|
||||
// FIXME: 2.1 Let settings be realm's settings object.
|
||||
// FIXME: 2.2 Add settings to the currently running task's script evaluation environment settings object set.
|
||||
}
|
||||
|
||||
// https://whatpr.org/html/9893/b8ea975...df5706b/webappapis.html#concept-realm-execution-context
|
||||
|
|
|
@ -96,8 +96,6 @@ public:
|
|||
// https://fetch.spec.whatwg.org/#concept-fetch-group
|
||||
Vector<JS::NonnullGCPtr<Fetch::Infrastructure::FetchRecord>>& fetch_group() { return m_fetch_group; }
|
||||
|
||||
void prepare_to_run_script();
|
||||
|
||||
void prepare_to_run_callback();
|
||||
void clean_up_after_running_callback();
|
||||
|
||||
|
@ -137,10 +135,12 @@ private:
|
|||
};
|
||||
|
||||
JS::ExecutionContext const& execution_context_of_realm(JS::Realm const&);
|
||||
inline JS::ExecutionContext& execution_context_of_realm(JS::Realm& realm) { return const_cast<JS::ExecutionContext&>(execution_context_of_realm(const_cast<JS::Realm const&>(realm))); }
|
||||
|
||||
RunScriptDecision can_run_script(JS::Realm const&);
|
||||
bool is_scripting_enabled(JS::Realm const&);
|
||||
bool is_scripting_disabled(JS::Realm const&);
|
||||
void prepare_to_run_script(JS::Realm&);
|
||||
void clean_up_after_running_script(JS::Realm const&);
|
||||
|
||||
EnvironmentSettingsObject& incumbent_settings_object();
|
||||
|
|
|
@ -133,8 +133,8 @@ JS::Promise* JavaScriptModuleScript::run(PreventErrorReporting)
|
|||
return promise;
|
||||
}
|
||||
|
||||
// 3. Prepare to run script given settings.
|
||||
settings.prepare_to_run_script();
|
||||
// 3. Prepare to run script given realm.
|
||||
prepare_to_run_script(realm);
|
||||
|
||||
// 4. Let evaluationPromise be null.
|
||||
JS::Promise* evaluation_promise = nullptr;
|
||||
|
|
|
@ -13,7 +13,7 @@ TemporaryExecutionContext::TemporaryExecutionContext(EnvironmentSettingsObject&
|
|||
: m_environment_settings(environment_settings)
|
||||
, m_callbacks_enabled(callbacks_enabled)
|
||||
{
|
||||
m_environment_settings->prepare_to_run_script();
|
||||
prepare_to_run_script(m_environment_settings->realm());
|
||||
if (m_callbacks_enabled == CallbacksEnabled::Yes)
|
||||
m_environment_settings->prepare_to_run_callback();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue