ladybird/Userland/Libraries/LibWeb/HTML/Scripting/WorkerEnvironmentSettingsObject.h
Andreas Kling bfd354492e LibWeb: Put most LibWeb GC objects in type-specific heap blocks
With this change, we now have ~1200 CellAllocators across both LibJS and
LibWeb in a normal WebContent instance.

This gives us a minimum heap size of 4.7 MiB in the scenario where we
only have one cell allocated per type. Of course, in practice there will
be many more of each type, so the effective overhead is quite a bit
smaller than that in practice.

I left a few types unconverted to this mechanism because I got tired of
doing this. :^)
2023-11-19 22:00:48 +01:00

49 lines
1.7 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);
JS_DECLARE_ALLOCATOR(WorkerEnvironmentSettingsObject);
public:
WorkerEnvironmentSettingsObject(NonnullOwnPtr<JS::ExecutionContext> execution_context, JS::NonnullGCPtr<WorkerGlobalScope> global_scope)
: EnvironmentSettingsObject(move(execution_context))
, m_global_scope(global_scope)
{
}
static JS::NonnullGCPtr<WorkerEnvironmentSettingsObject> setup(NonnullOwnPtr<JS::ExecutionContext> execution_context /* FIXME: null or an environment reservedEnvironment, a URL topLevelCreationURL, and an origin topLevelOrigin */);
virtual ~WorkerEnvironmentSettingsObject() override = default;
JS::GCPtr<DOM::Document> responsible_document() override { return nullptr; }
DeprecatedString 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; }
PolicyContainer policy_container() override { return m_policy_container; }
CanUseCrossOriginIsolatedAPIs cross_origin_isolated_capability() override { return CanUseCrossOriginIsolatedAPIs::No; }
private:
virtual void visit_edges(JS::Cell::Visitor&) override;
DeprecatedString m_api_url_character_encoding;
AK::URL m_url;
HTML::Origin m_origin;
HTML::PolicyContainer m_policy_container;
JS::NonnullGCPtr<WorkerGlobalScope> m_global_scope;
};
}