pub struct LayoutTree {
pub nodes: Vec<LayoutNodeHot>,
pub warm: Vec<LayoutNodeWarm>,
pub cold: Vec<LayoutNodeCold>,
pub root: usize,
pub dom_to_layout: HashMap<NodeId, Vec<usize>>,
pub children_arena: Vec<usize>,
pub children_offsets: Vec<(u32, u32)>,
pub subtree_needs_intrinsic: Vec<bool>,
}Expand description
The complete layout tree structure.
Uses a struct-of-arrays (SoA) layout for cache performance:
nodes(hot): accessed on every node in every layout passwarm: accessed during specific layout phasescold: construction / reconciliation only
Fields§
§nodes: Vec<LayoutNodeHot>Hot layout data — box props, parent, used_size, formatting context
warm: Vec<LayoutNodeWarm>Warm layout data — intrinsic sizes, baseline, inline layout, etc.
cold: Vec<LayoutNodeCold>Cold layout data — dirty flags, fingerprints, reconciliation data
root: usizeRoot node index
dom_to_layout: HashMap<NodeId, Vec<usize>>Mapping from DOM node IDs to layout node indices
children_arena: Vec<usize>Flat arena holding all children indices contiguously.
children_offsets: Vec<(u32, u32)>Per-node (start, len) into children_arena. Indexed by node index.
subtree_needs_intrinsic: Vec<bool>Per-node bit: this node or any descendant establishes a shrink-to-fit (STF) context whose sizing algorithm reads children’s intrinsic sizes (flex/grid/table/inline-block containers, floats, or abspos elements).
If subtree_needs_intrinsic[i] is false AND no ancestor of i is STF
either, the intrinsic sizing pass can skip the entire subtree — nothing
will ever read those values. This is the static-DOM optimization from
§58 Win #3 (the “safely re-enabled Fix C”).
Computed once at tree build time in generate_layout_tree. An empty
vec means “assume every subtree needs intrinsics” (safe fallback for
code paths that construct LayoutTree without going through the
builder — currently none, but preserves the invariant for tests).
Implementations§
Source§impl LayoutTree
impl LayoutTree
Sourcepub fn memory_report(&self) -> LayoutTreeMemoryReport
pub fn memory_report(&self) -> LayoutTreeMemoryReport
Approximate heap bytes retained by this LayoutTree.
Sourcepub fn children(&self, index: usize) -> &[usize]
pub fn children(&self, index: usize) -> &[usize]
Returns the children of node index as a contiguous slice from the arena.
Sourcepub fn get(&self, index: usize) -> Option<&LayoutNodeHot>
pub fn get(&self, index: usize) -> Option<&LayoutNodeHot>
Get hot layout data for a node (box_props, dom_node_id, used_size, etc.)
Sourcepub fn get_mut(&mut self, index: usize) -> Option<&mut LayoutNodeHot>
pub fn get_mut(&mut self, index: usize) -> Option<&mut LayoutNodeHot>
Get mutable hot layout data for a node.
Sourcepub fn warm(&self, index: usize) -> Option<&LayoutNodeWarm>
pub fn warm(&self, index: usize) -> Option<&LayoutNodeWarm>
Get warm layout data for a node (intrinsic_sizes, baseline, inline_layout, etc.)
Sourcepub fn warm_mut(&mut self, index: usize) -> Option<&mut LayoutNodeWarm>
pub fn warm_mut(&mut self, index: usize) -> Option<&mut LayoutNodeWarm>
Get mutable warm layout data for a node.
Sourcepub fn cold(&self, index: usize) -> Option<&LayoutNodeCold>
pub fn cold(&self, index: usize) -> Option<&LayoutNodeCold>
Get cold layout data for a node (dirty_flag, subtree_hash, fingerprint, etc.)
Sourcepub fn cold_mut(&mut self, index: usize) -> Option<&mut LayoutNodeCold>
pub fn cold_mut(&mut self, index: usize) -> Option<&mut LayoutNodeCold>
Get mutable cold layout data for a node.
pub fn root_node(&self) -> &LayoutNodeHot
Sourcepub fn get_full_node(&self, index: usize) -> Option<LayoutNode>
pub fn get_full_node(&self, index: usize) -> Option<LayoutNode>
Reconstruct a full LayoutNode from the split hot/warm/cold arrays.
Used when passing node data to LayoutTreeBuilder::clone_node_from_old().
Sourcepub fn resolve_box_props(
&mut self,
node_index: usize,
containing_block: LogicalSize,
viewport_size: LogicalSize,
element_font_size: f32,
root_font_size: f32,
)
pub fn resolve_box_props( &mut self, node_index: usize, containing_block: LogicalSize, viewport_size: LogicalSize, element_font_size: f32, root_font_size: f32, )
Re-resolve box properties for a node with the actual containing block size.
Sourcepub fn mark_dirty(&mut self, start_index: usize, flag: DirtyFlag)
pub fn mark_dirty(&mut self, start_index: usize, flag: DirtyFlag)
Marks a node and its ancestors as dirty with the given flag.
Sourcepub fn mark_subtree_dirty(&mut self, start_index: usize, flag: DirtyFlag)
pub fn mark_subtree_dirty(&mut self, start_index: usize, flag: DirtyFlag)
Marks a node and its entire subtree of descendants with the given dirty flag.
Sourcepub fn clear_all_dirty_flags(&mut self)
pub fn clear_all_dirty_flags(&mut self)
Resets the dirty flags of all nodes in the tree to None after layout is complete.
Sourcepub fn get_inline_layout_for_node(
&self,
layout_index: usize,
) -> Option<&Arc<UnifiedLayout>>
pub fn get_inline_layout_for_node( &self, layout_index: usize, ) -> Option<&Arc<UnifiedLayout>>
Get inline layout for a node, navigating through IFC membership if needed.
Sourcepub fn get_content_size(&self, index: usize) -> LogicalSize
pub fn get_content_size(&self, index: usize) -> LogicalSize
Get the content size of a node (for scrollbar calculations).
Trait Implementations§
Source§impl Clone for LayoutTree
impl Clone for LayoutTree
Source§fn clone(&self) -> LayoutTree
fn clone(&self) -> LayoutTree
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for LayoutTree
impl RefUnwindSafe for LayoutTree
impl Send for LayoutTree
impl Sync for LayoutTree
impl Unpin for LayoutTree
impl UnsafeUnpin for LayoutTree
impl UnwindSafe for LayoutTree
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more