pub struct LayoutNode {Show 24 fields
pub dom_node_id: Option<NodeId>,
pub pseudo_element: Option<PseudoElement>,
pub is_anonymous: bool,
pub anonymous_type: Option<AnonymousBoxType>,
pub children: Vec<usize>,
pub parent: Option<usize>,
pub dirty_flag: DirtyFlag,
pub box_props: BoxProps,
pub taffy_cache: Cache,
pub node_data_hash: u64,
pub subtree_hash: SubtreeHash,
pub formatting_context: FormattingContext,
pub parent_formatting_context: Option<FormattingContext>,
pub intrinsic_sizes: Option<IntrinsicSizes>,
pub used_size: Option<LogicalSize>,
pub relative_position: Option<LogicalPosition>,
pub baseline: Option<f32>,
pub inline_layout_result: Option<CachedInlineLayout>,
pub escaped_top_margin: Option<f32>,
pub escaped_bottom_margin: Option<f32>,
pub scrollbar_info: Option<ScrollbarRequirements>,
pub overflow_content_size: Option<LogicalSize>,
pub ifc_id: Option<IfcId>,
pub ifc_membership: Option<IfcMembership>,
}Expand description
A layout tree node representing the CSS box model
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§
§dom_node_id: Option<NodeId>Reference back to the original DOM node (None for anonymous boxes)
pseudo_element: Option<PseudoElement>Pseudo-element type (::marker, ::before, ::after) if this node is a pseudo-element
is_anonymous: boolWhether this is an anonymous box generated by the layout engine
anonymous_type: Option<AnonymousBoxType>Type of anonymous box (if applicable)
children: Vec<usize>Children indices in the layout tree
parent: Option<usize>Parent index (None for root)
dirty_flag: DirtyFlagDirty flags to track what needs recalculation.
box_props: BoxPropsThe resolved box model properties (margin, border, padding) in logical pixels.
taffy_cache: CacheCache for Taffy layout computations for this node.
node_data_hash: u64A hash of this node’s data (style, text content, etc.) used for fast reconciliation.
subtree_hash: SubtreeHashA hash of this node’s data and all of its descendants. Used for fast reconciliation.
formatting_context: FormattingContextThe formatting context this node establishes or participates in.
parent_formatting_context: Option<FormattingContext>Parent’s formatting context (needed to determine if stretch applies)
intrinsic_sizes: Option<IntrinsicSizes>Cached intrinsic sizes (min-content, max-content, etc.)
used_size: Option<LogicalSize>The size used during the last layout pass.
relative_position: Option<LogicalPosition>The position of this node relative to its parent’s content box.
baseline: Option<f32>The baseline of this box, if applicable, measured from its content-box top edge.
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.
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.
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.
scrollbar_info: Option<ScrollbarRequirements>Cached scrollbar information (calculated during layout) Used to determine if scrollbars appeared/disappeared requiring reflow
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.
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.
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.
Implementations§
Source§impl LayoutNode
impl LayoutNode
Sourcepub fn get_content_size(&self) -> LogicalSize
pub fn get_content_size(&self) -> LogicalSize
Calculates the actual content size of this node, including all children and text. This is used to determine if scrollbars should appear for overflow: auto.
Trait Implementations§
Source§impl Clone for LayoutNode
impl Clone for LayoutNode
Source§fn clone(&self) -> LayoutNode
fn clone(&self) -> LayoutNode
1.0.0 · 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 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