mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Move the initialize_data method out of the TNode trait.
This reduces the dependency of TNode implementations on layout types.
This commit is contained in:
parent
ae5cb0ceb0
commit
e723d72570
3 changed files with 22 additions and 29 deletions
|
@ -120,6 +120,19 @@ 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 ()) }
|
||||
};
|
||||
unsafe {
|
||||
self.node.init_style_and_layout_data(opaque);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ln> TNode for ServoLayoutNode<'ln> {
|
||||
|
@ -158,20 +171,6 @@ impl<'ln> TNode for ServoLayoutNode<'ln> {
|
|||
OpaqueNodeMethods::from_jsmanaged(unsafe { self.get_jsmanaged() })
|
||||
}
|
||||
|
||||
fn initialize_data(self) {
|
||||
let has_data = unsafe { self.borrow_data_unchecked().is_some() };
|
||||
if !has_data {
|
||||
let ptr: NonOpaqueStyleAndLayoutData =
|
||||
Box::into_raw(box RefCell::new(PrivateLayoutData::new()));
|
||||
let opaque = OpaqueStyleAndLayoutData {
|
||||
ptr: unsafe { NonZero::new(ptr as *mut ()) }
|
||||
};
|
||||
unsafe {
|
||||
self.node.init_style_and_layout_data(opaque);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn layout_parent_node(self, reflow_root: OpaqueNode) -> Option<ServoLayoutNode<'ln>> {
|
||||
if self.opaque() == reflow_root {
|
||||
None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue