mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:07:36 +00:00
LibWeb: Introduce the slot concept for HTML slot elements
A slot is an HTMLSlotElement. It may have any number of slottable nodes assigned to it.
This commit is contained in:
parent
45b36bd08a
commit
7870f10aa8
5 changed files with 71 additions and 1 deletions
36
Userland/Libraries/LibWeb/DOM/Slot.h
Normal file
36
Userland/Libraries/LibWeb/DOM/Slot.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <LibWeb/DOM/Slottable.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-slot
|
||||
class Slot {
|
||||
public:
|
||||
virtual ~Slot();
|
||||
|
||||
String const& slot_name() const { return m_name; } // Not called `name` to distinguish from `Element::name`.
|
||||
void set_slot_name(String name) { m_name = move(name); }
|
||||
|
||||
ReadonlySpan<DOM::Slottable> assigned_nodes_internal() const { return m_assigned_nodes; }
|
||||
void set_assigned_nodes(Vector<DOM::Slottable> assigned_nodes) { m_assigned_nodes = move(assigned_nodes); }
|
||||
|
||||
protected:
|
||||
void visit_edges(JS::Cell::Visitor&);
|
||||
|
||||
private:
|
||||
// https://dom.spec.whatwg.org/#slot-name
|
||||
String m_name;
|
||||
|
||||
// https://dom.spec.whatwg.org/#slot-assigned-nodes
|
||||
Vector<Slottable> m_assigned_nodes;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue