Skip to content

Commit

Permalink
Privatize Node
Browse files Browse the repository at this point in the history
  • Loading branch information
ttaubert committed Oct 13, 2014
1 parent da7590d commit 28061b1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
6 changes: 3 additions & 3 deletions components/layout/util.rs
Expand Up @@ -78,20 +78,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.borrow_unchecked())
mem::transmute(self.get().layout_data_unchecked())
}

#[inline(always)]
fn borrow_layout_data<'a>(&'a self) -> Ref<'a,Option<LayoutDataWrapper>> {
unsafe {
mem::transmute(self.get().layout_data.borrow())
mem::transmute(self.get().layout_data())
}
}

#[inline(always)]
fn mutate_layout_data<'a>(&'a self) -> RefMut<'a,Option<LayoutDataWrapper>> {
unsafe {
mem::transmute(self.get().layout_data.borrow_mut())
mem::transmute(self.get().layout_data_mut())
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions components/layout/wrapper.rs
Expand Up @@ -721,15 +721,15 @@ 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.borrow())
mem::transmute(self.get().layout_data())
}
}

/// Borrows the layout data mutably. Fails on a conflicting borrow.
#[inline(always)]
pub fn mutate_layout_data<'a>(&'a self) -> RefMut<'a,Option<LayoutDataWrapper>> {
unsafe {
mem::transmute(self.get().layout_data.borrow_mut())
mem::transmute(self.get().layout_data_mut())
}
}

Expand Down
20 changes: 18 additions & 2 deletions components/script/dom/node.rs
Expand Up @@ -73,9 +73,10 @@ use uuid;
/// An HTML node.
#[jstraceable]
#[must_root]
#[privatize]
pub struct Node {
/// The JavaScript reflector for this node.
pub eventtarget: EventTarget,
eventtarget: EventTarget,

/// The type of node that this is.
type_id: NodeTypeId,
Expand Down Expand Up @@ -108,7 +109,7 @@ pub struct Node {
///
/// Must be sent back to the layout task to be destroyed when this
/// node is finalized.
pub layout_data: LayoutDataRef,
layout_data: LayoutDataRef,

unique_id: RefCell<String>,
}
Expand Down Expand Up @@ -1149,6 +1150,21 @@ impl Node {
&self.eventtarget
}

#[inline]
pub fn layout_data(&self) -> Ref<Option<LayoutData>> {
self.layout_data.borrow()
}

#[inline]
pub fn layout_data_mut(&self) -> RefMut<Option<LayoutData>> {
self.layout_data.borrow_mut()
}

#[inline]
pub unsafe fn layout_data_unchecked(&self) -> *const Option<LayoutData> {
self.layout_data.borrow_unchecked()
}

// http://dom.spec.whatwg.org/#concept-node-adopt
pub fn adopt(node: JSRef<Node>, document: JSRef<Document>) {
// Step 1.
Expand Down

0 comments on commit 28061b1

Please sign in to comment.