v0.14.0
The MSRV for this release is 1.71.
The width, height and flex-basis properties now support min-content, max-content, fit-content, fit-content(), and stretch keywords. flex-basis additionally supports the content keyword. The min-width/max-width (and height) properties have been switched to use LengthPercentageAuto rather than Dimension, as they do not yet support these keywords.
Taffy now supports flex-wrap: balance and flex-line-count from CSS Flexbox Level 2, behind the default flexbox_balance feature.
See Balancing Text in CSS: The Flex-Wrap Last Row Problem for an explainer.
The layout effects of contain: layout, contain: paint, and contain: content are now supported, including independent formatting contexts, baseline suppression, and overflow containment. contain: size is not yet supported.
DetailedGridTracksInfo'sguttersandsizesfields are replaced by a singlepositionsvec.positionscontains the offset of every grid line in the implicit grid. This allows it to account for offsets introduce by content-alignment. And also allows for O(1) access to grid area sizes.- All data in
DetailedGridTracksInfois now stored in logical order (so right-to-left fordirection: rtlgrids) - Added
DetailedGridInfo::resolve_absolute_grid_areawhich can resolve a grid area for an item given it's position styles. This is useful for positioning hoisted absolutely positioned boxes relative to a grid containing block. - Added
grid_template_rowsandgrid_template_columnsmethods which serialize those properties into a string according to the CSS standard.
Caching logic is now more correct (#1010, #1155)
- Tagged-pointer style types now have
expand()methods that expose their values as plain enums (#1129). Layout::content_sizeis nowscrollable_overflow_rect: Rect<f32>. Itsrightandbottomfields replace the old width and height values;scroll_width()andscroll_height()are unchanged (#1118).LayoutOutput::first_baselinesis nowbaselines: Baselines, withfirstandlastbaseline fields (#1107).Style::min_sizeandmax_sizenow useLengthPercentageAutorather thanDimension(#1099).compute_layout_with_measurenow passes aLayoutInputand returnsLayoutOutput; callcompute_leaf_layoutexplicitly to preserve the old leaf-measurement behaviour (#1091).- Block and Flexbox no longer measure absolutely positioned children whose dimensions are already known (#1120).
CacheTree::cache_getandCache::getnow take&mut self, and the measure cache uses second-chance (clock) eviction (#1010).
- Cache: prevent axis-specific measurements from being reused for the wrong axis and avoid caching margin-collapse metadata (#1010).
- Flexbox: fix intrinsic sizing with negative margins and zero flex bases (#1152).
- Flexbox: apply inherent style sizing on top of content-size measurements (#1155).
- Flexbox: transfer definite stretched cross sizes through aspect ratios when calculating flex base sizes (#1155).
- Block/float: account for
clearwhen computing the intrinsic width of floats (#1150). - Flexbox: generate container baselines from the visually startmost line or item in reverse layouts (#1127).
- Block/Grid: clamp scroll-container baselines to the border box and synthesize missing Block baselines (#1108, #1126).
- Flexbox/Grid: exclude items with auto cross-axis margins from baseline alignment (#1109, #1125).
- Grid: exclude items with cyclic percentage block sizes from baseline alignment (3dbf2e46b).
- CSS parser: preserve unnamed grid lines when parsing
grid-template-rowsandgrid-template-columns(#1138). - Block/float: don't include overflowing in-flow content in the float contribution to a BFC's height (#1128).
- Block: resolve percentage heights and relative vertical insets against the correct definite height (#1122).
- Block: prevent bottom-margin collapsing when
min-heightdetermines the used height (#1082). - Block: resolve percentage padding and borders against the containing block's width (#1083).
- Block: resolve absolutely positioned auto margins against the clamped used size (#1096).
- Block/float: apply non-
normalalign-contentto formatting contexts and floated children (#1087, #1089). - Flexbox: correctly track definite sizes through nested layouts and percentage-sized descendants (#1003, #1123).
- Flexbox: don't distribute free space through
justify-contentafter auto margins consume it (#1115). - Flexbox: skip unnecessary automatic min-content measurements (#1119).
- Block/Flexbox/Grid: correct scrollable overflow handling for start-side overflow, RTL, and end padding (#1114, #1116, #1117).
TaffyTree::removenow marks the former parent dirty (#1085).- Grid: fix named-line numbering for repetitions and validate their line-name counts (#1035).
- Grid: prevent infinite loops during track sizing and auto-placement (#1036, #1037).
- Flexbox: wrap indefinite containers against their maximum main size (#1101).
- Grid: don't skip intrinsic sizing for tracks with an intrinsic minimum and fixed maximum (#1097).
- Grid: correctly distribute content contributions across flexible tracks (#1084).
v0.13.0
The MSRV for this release is 1.71.
-
Support for the
self-startandself-endalignment keywords (AlignItems::SELF_START/SELF_ENDand safe variants). These resolve against thedirectionof the item itself rather than that of its container, so they only differ fromstart/endwhen the item's direction differs from its container's. Supported foralign-self/align-itemsandjustify-self/justify-itemson both in-flow and absolutely positioned Flexbox and Grid items (#1074) -
Support for
display: flow-root. The newDisplay::FlowRootvariant lays out children using the block layout algorithm but always establishes a new block formatting context (its margins do not collapse with those of its children, it contains its own floats, and it avoids external floats)
- Numeric style helpers (
length,percent,fr,flex) now acceptInput: Into<f64>instead ofInput: Into<f32>. This allows bare float literals such aslength(800.0)to be used without triggering thefloat_literal_f32_fallbackfuture-compatibility lint, while widening the set of accepted numeric input types (#974) - Grid:
grid_template_areasis nowOption<GridTemplateAreas<S>>, where the newGridTemplateAreasstruct includesrow_count/column_countfields. This allows templates containing unnamed (.) cells beyond the extents of the named areas (e.g.grid-template-areas: "a .") to be represented. - Block/float:
BlockContext::place_floated_boxtakes an additionaladjoins_unresolved_strut: boolparameter indicating whether the float is being placed while the position of the current margin-collapse strut is still unresolved
A large number of miscelaneous bug fixes are included in this release:
- Flexbox: clamp the flex base size, automatic minimum size and hypothetical main/cross sizes with min/max sizes transferred through the aspect ratio, instead of baking them into the item's used min/max sizes (#989)
- Flexbox: resolve
justify-content: start/endandalign-self: start/end/self-start/self-endas writing-mode relative (rather than flex-relative) in the static position of absolutely positioned children; use the flex-relative start forjustify-content: space-between/normal, and a fallback ofstartforalign-self: baseline(#1072) - Flexbox: only let
automargins on absolutely positioned children absorb free space when the box is inset-constrained in that axis; otherwise they resolve to zero per CSS2 §10.3.7/§10.6.4 (#1072) - Grid: jump the auto-placement search past entire colliding occupied intervals rather than advancing one track at a time (#1038)
- Grid: resolve the grid lines used by absolutely positioned items to the edges of the adjacent tracks, so that free space distributed by
align-content/justify-contentis not included in the abspos grid area (#1071) - Grid: exclude absolutely positioned children from the implicit grid size estimate, as they do not take part in grid placement and must not create implicit tracks. Previously their out-of-range lines resolved to phantom implicit tracks instead of being treated as
auto(#1075) - Grid: align an empty grid (one whose tracks have all collapsed) within its container, rather than always placing it at the start (#1078)
- Grid: only distribute space "beyond limits" to tracks whose max track sizing function is
max-content(orfit-content()) (#1033) - Grid: don't clamp an explicitly specified preferred or minimum size by the spanned tracks' fixed max track sizing functions when computing an item's minimum contribution (#1022)
- Grid: ignore the tracks' growth limits when distributing an item's intrinsic size contribution "beyond limits" (#1022)
- Grid: convert the container's min/max size to a content-box size before using it in the track sizing algorithm (#1023)
- Grid: compute the flex factor sum over only the spanned tracks eligible to receive space when distributing intrinsic size contributions to flexible tracks (#1019)
- Grid: don't grow tracks past their growth limits when distributing free space to multiple tracks with asymmetric limits (#1001)
- Block/Grid: measure
Layout::content_sizefrom the container's padding-box origin and include the container's own end-side padding, matching Flexbox and browserscrollWidth/scrollHeightsemantics. Grid items in tracks that overflow the container now also contribute their position within the container, not just their own size (#1051) - Block: don't stretch-size replaced elements; an auto width now resolves to the intrinsic size (#1002)
- Block: don't let boxes that establish an independent formatting context overlap floats: they narrow to fit beside the float, or move down below it if they don't fit (#991)
- Block: detect floats placed by the subtree of a preceding in-flow sibling, not just floats among direct siblings, when placing a box that establishes an independent formatting context (#1049)
- Block: apply a negative margin as usual on a BFC root's float-free side, instead of clamping it to the containing block edge (#1061)
- Block: compute clearance from the hypothetical position of the cleared element (including its collapsed top margin), supporting negative clearance (#1042)
- Block: prevent the cleared element's top margin from collapsing with preceding margins and with the parent's top margin (#1043)
- Block: force clearance for floats placed while the position of the enclosing margin-collapse strut is unresolved, and position such floats including the pending collapsible margins (#1046)
- Block: collapse the top and bottom margins of a self-collapsing element with clearance with each other and apply them inside the parent, rather than collapsing them with the parent's bottom margin (#1044)
- Block/float: treat
clearas a no-op when no float has been placed on the relevant side(s) (#1041) - Block: allow elements containing only floated children to be collapsed through (#1040)
- Block/float: record zero-width floats in the float context, so their edge acts as an obstacle for boxes establishing an independent formatting context (#1062)
- Block/float: a float establishes a new block formatting context, so its margins no longer collapse with the margins of its children (#1065)
- Block/float: honour CSS2 §9.5.1 rules 3 & 7 when placing floats: a float unconstrained by other floats may overflow its containing block, but one placed beside another float may not (#1064)
- Block/float: apply CSS2 §9.5.1 rule 5 (float ceiling) and
clearpast zero-sized floats, which occupy no float segment and so were previously ignored when positioning later floats and cleared elements (#1056) - Block/float: sum float contributions when computing a float container's intrinsic width under definite available space (clamped between the widest single float and the available width), instead of dropping them entirely (#1055)
v0.12.1
This release container a couple of critical fixes for layout/caching bugs in the 0.12.0 release.
- Block: don't commit deferred in-flow layouts to the tree when only computing size (#971)
- Block: pass through the requested
run_modewhen performing final layout on in-flow children, instead of always usingMeasureSize(#972)
v0.12.0
The MSRV for this release is 1.71.
Block containers now implement align_content along the block axis for their in-flow children.
- The cache key now includes the axis, parent size, and available space, and ignores available space in an axis when a known dimension is set there. This is a performance hit (~10% in common cases, ~60% in pathalogically ones) but is necessary for correctness. It does also enable early-return optimizations (in cases where only the horizontal size is needed, which can allow that performance to be recouped in some cases (#911)
- Flexbox: fall back to safe
align-selfofstarton absolute-position overflow (#958) - Block: derive definite height from
aspect-ratioat final layout. A block container withaspect-ratioand an automatic height now becomes definite when its width is filled/stretched, so children's percentage heights resolve correctly and the ratio is preserved (#965)
v0.11.0
The MSRV for this release is 1.71.
Taffy now implements safe alignment (in addition to unsafe alignment).
The alignment style types are now structs consisting of an AlignmentKeyword and an AlignmentSafety modifier. For most users this will mean changing from using enum variants like AlignContent::Start to associated constants like AlignContent::START.
This change applies to the AlignContent, JustifyContent, AlignItems, JustifyItems, AlignSelf, and JustifySelf types.
- Grid: resolve item percentages against grid area rather than grid container (#960)
v0.10.0
The MSRV for this release is 1.71.
The direction property is now supported, allowing for RTL layout of boxes in Block, Flexbox, and CSS Grid layout modes.
The float and clear properties are now supported. Support consists of a general-purpose FloatContext in the compute module, and integration of float layout into Block layout. Block layout now also has a BlockContext that allows a FloatContext to be shared across an entire Block formatting context.
Float support is feature flagged by the float_layout feature.
All of Taffy's style types (except the top-level Style struct) now have FromStr implementations that parses the type from the CSS representation of that value (e.g. 30px or 50% for LengthPercentage. A future version of Taffy will likely add support for parsing Style from ;-seperated CSS.
CSS parsing is feature flagged by the parse feature.
- Make
DetailedGridTracksInfostruct accessible from a public module (#899) - Add
TaffyTree::write_treemethod to debug print the tree into an arbitrary writer (#925) - The cache
setandsetAPIs now take&LayoutInputrather than individual values (#933)
- Flexbox: apply gap even when there are auto margins (#938)