Skip to main content

LayoutNode

Struct LayoutNode 

Source
pub struct LayoutNode {
Show 19 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 last_child_layout_content: Option<(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>>,
}
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§last_child_layout_content: Option<(f32, f32)>

Content-box size used the last time this node formatted its descendants.

§table_grid: Option<TableBorderGrid>

Table border grid matrix for collapsed border rendering (CSS 2.1 §17.6.2).

§entity_id: EntityId

Unique 64-bit entity identifier associating this layout node with its blueprint element.

§active_transitions: bool

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

True 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.

Implementations§

Source§

impl LayoutNode

Source

pub fn new(style: ComputedStyle) -> Self

Constructs a leaf layout node with specified computed styles.

Source

pub fn with_children(style: ComputedStyle, children: Vec<LayoutNode>) -> Self

Constructs a layout node with child nodes.

Source

pub fn with_text(style: ComputedStyle, text: String) -> Self

Constructs a text leaf node with computed styles and string content.

Source

pub fn with_inline_items( style: ComputedStyle, inline_items: Vec<InlineItem>, ) -> Self

Constructs an inline phrasing container with an inline item stream.

Source

pub fn with_svg_path(style: ComputedStyle, svg_path: String) -> Self

Constructs an SVG vector path leaf node with computed styles and path string.

Source

pub fn with_svg_items(style: ComputedStyle, svg_items: Vec<SvgItem>) -> Self

Constructs an SVG layout node with multiple styled vector items and viewBox.

Source

pub fn with_image(style: ComputedStyle, image: ImageResource) -> Self

Constructs a replaced raster image leaf node with intrinsic dimensions.

Source

pub fn has_active_transitions(&self) -> bool

Returns true if this node or any of its descendants currently has an active CSS transition.

Source

pub fn with_scene_3d(self, handle: ViewportSceneHandle) -> Self

Attaches a 3D viewport scene handle to this layout node.

Source

pub fn set_scene_3d(&mut self, handle: Option<ViewportSceneHandle>)

Mutably sets or clears the 3D viewport scene handle on this layout node.

Source

pub fn with_entity_id(self, entity_id: EntityId) -> Self

Sets the EntityId on this layout node.

Source

pub fn set_entity_id(&mut self, entity_id: EntityId)

Mutably assigns the EntityId on this layout node.

Source

pub fn find_by_entity_id(&self, target_id: EntityId) -> Option<&LayoutNode>

Recursively locates a layout node by its EntityId.

Source

pub fn find_by_entity_id_mut( &mut self, target_id: EntityId, ) -> Option<&mut LayoutNode>

Recursively locates a mutable layout node by its EntityId.

Source

pub fn add_child(&mut self, child: LayoutNode)

Appends a child layout node.

Source

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.

Source

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

Source

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::Fixed subtrees do not scroll unless an ancestor at or inside the scroll container established a fixed containing block (transform, filter, backdrop-filter).
  • Position::Absolute subtrees do not scroll unless an ancestor at or inside the scroll container established an absolute containing block (position != Static or fixed CB).
Source

pub fn layout_children(&mut self)

Formats the children of this node within its already-resolved content box.

Source

pub fn layout_children_guarded(&mut self, guard: LayoutDepthGuard)

Formats the children of this node with an active depth guard.

Source

pub fn compute_layout(&mut self, available_width: f32, available_height: f32)

Computes layout geometry for this node and all descendants given available bounds.

Source

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.

Source

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.

Source

pub fn invalidate_cache(&mut self)

Invalidates layout cache on this node and all descendants using an iterative heap stack.

Source

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:

  1. Explicit CSS contain: strict or contain: content
  2. Explicit CSS contain: layout combined with contain: size or definite pixel dimensions
  3. CSS content-visibility: auto or hidden with definite pixel dimensions
  4. Out-of-flow positioned boxes with clipping and definite pixel dimensions
Source

pub fn has_definite_dimensions(&self) -> bool

Checks if both width and height are definite non-auto pixel dimensions.

Source

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.

Source

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.

Source

pub fn invalidate_layout_boundary(&mut self, path: &[usize]) -> bool

Invalidates layout cache only for nodes along path under the nearest layout boundary.

Source

pub fn find_path_by_entity_id(&self, target_id: EntityId) -> Option<Vec<usize>>

Recursively calculates the index path to the layout node with matching EntityId.

Source

pub fn invalidate_ancestors(&mut self, path: &[usize])

Invalidates layout cache on self and all ancestors leading down to path.

Source

pub fn update_scroll_metrics(&mut self)

Evaluates child geometry to compute scroll_bounds and has_scroll for this container.

Trait Implementations§

Source§

impl Clone for LayoutNode

Source§

fn clone(&self) -> Self

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 LayoutNode

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Drop for LayoutNode

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl PartialEq for LayoutNode

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for LayoutNode

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.