Truly independent web browser
/*
* Copyright (c) 2026, Tim Ledbetter <[email protected]>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Utf16View.h>
#include <AK/Vector.h>
#include <LibGC/Ptr.h>
#include <LibGC/Weak.h>
#include <LibWeb/Forward.h>
namespace Web::DOM {
class SlotRegistry {
public:
AK_ALLOC_WITH_KMALLOC;
void add(HTML::HTMLSlotElement&);
void remove(HTML::HTMLSlotElement&);
GC::Ptr<HTML::HTMLSlotElement> first_slot_with_name(Utf16View name) const;
template<typename Callback>
void for_each_slot(Callback callback)
{
if (is_empty())
return;
for (auto& slot : m_slots) {
if (slot)
callback(*slot);
}
}
bool is_empty() const;
private:
bool try_insert_in_tree_order(HTML::HTMLSlotElement&);
Vector<GC::Weak<HTML::HTMLSlotElement>> m_slots;
size_t m_slot_count { 0 };
};
}