1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:28:11 +00:00

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.
This commit is contained in:
Andreas Kling 2022-08-04 21:30:33 +02:00
parent 0781bdb23e
commit 602f927982
13 changed files with 315 additions and 78 deletions

View file

@ -18,17 +18,17 @@ class WorkerEnvironmentSettingsObject final
: public EnvironmentSettingsObject
, public Weakable<WorkerEnvironmentSettingsObject> {
public:
WorkerEnvironmentSettingsObject(DOM::Document& document, JS::ExecutionContext& execution_context)
: EnvironmentSettingsObject(execution_context)
WorkerEnvironmentSettingsObject(DOM::Document& document, NonnullOwnPtr<JS::ExecutionContext> execution_context)
: EnvironmentSettingsObject(move(execution_context))
, m_document(document)
{
}
static WeakPtr<WorkerEnvironmentSettingsObject> setup(DOM::Document& document, JS::ExecutionContext& execution_context /* FIXME: null or an environment reservedEnvironment, a URL topLevelCreationURL, and an origin topLevelOrigin */)
static WeakPtr<WorkerEnvironmentSettingsObject> setup(DOM::Document& document, NonnullOwnPtr<JS::ExecutionContext> execution_context /* FIXME: null or an environment reservedEnvironment, a URL topLevelCreationURL, and an origin topLevelOrigin */)
{
auto* realm = execution_context.realm;
auto* realm = execution_context->realm;
VERIFY(realm);
auto settings_object = adopt_own(*new WorkerEnvironmentSettingsObject(document, execution_context));
auto settings_object = adopt_own(*new WorkerEnvironmentSettingsObject(document, move(execution_context)));
settings_object->target_browsing_context = nullptr;
realm->set_host_defined(move(settings_object));