Skip to main content

LayoutNode

Struct LayoutNode 

Source
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: bool

Whether 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: DirtyFlag

Dirty flags to track what needs recalculation.

§box_props: BoxProps

The resolved box model properties (margin, border, padding) in logical pixels.

§taffy_cache: Cache

Cache for Taffy layout computations for this node.

§node_data_hash: u64

A hash of this node’s data (style, text content, etc.) used for fast reconciliation.

§subtree_hash: SubtreeHash

A hash of this node’s data and all of its descendants. Used for fast reconciliation.

§formatting_context: FormattingContext

The 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

Source

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

Source§

fn clone(&self) -> LayoutNode

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LayoutNode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<G1, G2> Within<G2> for G1
where G2: Contains<G1>,

Source§

fn is_within(&self, b: &G2) -> bool