Introduce BindContext with in_doc and connected flags

Fix some is_in_doc -> is_connected mistakes
This commit is contained in:
Fernando Jiménez Moreno 2019-03-05 18:01:59 +01:00
parent 740aae06ba
commit 813b242419
21 changed files with 105 additions and 84 deletions

View file

@ -296,7 +296,10 @@ impl Node {
node.set_flag(NodeFlags::IS_CONNECTED, parent_is_connected);
// Out-of-document elements never have the descendants flag set.
debug_assert!(!node.get_flag(NodeFlags::HAS_DIRTY_DESCENDANTS));
vtable_for(&&*node).bind_to_tree(parent_is_connected);
vtable_for(&&*node).bind_to_tree(&BindContext {
tree_connected: parent_is_connected,
tree_in_doc: parent_in_doc,
});
}
}
@ -3025,6 +3028,14 @@ impl<'a> ChildrenMutation<'a> {
}
}
/// The context of the binding to tree of a node.
pub struct BindContext {
/// Whether the tree is connected.
pub tree_connected: bool,
/// Whether the tree is in the document.
pub tree_in_doc: bool,
}
/// The context of the unbinding from a tree of a node when one of its
/// inclusive ancestors is removed.
pub struct UnbindContext<'a> {
@ -3038,6 +3049,8 @@ pub struct UnbindContext<'a> {
pub next_sibling: Option<&'a Node>,
/// Whether the tree is connected.
pub tree_connected: bool,
/// Whether the tree is in doc.
pub tree_in_doc: bool,
}
impl<'a> UnbindContext<'a> {
@ -3054,6 +3067,7 @@ impl<'a> UnbindContext<'a> {
prev_sibling: prev_sibling,
next_sibling: next_sibling,
tree_connected: parent.is_connected(),
tree_in_doc: parent.is_in_doc(),
}
}