Expand description
The host MEASURE contract. The VAPP-4 verdict: never one FFI upcall per
taffy measure call (taffy asks a leaf 10–15 times per pass). The core
batches: ONE upcall for the intrinsic widths of every dirty leaf (with the
resolved text style, so Compose can pick the font before its first pass),
taffy runs against a Rust-side memo, ONE upcall for the heights at the
widths taffy decided, and a third round only when a height changed a width
decision (counted in LayoutOutput::measure_rounds). In-process painters
(gpui) may answer per request through DirectMeasure; nothing crosses
an FFI there.
Structs§
- Control
Box - The control box a leaf’s recipe fixes (padding inside the measured size,
definite sizes taffy already knows). The measurer adds the padding around
the content it shapes and honours
min_*.padding_horizontal/padding_verticalare the AVERAGES of the two sides (a measurer adding2 × paddinggets the exact total);paddinghas every side. - Direct
Measure - The per-request form for in-process painters (gpui): one closure that
answers
(leaf, wrap_width)with a size.None= unconstrained (max-content);Some(0.0)= min-content. No baselines (seeDirectMeasureWithBaseline). - Direct
Measure With Baseline DirectMeasurewhose closure also answers the first baseline:(leaf, wrap_width) → (width, height, baseline).- Fixed
Measure - The geometry-test measure every platform reproduces exactly: 8 px per
character on ONE 20 px line (no wrapping), fixed boxes per control, or an
explicit size per node id (
fixtures/layout-geometry.jsonmeasures). - Height
Request - Second phase: the height of leaf
indexwhen laid outwidthwide. - Intrinsics
- What the host answers for one leaf: the width it needs with every line
break taken (
min_content), with none (max_content), the height atmax_contentwidth (one line for text) and the FIRST BASELINE from the top of the border box (alignItems: baseline; it does not move with the width: the first line stays the first line).None= no baseline (an icon, a box): the bottom edge stands in, like CSS. Controls with a fixed box return it in both widths. - Leaf
Request - One leaf the host must measure.
indexnames the layout node; the host keys its own caches on it.lines= theTextprop (truncate to N lines). - Measure
Memo - The Rust-side memo taffy’s measure closure answers from. Keyed by layout
node index;
content_versionbumps clear a leaf’s entries. - Measure
Request - A measured leaf’s answer for one taffy request, from the memo.
widthtaffy already knows wins; else the available space picks min/max content; a definite available width clamps max-content (text wraps). - Text
Style - Typography a measured leaf is laid out with (the theme’s resolved recipe).
Constants§
- FIXED_
ASCENT - The fixed measure’s ascent: a 20 px line’s baseline sits 15 px down.
- FIXED_
CHAR_ WIDTH - FIXED_
LINE_ HEIGHT
Traits§
- Measure
- Implemented by the host. Both calls receive batches; the core never calls them per taffy request.
Functions§
- finite_
or_ zero vwhen finite and non-negative, else 0 (R8 F53: a host’s NaN, ±inf or negative size never reaches the memo or taffy).