mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Move some more methods into the LayoutNodeLayoutData trait.
This commit is contained in:
parent
c910ef2072
commit
16d6555f4d
2 changed files with 18 additions and 16 deletions
|
@ -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>,
|
||||
|
|
|
@ -91,6 +91,8 @@ pub trait LayoutNodeLayoutData {
|
|||
unsafe fn borrow_layout_data_unchecked(&self) -> Option<*const PrivateLayoutData>;
|
||||
fn borrow_layout_data(&self) -> Option<Ref<PrivateLayoutData>>;
|
||||
fn mutate_layout_data(&self) -> Option<RefMut<PrivateLayoutData>>;
|
||||
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<PartialStyleAndLayoutData>) }
|
||||
};
|
||||
self.init_style_and_layout_data(opaque);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ln> TNode for ServoLayoutNode<'ln> {
|
||||
|
@ -349,6 +340,21 @@ impl<T: LayoutNode> 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<PartialStyleAndLayoutData>) }
|
||||
};
|
||||
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<Node> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue