Skip to main content

LayoutTree

Struct LayoutTree 

Source
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 pass
  • warm: accessed during specific layout phases
  • cold: 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: usize

Root 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

Source

pub fn memory_report(&self) -> LayoutTreeMemoryReport

Approximate heap bytes retained by this LayoutTree.

Source

pub fn children(&self, index: usize) -> &[usize]

Returns the children of node index as a contiguous slice from the arena.

Source

pub fn get(&self, index: usize) -> Option<&LayoutNodeHot>

Get hot layout data for a node (box_props, dom_node_id, used_size, etc.)

Source

pub fn get_mut(&mut self, index: usize) -> Option<&mut LayoutNodeHot>

Get mutable hot layout data for a node.

Source

pub fn warm(&self, index: usize) -> Option<&LayoutNodeWarm>

Get warm layout data for a node (intrinsic_sizes, baseline, inline_layout, etc.)

Source

pub fn warm_mut(&mut self, index: usize) -> Option<&mut LayoutNodeWarm>

Get mutable warm layout data for a node.

Source

pub fn cold(&self, index: usize) -> Option<&LayoutNodeCold>

Get cold layout data for a node (dirty_flag, subtree_hash, fingerprint, etc.)

Source

pub fn cold_mut(&mut self, index: usize) -> Option<&mut LayoutNodeCold>

Get mutable cold layout data for a node.

Source

pub fn root_node(&self) -> &LayoutNodeHot

Source

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().

Source

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.

Source

pub fn mark_dirty(&mut self, start_index: usize, flag: DirtyFlag)

Marks a node and its ancestors as dirty with the given flag.

Source

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.

Source

pub fn clear_all_dirty_flags(&mut self)

Resets the dirty flags of all nodes in the tree to None after layout is complete.

Source

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.

Source

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

Source§

fn clone(&self) -> LayoutTree

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for LayoutTree

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.