mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 16:07:45 +00:00
LibJS: Let Shape store a Realm instead of a GlobalObject
This is a cautious first step towards being able to create JS objects before a global object has been instantiated.
This commit is contained in:
parent
7a6935a2ff
commit
50d951aea2
22 changed files with 104 additions and 55 deletions
|
@ -14,8 +14,9 @@
|
|||
|
||||
namespace WebContent {
|
||||
|
||||
ConsoleGlobalObject::ConsoleGlobalObject(Web::Bindings::WindowObject& parent_object)
|
||||
: m_window_object(&parent_object)
|
||||
ConsoleGlobalObject::ConsoleGlobalObject(JS::Realm& realm, Web::Bindings::WindowObject& parent_object)
|
||||
: GlobalObject(realm)
|
||||
, m_window_object(&parent_object)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ class ConsoleGlobalObject final : public JS::GlobalObject {
|
|||
JS_OBJECT(ConsoleGlobalObject, JS::GlobalObject);
|
||||
|
||||
public:
|
||||
ConsoleGlobalObject(Web::Bindings::WindowObject&);
|
||||
ConsoleGlobalObject(JS::Realm&, Web::Bindings::WindowObject&);
|
||||
virtual ~ConsoleGlobalObject() override = default;
|
||||
|
||||
virtual JS::ThrowCompletionOr<Object*> internal_get_prototype_of() const override;
|
||||
|
|
|
@ -26,12 +26,13 @@ WebContentConsoleClient::WebContentConsoleClient(JS::Console& console, WeakPtr<J
|
|||
auto& vm = m_interpreter->vm();
|
||||
auto& global_object = m_interpreter->global_object();
|
||||
|
||||
auto console_global_object = m_interpreter->heap().allocate_without_global_object<ConsoleGlobalObject>(static_cast<Web::Bindings::WindowObject&>(global_object));
|
||||
auto console_global_object = m_interpreter->heap().allocate_without_global_object<ConsoleGlobalObject>(m_interpreter->realm(), static_cast<Web::Bindings::WindowObject&>(global_object));
|
||||
|
||||
// NOTE: We need to push an execution context here for NativeFunction::create() to succeed during global object initialization.
|
||||
// It gets removed immediately after creating the interpreter in Document::interpreter().
|
||||
auto& eso = verify_cast<Web::HTML::EnvironmentSettingsObject>(*m_interpreter->realm().host_defined());
|
||||
vm.push_execution_context(eso.realm_execution_context());
|
||||
console_global_object->set_associated_realm(m_interpreter->realm());
|
||||
console_global_object->initialize_global_object();
|
||||
vm.pop_execution_context();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue