Skip to main content

StoreLayoutEngine

Trait StoreLayoutEngine 

Source
pub trait StoreLayoutEngine: Send {
Show 22 methods // Required methods fn name(&self) -> &'static str; fn sync_changes(&mut self, store: &NodeStore, changes: &ChangeSet); fn top_layer(&self) -> &TopLayerIndex; fn compute_layout( &mut self, store: &NodeStore, root: NodeId, viewport: Viewport, ) -> bool; fn layout_of(&self, id: NodeId) -> Option<LayoutRect>; fn set_text_measurer(&mut self, measurer: Arc<dyn TextMeasurer>); fn reset(&mut self); // Provided methods fn sync_changes_with_interaction( &mut self, store: &NodeStore, changes: &ChangeSet, _interaction: Option<&InteractionTracker>, ) { ... } fn compute_layout_with_interaction( &mut self, store: &NodeStore, root: NodeId, viewport: Viewport, _interaction: Option<&InteractionTracker>, ) -> bool { ... } fn sync_interaction_paragraphs( &mut self, _store: &NodeStore, _interaction: &InteractionTracker, _dirty_nodes: &[NodeId], ) -> (&[NodeId], &[NodeId]) { ... } fn paragraphs(&self) -> Option<&ParagraphStore> { ... } fn paragraphs_mut(&mut self) -> Option<&mut ParagraphStore> { ... } fn measure_root( &mut self, _store: &NodeStore, _root: NodeId, _constraints: SizeConstraints, _ideal: bool, ) -> SurfaceMeasure { ... } fn changed_rects(&self) -> Option<&[NodeId]> { ... } fn set_capture_box_edges(&mut self, _enabled: bool) { ... } fn capture_box_edges(&self) -> bool { ... } fn box_edges_of(&self, _id: NodeId) -> Option<ResolvedBoxEdges> { ... } fn register_measure_hook( &mut self, _slot: TableSlot, _hook: Arc<dyn LeafMeasureHook>, ) -> bool { ... } fn set_media_env(&mut self, _env: MediaEnv) -> bool { ... } fn visit_responsive_patches<'a>( &self, _store: &'a NodeStore, _id: NodeId, _f: &mut dyn FnMut(ConditionalTier, RowPatchView<'a>), ) { ... } fn is_show_on_hidden(&self, _store: &NodeStore, _id: NodeId) -> bool { ... } fn responsive_epoch(&self) -> u64 { ... }
}
Expand description

Direct NodeStore layout engine trait implemented by crate::TaffyStoreLayout, real React Native Yoga (packages/modules/layout-yoga), custom layout engines, and DynLayoutEngine (Box<dyn StoreLayoutEngine>).

Computed rectangles returned by StoreLayoutEngine::layout_of are expressed in surface-space (root-relative absolute) coordinates in logical points.

Required Methods§

Source

fn name(&self) -> &'static str

Human-readable engine identifier (e.g. "taffy", "yoga").

Source

fn sync_changes(&mut self, store: &NodeStore, changes: &ChangeSet)

Invalidates cached layout entries for every layout/measure/structural change in changes.

Every engine owns one TopLayerIndex and syncs it first (TopLayerIndex::sync), then hoists exactly its TopLayerIndex::hoisted roots to the layout root.

Source

fn top_layer(&self) -> &TopLayerIndex

The engine’s top-layer index: the single source of which overlay roots are hoisted. After every Self::sync_changes it covers every store slot (TopLayerIndex::sync guarantees it); the runtime publishes its states() zero-copy as the top_layer_states scene fact.

Source

fn compute_layout( &mut self, store: &NodeStore, root: NodeId, viewport: Viewport, ) -> bool

Computes layout for root at viewport directly from store word columns.

Self-gating contract: the engine is the single owner of the clean-frame gate. Callers invoke this on every frame after StoreLayoutEngine::sync_changes; when nothing that affects layout changed since the last pass (no layout/measure/structural change, same root and viewport, no measurer swap or reset), the engine returns false without running a pass and every StoreLayoutEngine::layout_of result stays current. Returns true when a pass ran (layout results may have changed). A pass that unwinds (e.g. a panicking host TextMeasurer) must leave the engine dirty so the next call retries.

Source

fn layout_of(&self, id: NodeId) -> Option<LayoutRect>

Returns the absolute rounded layout rect of id from the latest pass, if live.

Source

fn set_text_measurer(&mut self, measurer: Arc<dyn TextMeasurer>)

Installs a custom text measurer and invalidates cached text measurements.

Source

fn reset(&mut self)

Clears all cached layout state.

Provided Methods§

Source

fn sync_changes_with_interaction( &mut self, store: &NodeStore, changes: &ChangeSet, _interaction: Option<&InteractionTracker>, )

Variant of Self::sync_changes that also resolves active :hover/:active state rules on inline paragraph runs.

Source

fn compute_layout_with_interaction( &mut self, store: &NodeStore, root: NodeId, viewport: Viewport, _interaction: Option<&InteractionTracker>, ) -> bool

Variant of Self::compute_layout that threads active InteractionTracker state into compiled paragraph runs when deferred inheritance runs.

Source

fn sync_interaction_paragraphs( &mut self, _store: &NodeStore, _interaction: &InteractionTracker, _dirty_nodes: &[NodeId], ) -> (&[NodeId], &[NodeId])

Recompiles only paragraphs owning dirty_nodes after an interactive pseudo-state change (:hover/:active/:focus). Returns (layout_dirty_paragraphs, paint_dirty_paragraphs).

Source

fn paragraphs(&self) -> Option<&ParagraphStore>

