ladybird/Userland/Libraries/LibWeb/HTML/BrowsingContextGroup.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.3 KiB
C++

/*
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/HashMap.h>
#include <AK/NonnullRefPtr.h>
#include <AK/WeakPtr.h>
#include <LibJS/Heap/Cell.h>
#include <LibWeb/Forward.h>
namespace Web::HTML {
class BrowsingContextGroup final : public JS::Cell {
JS_CELL(BrowsingContextGroup, JS::Cell);
JS_DECLARE_ALLOCATOR(BrowsingContextGroup);
public:
struct BrowsingContextGroupAndDocument {
JS::NonnullGCPtr<HTML::BrowsingContextGroup> browsing_context;
JS::NonnullGCPtr<DOM::Document> document;
};
static WebIDL::ExceptionOr<BrowsingContextGroupAndDocument> create_a_new_browsing_context_group_and_document(Page&);
~BrowsingContextGroup();
Page* page() { return m_page; }
Page const* page() const { return m_page; }
auto& browsing_context_set() { return m_browsing_context_set; }
auto const& browsing_context_set() const { return m_browsing_context_set; }
void append(BrowsingContext&);
private:
explicit BrowsingContextGroup(Web::Page&);
virtual void visit_edges(Cell::Visitor&) override;
// https://html.spec.whatwg.org/multipage/browsers.html#browsing-context-group-set
OrderedHashTable<JS::NonnullGCPtr<BrowsingContext>> m_browsing_context_set;
WeakPtr<Page> m_page;
};
}