
This Intrinsics object hangs off of a new HostDefined struct that takes the place of EnvironmentSettingsObject as the true [[HostDefined]] slot on JS::Realm objects created by LibWeb. This gets the intrinsics off of the GlobalObject, Window, similar to the previous refactor of LibJS to move the intrinsics into the Realm's [[Intrinics]] internal slot. A side effect of this change is that we cannot fully initialize a Window object until the [[HostDefined]] slot has been installed into the realm, which happens with the creation of the WindowEnvironmentSettingsObject. As such, any Window usage that has not been funned through a WindowESO will not have any cached Web prototyped or constructors, and will not have Window APIs available to javascript code. Currently this seems limited to usage of Window in the CSS parser, but a subsequent commit will clean those up to take Realm as well. However, this commit compiles so let's cut it off here :^).
53 lines
1.8 KiB
C++
53 lines
1.8 KiB
C++
/*
|
|
* Copyright (c) 2022, Ben Abraham <ben.d.abraham@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/URL.h>
|
|
#include <LibWeb/DOM/Document.h>
|
|
#include <LibWeb/Forward.h>
|
|
|
|
namespace Web::HTML {
|
|
|
|
class WorkerEnvironmentSettingsObject final
|
|
: public EnvironmentSettingsObject {
|
|
JS_CELL(WindowEnvironmentSettingsObject, EnvironmentSettingsObject);
|
|
|
|
public:
|
|
WorkerEnvironmentSettingsObject(NonnullOwnPtr<JS::ExecutionContext> execution_context)
|
|
: EnvironmentSettingsObject(move(execution_context))
|
|
{
|
|
}
|
|
|
|
static JS::NonnullGCPtr<WorkerEnvironmentSettingsObject> setup(NonnullOwnPtr<JS::ExecutionContext> execution_context /* FIXME: null or an environment reservedEnvironment, a URL topLevelCreationURL, and an origin topLevelOrigin */)
|
|
{
|
|
auto* realm = execution_context->realm;
|
|
VERIFY(realm);
|
|
auto settings_object = realm->heap().allocate<WorkerEnvironmentSettingsObject>(*realm, move(execution_context));
|
|
settings_object->target_browsing_context = nullptr;
|
|
|
|
auto* intrinsics = realm->heap().allocate<Bindings::Intrinsics>(*realm, *realm);
|
|
auto host_defined = make<Bindings::HostDefined>(*settings_object, *intrinsics);
|
|
realm->set_host_defined(move(host_defined));
|
|
|
|
return *settings_object;
|
|
}
|
|
|
|
virtual ~WorkerEnvironmentSettingsObject() override = default;
|
|
|
|
JS::GCPtr<DOM::Document> responsible_document() override { return nullptr; }
|
|
String api_url_character_encoding() override { return m_api_url_character_encoding; }
|
|
AK::URL api_base_url() override { return m_url; }
|
|
Origin origin() override { return m_origin; }
|
|
CanUseCrossOriginIsolatedAPIs cross_origin_isolated_capability() override { TODO(); }
|
|
|
|
private:
|
|
String m_api_url_character_encoding;
|
|
AK::URL m_url;
|
|
HTML::Origin m_origin;
|
|
};
|
|
|
|
}
|