Skip to content

v0.16.0

Choose a tag to compare

@nicoburns nicoburns released this 23 Nov 16:02
· 6 commits to main since this release
497de49

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_box and FloatContext::place_floated_box take a caller-defined id: u64, which is stored on PlacedFloatedBox. BlockContext::float_mark and BlockContext::floats_placed_since return 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_slot takes the height of the content being placed, and find_bfc_slot a min_height, and both avoid floats beside that height rather than only at its top edge. ContentSlot::height and the new BfcSlot::height are how far down the slot's width stays valid (previously ContentSlot::height was always infinite).
  • A new FloatInsets type (left/right) replaces the [f32; 2] insets and margins taken by BlockContext::sub_context, BlockContext::apply_content_box_inset, BlockContext::find_bfc_slot and the FloatContext placement methods. FloatDirection::opposite has also been added.

Changed

  • BREAKING: CacheTree::cache_get and Cache::get take &self rather than &mut self, with the measure cache's eviction clock stored in an AtomicU16. Cache no longer implements Serialize with the serde feature (#1409, #1410).
  • Upgrade cssparser to 0.38 (used by the parse feature). Parse error messages no longer name the offending token (#1414).

Performance

  • TaffyTree uses FxHash for node context lookups when std is 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 clear and 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 width and max-width against zero in the min-content contribution of compressible replaced children, so shrink-to-fit blocks holding a width: 100% image no longer grow to the image's natural width (#1401).
  • Flexbox: fall back to flex-start rather than start when overflowing lines or items are aligned with align-content: stretch/normal or justify-content: stretch, fixing wrap-reverse and 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).