aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/dom/bindings/js.rs
diff options
context:
space:
mode:
authorTetsuharu OHZEKI <saneyuki.snyk@gmail.com>2014-05-28 05:32:54 +0900
committerTetsuharu OHZEKI <saneyuki.snyk@gmail.com>2014-05-30 03:53:07 +0900
commit92da2f16fc55ad525f1ebe557ef4b4889d9e00bd (patch)
treeb8b4e9651f2d23e5b9d383514e52d0147dc1f78d /src/components/script/dom/bindings/js.rs
parentb0239b5a5ade3723d08ec59c5ca6a03f561d26fd (diff)
downloadservo-92da2f16fc55ad525f1ebe557ef4b4889d9e00bd.tar.gz
servo-92da2f16fc55ad525f1ebe557ef4b4889d9e00bd.zip
Implement OptionalSettable for 'Cell<Option<JS<U>>>'.
Diffstat (limited to 'src/components/script/dom/bindings/js.rs')
-rw-r--r--src/components/script/dom/bindings/js.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/components/script/dom/bindings/js.rs b/src/components/script/dom/bindings/js.rs
index b5a83b01e7c..bbceae0ad6d 100644
--- a/src/components/script/dom/bindings/js.rs
+++ b/src/components/script/dom/bindings/js.rs
@@ -47,7 +47,7 @@ use layout_interface::TrustedNodeAddress;
use script_task::StackRoots;
use std::cast;
-use std::cell::RefCell;
+use std::cell::{Cell, RefCell};
use std::kinds::marker::ContravariantLifetime;
/// A type that represents a JS-owned value that is rooted for the lifetime of this value.
@@ -269,6 +269,15 @@ impl<T: Assignable<U>, U: Reflectable> OptionalSettable<T> for Option<JS<U>> {
}
}
+impl<T: Assignable<U>, U: Reflectable> OptionalSettable<T> for Cell<Option<JS<U>>> {
+ fn assign(&mut self, val: Option<T>) {
+ let mut item = self.get();
+ item.assign(val);
+ self.set(item);
+ }
+}
+
+
/// Root a rootable Option type (used for Option<Temporary<T>>)
pub trait OptionalRootable<T> {
fn root<'a, 'b>(self) -> Option<Root<'a, 'b, T>>;