aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/trace.rs
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2015-07-25 11:39:20 -0600
committerbors-servo <metajack+bors@gmail.com>2015-07-25 11:39:20 -0600
commit705c95dedbbaa60ffd08e70579915e228d5b6ee0 (patch)
tree4cbafee85f191cfbd96986b4d520610adb27a26c /components/script/dom/bindings/trace.rs
parent8edf1a5ecdecc9f6de8210fc875cff3679fda09e (diff)
parent7b40cc9fd7ea4dcc3816be0cb1ad6543bb5c88e0 (diff)
downloadservo-705c95dedbbaa60ffd08e70579915e228d5b6ee0.tar.gz
servo-705c95dedbbaa60ffd08e70579915e228d5b6ee0.zip
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 -->
Diffstat (limited to 'components/script/dom/bindings/trace.rs')
-rw-r--r--components/script/dom/bindings/trace.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs
index a2c82b80722..ad8da0e41b0 100644
--- a/components/script/dom/bindings/trace.rs
+++ b/components/script/dom/bindings/trace.rs
@@ -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);