diff options
-rw-r--r-- | components/layout/util.rs | 6 | ||||
-rw-r--r-- | components/layout/wrapper.rs | 4 | ||||
-rw-r--r-- | components/script/dom/node.rs | 42 |
3 files changed, 27 insertions, 25 deletions
diff --git a/components/layout/util.rs b/components/layout/util.rs index 98a2b8d440e..6f29005e839 100644 --- a/components/layout/util.rs +++ b/components/layout/util.rs @@ -77,20 +77,20 @@ pub trait LayoutDataAccess { impl<'ln> LayoutDataAccess for LayoutNode<'ln> { #[inline(always)] unsafe fn borrow_layout_data_unchecked(&self) -> *const Option<LayoutDataWrapper> { - mem::transmute(self.get().layout_data.deref().borrow_unchecked()) + mem::transmute(self.get().layout_data.borrow_unchecked()) } #[inline(always)] fn borrow_layout_data<'a>(&'a self) -> Ref<'a,Option<LayoutDataWrapper>> { unsafe { - mem::transmute(self.get().layout_data.deref().borrow()) + mem::transmute(self.get().layout_data.borrow()) } } #[inline(always)] fn mutate_layout_data<'a>(&'a self) -> RefMut<'a,Option<LayoutDataWrapper>> { unsafe { - mem::transmute(self.get().layout_data.deref().borrow_mut()) + mem::transmute(self.get().layout_data.borrow_mut()) } } } diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index 9c68c0b88a0..2c31186846c 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -667,7 +667,7 @@ impl<'ln> ThreadSafeLayoutNode<'ln> { #[inline(always)] pub fn borrow_layout_data<'a>(&'a self) -> Ref<'a,Option<LayoutDataWrapper>> { unsafe { - mem::transmute(self.get().layout_data.deref().borrow()) + mem::transmute(self.get().layout_data.borrow()) } } @@ -675,7 +675,7 @@ impl<'ln> ThreadSafeLayoutNode<'ln> { #[inline(always)] pub fn mutate_layout_data<'a>(&'a self) -> RefMut<'a,Option<LayoutDataWrapper>> { unsafe { - mem::transmute(self.get().layout_data.deref().borrow_mut()) + mem::transmute(self.get().layout_data.borrow_mut()) } } diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index c86c3215581..f84e2529450 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -25,7 +25,7 @@ use dom::bindings::global; use dom::bindings::js::{JS, JSRef, RootedReference, Temporary, Root}; use dom::bindings::js::{OptionalSettable, TemporaryPushable, OptionalRootedRootable}; use dom::bindings::js::{ResultRootable, OptionalRootable, MutNullableJS}; -use dom::bindings::trace::{Traceable, Untraceable}; +use dom::bindings::trace::JSTraceable; use dom::bindings::utils; use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object}; use dom::characterdata::CharacterData; @@ -53,7 +53,7 @@ use servo_util::geometry::Au; use servo_util::str::{DOMString, null_str_as_empty}; use style::{parse_selector_list_from_str, matches}; -use js::jsapi::{JSContext, JSObject, JSRuntime}; +use js::jsapi::{JSContext, JSObject, JSTracer, JSRuntime}; use js::jsfriendapi; use libc; use libc::uintptr_t; @@ -102,13 +102,13 @@ pub struct Node { child_list: MutNullableJS<NodeList>, /// A bitfield of flags for node items. - flags: Traceable<RefCell<NodeFlags>>, + flags: RefCell<NodeFlags>, /// Layout information. Only the layout task may touch this data. /// /// Must be sent back to the layout task to be destroyed when this /// node is finalized. - pub layout_data: Untraceable<LayoutDataRef>, + pub layout_data: LayoutDataRef, unique_id: RefCell<String>, } @@ -189,6 +189,8 @@ pub struct LayoutDataRef { pub data_cell: RefCell<Option<LayoutData>>, } +untraceable!(LayoutDataRef) + impl LayoutDataRef { pub fn new() -> LayoutDataRef { LayoutDataRef { @@ -453,7 +455,7 @@ impl<'a> NodeHelpers<'a> for JSRef<'a, Node> { } fn is_in_doc(self) -> bool { - self.deref().flags.deref().borrow().contains(IsInDoc) + self.deref().flags.borrow().contains(IsInDoc) } /// Returns the type ID of this node. Fails if this node is borrowed mutably. @@ -512,38 +514,38 @@ impl<'a> NodeHelpers<'a> for JSRef<'a, Node> { } fn get_hover_state(self) -> bool { - self.flags.deref().borrow().contains(InHoverState) + self.flags.borrow().contains(InHoverState) } fn set_hover_state(self, state: bool) { if state { - self.flags.deref().borrow_mut().insert(InHoverState); + self.flags.borrow_mut().insert(InHoverState); } else { - self.flags.deref().borrow_mut().remove(InHoverState); + self.flags.borrow_mut().remove(InHoverState); } } fn get_disabled_state(self) -> bool { - self.flags.deref().borrow().contains(InDisabledState) + self.flags.borrow().contains(InDisabledState) } fn set_disabled_state(self, state: bool) { if state { - self.flags.deref().borrow_mut().insert(InDisabledState); + self.flags.borrow_mut().insert(InDisabledState); } else { - self.flags.deref().borrow_mut().remove(InDisabledState); + self.flags.borrow_mut().remove(InDisabledState); } } fn get_enabled_state(self) -> bool { - self.flags.deref().borrow().contains(InEnabledState) + self.flags.borrow().contains(InEnabledState) } fn set_enabled_state(self, state: bool) { if state { - self.flags.deref().borrow_mut().insert(InEnabledState); + self.flags.borrow_mut().insert(InEnabledState); } else { - self.flags.deref().borrow_mut().remove(InEnabledState); + self.flags.borrow_mut().remove(InEnabledState); } } @@ -1034,9 +1036,9 @@ impl Node { owner_doc: MutNullableJS::new(doc), child_list: Default::default(), - flags: Traceable::new(RefCell::new(NodeFlags::new(type_id))), + flags: RefCell::new(NodeFlags::new(type_id)), - layout_data: Untraceable::new(LayoutDataRef::new()), + layout_data: LayoutDataRef::new(), unique_id: RefCell::new("".to_string()), } @@ -1236,9 +1238,9 @@ impl Node { let is_in_doc = parent.is_in_doc(); for kid in node.traverse_preorder() { if is_in_doc { - kid.flags.deref().borrow_mut().insert(IsInDoc); + kid.flags.borrow_mut().insert(IsInDoc); } else { - kid.flags.deref().borrow_mut().remove(IsInDoc); + kid.flags.borrow_mut().remove(IsInDoc); } } } @@ -1325,7 +1327,7 @@ impl Node { // Step 8. parent.remove_child(node); - node.deref().flags.deref().borrow_mut().remove(IsInDoc); + node.deref().flags.borrow_mut().remove(IsInDoc); // Step 9. match suppress_observers { @@ -1449,7 +1451,7 @@ impl Node { /// Sends layout data, if any, back to the layout task to be destroyed. unsafe fn reap_layout_data(&mut self) { if self.layout_data.is_present() { - let layout_data = mem::replace(self.layout_data.deref_mut(), LayoutDataRef::new()); + let layout_data = mem::replace(&mut self.layout_data, LayoutDataRef::new()); let layout_chan = layout_data.take_chan(); match layout_chan { None => {} |