Implement shadow dom slots (#35013)

* Implement slot-related algorithms

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Hook up slot elements to DOM creation logic

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Set a slot assignment mode for servo-internal shadow roots

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Assign slots when a slottable's slot attribute changes

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Properly compute slot name

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* ./mach test-tidy

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Update <slot> name when name attribute changes

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Implement fast path for Node::assign_slottables_for_a_tree

assign_slottables_for_a_tree traverses all descendants of the node
and is potentially very expensive. If the node is not a shadow root
then assigning slottables to it won't have any effect, so we
take a fast path out.

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Move slottable data into ElementRareData

This shrinks all element descendants back to their
original size.

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Address review comments

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Update WPT expectations

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
Simon Wülker 2025-01-19 15:05:05 +01:00 committed by GitHub
parent 8bb50fa3c9
commit dabe162d44
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
31 changed files with 758 additions and 355 deletions

View file

@ -1,19 +1,4 @@
[HTMLSlotElement-interface.html]
[HTMLSlotElement must be defined on window]
expected: FAIL
["name" attribute on HTMLSlotElement must reflect "name" attribute]
expected: FAIL
[assignedNodes() on a HTMLSlotElement must return an empty array when the slot element is not in a tree or in a document tree]
expected: FAIL
[assignedNodes({"flattened":false}) on a HTMLSlotElement must return an empty array when the slot element is not in a tree or in a document tree]
expected: FAIL
[assignedNodes({"flattened":true}) on a HTMLSlotElement must return an empty array when the slot element is not in a tree or in a document tree]
expected: FAIL
[assignedNodes() must return the list of assigned nodes when none of the assigned nodes themselves are slots]
expected: FAIL
@ -32,15 +17,6 @@
[assignedNodes({"flattened":true}) must update when slot and name attributes are modified]
expected: FAIL
[assignedNodes() must update when a default slot is introduced dynamically by a slot rename]
expected: FAIL
[assignedNodes({"flattened":false}) must update when a default slot is introduced dynamically by a slot rename]
expected: FAIL
[assignedNodes({"flattened":true}) must update when a default slot is introduced dynamically by a slot rename]
expected: FAIL
[assignedNodes() must update when slot elements are inserted or removed]
expected: FAIL

View file

@ -1,12 +1,3 @@
[Slottable-mixin.html]
[assignedSlot attribute must be defined on Element and Text interfaces]
expected: FAIL
[assignedSlot must return null when the node does not have an assigned node]
expected: FAIL
[assignedSlot must return the assigned slot]
expected: FAIL
[assignedSlot must return null when the assigned slot element is inside a closed shadow tree]
expected: FAIL

View file

@ -1,33 +1,31 @@
[imperative-slot-api-slotchange.html]
expected: TIMEOUT
[slotchange event must not fire synchronously.]
expected: FAIL
[slotchange event should not fire when assignments do not change assignedNodes.]
expected: FAIL
expected: TIMEOUT
[slotchange event should not fire when same node is assigned.]
expected: FAIL
expected: TIMEOUT
[Fire slotchange event when slot's assigned nodes changes.]
expected: FAIL
expected: TIMEOUT
[Fire slotchange event on previous slot and new slot when node is reassigned.]
expected: FAIL
expected: TIMEOUT
[Fire slotchange event on node assignment and when assigned node is removed.]
expected: FAIL
expected: TIMEOUT
[Fire slotchange event when order of assigned nodes changes.]
expected: FAIL
expected: TIMEOUT
[Fire slotchange event when assigned node is removed.]
expected: FAIL
expected: TIMEOUT
[Fire slotchange event when removing a slot from Shadows Root that changes its assigned nodes.]
expected: FAIL
expected: NOTRUN
[Fire slotchange event when assign node to nested slot, ensure event bubbles ups.]
expected: FAIL
expected: TIMEOUT
[Signal a slot change should be done in tree order.]
expected: FAIL
expected: NOTRUN

View file

@ -1,22 +1,4 @@
[imperative-slot-api.html]
[attachShadow can take slotAssignment parameter.]
expected: FAIL
[slot.attach() should take variadic not sequence.]
expected: FAIL
[Imperative slot API can assign nodes in manual slot assignment.]
expected: FAIL
[Order of slottables is preserved in manual slot assignment.]
expected: FAIL
[Previously assigned slottable is moved to new slot when it's reassigned.]
expected: FAIL
[Order and assignment of nodes are preserved during multiple assignment in a row.]
expected: FAIL
[Assigning invalid nodes should be allowed.]
expected: FAIL
@ -29,15 +11,6 @@
[Appending slottable to different host, it loses slot assignment. It can be re-assigned within a new host.]
expected: FAIL
[Previously assigned node should not be assigned if slot moved to a new shadow root. The node is re-assigned when moved back.]
expected: FAIL
[Assignment with the same node in parameters should be ignored, first one wins.]
expected: FAIL
[Removing a slot from DOM resets its slottable's slot assignment.]
expected: FAIL
[Nodes can be assigned even if slots or nodes aren't in the same tree.]
expected: FAIL

View file

@ -1,6 +0,0 @@
[imperative-slot-initial-fallback.html]
[Unassigned imperative slot can render text node as the initial fallback]
expected: FAIL
[Unassigned imperative slot can render element as the initial fallback]
expected: FAIL

View file

@ -1,22 +1,4 @@
[slots-fallback.html]
[Slots fallback: Basic.]
expected: FAIL
[Slots fallback: Basic, elements only.]
expected: FAIL
[Slots fallback: Slots in Slots.]
expected: FAIL
[Slots fallback: Slots in Slots, elements only.]
expected: FAIL
[Slots fallback: Fallback contents should not be used if a node is assigned.]
expected: FAIL
[Slots fallback: Slots in Slots: Assigned nodes should be used as fallback contents of another slot]
expected: FAIL
[Slots fallback: Complex case.]
expected: FAIL

View file

@ -1,3 +0,0 @@
[slots-outside-shadow-dom.html]
[Light DOM slot element should be in flattened assignedNodes]
expected: FAIL

View file

@ -1,37 +1,4 @@
[slots.html]
[Slots: Basic.]
expected: FAIL
[Slots: Basic, elements only.]
expected: FAIL
[Slots: Slots in closed.]
expected: FAIL
[Slots: Slots in closed, elements only.]
expected: FAIL
[Slots: Slots not in a shadow tree.]
expected: FAIL
[Slots: Slots not in a shadow tree, elements only.]
expected: FAIL
[Slots: Distributed nodes for Slots not in a shadow tree.]
expected: FAIL
[Slots: Name matching]
expected: FAIL
[Slots: No direct host child.]
expected: FAIL
[Slots: Default Slot.]
expected: FAIL
[Slots: Slot in Slot does not matter in assignment.]
expected: FAIL
[Slots: Slot is assigned to another slot]
expected: FAIL
@ -50,21 +17,12 @@
[Slots: Mutation: appendChild.]
expected: FAIL
[Slots: Mutation: Change slot= attribute 1.]
expected: FAIL
[Slots: Mutation: Change slot= attribute 2.]
expected: FAIL
[Slots: Mutation: Change slot= attribute 3.]
expected: FAIL
[Slots: Mutation: Remove a child.]
expected: FAIL
[Slots: Mutation: Add a slot: after.]
expected: FAIL
[Slots: Mutation: Add a slot: before.]
expected: FAIL