pub struct LayoutNode {Show 28 fields
pub style: ComputedStyle,
pub geometry: LayoutGeometry,
pub children: Vec<LayoutNode>,
pub text: Option<String>,
pub svg_path: Option<String>,
pub svg_items: Vec<SvgItem>,
pub image: Option<ImageResource>,
pub scene_3d: Option<ViewportSceneHandle>,
pub inline_items: Vec<InlineItem>,
pub line_boxes: Vec<LineBox>,
pub layout_cache: LayoutCacheEntry,
pub measure_cache: [MeasureCacheEntry; 2],
pub intrinsic_cache: IntrinsicCacheCell,
pub last_child_layout_content: Option<(f32, f32)>,
pub children_layout_clean: bool,
pub last_preserved_box: Option<(f32, f32, f32, f32, bool)>,
pub applied_relative_offset: (f32, f32),
pub table_grid: Option<TableBorderGrid>,
pub entity_id: EntityId,
pub active_transitions: bool,
pub element_id: Option<String>,
pub anchor_name: Option<String>,
pub is_top_layer: bool,
pub portal_anchor: Option<Box<PortalAnchorSpec>>,
pub subtree_hit_flags: u8,
pub subtree_bounds: Rect,
pub transition_layout_width_px: Option<f32>,
pub transition_layout_height_px: Option<f32>,
}Expand description
A node participating in the layout tree.
Fields§
§style: ComputedStyle§geometry: LayoutGeometry§children: Vec<LayoutNode>§text: Option<String>§svg_path: Option<String>§svg_items: Vec<SvgItem>§image: Option<ImageResource>§scene_3d: Option<ViewportSceneHandle>§inline_items: Vec<InlineItem>§line_boxes: Vec<LineBox>§layout_cache: LayoutCacheEntry§measure_cache: [MeasureCacheEntry; 2]Two-slot measurement probe cache used by Flexbox Pass 1 & Pass 2 to skip clean subtrees in O(1) without clobbering their final Pass-4 child geometry.
intrinsic_cache: IntrinsicCacheCellPersistent per-node intrinsic min/max sizing cache cleared only on subtree invalidation.
last_child_layout_content: Option<(f32, f32)>Content-box size used the last time this node formatted its descendants.
children_layout_clean: boolTrue when this node’s descendants have been laid out for the current style/tree state and
neither self nor any descendant has been invalidated since.
last_preserved_box: Option<(f32, f32, f32, f32, bool)>Last preserved box parameters (x, y, border_w, border_h, resolve_positioned) formatted by
layout_children_inner_guarded, enabling O(1) skip + translate when unchanged.
applied_relative_offset: (f32, f32)Cumulative position: relative (dx, dy) offset already translated onto this node’s
geometry so nested positioning passes remain strictly idempotent.
table_grid: Option<TableBorderGrid>Table border grid matrix for collapsed border rendering (CSS 2.1 §17.6.2).
entity_id: EntityIdUnique 64-bit entity identifier associating this layout node with its blueprint element.
active_transitions: boolTrue when one or more CSS transition-* interpolations are currently in-flight on this node.
element_id: Option<String>DOM id or data-anchor-id attribute used for live anchor lookup.
anchor_name: Option<String>CSS anchor-name (e.g. --card-menu-trigger) declared on this element.
is_top_layer: boolTrue when this element renders in the root Top Layer (<Portal> / create_portal),
escaping all ancestor overflow, transform, filter, and stacking-context boundaries.
portal_anchor: Option<Box<PortalAnchorSpec>>Live anchor positioning specification resolved against post-scroll trigger bounds.
subtree_hit_flags: u8Bitflags summarizing descendants (SUBTREE_HAS_*, SUBTREE_META_VALID).
subtree_bounds: RectConservative axis-aligned bounding box covering this node and in-flow descendants.
transition_layout_width_px: Option<f32>Expanded border-box width locked during collapse/expand transitions so children avoid 0px squeeze.
transition_layout_height_px: Option<f32>Expanded border-box height locked during collapse/expand transitions so children avoid 0px squeeze.
Implementations§
Source§impl LayoutNode
impl LayoutNode
Sourcepub fn new(style: ComputedStyle) -> Self
pub fn new(style: ComputedStyle) -> Self
Constructs a leaf layout node with specified computed styles.
Sourcepub fn with_children(style: ComputedStyle, children: Vec<LayoutNode>) -> Self
pub fn with_children(style: ComputedStyle, children: Vec<LayoutNode>) -> Self
Constructs a layout node with child nodes.
Sourcepub fn with_text(style: ComputedStyle, text: String) -> Self
pub fn with_text(style: ComputedStyle, text: String) -> Self
Constructs a text leaf node with computed styles and string content.
Sourcepub fn with_inline_items(
style: ComputedStyle,
inline_items: Vec<InlineItem>,
) -> Self
pub fn with_inline_items( style: ComputedStyle, inline_items: Vec<InlineItem>, ) -> Self
Constructs an inline phrasing container with an inline item stream.
Sourcepub fn with_svg_path(style: ComputedStyle, svg_path: String) -> Self
pub fn with_svg_path(style: ComputedStyle, svg_path: String) -> Self
Constructs an SVG vector path leaf node with computed styles and path string.
Sourcepub fn with_svg_items(style: ComputedStyle, svg_items: Vec<SvgItem>) -> Self
pub fn with_svg_items(style: ComputedStyle, svg_items: Vec<SvgItem>) -> Self
Constructs an SVG layout node with multiple styled vector items and viewBox.
Sourcepub fn with_image(style: ComputedStyle, image: ImageResource) -> Self
pub fn with_image(style: ComputedStyle, image: ImageResource) -> Self
Constructs a replaced raster image leaf node with intrinsic dimensions.
Sourcepub fn has_active_transitions(&self) -> bool
pub fn has_active_transitions(&self) -> bool
Returns true if this node or any of its descendants currently has an active CSS transition (O(1) call stack).
Sourcepub fn transition_content_width(&self) -> Option<f32>
pub fn transition_content_width(&self) -> Option<f32>
Inner content-box width override used during collapse/expand transitions so children keep their expanded layout width without squeezing to zero mid-animation.
Sourcepub fn transition_content_height(&self) -> Option<f32>
pub fn transition_content_height(&self) -> Option<f32>
Inner content-box height override used during collapse/expand transitions.
Sourcepub fn with_scene_3d(self, handle: ViewportSceneHandle) -> Self
pub fn with_scene_3d(self, handle: ViewportSceneHandle) -> Self
Attaches a 3D viewport scene handle to this layout node.
Sourcepub fn set_scene_3d(&mut self, handle: Option<ViewportSceneHandle>)
pub fn set_scene_3d(&mut self, handle: Option<ViewportSceneHandle>)
Mutably sets or clears the 3D viewport scene handle on this layout node.
Sourcepub fn with_entity_id(self, entity_id: EntityId) -> Self
pub fn with_entity_id(self, entity_id: EntityId) -> Self
Sets the EntityId on this layout node.
Sourcepub fn set_entity_id(&mut self, entity_id: EntityId)
pub fn set_entity_id(&mut self, entity_id: EntityId)
Mutably assigns the EntityId on this layout node.
Sourcepub fn find_by_entity_id(&self, target_id: EntityId) -> Option<&LayoutNode>
pub fn find_by_entity_id(&self, target_id: EntityId) -> Option<&LayoutNode>
Iteratively locates a layout node by its EntityId (O(1) call stack).
Sourcepub fn find_by_entity_id_mut(
&mut self,
target_id: EntityId,
) -> Option<&mut LayoutNode>
pub fn find_by_entity_id_mut( &mut self, target_id: EntityId, ) -> Option<&mut LayoutNode>
Iteratively locates a mutable layout node by its EntityId (O(1) call stack).
Sourcepub fn add_child(&mut self, child: LayoutNode)
pub fn add_child(&mut self, child: LayoutNode)
Appends a child layout node.
Sourcepub fn establishes_stacking_context_in(
&self,
parent_display: Option<Display>,
is_root: bool,
) -> bool
pub fn establishes_stacking_context_in( &self, parent_display: Option<Display>, is_root: bool, ) -> bool
Evaluates if this layout node establishes an atomic CSS stacking context within parent_display.
Sourcepub fn translate(&mut self, dx: f32, dy: f32)
pub fn translate(&mut self, dx: f32, dy: f32)
Translates this node’s geometry and all descendants by (dx, dy) using an iterative heap stack (O(1) call stack).
Sourcepub fn translate_scrolled(
&mut self,
dx: f32,
dy: f32,
parent_is_abs_cb: bool,
parent_is_fixed_cb: bool,
)
pub fn translate_scrolled( &mut self, dx: f32, dy: f32, parent_is_abs_cb: bool, parent_is_fixed_cb: bool, )
Translates descendants of a scroll container by (dx, dy) while honoring CSS containing-block
escape semantics:
Position::Fixedsubtrees do not scroll unless an ancestor at or inside the scroll container established a fixed containing block (transform,filter,backdrop-filter).Position::Absolutesubtrees do not scroll unless an ancestor at or inside the scroll container established an absolute containing block (position != Staticor fixed CB).
Sourcepub fn layout_children(&mut self)
pub fn layout_children(&mut self)
Formats the children of this node within its already-resolved content box.
Sourcepub fn layout_children_guarded(&mut self, guard: LayoutDepthGuard)
pub fn layout_children_guarded(&mut self, guard: LayoutDepthGuard)
Formats the children of this node with an active depth guard.
Sourcepub fn compute_layout(&mut self, available_width: f32, available_height: f32)
pub fn compute_layout(&mut self, available_width: f32, available_height: f32)
Computes layout geometry for this node and all descendants given available bounds.
Sourcepub fn compute_layout_with_exclusions(
&mut self,
available_width: f32,
available_height: f32,
exclusions: Option<&mut ExclusionSpace>,
bfc_offset_y: f32,
)
pub fn compute_layout_with_exclusions( &mut self, available_width: f32, available_height: f32, exclusions: Option<&mut ExclusionSpace>, bfc_offset_y: f32, )
Computes layout geometry passing an active exclusion space for float obstructions.
Sourcepub fn refresh_subtree_hit_metadata(&mut self)
pub fn refresh_subtree_hit_metadata(&mut self)
Recomputes subtree_hit_flags and subtree_bounds bottom-up across the layout tree
using an explicit heap stack (O(1) call stack, #![forbid(unsafe_code)]), skipping
clean subtrees whose SUBTREE_META_VALID flag is already up to date.
Sourcepub fn compute_layout_guarded(
&mut self,
available_width: f32,
available_height: f32,
exclusions: Option<&mut ExclusionSpace>,
bfc_offset_y: f32,
guard: LayoutDepthGuard,
)
pub fn compute_layout_guarded( &mut self, available_width: f32, available_height: f32, exclusions: Option<&mut ExclusionSpace>, bfc_offset_y: f32, guard: LayoutDepthGuard, )
Computes layout geometry passing an active exclusion space and depth guard.
Sourcepub fn invalidate_self_caches(&mut self)
pub fn invalidate_self_caches(&mut self)
Invalidates all layout, measurement, intrinsic sizing, and hit-metadata caches strictly on this node without disturbing clean child subtrees.
Sourcepub fn invalidate_cache(&mut self)
pub fn invalidate_cache(&mut self)
Invalidates layout cache on this node and all descendants using an iterative heap stack.
Sourcepub fn is_layout_boundary(&self) -> bool
pub fn is_layout_boundary(&self) -> bool
Returns true if this node forms an isolated layout boundary (W3C CSS Containment Level 2 §3.1).
An element is a layout boundary if internal descendant changes can never affect the layout of ancestor or sibling elements outside this boundary:
- Explicit CSS
contain: strictorcontain: content - Explicit CSS
contain: layoutcombined withcontain: sizeor definite pixel dimensions - CSS
content-visibility: autoorhiddenwith definite pixel dimensions - Out-of-flow positioned boxes with clipping and definite pixel dimensions
Sourcepub fn has_definite_dimensions(&self) -> bool
pub fn has_definite_dimensions(&self) -> bool
Checks if both width and height are definite non-auto pixel dimensions.
Sourcepub fn find_layout_boundary_path<'a>(
&self,
path: &'a [usize],
) -> Option<&'a [usize]>
pub fn find_layout_boundary_path<'a>( &self, path: &'a [usize], ) -> Option<&'a [usize]>
Recursively searches for the nearest ancestor layout boundary containing the given index path.
Returns the prefix of path that terminates at the nearest layout boundary container.
Sourcepub fn compute_subgrid_or_boundary_layout(&mut self, path: &[usize]) -> bool
pub fn compute_subgrid_or_boundary_layout(&mut self, path: &[usize]) -> bool
Recomputes layout for the subtree rooted at path within its containing layout boundary.
If an ancestor layout boundary exists along path, layout is recomputed ONLY for that
boundary container and its descendants, guaranteeing zero re-layouts on the rest of the tree.
Returns true if a layout boundary was found and laid out locally, or false if root
layout recomputation is required.
Sourcepub fn invalidate_layout_boundary(&mut self, path: &[usize]) -> bool
pub fn invalidate_layout_boundary(&mut self, path: &[usize]) -> bool
Invalidates layout cache only for nodes along path under the nearest layout boundary.
Sourcepub fn find_path_by_entity_id(&self, target_id: EntityId) -> Option<Vec<usize>>
pub fn find_path_by_entity_id(&self, target_id: EntityId) -> Option<Vec<usize>>
Iteratively calculates the index path to the layout node with matching EntityId (O(1) call stack).
Sourcepub fn invalidate_ancestors(&mut self, path: &[usize])
pub fn invalidate_ancestors(&mut self, path: &[usize])
Invalidates layout cache on self and all ancestors leading down to path.
Sourcepub fn update_scroll_metrics(&mut self)
pub fn update_scroll_metrics(&mut self)
Evaluates child geometry to compute scroll_bounds and has_scroll for this container.