Skip to content

fix(geometry): check height overflow when white-space is nowrap - #231

Merged
LeadcodeDev merged 1 commit into
chantier/audit-2026-09from
fix/geometry-nowrap-height
Sep 22, 2026
Merged

LeadcodeDev merged 1 commit into
chantier/audit-2026-09from
fix/geometry-nowrap-height

Conversation

@LeadcodeDev

Copy link
Copy Markdown
Owner

Severity Low, category correctness. Location: crates/rustmotion/src/cli/commands/geometry.rs:844

Impact

check_unwrappable_text — the only check left for a nowrap node — compares width only and always emits Axis::X (geometry.rs:781-793). So the Y axis is unchecked for any white-space: nowrap|pre text. {"type":"text","content":"Hi","style":{"font-size":"120px","white-space":"nowrap","height":"40px"}} has a single line ~156px tall painted out of a 40px content box and validates clean; delete the white-space key and the identical fixture is correctly reported as ContentOverflowsBox/Axis::Y (proved by the existing test wrapped_text_taller_than_its_fixed_height_card_is_flagged, geometry.rs:2806). The stated rationale only justifies skipping the wrap-dependent width re-measure; a nowrap node's height is exactly one line_height and needs no wrapping to compute.

Fix

Instead of returning early on nowrap, measure with (AvailableSpace::MaxContent, AvailableSpace::Definite(ch)) and report only the Y axis (leave X to check_unwrappable_text), so a single unwrapped line taller than its box is still caught.

Evidence the audit read

// nowrap/pre is check_unwrappable_text's territory: re-measuring it
// here at a constrained width would wrap text that will actually
// paint as one (too-wide) line, producing a height number that
// doesn't correspond to anything that gets painted.
if nowrap {
    return;
}

Stacked on fix/geometry-text-overflow-box, which carries the previous finding of this workstream. GitHub shows only this finding's diff; merge in order.

Part of the September 2026 audit remediation chantier. Refs #220 (RM-32).

@LeadcodeDev LeadcodeDev added the bug Something isn't working label Sep 21, 2026
@LeadcodeDev LeadcodeDev self-assigned this Sep 21, 2026
@LeadcodeDev
LeadcodeDev force-pushed the fix/geometry-text-overflow-box branch from 25b96c4 to b142b14 Compare September 21, 2026 23:39
@LeadcodeDev
LeadcodeDev force-pushed the fix/geometry-nowrap-height branch from 9467962 to da572b3 Compare September 21, 2026 23:39
@LeadcodeDev
LeadcodeDev force-pushed the fix/geometry-text-overflow-box branch from 53cb999 to da0db80 Compare September 22, 2026 06:09
@LeadcodeDev
LeadcodeDev force-pushed the fix/geometry-nowrap-height branch from 7be118b to 3bc56f9 Compare September 22, 2026 06:09
@LeadcodeDev
LeadcodeDev force-pushed the fix/geometry-text-overflow-box branch from da0db80 to 82dafe2 Compare September 22, 2026 08:33
@LeadcodeDev
LeadcodeDev force-pushed the fix/geometry-nowrap-height branch from 3bc56f9 to c5036fe Compare September 22, 2026 08:34
@LeadcodeDev
LeadcodeDev force-pushed the fix/geometry-text-overflow-box branch from 82dafe2 to 931a445 Compare September 22, 2026 08:43
@LeadcodeDev
LeadcodeDev force-pushed the fix/geometry-nowrap-height branch from c5036fe to 5521bc8 Compare September 22, 2026 08:43
@LeadcodeDev
LeadcodeDev changed the base branch from fix/geometry-text-overflow-box to chantier/audit-2026-09 September 22, 2026 08:52
`check_unwrappable_text` — the only check left for a nowrap node — compares width only and always emits `Axis::X` (geometry.rs:781-793). So the Y axis is unchecked for any `white-space: nowrap|pre` text. `{"type":"text","content":"Hi","style":{"font-size":"120px","white-space":"nowrap","height":"40px"}}` has a single line ~156px tall painted out of a 40px content box and validates clean; delete the `white-space` key and the identical fixture is correctly reported as `ContentOverflowsBox`/`Axis::Y` (proved by the existing test `wrapped_text_taller_than_its_fixed_height_card_is_flagged`, geometry.rs:2806). The stated rationale only justifies skipping the *wrap-dependent* width re-measure; a nowrap node's height is exactly one `line_height` and needs no wrapping to compute.

Refs #220
@LeadcodeDev
LeadcodeDev force-pushed the fix/geometry-nowrap-height branch from 5521bc8 to 6a84dde Compare September 22, 2026 08:59
@LeadcodeDev
LeadcodeDev merged commit 91c1868 into chantier/audit-2026-09 Sep 22, 2026
LeadcodeDev added a commit that referenced this pull request Sep 22, 2026
`check_unwrappable_text` — the only check left for a nowrap node — compares width only and always emits `Axis::X` (geometry.rs:781-793). So the Y axis is unchecked for any `white-space: nowrap|pre` text. `{"type":"text","content":"Hi","style":{"font-size":"120px","white-space":"nowrap","height":"40px"}}` has a single line ~156px tall painted out of a 40px content box and validates clean; delete the `white-space` key and the identical fixture is correctly reported as `ContentOverflowsBox`/`Axis::Y` (proved by the existing test `wrapped_text_taller_than_its_fixed_height_card_is_flagged`, geometry.rs:2806). The stated rationale only justifies skipping the *wrap-dependent* width re-measure; a nowrap node's height is exactly one `line_height` and needs no wrapping to compute.

Refs #220
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant