fix(layout): hand IntrinsicMeasure both sizes in the content box - #222
Closed
LeadcodeDev wants to merge 1 commit into
Closed
LeadcodeDev wants to merge 1 commit into
LeadcodeDev wants to merge 1 commit into
Conversation
LeadcodeDev
force-pushed
the
fix/em-font-size
branch
from
September 21, 2026 23:43
9ad0f9d to
95ffad7
Compare
LeadcodeDev
force-pushed
the
fix/measure-fn-box-model
branch
from
September 21, 2026 23:43
6dfb6fd to
818f675
Compare
53 tasks
LeadcodeDev
force-pushed
the
fix/em-font-size
branch
from
September 22, 2026 06:12
b2120a4 to
3b3111e
Compare
LeadcodeDev
force-pushed
the
fix/measure-fn-box-model
branch
from
September 22, 2026 06:12
34a9483 to
0d95a3b
Compare
LeadcodeDev
force-pushed
the
fix/em-font-size
branch
from
September 22, 2026 08:36
3b3111e to
5b5c226
Compare
LeadcodeDev
force-pushed
the
fix/measure-fn-box-model
branch
from
September 22, 2026 08:36
0d95a3b to
e69bb81
Compare
LeadcodeDev
force-pushed
the
fix/em-font-size
branch
from
September 22, 2026 08:46
5b5c226 to
498b1bc
Compare
taffy 0.10.1 (compute/leaf.rs) subtracts content_box_inset (padding+border)
from available_space before calling the measure fn, but passes
known_dimensions — the outer border-box size — untouched. The two arguments
are therefore in different coordinate spaces, and neither IntrinsicMeasure's
trait doc (box_tree.rs:114-122) nor this closure says so.
TextIntrinsic::measure (rustmotion-components/src/intrinsic.rs:224) prefers
known.0 as its wrap width, while Text::paint wraps at layout.content_box()
width (legacy_dispatch.rs:145-155). A text with horizontal padding is
therefore measured at a wider line width than it is painted at: fewer
wrapped lines, a reserved box one line too short, and the text spills out of
its own box. The geometry validator re-measures through the same intrinsic,
so it signs the overflow off. intrinsic.rs:258-265 explicitly asserts the
opposite ("taffy hands a leaf its own known/available height already
padding/border-subtracted") — true for available, false for known.
Fix: Use the _style argument already handed to the closure to subtract
resolved padding+border from known before calling intr.measure, so both
arguments are content-box. Then state that invariant on
IntrinsicMeasure::measure in box_tree.rs, and add a regression test for a
padded text (measured height vs painted line count).
Refs #220
LeadcodeDev
force-pushed
the
fix/measure-fn-box-model
branch
from
September 22, 2026 08:46
e69bb81 to
a3ca2f6
Compare
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.
Severity Low, category correctness. Location:
crates/rustmotion-core/src/engine/layout_pass.rs:97Impact
taffy 0.10.1 (
compute/leaf.rs) subtractscontent_box_inset(padding+border) fromavailable_spacebefore calling the measure fn, but passesknown_dimensions— the outer border-box size — untouched. The two arguments are therefore in different coordinate spaces, and neitherIntrinsicMeasure's trait doc (box_tree.rs:114-122) nor this closure says so.TextIntrinsic::measure(rustmotion-components/src/intrinsic.rs:224) prefersknown.0as its wrap width, whileText::paintwraps atlayout.content_box()width (legacy_dispatch.rs:145-155). Atextwith horizontal padding is therefore measured at a wider line width than it is painted at: fewer wrapped lines, a reserved box one line too short, and the text spills out of its own box. The geometry validator re-measures through the same intrinsic, so it signs the overflow off. intrinsic.rs:258-265 explicitly asserts the opposite ("taffy hands a leaf its own known/available height already padding/border-subtracted") — true foravailable, false forknown.Fix
Use the
_styleargument already handed to the closure to subtract resolved padding+border fromknownbefore callingintr.measure, so both arguments are content-box. Then state that invariant onIntrinsicMeasure::measurein box_tree.rs, and add a regression test for a paddedtext(measured height vs painted line count).Evidence the audit read
Part of the September 2026 audit remediation chantier. Refs #220 (RM-27).