Hello, I'm currently trying to optimise Node.childList and to do so I need to propagate changes in children of nodes to the corresponding NodeList. I took upon the task of cleaning the mess that are the various virtual methods called on insertion and removal of nodes and introduced a new children_changed() virtual method in #6660 [1] and an enum to represent the mutations:
fn children_changed(&self, mutation: &ChildrenMutation); pub enum ChildrenMutation<'a> { Append(/* prev */ &'a Node, /* added */ &'a [&'a Node]), Insert(/* prev */ &'a Node, /* added */ &'a [&'a Node], /* next */ &'a Node), Prepend(/* added */ &'a [&'a Node], /* next */ &'a Node), Replace(/* prev */ Option<&'a Node>, /* removed */ &'a Node, /* added */ &'a [&'a Node], /* next */ Option<&'a Node>), ReplaceAll(/* removed */ &'a [&'a Node], /* added */ &'a [&'a Node]), } Does anyone see an immediate problem with this? This might look bad, but I find it quite useful for the actual code in NodeList and it avoids some impossible mutations that can be represented by a naive tuple (previous_node, removed_nodes, added_nodes, next_node), like removing multiple (but not all) children of a node. Regards. [1] https://github.com/servo/servo/pull/6660 _______________________________________________ dev-servo mailing list dev-servo@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-servo