Skip to main content

TaffyEngine

Struct TaffyEngine 

Source
pub struct TaffyEngine { /* private fields */ }
Expand description

Taffy 0.10 backend.

Invariant: every dom id in id_map has a valid NodeId in tree.

Implementations§

Source§

impl TaffyEngine

Source

pub fn new() -> Self

Create an empty engine.

Source

pub fn computed_absolute(&self, id: u32) -> Option<Rect>

The node’s rounded ABSOLUTE (root-relative) rect — x/y are the sum of the rounded parent-relative offsets down the ancestor chain (the integer cell where the renderer paints the node); width/height are identical to LayoutEngine::computed’s.

ADDITIVE companion to computed (which stays parent-relative — wire/API covenant): produced by the same round_node post-pass, so the two are coherent per calculate. Returns None for unknown, freed, or never-calculated ids. A node detached AFTER the last calculate (remove_child without destroy) serves its last-calculated rect until the next calculate evicts it — the same staleness contract as rounded (see destroy’s eviction note). No live-taffy fallback like computed’s: an absolute position requires the ancestor chain walked by calculate, which a not-yet-calculated node does not have. The rendered path (build → calculate → read) never hits that case.

Trait Implementations§

Source§

impl Default for TaffyEngine

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl LayoutEngine for TaffyEngine

Source§

fn create(&mut self, id: u32) -> Result<(), String>

Register a new node with the engine. Read more
Source§

fn apply_style(&mut self, id: u32, style: &Style) -> Result<(), String>

Update the layout style for id. Read more
Source§

fn set_measure(&mut self, id: u32, f: Box<MeasureFn>)

Attach a measure callback to leaf node id. Read more
Source§

fn insert_child( &mut self, parent: u32, child: u32, index: usize, ) -> Result<(), String>

Insert child under parent at index. Read more
Source§

fn remove_child(&mut self, parent: u32, child: u32) -> Result<(), String>

Remove child from parent. Read more
Source§

fn destroy(&mut self, id: u32)

Remove a node from the engine entirely, freeing its taffy node. Read more
Source§

fn mark_dirty(&mut self, id: u32) -> Result<(), String>

Mark node id dirty so it is recomputed on the next calculate. Read more
Source§

fn calculate( &mut self, root_id: u32, viewport_width: f32, viewport_height: Option<f32>, ) -> Result<(), String>

Compute layout for the whole tree rooted at root_id. Read more
Source§

fn computed(&self, id: u32) -> Option<Rect>

Return the computed rect for id after the last calculate. 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> 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, 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.