mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 21:59:07 +00:00
LibWeb: Pass old parent's root to Node::removed_from()
This will allow nodes to access the root they've just been removed from.
This commit is contained in:
parent
d465e2aa2b
commit
7269fc3e52
Notes:
github-actions[bot]
2025-01-23 20:40:20 +00:00
Author: https://github.com/awesomekling
Commit: 7269fc3e52
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3345
Reviewed-by: https://github.com/AtkinsSJ
39 changed files with 65 additions and 60 deletions
|
@ -906,9 +906,11 @@ void Node::remove(bool suppress_observers)
|
|||
if (auto assigned_slot = assigned_slot_for_node(*this))
|
||||
assign_slottables(*assigned_slot);
|
||||
|
||||
auto& parent_root = parent->root();
|
||||
|
||||
// 13. If parent’s root is a shadow root, and parent is a slot whose assigned nodes is the empty list, then run
|
||||
// signal a slot change for parent.
|
||||
if (parent->root().is_shadow_root() && is<HTML::HTMLSlotElement>(parent)) {
|
||||
if (parent_root.is_shadow_root() && is<HTML::HTMLSlotElement>(parent)) {
|
||||
auto& slot = static_cast<HTML::HTMLSlotElement&>(*parent);
|
||||
|
||||
if (slot.assigned_nodes_internal().is_empty())
|
||||
|
@ -925,14 +927,14 @@ void Node::remove(bool suppress_observers)
|
|||
|
||||
if (has_descendent_slot) {
|
||||
// 1. Run assign slottables for a tree with parent’s root.
|
||||
assign_slottables_for_a_tree(parent->root());
|
||||
assign_slottables_for_a_tree(parent_root);
|
||||
|
||||
// 2. Run assign slottables for a tree with node.
|
||||
assign_slottables_for_a_tree(*this);
|
||||
}
|
||||
|
||||
// 15. Run the removing steps with node and parent.
|
||||
removed_from(parent);
|
||||
removed_from(parent, parent_root);
|
||||
|
||||
// 16. Let isParentConnected be parent’s connected.
|
||||
bool is_parent_connected = parent->is_connected();
|
||||
|
@ -953,7 +955,7 @@ void Node::remove(bool suppress_observers)
|
|||
// 18. For each shadow-including descendant descendant of node, in shadow-including tree order, then:
|
||||
for_each_shadow_including_descendant([&](Node& descendant) {
|
||||
// 1. Run the removing steps with descendant
|
||||
descendant.removed_from(nullptr);
|
||||
descendant.removed_from(nullptr, parent_root);
|
||||
|
||||
// 2. If descendant is custom and isParentConnected is true, then enqueue a custom element callback reaction with descendant,
|
||||
// callback name "disconnectedCallback", and an empty argument list.
|
||||
|
@ -1433,7 +1435,7 @@ void Node::inserted()
|
|||
set_needs_style_update(true);
|
||||
}
|
||||
|
||||
void Node::removed_from(Node*)
|
||||
void Node::removed_from(Node*, Node&)
|
||||
{
|
||||
m_layout_node = nullptr;
|
||||
m_paintable = nullptr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue