Optimise Node.childNodes

We use the virtual method children_changed() to propagate changes in the children
list to the NodeList tied to Node.childNodes.
This commit is contained in:
Anthony Ramine 2015-07-24 15:38:05 +02:00
parent a49eb14615
commit 4e8922a53a
3 changed files with 207 additions and 15 deletions

View file

@ -40,7 +40,7 @@ use dom::element::{AttributeHandlers, Element, ElementCreator, ElementTypeId};
use dom::element::ElementHelpers;
use dom::eventtarget::{EventTarget, EventTargetTypeId};
use dom::htmlelement::HTMLElementTypeId;
use dom::nodelist::NodeList;
use dom::nodelist::{NodeList, NodeListHelpers};
use dom::processinginstruction::{ProcessingInstruction, ProcessingInstructionHelpers};
use dom::text::Text;
use dom::virtualmethods::{VirtualMethods, vtable_for};
@ -2582,6 +2582,9 @@ impl<'a> VirtualMethods for &'a Node {
self.children_count.set(added.len() as u32);
},
}
if let Some(list) = self.child_list.get().map(|list| list.root()) {
list.as_children_list().children_changed(mutation);
}
}
}