Flexbox: apply transferred min/max sizes to flex base size and hypothetical sizes - #989
Merged
Merged
Conversation
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
nicoburns
marked this pull request as ready for review
July 25, 2026 01:58
nicoburns
enabled auto-merge (squash)
July 25, 2026 01:58
nicoburns
force-pushed
the
devin/1784873230-flex-transferred-sizes
branch
from
July 25, 2026 01:58
a1ebac1 to
4708ca9
Compare
nicoburns
pushed a commit
to HelgeSverre/taffy
that referenced
this pull request
Aug 21, 2026
A flex child with a style width that resolves wider than its own max_width (width: 100% of a wider parent, or a fixed width above the cap) used to have its content measured at the unclamped width while being laid out at the clamped one. A measure function whose height depends on width (wrapped text) then reported a taller size in the final pass than the height reserved from the sizing pass, and the child's flex base size went stale: the child and its ancestors ended up shorter than the content painted inside them. The clamp added in DioxusLabs#989 (motivated by aspect-ratio transferred sizes) also fixed this for plain min/max constraints, but left the measure-function case untested. These tests pin it down with wrapping Ahem text whose line count differs between the unclamped and clamped widths, through both the definite-parent path and the intrinsic-sizing path.
nicoburns
pushed a commit
to HelgeSverre/taffy
that referenced
this pull request
Aug 25, 2026
A flex child with a style width that resolves wider than its own max_width (width: 100% of a wider parent, or a fixed width above the cap) used to have its content measured at the unclamped width while being laid out at the clamped one. A measure function whose height depends on width (wrapped text) then reported a taller size in the final pass than the height reserved from the sizing pass, and the child's flex base size went stale: the child and its ancestors ended up shorter than the content painted inside them. The clamp added in DioxusLabs#989 (motivated by aspect-ratio transferred sizes) also fixed this for plain min/max constraints, but left the measure-function case untested. These tests pin it down with wrapping Ahem text whose line count differs between the unclamped and clamped widths, through both the definite-parent path and the intrinsic-sizing path.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
Fix flexbox sizing of items with an aspect ratio and min/max constraints in the opposite axis (e.g. replaced images with
max-heightin a row flex container). Previously, transferred sizes were baked directly intoFlexItem::min_size/max_sizeviamaybe_apply_aspect_ratio, so they incorrectly participated in resolving flexible lengths and clamping the item's final size. Per w3c/csswg-drafts#10997 and browser behaviour, transferred sizes should only clamp:Pseudo-diff of the approach:
In
determine_flex_base_sizeanddetermine_hypothetical_cross_size,transferred_{min,max}_size = child.{min,max}_size.maybe_apply_aspect_ratio(child.aspect_ratio)are now used for: the cross-axis available-space clamp, the known-cross-dimension clamp, the automatic-minimum-size cap, and the hypothetical main/cross size clamps. Elsewhere (flexible length resolution, final clamping) the untransferred min/max sizes are used, as before this change they were the transferred ones.Context
Found while fixing css-flexbox WPT failures in Blitz (companion PR: DioxusLabs/blitz#526). With this change plus the Blitz-side fixes, the following WPT tests newly pass:
flex-minimum-width-flex-items-012,flexbox-min-width-auto-002c,flexbox-min-height-auto-002c,flex-minimum-height-flex-items-021,flex-aspect-ratio-img-column-005,aspect-ratio-transferred-max-size— with no regressions across the full css-flexbox suite (699 → 705 whole tests, 1765 → 1771 subtests).All existing Taffy tests pass (
cargo test: 4421 generated fixture tests green).Feedback wanted
Taffy currently applies aspect ratios to border-box sizes; a fully content-box-aware transfer (needed for items with asymmetric borders, e.g. WPT
flex-aspect-ratio-img-row-005subtest 3) is left for follow-up.Link to Devin session: https://app.devin.ai/sessions/0f8547b7fbb949e28e9acdbedb1ca8d2
Requested by: @nicoburns
Devin Review