Skip to content

Fix line-box content detection for negative-height boxes, NBSP width handling and inline box quantization - #22

Closed
nicoburns wants to merge 3 commits into
devin/1788383056-vertical-alignfrom
devin/1788404063-vertical-align-fixes
Closed

Fix line-box content detection for negative-height boxes, NBSP width handling and inline box quantization#22
nicoburns wants to merge 3 commits into
devin/1788383056-vertical-alignfrom
devin/1788404063-vertical-align-fixes

Conversation

@nicoburns

@nicoburns nicoburns commented Sep 3, 2026

Copy link
Copy Markdown
Member

LLM Contributions: This PR was produced with Devin (an LLM tool) under the direction of the requester; the follow-up regression triage of Blitz #832 is documented on that PR.

Three fixes for regressions found while triaging the WPT diff of DioxusLabs/blitz#832 (which consumes #18).

  1. LineBoxMetrics::add_inline_box (parley/src/layout/line_break.rs) treated an inline box with ascent + descent <= 0 as "no content", so a line containing only an atomic inline with a large negative margin-top (reserved height negative but finite) was laid out as an empty/invisible line with no strut. Now any finite non-zero extents count as content; only out-of-flow boxes (which Blitz passes with NEG_INFINITY extents) are still skipped.

  2. add_inline_box also rounded ascent and descent independently when quantize is set. For a box whose baseline splits it into two .5 halves this reserves one more pixel than the box's (already integral) height, e.g. 82px for an 81px box. Inline box extents are exact sizes from the caller, not font metrics, so they are no longer rounded (the box height and the resulting line coords are still quantized as before). Together with (1) this fixes css/CSS2/floats-clear/floats-141.xht.

  3. calculate_content_widths (parley/src/layout/data.rs) subtracted NBSP advances as "trailing whitespace" when computing min/max content widths. NBSP is neither collapsible nor hangable (css-text-3 §4.1.1, §4.1.3), so a shrink-to-fit inline-block containing only &nbsp; collapsed to zero width. Only U+0020 is trimmed now. Fixes inline-block-zorder-004/005.xht and t41-html4-keywords-a.xht in Blitz WPT. The line-breaker's own is_space check at line-break time is intentionally left as is_space_or_nbsp(): changing it made 8 justify/trailing-space tests pass but regressed line-break-anywhere-overrides-uax-behavior-004/006, so that is left for a separate change.

Regression tests added in parley/src/tests/test_style_metrics.rs:

  • line_with_negative_height_inline_box_is_not_invisible
  • quantized_inline_box_extents_are_not_rounded_separately
  • no_break_spaces_are_not_hanging_whitespace

Changelog: None

Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/5c4401ef6292427a952400c36ae85272
Open in Devin Desktop: https://dioxus.staging.devinenterprise.com/desktop/session/5c4401ef6292427a952400c36ae85272?variant=devin-insiders
Requested by: @nicoburns

- An in-flow inline box with a negative reserved height (e.g. an atomic
  inline with a large negative margin-top) is still content: the strut
  must apply and the line must not be treated as empty. Only out-of-flow
  boxes (infinitely negative extents) are ignored.
- Only ordinary spaces (U+0020) are collapsible/hangable whitespace for
  the purposes of min/max content widths and line-end trimming; no-break
  spaces are preserved (css-text-3 §4.1.1, §4.1.3).
@staging-devin-ai-integration

Copy link
Copy Markdown

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Inline box extents are exact sizes supplied by the caller; rounding the
ascent and descent independently could reserve one more pixel than the
box's height, producing an off-by-one line height (WPT floats-141).
Only the content-width calculation should stop trimming NBSP; changing
the line-break-time handling regresses line-break: anywhere tests.
@staging-devin-ai-integration staging-devin-ai-integration Bot changed the title Fix line-box content detection for negative-height boxes and NBSP width handling Fix line-box content detection for negative-height boxes, NBSP width handling and inline box quantization Sep 3, 2026
@staging-devin-ai-integration

Copy link
Copy Markdown

Folded into #18 (commits 9ac58e1, 7991b17, 5f301bf cherry-picked onto its branch).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant