mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:08:11 +00:00
LibWeb: Implement manual slottable assignment
This implements manual slottable assignment by way of HTMLSlotElement's `assign` API. This includes all of the slottable-related AOs needed to perform the assignment.
This commit is contained in:
parent
7870f10aa8
commit
e9da74ebe0
5 changed files with 254 additions and 1 deletions
|
@ -7,11 +7,19 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/Variant.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibJS/Heap/Handle.h>
|
||||
#include <LibWeb/DOM/Slot.h>
|
||||
#include <LibWeb/DOM/Slottable.h>
|
||||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
struct AssignedNodesOptions {
|
||||
bool flatten { false };
|
||||
};
|
||||
|
||||
class HTMLSlotElement final
|
||||
: public HTMLElement
|
||||
, public DOM::Slot {
|
||||
|
@ -20,11 +28,22 @@ class HTMLSlotElement final
|
|||
public:
|
||||
virtual ~HTMLSlotElement() override;
|
||||
|
||||
Vector<JS::Handle<DOM::Node>> assigned_nodes(AssignedNodesOptions options = {});
|
||||
Vector<JS::Handle<DOM::Element>> assigned_elements(AssignedNodesOptions options = {});
|
||||
|
||||
using SlottableHandle = Variant<JS::Handle<DOM::Element>, JS::Handle<DOM::Text>>;
|
||||
void assign(Vector<SlottableHandle> nodes);
|
||||
|
||||
ReadonlySpan<DOM::Slottable> manually_assigned_nodes() const { return m_manually_assigned_nodes; }
|
||||
|
||||
private:
|
||||
HTMLSlotElement(DOM::Document&, DOM::QualifiedName);
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(JS::Cell::Visitor&) override;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/scripting.html#manually-assigned-nodes
|
||||
Vector<DOM::Slottable> m_manually_assigned_nodes;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue