Split initialize_data into two.

The first one handles the layout-specific part, and calls the second one to
handle the script-specific part.
This commit is contained in:
Ms2ger 2016-06-15 00:56:12 +01:00
parent d50c166786
commit 8b05833e52

View file

@ -81,6 +81,8 @@ pub trait LayoutNode: TNode {
fn get_style_data(&self) -> Option<&RefCell<PartialStyleAndLayoutData>>; fn get_style_data(&self) -> Option<&RefCell<PartialStyleAndLayoutData>>;
fn init_style_and_layout_data(&self, data: OpaqueStyleAndLayoutData);
/// Similar to borrow_data*, but returns the full PrivateLayoutData rather /// Similar to borrow_data*, but returns the full PrivateLayoutData rather
/// than only the PrivateStyleData. /// than only the PrivateStyleData.
unsafe fn borrow_layout_data_unchecked(&self) -> Option<*const PrivateLayoutData>; unsafe fn borrow_layout_data_unchecked(&self) -> Option<*const PrivateLayoutData>;
@ -131,9 +133,7 @@ impl<'ln> ServoLayoutNode<'ln> {
let opaque = OpaqueStyleAndLayoutData { let opaque = OpaqueStyleAndLayoutData {
ptr: unsafe { NonZero::new(ptr as *mut RefCell<PartialStyleAndLayoutData>) } ptr: unsafe { NonZero::new(ptr as *mut RefCell<PartialStyleAndLayoutData>) }
}; };
unsafe { self.init_style_and_layout_data(opaque);
self.node.init_style_and_layout_data(opaque);
}
} }
} }
} }
@ -308,6 +308,12 @@ impl<'ln> LayoutNode for ServoLayoutNode<'ln> {
} }
} }
fn init_style_and_layout_data(&self, data: OpaqueStyleAndLayoutData) {
unsafe {
self.get_jsmanaged().init_style_and_layout_data(data);
}
}
unsafe fn borrow_layout_data_unchecked(&self) -> Option<*const PrivateLayoutData> { unsafe fn borrow_layout_data_unchecked(&self) -> Option<*const PrivateLayoutData> {
self.get_jsmanaged().get_style_and_layout_data().map(|opaque| { self.get_jsmanaged().get_style_and_layout_data().map(|opaque| {
let container = *opaque.ptr as NonOpaqueStyleAndLayoutData; let container = *opaque.ptr as NonOpaqueStyleAndLayoutData;