Conversation
`intrinsic_cross_height` estimated one line of text from the font metric alone, ignoring a specified `line-height`. Grid takes the greater of that estimate and the item's laid-out height, so the estimate isn't a harmless over-guess — when `line-height` is shorter than the font's natural metric the estimate wins and the auto row is laid out taller than its content. An item with one line of 10px text and `line-height: 10px` produced a 13px row. Every other place that combines the two prefers the specified value and falls back to the metric; this one now does the same. Co-authored-by: Cursor <cursoragent@cursor.com>
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.
What & why
intrinsic_cross_heightincrates/layout/src/flex.rsestimated an item'ssingle-line height straight from the font metric:
A specified
line-heightnever entered into it. Everywhere else the two are combinedthe specified value wins and the metric is the fallback —
inline.rs,build.rsandintrinsic.rsall usestyle.line_height.unwrap_or_else(|| measurer.line_height(…)).That would be a harmless over-guess if the estimate were only a floor, but
resolve_row_heightstakes the greater of this estimate and the item's laid-outheight. So whenever
line-heightis shorter than the font's natural metric, theestimate wins and the auto row is laid out taller than the content it contains: one
line of 10px text with
line-height: 10pxgave a 13px row.Reproduced against a grid item and its longhand-styled equivalent — the row measured
13px where a plain block with the same styles correctly measured 10px.
This is also what makes
css/css-grid/grid-items/grid-item-block-axis-content-contribution-00{1,2,3}fail: those compare an auto-sized grid row against a reference with an explicit
height: 10px, and with this they match exactly (0 differing pixels). They currently"pass" only because
font: 10px/1 Ahemis ignored on both sides (see #135), so bothrender at 16px and the row height never gets checked. With #135 landed and this one
not, they fail; with both, they pass for the right reason.
The fix is to prefer the specified value, as the other three call sites do. The test
covers both directions, so it can't regress to a different hard-coded answer:
line-height: 10pxgives a 10px row, andline-height: normalstill gives thefont metric's 13px.
🤖 How this was built
Checklist
cargo test --workspacepassescargo fmt --all+cargo clippycleanMade with Cursor