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:
Anthony Ramine 2015-10-24 02:58:31 +02:00
parent b63ca94c7f
commit 8f01790f06
10 changed files with 41 additions and 45 deletions

View file

@ -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,
}