diff --git a/src/components/script/dom/attr.rs b/src/components/script/dom/attr.rs index 68300bcb29f..1b49c9f05c2 100644 --- a/src/components/script/dom/attr.rs +++ b/src/components/script/dom/attr.rs @@ -13,6 +13,7 @@ use dom::virtualmethods::vtable_for; use servo_util::namespace; use servo_util::namespace::Namespace; use servo_util::str::DOMString; +use std::cell::Cell; pub enum AttrSettingType { FirstSetAttr, @@ -29,7 +30,7 @@ pub struct Attr { pub prefix: Option, /// the element that owns this attribute. - pub owner: JS, + pub owner: Cell>, } impl Reflectable for Attr { @@ -53,7 +54,7 @@ impl Attr { name: name, //TODO: Intern attribute names namespace: namespace, prefix: prefix, - owner: owner.unrooted(), + owner: Cell::new(owner.unrooted()), } } @@ -65,7 +66,7 @@ impl Attr { } pub fn set_value(&mut self, set_type: AttrSettingType, value: DOMString) { - let mut owner = self.owner.root(); + let mut owner = self.owner.get().root(); let node: &mut JSRef = NodeCast::from_mut_ref(&mut *owner); let namespace_is_null = self.namespace == namespace::Null; diff --git a/src/components/script/dom/attrlist.rs b/src/components/script/dom/attrlist.rs index 8ed4dca07a4..107cd5a184e 100644 --- a/src/components/script/dom/attrlist.rs +++ b/src/components/script/dom/attrlist.rs @@ -39,11 +39,11 @@ pub trait AttrListMethods { impl<'a> AttrListMethods for JSRef<'a, AttrList> { fn Length(&self) -> u32 { - self.owner.root().attrs.len() as u32 + self.owner.root().attrs.borrow().len() as u32 } fn Item(&self, index: u32) -> Option> { - self.owner.root().attrs.as_slice().get(index as uint).map(|x| Temporary::new(x.clone())) + self.owner.root().attrs.borrow().as_slice().get(index as uint).map(|x| Temporary::new(x.clone())) } fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option> { diff --git a/src/components/script/dom/clientrectlist.rs b/src/components/script/dom/clientrectlist.rs index 6072b86df71..6c069807151 100644 --- a/src/components/script/dom/clientrectlist.rs +++ b/src/components/script/dom/clientrectlist.rs @@ -18,9 +18,10 @@ pub struct ClientRectList { impl ClientRectList { pub fn new_inherited(window: &JSRef, rects: Vec>) -> ClientRectList { + let rects = rects.iter().map(|rect| rect.unrooted()).collect(); ClientRectList { reflector_: Reflector::new(), - rects: rects.iter().map(|rect| rect.unrooted()).collect(), + rects: rects, window: window.unrooted(), } } @@ -44,8 +45,9 @@ impl<'a> ClientRectListMethods for JSRef<'a, ClientRectList> { } fn Item(&self, index: u32) -> Option> { - if index < self.rects.len() as u32 { - Some(Temporary::new(self.rects.get(index as uint).clone())) + let rects = &self.rects; + if index < rects.len() as u32 { + Some(Temporary::new(rects.get(index as uint).clone())) } else { None }