#[repr(C)]pub struct LayoutNode {Show 26 fields
pub box_props: BoxProps,
pub dom_node_id: Option<NodeId>,
pub children: Vec<usize>,
pub used_size: Option<LogicalSize>,
pub formatting_context: FormattingContext,
pub parent: Option<usize>,
pub intrinsic_sizes: Option<IntrinsicSizes>,
pub baseline: Option<f32>,
pub inline_layout_result: Option<CachedInlineLayout>,
pub scrollbar_info: Option<ScrollbarRequirements>,
pub relative_position: Option<LogicalPosition>,
pub overflow_content_size: Option<LogicalSize>,
pub taffy_cache: Cache,
pub computed_style: ComputedLayoutStyle,
pub pseudo_element: Option<PseudoElement>,
pub escaped_top_margin: Option<f32>,
pub escaped_bottom_margin: Option<f32>,
pub parent_formatting_context: Option<FormattingContext>,
pub ifc_membership: Option<IfcMembership>,
pub containing_block_index: Option<usize>,
pub anonymous_type: Option<AnonymousBoxType>,
pub node_data_fingerprint: NodeDataFingerprint,
pub subtree_hash: SubtreeHash,
pub dirty_flag: DirtyFlag,
pub unresolved_box_props: UnresolvedBoxProps,
pub ifc_id: Option<IfcId>,
}Expand description
A layout tree node representing the CSS box model.
§Memory Layout Optimization (#[repr(C)])
Fields are ordered by access frequency (hottest first) to maximize CPU
cache line utilization during tree traversal. With #[repr(C)], the
compiler preserves this ordering. The 6 hottest fields (~140 bytes)
occupy the first 2-3 cache lines (64 bytes each), which are loaded
first by the hardware prefetcher.
| Tier | Fields | ~Bytes | Accesses |
|---|---|---|---|
| HOT | box_props, dom_node_id, children, | ~140 | 410+ |
| used_size, formatting_context, parent | |||
| WARM | intrinsic_sizes..computed_style | ~220 | ~80 |
| COLD | dirty_flag..is_anonymous | ~190 | ~20 |
Note: An absolute position is a final paint-time value and shouldn’t be cached on the node itself, as it can change even if the node’s layout is clean (e.g., if a sibling changes size). We will calculate it in a separate map.
Fields§
§box_props: BoxPropsThe resolved box model properties (margin, border, padding) in logical pixels. Cached after first resolution. (148 accesses — hottest field)
dom_node_id: Option<NodeId>Reference back to the original DOM node (None for anonymous boxes) (111 accesses)
children: Vec<usize>Children indices in the layout tree (53 accesses)
used_size: Option<LogicalSize>The size used during the last layout pass. (43 accesses)
formatting_context: FormattingContextThe formatting context this node establishes or participates in. (30 accesses)
parent: Option<usize>Parent index (None for root) (25 accesses)
intrinsic_sizes: Option<IntrinsicSizes>Cached intrinsic sizes (min-content, max-content, etc.) (16 accesses — sizing pass only)
baseline: Option<f32>The baseline of this box, if applicable, measured from its content-box top edge. (14 accesses — IFC/table alignment)
inline_layout_result: Option<CachedInlineLayout>Cached inline layout result with the constraints used to compute it.
This field stores both the computed layout AND the constraints (available width, float state) under which it was computed. This is essential for correctness:
- Table cells are measured multiple times with different widths
- Min-content/max-content intrinsic sizing uses special constraint values
- The final layout must use the actual available width, not a measurement width
By tracking the constraints, we avoid the bug where a min-content measurement (with width=0) would be incorrectly reused for final rendering. (13 accesses — IFC roots / table cells)
scrollbar_info: Option<ScrollbarRequirements>Cached scrollbar information (calculated during layout) Used to determine if scrollbars appeared/disappeared requiring reflow (12 accesses — scrollable containers only)
relative_position: Option<LogicalPosition>The position of this node relative to its parent’s content box. (9 accesses — positioning pass)
overflow_content_size: Option<LogicalSize>The actual content size (children overflow size) for scrollable containers.
This is the size of all content that might need to be scrolled, which can
be larger than used_size when content overflows the container.
(7 accesses — scrollable containers)
taffy_cache: CacheCache for Taffy layout computations for this node. (6 accesses — Taffy bridge)
computed_style: ComputedLayoutStylePre-computed CSS properties needed during layout. Computed once during layout tree build to avoid repeated style lookups. (5 accesses — cache.rs only)
pseudo_element: Option<PseudoElement>Pseudo-element type (::marker, ::before, ::after) if this node is a pseudo-element (5 accesses — pseudo-elements only)
escaped_top_margin: Option<f32>Escaped top margin (CSS 2.1 margin collapsing) If this BFC’s first child’s top margin “escaped” the BFC, this contains the collapsed margin that should be applied by the parent. (4 accesses — BFC margin collapsing)
escaped_bottom_margin: Option<f32>Escaped bottom margin (CSS 2.1 margin collapsing)
If this BFC’s last child’s bottom margin “escaped” the BFC, this contains
the collapsed margin that should be applied by the parent.
(4 accesses)
parent_formatting_context: Option<FormattingContext>Parent’s formatting context (needed to determine if stretch applies) (4 accesses — flex/grid children)
ifc_membership: Option<IfcMembership>If this node participates in an IFC (is inline content like text), stores the reference back to the IFC root and the run index. This allows text nodes to find their layout data in the parent’s IFC. (3 accesses — text nodes only)
containing_block_index: Option<usize>The layout tree index of this node’s containing block.
- For abs-pos elements: nearest positioned (non-static) ancestor
- For fixed elements: root / None (viewport)
- For normal-flow: parent (None = implicit) Used for clip exemption: abs-pos elements whose containing block is above an overflow clipper should not be clipped.
anonymous_type: Option<AnonymousBoxType>Type of anonymous box (if applicable) (2 accesses)
node_data_fingerprint: NodeDataFingerprintMulti-field fingerprint of this node’s data (style, text, etc.) for granular change detection during reconciliation. (2 accesses — reconciliation only)
subtree_hash: SubtreeHashA hash of this node’s data and all of its descendants. Used for fast reconciliation. (9 accesses — all in cache.rs reconciliation)
dirty_flag: DirtyFlagDirty flags to track what needs recalculation. (7 accesses — reconciliation setup)
unresolved_box_props: UnresolvedBoxPropsUnresolved box model properties (raw CSS values). These are resolved lazily during layout when containing block is known. (1 access — initial resolution only)
ifc_id: Option<IfcId>If this node is an IFC root, stores the IFC ID.
Used to identify which IFC this node’s inline_layout_result belongs to.
(1 access — IFC creation only)
Implementations§
Source§impl LayoutNode
impl LayoutNode
Sourcepub fn split(self) -> (LayoutNodeHot, LayoutNodeWarm, LayoutNodeCold)
pub fn split(self) -> (LayoutNodeHot, LayoutNodeWarm, LayoutNodeCold)
Split this full layout node into hot/warm/cold components.
Used during LayoutTreeBuilder::build() to create the SoA layout.
Trait Implementations§
Source§impl Clone for LayoutNode
impl Clone for LayoutNode
Source§fn clone(&self) -> LayoutNode
fn clone(&self) -> LayoutNode
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 LayoutNode
impl RefUnwindSafe for LayoutNode
impl Send for LayoutNode
impl Sync for LayoutNode
impl Unpin for LayoutNode
impl UnsafeUnpin for LayoutNode
impl UnwindSafe for LayoutNode
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