mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-23 08:00:20 +00:00
LibWeb: Implement the 'Current {settings,global} object' concepts
This commit is contained in:
parent
bc1b33eb22
commit
db983b469d
Notes:
sideshowbarker
2024-07-17 22:55:25 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/db983b469d Pull-request: https://github.com/SerenityOS/serenity/pull/12919 Reviewed-by: https://github.com/awesomekling ✅
2 changed files with 24 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
|
||||
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -270,4 +271,24 @@ JS::GlobalObject& incumbent_global_object()
|
|||
return incumbent_settings_object().global_object();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#current-settings-object
|
||||
EnvironmentSettingsObject& current_settings_object()
|
||||
{
|
||||
auto& event_loop = HTML::main_thread_event_loop();
|
||||
auto& vm = event_loop.vm();
|
||||
|
||||
// Then, the current settings object is the environment settings object of the current Realm Record.
|
||||
return verify_cast<EnvironmentSettingsObject>(*vm.current_realm()->host_defined());
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#current-global-object
|
||||
JS::GlobalObject& current_global_object()
|
||||
{
|
||||
auto& event_loop = HTML::main_thread_event_loop();
|
||||
auto& vm = event_loop.vm();
|
||||
|
||||
// Similarly, the current global object is the global object of the current Realm Record.
|
||||
return vm.current_realm()->global_object();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
|
||||
* Copyright (c) 2022, Linus Groh <linusg@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -117,5 +118,7 @@ private:
|
|||
EnvironmentSettingsObject& incumbent_settings_object();
|
||||
JS::Realm& incumbent_realm();
|
||||
JS::GlobalObject& incumbent_global_object();
|
||||
EnvironmentSettingsObject& current_settings_object();
|
||||
JS::GlobalObject& current_global_object();
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue