mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09:00
LibWeb: Add scaffold for for "execution context of a realm"
Alongside some const qualfied getters that this requires.
This commit is contained in:
parent
aef18435fb
commit
0628b74272
Notes:
github-actions[bot]
2024-11-01 19:16:30 +00:00
Author: https://github.com/shannonbooth
Commit: 0628b74272
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1932
Reviewed-by: https://github.com/ADKaster ✅
4 changed files with 25 additions and 0 deletions
|
@ -48,6 +48,8 @@ public:
|
|||
}
|
||||
|
||||
HostDefined* host_defined() { return m_host_defined; }
|
||||
HostDefined const* host_defined() const { return m_host_defined; }
|
||||
|
||||
void set_host_defined(OwnPtr<HostDefined> host_defined) { m_host_defined = move(host_defined); }
|
||||
|
||||
void define_builtin(Bytecode::Builtin builtin, NonnullGCPtr<NativeFunction> value)
|
||||
|
|
|
@ -33,6 +33,11 @@ struct HostDefined : public JS::Realm::HostDefined {
|
|||
return *verify_cast<HostDefined>(realm.host_defined())->environment_settings_object;
|
||||
}
|
||||
|
||||
[[nodiscard]] inline HTML::EnvironmentSettingsObject const& host_defined_environment_settings_object(JS::Realm const& realm)
|
||||
{
|
||||
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;
|
||||
|
|
|
@ -65,6 +65,12 @@ JS::ExecutionContext& EnvironmentSettingsObject::realm_execution_context()
|
|||
return *m_realm_execution_context;
|
||||
}
|
||||
|
||||
JS::ExecutionContext const& EnvironmentSettingsObject::realm_execution_context() const
|
||||
{
|
||||
// NOTE: All environment settings objects are created with a realm execution context, so it's stored and returned here in the base class.
|
||||
return *m_realm_execution_context;
|
||||
}
|
||||
|
||||
ModuleMap& EnvironmentSettingsObject::module_map()
|
||||
{
|
||||
return *m_module_map;
|
||||
|
@ -124,6 +130,15 @@ void EnvironmentSettingsObject::prepare_to_run_script()
|
|||
// FIXME: 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
|
||||
JS::ExecutionContext const& execution_context_of_realm(JS::Realm const& realm)
|
||||
{
|
||||
// FIXME: 1. If realm is a principal realm, then return the realm execution context of the environment settings object of realm.
|
||||
// FIXME: 2. Assert: realm is a synthetic realm.
|
||||
// FIXME: 3. Return the execution context of the synthetic realm settings object of realm.
|
||||
return Bindings::host_defined_environment_settings_object(realm).realm_execution_context();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#clean-up-after-running-script
|
||||
void EnvironmentSettingsObject::clean_up_after_running_script()
|
||||
{
|
||||
|
|
|
@ -63,6 +63,7 @@ public:
|
|||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#concept-environment-target-browsing-context
|
||||
JS::ExecutionContext& realm_execution_context();
|
||||
JS::ExecutionContext const& realm_execution_context() const;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#concept-settings-object-module-map
|
||||
ModuleMap& module_map();
|
||||
|
@ -135,6 +136,8 @@ private:
|
|||
bool m_discarded { false };
|
||||
};
|
||||
|
||||
JS::ExecutionContext const& execution_context_of_realm(JS::Realm const&);
|
||||
|
||||
RunScriptDecision can_run_script(JS::Realm const&);
|
||||
bool is_scripting_enabled(JS::Realm const&);
|
||||
bool is_scripting_disabled(JS::Realm const&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue