mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-28 23:39:02 +00:00
LibWeb: Implement the 'Relevant realm/{settings,global} object' concepts
This commit is contained in:
parent
db983b469d
commit
11d0e37d8e
Notes:
sideshowbarker
2024-07-17 17:52:03 +09:00
Author: https://github.com/linusg
Commit: 11d0e37d8e
Pull-request: https://github.com/SerenityOS/serenity/pull/12919
Reviewed-by: https://github.com/awesomekling ✅
2 changed files with 25 additions and 0 deletions
|
@ -291,4 +291,25 @@ JS::GlobalObject& current_global_object()
|
|||
return vm.current_realm()->global_object();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#concept-relevant-realm
|
||||
JS::Realm& relevant_realm(JS::Object const& object)
|
||||
{
|
||||
// The relevant Realm for a platform object is the value of its [[Realm]] field.
|
||||
return *object.global_object().associated_realm();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#relevant-settings-object
|
||||
EnvironmentSettingsObject& relevant_settings_object(JS::Object const& object)
|
||||
{
|
||||
// Then, the relevant settings object for a platform object o is the environment settings object of the relevant Realm for o.
|
||||
return verify_cast<EnvironmentSettingsObject>(*relevant_realm(object).host_defined());
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#concept-relevant-global
|
||||
JS::GlobalObject& relevant_global_object(JS::Object const& object)
|
||||
{
|
||||
// Similarly, the relevant global object for a platform object o is the global object of the relevant Realm for o.
|
||||
return relevant_realm(object).global_object();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue