Auto merge of #6660 - nox:children-changed, r=jdm

Introduce VirtualMethods::children_changed()

This virtual method mimics the behaviour of mutation observers and make it more viable than the older child_inserted(), which didn't cover removed nodes and was called as many times as there were inserted nodes.

A few other shortcomings where remove_child() was called directly instead of Node::remove() were also fixed while at it.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6660)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-07-25 11:39:20 -06:00
commit 705c95dedb
11 changed files with 218 additions and 200 deletions

View file

@ -70,6 +70,7 @@ use std::collections::hash_state::HashState;
use std::ffi::CString;
use std::hash::{Hash, Hasher};
use std::intrinsics::return_address;
use std::mem;
use std::ops::{Deref, DerefMut};
use std::rc::Rc;
use std::sync::Arc;
@ -482,6 +483,13 @@ impl<T: JSTraceable + Reflectable> RootedVec<T> {
}
}
impl<T: JSTraceable + Reflectable> RootedVec<JS<T>> {
/// Obtain a safe slice of references that can't outlive that RootedVec.
pub fn r(&self) -> &[&T] {
unsafe { mem::transmute(&*self.v) }
}
}
impl<T: JSTraceable + Reflectable> Drop for RootedVec<T> {
fn drop(&mut self) {
RootedTraceableSet::remove(self);