mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-06-18 15:52:21 +00:00
Represent WebIDL C++ types with a single CppType model that tracks nullability, optional presence, and contained storage. GC-like values now use GC::Ref/GC::Ptr directly, while containers choose "plain", "Root", or "Conservative" container types depending on what they contain. For example, sequence<Element> becomes a RootVector of GC::Ref values, while sequence<SomeDictionary> becomes a ConservativeVector only when the dictionary contains GC-like values. This moves the generated bindings away from wrapping GC values in GC::Root by default. This has broad fallout as the types passed to interfaces for GC objects changes almost fully across the board.
59 lines
1.8 KiB
C++
59 lines
1.8 KiB
C++
/*
|
|
* Copyright (c) 2020, the SerenityOS developers.
|
|
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Variant.h>
|
|
#include <AK/Vector.h>
|
|
#include <LibGC/ConservativeVector.h>
|
|
#include <LibGC/Root.h>
|
|
#include <LibWeb/Bindings/HTMLSlotElement.h>
|
|
#include <LibWeb/DOM/Slot.h>
|
|
#include <LibWeb/DOM/Slottable.h>
|
|
#include <LibWeb/HTML/HTMLElement.h>
|
|
|
|
namespace Web::HTML {
|
|
|
|
class HTMLSlotElement final
|
|
: public HTMLElement
|
|
, public DOM::Slot {
|
|
WEB_PLATFORM_OBJECT(HTMLSlotElement, HTMLElement);
|
|
GC_DECLARE_ALLOCATOR(HTMLSlotElement);
|
|
|
|
public:
|
|
virtual ~HTMLSlotElement() override;
|
|
|
|
Vector<GC::Root<DOM::Node>> assigned_nodes(Bindings::AssignedNodesOptions options = {}) const;
|
|
Vector<GC::Root<DOM::Element>> assigned_elements(Bindings::AssignedNodesOptions options = {}) const;
|
|
|
|
using SlottableHandle = Variant<GC::Ref<DOM::Element>, GC::Ref<DOM::Text>>;
|
|
void assign(GC::ConservativeVector<SlottableHandle> nodes);
|
|
|
|
ReadonlySpan<DOM::Slottable> manually_assigned_nodes() const { return m_manually_assigned_nodes; }
|
|
|
|
private:
|
|
HTMLSlotElement(DOM::Document&, DOM::QualifiedName);
|
|
|
|
virtual bool is_html_slot_element() const override { return true; }
|
|
|
|
virtual void initialize(JS::Realm&) override;
|
|
virtual void visit_edges(JS::Cell::Visitor&) override;
|
|
|
|
virtual void attribute_changed(FlyString const& name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_) override;
|
|
|
|
// https://html.spec.whatwg.org/multipage/scripting.html#manually-assigned-nodes
|
|
Vector<DOM::Slottable> m_manually_assigned_nodes;
|
|
};
|
|
|
|
}
|
|
|
|
namespace Web::DOM {
|
|
|
|
template<>
|
|
inline bool Node::fast_is<HTML::HTMLSlotElement>() const { return is_html_slot_element(); }
|
|
|
|
}
|