Add regression tests for content measured at the unclamped style width - #1095
Open
HelgeSverre wants to merge 2 commits into
Open
Add regression tests for content measured at the unclamped style width#1095HelgeSverre wants to merge 2 commits into
HelgeSverre wants to merge 2 commits into
Conversation
nicoburns
requested changes
Aug 13, 2026
nicoburns
left a comment
Member
There was a problem hiding this comment.
Thanks! But could we make these generated tests please? Generated tests automatically assert their layout against Chrome, so don't need to trust/verify their assertions and they are easier to maintain.
See CONTRIBUTING.md
Author
|
I think i did it right, let me know if this is what you meant @nicoburns |
nicoburns
force-pushed
the
tests/measure-clamped-known-width
branch
from
August 21, 2026 14:58
e9f6c77 to
39fea26
Compare
nicoburns
enabled auto-merge (squash)
August 21, 2026 14:58
Author
|
@nicoburns feel free to close this if you merged a superseding version in already. |
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
force-pushed
the
tests/measure-clamped-known-width
branch
from
August 25, 2026 15:52
c7d7fcf to
ccfd425
Compare
Member
|
Ack, I thought I had merged this, but I guess the auto-merge never triggered. |
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
Pin down a failure mode that #989 fixed incidentally but left untested: a flex child whose style width 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. With a measure function whose height depends on its width (wrapped text), the child's flex base size went stale — the child and its ancestors ended up shorter than the content laid out inside them.On 0.12.2 and earlier this makes downstream UIs paint blocks on top of each other: gpui/Zed's long-standing "overlapping text" bugs (zed-industries/zed#30002, zed-industries/zed#30097, worked around in-app in zed-industries/zed#30377) reduce to exactly this — gpui's virtualized list stacks items by their root height, and a
width: 100%; max-width: Nreadable column inside an item left the root ~1 line short per wrapped paragraph.Minimal standalone repro — fails on 0.12.2 (`column: 560x40` vs text `560x60`), passes on 0.13.0
The clamp added in #989 (motivated by aspect-ratio transferred sizes) also covers plain min/max constraints at the flex-basis site, which fixes this class — but nothing exercised the measure-function/wrapped-text consequence, so it could silently regress.
For conformance context: Chrome lays out the analog DOM (
width: 100%; max-width: 560pxaround wrapping text) with the container containing its wrapped text, and flexbox §9.2 step 3 item E sizes the item at its used cross size (the "min and max sizes are ignored" exemption at flex-basis time is main-axis only).Changes
Two generated HTML fixtures in
test_fixtures/flex, using Ahem text whose line count differs between the unclamped and clamped widths (2 lines at 300px vs 3 lines at 200px):measure_child_with_percent_width_clamped_by_max_width—width: 100%of a 300px parent withmax-width: 200px; the text and containing column are 200px × 30px.measure_child_with_fixed_width_clamped_by_max_width_intrinsic— the same clamp through the intrinsic-sizing path with a content-sized root.The generator renders both fixtures in Chrome and emits border-box/content-box and LTR/RTL variants, so all expected layouts are browser-derived.
Test results
cargo test --test xml: 5549 passed, 0 failed.cargo test --tests: passed (4 pre-existing ignored tests).cargo +nightly clippy --workspace: passed.just gentestrun produced byte-identical generated output.