mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Introduce UnbindContext
This holds the context that describes the original node that was removed from a tree when unbinding from a tree.
This commit is contained in:
parent
b63ca94c7f
commit
8f01790f06
10 changed files with 41 additions and 45 deletions
|
@ -318,15 +318,18 @@ impl Node {
|
|||
}
|
||||
}
|
||||
|
||||
let context = UnbindContext {
|
||||
tree_in_doc: child.is_in_doc(),
|
||||
};
|
||||
|
||||
child.prev_sibling.set(None);
|
||||
child.next_sibling.set(None);
|
||||
child.parent_node.set(None);
|
||||
self.children_count.set(self.children_count.get() - 1);
|
||||
|
||||
let parent_in_doc = self.is_in_doc();
|
||||
for node in child.traverse_preorder() {
|
||||
node.set_flag(IS_IN_DOC, false);
|
||||
vtable_for(&&*node).unbind_from_tree(parent_in_doc);
|
||||
vtable_for(&&*node).unbind_from_tree(&context);
|
||||
node.layout_data.dispose(&node);
|
||||
}
|
||||
|
||||
|
@ -2420,3 +2423,10 @@ impl<'a> ChildrenMutation<'a> {
|
|||
ChildrenMutation::ReplaceAll { removed: removed, added: added }
|
||||
}
|
||||
}
|
||||
|
||||
/// The context of the unbinding from a tree of a node when one of its
|
||||
/// inclusive ancestors is removed.
|
||||
pub struct UnbindContext {
|
||||
/// Whether the tree is in a document.
|
||||
pub tree_in_doc: bool,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue