Repository navigation
v0.16.0
The MSRV for this release is 1.85, and Taffy now uses the 2024 edition.
As a result of the MSRV bump, the strict_provenance feature has been removed: CompactLength now always uses the strict provenance pointer APIs (#1411, #1413, #1419).
calc() values are stored as a CalcHandle (#1400)
calc() values are now stored as an opaque CalcHandle rather than a *const (). Create one with CalcHandle::from_ptr or CalcHandle::from_bits, and read it back with ptr() or to_bits(). The calc/fit_content_calc constructors take a CalcHandle, and calc_value(), the Expanded*::Calc variants, LayoutPartialTree::resolve_calc_value and calc resolver closures return or receive one.
This allows handles to have 61 bits available on every target: previously 32-bit targets were limited to a 32-bit pointer.
Scrollable overflow supports reversed scroll origins (#1372)
Layout::scrollable_overflow_rect and LayoutOutput::scrollable_overflow_rect are now a ScrollableOverflow rather than a Rect<f32>. As well as the overflow rectangle, it records whether each physical axis has a reversed scroll origin (is_reversed()), where scrolling starts at the end edge. Read the rectangle with rect() or the left()/right()/top()/bottom() accessors.
Reversed (row-reverse, column-reverse) and wrap-reverse flex containers now retain reachable negative overflow, and scroll containers clip overflow that is unreachable by scrolling.
Improved Float placement API for custom formatting contexts (#1303, #1385, #1386, #1389, #1394)
Most users will never need to interact this directly, but it affects consumers who integrate float-supporting text/inline with Taffy.
BlockContext::place_floated_boxandFloatContext::place_floated_boxtake a caller-definedid: u64, which is stored onPlacedFloatedBox.BlockContext::float_markandBlockContext::floats_placed_sincereturn the id and position of the floats placed since a mark, so custom formatting contexts which place floats don't need to keep their own list of placements.find_content_slottakes theheightof the content being placed, andfind_bfc_slotamin_height, and both avoid floats beside that height rather than only at its top edge.ContentSlot::heightand the newBfcSlot::heightare how far down the slot's width stays valid (previouslyContentSlot::heightwas always infinite).- A new
FloatInsetstype (left/right) replaces the[f32; 2]insets and margins taken byBlockContext::sub_context,BlockContext::apply_content_box_inset,BlockContext::find_bfc_slotand theFloatContextplacement methods.FloatDirection::oppositehas also been added.
Changed
- BREAKING:
CacheTree::cache_getandCache::gettake&selfrather than&mut self, with the measure cache's eviction clock stored in anAtomicU16.Cacheno longer implementsSerializewith theserdefeature (#1409, #1410). - Upgrade
cssparserto 0.38 (used by theparsefeature). Parse error messages no longer name the offending token (#1414).
Performance
TaffyTreeuses FxHash for node context lookups whenstdis enabled (#1402).
Fixed
- Block/float: include the bottom padding and border of a box that establishes a block formatting context below the floats it contains (#1384).
- Block/float: make a box that establishes a block formatting context avoid floats beside its whole laid-out height, not just its top edge, narrowing it or moving it down to the next slot that fits (#1385, #1396).
- Block/float: move an
auto-width box that establishes a block formatting context below a float when its padding and border don't fit beside it (#1417). - Block/float: make zero-height floats affect content and block formatting context roots that cross them, not just
clearand later floats (#1387). - Block: don't add the margins of leading children that collapse through a block to its height when it has a bottom but no top padding or border (#1397).
- Block: resolve percentage
widthandmax-widthagainst zero in the min-content contribution of compressible replaced children, so shrink-to-fit blocks holding awidth: 100%image no longer grow to the image's natural width (#1401). - Flexbox: fall back to
flex-startrather thanstartwhen overflowing lines or items are aligned withalign-content: stretch/normalorjustify-content: stretch, fixingwrap-reverseand reversed directions (#1363). - Grid: leave room for an item's margins and baseline shim when clamping its content-based minimum size to the fixed max track sizing functions it spans (#1362).