Borrowed compiled ParagraphStore shared with nativeview-runtime, SkiaBackend, and a11y.

Source

fn paragraphs_mut(&mut self) -> Option<&mut ParagraphStore>

Mutable borrow of the compiled ParagraphStore (used to lock capacity before publish).

Source

fn measure_root( &mut self, _store: &NodeStore, _root: NodeId, _constraints: SizeConstraints, _ideal: bool, ) -> SurfaceMeasure

Measures root under constraints (or unconstrained intrinsic sizing when ideal is true) without mutating committed layout boxes, published rects, or viewport state.

Source

fn changed_rects(&self) -> Option<&[NodeId]>

Exact set of reachable live nodes whose committed Self::layout_of changed (bitwise) or became newly laid out during the latest Self::compute_layout pass, or None when the full delta is unavailable and callers must fall back to scanning all live nodes.

Contract:

  • Some(&[]) after a clean frame where Self::compute_layout returned false or after Self::reset.
  • Some(ids) includes nodes transitioning to/from display: none or display: contents when their committed rect changes, as well as newly laid-out / slot-reused nodes.
  • Removed nodes are reported via ChangeSet::removed; inline/box transitions via ParagraphStore.
  • None for engines without delta tracking (default) or when the entire tree was invalidated (e.g. dead root or a multi-pass top_layer_rerun fallback).
Source

fn set_capture_box_edges(&mut self, _enabled: bool)

Enables or disables opt-in resolved CSS box-edge capture (margin/border/padding/ content_size) for the Visual Layout Inspector. Disabled by default (0 B overhead).

Source

fn capture_box_edges(&self) -> bool

Returns whether opt-in box-edge capture is currently active.

Source

fn box_edges_of(&self, _id: NodeId) -> Option<ResolvedBoxEdges>

Returns the exact resolved box edges of id from the latest layout pass when opt-in capture is enabled, or None when disabled or unsupported by this engine.

Source

fn register_measure_hook( &mut self, _slot: TableSlot, _hook: Arc<dyn LeafMeasureHook>, ) -> bool

Registers an intrinsic LeafMeasureHook for nodes carrying slot, invalidating cached layout entries, and returns true if a prior hook at slot was replaced. Engines without leaf-hook support ignore it and return false by default.

Source

fn set_media_env(&mut self, _env: MediaEnv) -> bool

Sets the @media environment (compute_layout supplies the viewport size). Returns true when it changed. Engines without responsive support ignore it.

Source

fn visit_responsive_patches<'a>( &self, _store: &'a NodeStore, _id: NodeId, _f: &mut dyn FnMut(ConditionalTier, RowPatchView<'a>), )

Visits id’s matching @media then @container rule patches (cascade order) under the environment of the last committed pass. Engines without responsive support visit nothing.

Source

fn is_show_on_hidden(&self, _store: &NodeStore, _id: NodeId) -> bool

Whether id’s Responsive::show_on gate fails under the engine’s @media environment (display: none that beats every rule). Engines without responsive support never hide.

Source

fn responsive_epoch(&self) -> u64

Bumped whenever responsive styles may resolve differently without a store commit (the media signature or a committed @container env changed). Caches of derived style (e.g. stacking plans) key on it. Engines without responsive support stay at 0.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<L: StoreLayoutEngine + ?Sized> StoreLayoutEngine for Box<L>

Source§

fn name(&self) -> &'static str

Source§

fn sync_changes(&mut self, store: &NodeStore, changes: &ChangeSet)

Source§

fn top_layer(&self) -> &TopLayerIndex

Source§

fn sync_changes_with_interaction( &mut self, store: &NodeStore, changes: &ChangeSet, interaction: Option<&InteractionTracker>, )

Source§

fn compute_layout( &mut self, store: &NodeStore, root: NodeId, viewport: Viewport, ) -> bool

Source§

fn compute_layout_with_interaction( &mut self, store: &NodeStore, root: NodeId, viewport: Viewport, interaction: Option<&InteractionTracker>, ) -> bool

Source§

fn sync_interaction_paragraphs( &mut self, store: &NodeStore, interaction: &InteractionTracker, dirty_nodes: &[NodeId], ) -> (&[NodeId], &[NodeId])

Source§

fn paragraphs(&self) -> Option<&ParagraphStore>

Source§

fn paragraphs_mut(&mut self) -> Option<&mut ParagraphStore>

Source§

fn measure_root( &mut self, store: &NodeStore, root: NodeId, constraints: SizeConstraints, ideal: bool, ) -> SurfaceMeasure

Source§

fn layout_of(&self, id: NodeId) -> Option<LayoutRect>

Source§

fn changed_rects(&self) -> Option<&[NodeId]>

Source§

fn set_capture_box_edges(&mut self, enabled: bool)

Source§

fn capture_box_edges(&self) -> bool

Source§

fn box_edges_of(&self, id: NodeId) -> Option<ResolvedBoxEdges>

Source§

fn set_text_measurer(&mut self, measurer: Arc<dyn TextMeasurer>)

Source§

fn register_measure_hook( &mut self, slot: TableSlot, hook: Arc<dyn LeafMeasureHook>, ) -> bool

Source§

fn reset(&mut self)

Source§

fn set_media_env(&mut self, env: MediaEnv) -> bool

Source§

fn visit_responsive_patches<'a>( &self, store: &'a NodeStore, id: NodeId, f: &mut dyn FnMut(ConditionalTier, RowPatchView<'a>), )

Source§

fn is_show_on_hidden(&self, store: &NodeStore, id: NodeId) -> bool

Source§

fn responsive_epoch(&self) -> u64

Implementors§