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§
Sourcefn sync_changes(&mut self, store: &NodeStore, changes: &ChangeSet)
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.
Sourcefn top_layer(&self) -> &TopLayerIndex
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.
Sourcefn compute_layout(
&mut self,
store: &NodeStore,
root: NodeId,
viewport: Viewport,
) -> bool
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.
Sourcefn layout_of(&self, id: NodeId) -> Option<LayoutRect>
fn layout_of(&self, id: NodeId) -> Option<LayoutRect>
Returns the absolute rounded layout rect of id from the latest pass, if live.
Sourcefn set_text_measurer(&mut self, measurer: Arc<dyn TextMeasurer>)
fn set_text_measurer(&mut self, measurer: Arc<dyn TextMeasurer>)
Installs a custom text measurer and invalidates cached text measurements.
Provided Methods§
Sourcefn sync_changes_with_interaction(
&mut self,
store: &NodeStore,
changes: &ChangeSet,
_interaction: Option<&InteractionTracker>,
)
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.
Sourcefn compute_layout_with_interaction(
&mut self,
store: &NodeStore,
root: NodeId,
viewport: Viewport,
_interaction: Option<&InteractionTracker>,
) -> bool
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.
Sourcefn sync_interaction_paragraphs(
&mut self,
_store: &NodeStore,
_interaction: &InteractionTracker,
_dirty_nodes: &[NodeId],
) -> (&[NodeId], &[NodeId])
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).
Sourcefn paragraphs(&self) -> Option<&ParagraphStore>
fn paragraphs(&self) -> Option<&ParagraphStore>
Borrowed compiled ParagraphStore shared with nativeview-runtime, SkiaBackend, and a11y.
Sourcefn paragraphs_mut(&mut self) -> Option<&mut ParagraphStore>
fn paragraphs_mut(&mut self) -> Option<&mut ParagraphStore>
Mutable borrow of the compiled ParagraphStore (used to lock capacity before publish).
Sourcefn measure_root(
&mut self,
_store: &NodeStore,
_root: NodeId,
_constraints: SizeConstraints,
_ideal: bool,
) -> SurfaceMeasure
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.
Sourcefn changed_rects(&self) -> Option<&[NodeId]>
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 whereSelf::compute_layoutreturnedfalseor afterSelf::reset.Some(ids)includes nodes transitioning to/fromdisplay: noneordisplay: contentswhen their committed rect changes, as well as newly laid-out / slot-reused nodes.- Removed nodes are reported via
ChangeSet::removed; inline/box transitions viaParagraphStore. Nonefor engines without delta tracking (default) or when the entire tree was invalidated (e.g. dead root or a multi-passtop_layer_rerunfallback).
Sourcefn set_capture_box_edges(&mut self, _enabled: bool)
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).
Sourcefn capture_box_edges(&self) -> bool
fn capture_box_edges(&self) -> bool
Returns whether opt-in box-edge capture is currently active.
Sourcefn box_edges_of(&self, _id: NodeId) -> Option<ResolvedBoxEdges>
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.
Sourcefn register_measure_hook(
&mut self,
_slot: TableSlot,
_hook: Arc<dyn LeafMeasureHook>,
) -> bool
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.
Sourcefn set_media_env(&mut self, _env: MediaEnv) -> bool
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.
Sourcefn visit_responsive_patches<'a>(
&self,
_store: &'a NodeStore,
_id: NodeId,
_f: &mut dyn FnMut(ConditionalTier, RowPatchView<'a>),
)
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.
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.
Sourcefn responsive_epoch(&self) -> u64
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".