diff --git a/components/layout/traversal.rs b/components/layout/traversal.rs index b1ccaf638c3..14289683d4d 100644 --- a/components/layout/traversal.rs +++ b/components/layout/traversal.rs @@ -18,7 +18,7 @@ use style::traversal::{DomTraversalContext, STYLE_BLOOM}; use style::traversal::{put_thread_local_bloom_filter, recalc_style_at}; use util::opts; use util::tid::tid; -use wrapper::{LayoutNode, ServoLayoutNode, ThreadSafeLayoutNode}; +use wrapper::{LayoutNode, LayoutNodeLayoutData, ServoLayoutNode, ThreadSafeLayoutNode}; pub struct RecalcStyleAndConstructFlows<'lc> { context: LayoutContext<'lc>, diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs index 2acb1636f4e..f5d77472e70 100644 --- a/components/layout/wrapper.rs +++ b/components/layout/wrapper.rs @@ -91,6 +91,8 @@ pub trait LayoutNodeLayoutData { unsafe fn borrow_layout_data_unchecked(&self) -> Option<*const PrivateLayoutData>; fn borrow_layout_data(&self) -> Option>; fn mutate_layout_data(&self) -> Option>; + fn initialize_data(self); + fn flow_debug_id(self) -> usize; } #[derive(Copy, Clone)] @@ -128,17 +130,6 @@ impl<'ln> ServoLayoutNode<'ln> { chain: self.chain, } } - - pub fn initialize_data(self) { - if unsafe { self.borrow_data_unchecked() }.is_none() { - let ptr: NonOpaqueStyleAndLayoutData = - Box::into_raw(box RefCell::new(PrivateLayoutData::new())); - let opaque = OpaqueStyleAndLayoutData { - ptr: unsafe { NonZero::new(ptr as *mut RefCell) } - }; - self.init_style_and_layout_data(opaque); - } - } } impl<'ln> TNode for ServoLayoutNode<'ln> { @@ -349,6 +340,21 @@ impl LayoutNodeLayoutData for T { }) } } + + fn initialize_data(self) { + if unsafe { self.borrow_data_unchecked() }.is_none() { + let ptr: NonOpaqueStyleAndLayoutData = + Box::into_raw(box RefCell::new(PrivateLayoutData::new())); + let opaque = OpaqueStyleAndLayoutData { + ptr: unsafe { NonZero::new(ptr as *mut RefCell) } + }; + self.init_style_and_layout_data(opaque); + } + } + + fn flow_debug_id(self) -> usize { + self.borrow_layout_data().map_or(0, |d| d.flow_construction_result.debug_id()) + } } @@ -372,10 +378,6 @@ impl<'ln> ServoLayoutNode<'ln> { self.type_id(), self.has_changed(), self.is_dirty(), self.has_dirty_descendants()) } - pub fn flow_debug_id(self) -> usize { - self.borrow_layout_data().map_or(0, |d| d.flow_construction_result.debug_id()) - } - /// Returns the interior of this node as a `LayoutJS`. This is highly unsafe for layout to /// call and as such is marked `unsafe`. unsafe fn get_jsmanaged(&self) -> &LayoutJS {