diff options
author | Andreas Kling <kling@serenityos.org> | 2022-08-04 21:30:33 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-08-05 12:46:40 +0200 |
commit | 602f927982dc7a1a824c8b85ba7075482a4d170e (patch) | |
tree | 9d5210ea51d64e5deab7bba69e6405e364c28ad2 /Userland/Libraries/LibWeb/HTML/Worker.cpp | |
parent | 0781bdb23e43412a3e591a9574bdee5c17364aa4 (diff) | |
download | serenity-602f927982dc7a1a824c8b85ba7075482a4d170e.zip |
LibWeb: Start implementing "create and initialize a Document" from HTML
The way we've been creating DOM::Document has been pretty far from what
the spec tells us to do, and this is a first big step towards getting us
closer to spec.
The new Document::create_and_initialize() is called by FrameLoader after
loading a "text/html" resource.
We create the JS Realm and the Window object when creating the Document
(previously, we'd do it on first access to Document::interpreter().)
The realm execution context is owned by the Environment Settings Object.
Diffstat (limited to 'Userland/Libraries/LibWeb/HTML/Worker.cpp')
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/Worker.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/Worker.cpp b/Userland/Libraries/LibWeb/HTML/Worker.cpp index 55cebc5afd..f8ee7b36b7 100644 --- a/Userland/Libraries/LibWeb/HTML/Worker.cpp +++ b/Userland/Libraries/LibWeb/HTML/Worker.cpp @@ -24,7 +24,6 @@ Worker::Worker(FlyString const& script_url, WorkerOptions const options, DOM::Do , m_worker_vm(JS::VM::create(adopt_own(m_custom_data))) , m_interpreter(JS::Interpreter::create<JS::GlobalObject>(m_worker_vm)) , m_interpreter_scope(*m_interpreter) - , m_execution_context(m_worker_vm->heap()) , m_implicit_port(MessagePort::create()) { } @@ -153,22 +152,23 @@ void Worker::run_a_worker(AK::URL& url, EnvironmentSettingsObject& outside_setti // FIXME: This is because I don't know all the libraries well enough to properly setup the environment to spec // let alone making it a parallel implementation. - m_execution_context.current_node = nullptr; - m_execution_context.this_value = m_worker_scope; - m_execution_context.function_name = "(global execution context)"sv; - m_execution_context.lexical_environment = &m_worker_realm->global_environment(); - m_execution_context.variable_environment = &m_worker_realm->global_environment(); - m_execution_context.realm = m_worker_realm; + auto execution_context = make<JS::ExecutionContext>(m_worker_vm->heap()); + execution_context->current_node = nullptr; + execution_context->this_value = m_worker_scope; + execution_context->function_name = "(global execution context)"sv; + execution_context->lexical_environment = &m_worker_realm->global_environment(); + execution_context->variable_environment = &m_worker_realm->global_environment(); + execution_context->realm = m_worker_realm; - m_worker_vm->push_execution_context(m_execution_context); - m_worker_realm->set_global_object(*m_worker_scope, m_worker_scope); + m_worker_vm->push_execution_context(*execution_context); + m_worker_realm->set_global_object(m_worker_scope, m_worker_scope); // 8. Let worker global scope be the global object of realm execution context's Realm component. // NOTE: This is the DedicatedWorkerGlobalScope or SharedWorkerGlobalScope object created in the previous step. // 9. Set up a worker environment settings object with realm execution context, // outside settings, and unsafeWorkerCreationTime, and let inside settings be the result. - m_inner_settings = WorkerEnvironmentSettingsObject::setup(*m_document, m_execution_context); + m_inner_settings = WorkerEnvironmentSettingsObject::setup(*m_document, move(execution_context)); // 10. Set worker global scope's name to the value of options's name member. // FIXME: name property requires the SharedWorkerGlobalScope or DedicatedWorkerGlobalScope child class to be used |