aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/dom/bindings/js.rs
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2014-04-17 23:26:42 -0400
committerJosh Matthews <josh@joshmatthews.net>2014-05-03 14:18:31 -0400
commit7b3e6d1f2125faf598919722b72cc56197d0102c (patch)
treebc5a2f34b3d5924e49fb586bcfbb7b022758093c /src/components/script/dom/bindings/js.rs
parentaaf0a6119414072b34e3ef2109827eaf2f2a3156 (diff)
downloadservo-7b3e6d1f2125faf598919722b72cc56197d0102c.tar.gz
servo-7b3e6d1f2125faf598919722b72cc56197d0102c.zip
Remove all root collections.
Diffstat (limited to 'src/components/script/dom/bindings/js.rs')
-rw-r--r--src/components/script/dom/bindings/js.rs29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/components/script/dom/bindings/js.rs b/src/components/script/dom/bindings/js.rs
index 1efd25dc72c..1ee1b8da51d 100644
--- a/src/components/script/dom/bindings/js.rs
+++ b/src/components/script/dom/bindings/js.rs
@@ -54,7 +54,7 @@ impl<T: Reflectable> Temporary<T> {
}
/// Root this unrooted value.
- pub fn root<'a, 'b>(self, _collection: &'a RootCollection) -> Root<'a, 'b, T> {
+ pub fn root<'a, 'b>(self) -> Root<'a, 'b, T> {
local_data::get(StackRoots, |opt| {
let collection = opt.unwrap();
unsafe {
@@ -119,8 +119,13 @@ impl<T: Reflectable> JS<T> {
}
/// Root this JS-owned value to prevent its collection as garbage.
- pub fn root<'a, 'b>(&self, collection: &'a RootCollection) -> Root<'a, 'b, T> {
- collection.new_root(self)
+ pub fn root<'a, 'b>(&self) -> Root<'a, 'b, T> {
+ local_data::get(StackRoots, |opt| {
+ let collection = opt.unwrap();
+ unsafe {
+ (**collection).new_root(self)
+ }
+ })
}
}
@@ -214,32 +219,32 @@ impl<T: Assignable<U>, U: Reflectable> OptionalAssignable<T> for Option<JS<U>> {
}
pub trait OptionalRootable<T> {
- fn root<'a, 'b>(self, roots: &'a RootCollection) -> Option<Root<'a, 'b, T>>;
+ fn root<'a, 'b>(self) -> Option<Root<'a, 'b, T>>;
}
impl<T: Reflectable> OptionalRootable<T> for Option<Temporary<T>> {
- fn root<'a, 'b>(self, roots: &'a RootCollection) -> Option<Root<'a, 'b, T>> {
- self.map(|inner| inner.root(roots))
+ fn root<'a, 'b>(self) -> Option<Root<'a, 'b, T>> {
+ self.map(|inner| inner.root())
}
}
pub trait OptionalRootedRootable<T> {
- fn root<'a, 'b>(&self, roots: &'a RootCollection) -> Option<Root<'a, 'b, T>>;
+ fn root<'a, 'b>(&self) -> Option<Root<'a, 'b, T>>;
}
impl<T: Reflectable> OptionalRootedRootable<T> for Option<JS<T>> {
- fn root<'a, 'b>(&self, roots: &'a RootCollection) -> Option<Root<'a, 'b, T>> {
- self.as_ref().map(|inner| inner.root(roots))
+ fn root<'a, 'b>(&self) -> Option<Root<'a, 'b, T>> {
+ self.as_ref().map(|inner| inner.root())
}
}
pub trait ResultRootable<T,U> {
- fn root<'a, 'b>(self, roots: &'a RootCollection) -> Result<Root<'a, 'b, T>, U>;
+ fn root<'a, 'b>(self) -> Result<Root<'a, 'b, T>, U>;
}
impl<T: Reflectable, U> ResultRootable<T, U> for Result<Temporary<T>, U> {
- fn root<'a, 'b>(self, roots: &'a RootCollection) -> Result<Root<'a, 'b, T>, U> {
- self.map(|inner| inner.root(roots))
+ fn root<'a, 'b>(self) -> Result<Root<'a, 'b, T>, U> {
+ self.map(|inner| inner.root())
}
}