mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-14 02:10:36 +00:00
LibWeb: Implement element slot-related attributes and settings
This implements the element's slot attribute itself, and setting the slot assignment on the element's shadow root.
This commit is contained in:
parent
4e32f0d39f
commit
54b5a431a3
Notes:
sideshowbarker
2024-07-16 21:34:08 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/54b5a431a3 Pull-request: https://github.com/SerenityOS/serenity/pull/20965 Reviewed-by: https://github.com/Lubrsi Reviewed-by: https://github.com/shannonbooth
6 changed files with 12 additions and 4 deletions
|
@ -599,7 +599,8 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<ShadowRoot>> Element::attach_shadow(ShadowR
|
|||
if (m_custom_element_state == CustomElementState::Precustomized || m_custom_element_state == CustomElementState::Custom)
|
||||
shadow->set_available_to_element_internals(true);
|
||||
|
||||
// FIXME: 8. Set shadow’s slot assignment to init["slotAssignment"].
|
||||
// 8. Set shadow’s slot assignment to init["slotAssignment"].
|
||||
shadow->set_slot_assignment(init.slot_assignment);
|
||||
|
||||
// 9. Set this’s shadow root to shadow.
|
||||
set_shadow_root(shadow);
|
||||
|
|
|
@ -30,6 +30,7 @@ namespace Web::DOM {
|
|||
struct ShadowRootInit {
|
||||
Bindings::ShadowRootMode mode;
|
||||
bool delegates_focus = false;
|
||||
Bindings::SlotAssignmentMode slot_assignment { Bindings::SlotAssignmentMode::Named };
|
||||
};
|
||||
|
||||
// https://w3c.github.io/csswg-drafts/cssom-view-1/#dictdef-scrollintoviewoptions
|
||||
|
|
|
@ -49,6 +49,7 @@ interface Element : Node {
|
|||
[Reflect, CEReactions] attribute DOMString id;
|
||||
[Reflect=class, CEReactions] attribute DOMString className;
|
||||
[SameObject, PutForwards=value] readonly attribute DOMTokenList classList;
|
||||
[Reflect, CEReactions, Unscopable] attribute DOMString slot;
|
||||
|
||||
ShadowRoot attachShadow(ShadowRootInit init);
|
||||
readonly attribute ShadowRoot? shadowRoot;
|
||||
|
@ -90,7 +91,7 @@ interface Element : Node {
|
|||
dictionary ShadowRootInit {
|
||||
required ShadowRootMode mode;
|
||||
boolean delegatesFocus = false;
|
||||
// FIXME: SlotAssignmentMode slotAssignment = "named";
|
||||
SlotAssignmentMode slotAssignment = "named";
|
||||
};
|
||||
|
||||
Element includes ParentNode;
|
||||
|
|
|
@ -17,6 +17,9 @@ class ShadowRoot final : public DocumentFragment {
|
|||
public:
|
||||
Bindings::ShadowRootMode mode() const { return m_mode; }
|
||||
|
||||
Bindings::SlotAssignmentMode slot_assignment() const { return m_slot_assignment; }
|
||||
void set_slot_assignment(Bindings::SlotAssignmentMode slot_assignment) { m_slot_assignment = slot_assignment; }
|
||||
|
||||
bool delegates_focus() const { return m_delegates_focus; }
|
||||
void set_delegates_focus(bool delegates_focus) { m_delegates_focus = delegates_focus; }
|
||||
|
||||
|
@ -37,8 +40,9 @@ private:
|
|||
virtual DeprecatedFlyString node_name() const override { return "#shadow-root"; }
|
||||
virtual bool is_shadow_root() const final { return true; }
|
||||
|
||||
// NOTE: The specification doesn't seem to specify a default value for closed. Assuming closed for now.
|
||||
// NOTE: The specification doesn't seem to specify a default value for mode. Assuming closed for now.
|
||||
Bindings::ShadowRootMode m_mode { Bindings::ShadowRootMode::Closed };
|
||||
Bindings::SlotAssignmentMode m_slot_assignment { Bindings::SlotAssignmentMode::Named };
|
||||
bool m_delegates_focus { false };
|
||||
bool m_available_to_element_internals { false };
|
||||
};
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
interface ShadowRoot : DocumentFragment {
|
||||
readonly attribute ShadowRootMode mode;
|
||||
// FIXME: readonly attribute boolean delegatesFocus;
|
||||
// FIXME: readonly attribute SlotAssignmentMode slotAssignment;
|
||||
readonly attribute SlotAssignmentMode slotAssignment;
|
||||
readonly attribute Element host;
|
||||
// FIXME: attribute EventHandler onslotchange;
|
||||
};
|
||||
|
|
|
@ -214,6 +214,7 @@ namespace AttributeNames {
|
|||
__ENUMERATE_HTML_ATTRIBUTE(shape) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(size) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(sizes) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(slot) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(span) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(src) \
|
||||
__ENUMERATE_HTML_ATTRIBUTE(srcdoc) \
|
||||
|
|
Loading…
Reference in a new issue