Skip to content

Fix max-content width of inline boxes following a mandatory break - #12

Open
nicoburns wants to merge 7 commits into
mainfrom
devin/1786652166-inline-box-after-newline-content-width
Open

Fix max-content width of inline boxes following a mandatory break#12
nicoburns wants to merge 7 commits into
mainfrom
devin/1786652166-inline-box-after-newline-content-width

Conversation

@nicoburns

Copy link
Copy Markdown
Member

LLM Contributions: This PR (code, test, and description) was produced by Devin, an AI agent, at nicoburns' request.

calculate_content_widths detected a mandatory line break via the Boundary::Mandatory flag on the text atom after the break. Any inline boxes located between the newline character and that atom had already been accumulated into running_max_width by then, so their widths were attributed to the line before the break — under-reporting the max-content width of the line they actually end up on.

This is the root cause of DioxusLabs/blitz#705: inline-block links following a <br> wrapped inside a shrink-to-fit container on https://freyaui.dev even though they fit on one line (Blitz sized the container from parley's under-reported max-content width).

The fix mirrors the line breaker's behavior directly in calculate_content_widths: when an atom is a Whitespace::Newline, the current line is finalized immediately (for both min- and max-content accumulators) and the newline contributes no advance — matching break_all_lines, where a newline ends the line right after itself and everything following it (including inline boxes) belongs to the next line. The Boundary::Mandatory flag on the following atom now only acts as a soft break opportunity for the min-content width.

Includes a regression test (inline_boxes_after_newline_max_content_width) with a newline followed by three inline boxes; it fails on main (layout broken at the reported max-content width comes out wider than that width, i.e. boxes wrap) and passes with this change.

Changelog

Fixed

  • Inline boxes directly following a mandatory line break now contribute to the max-content width of the line they end up on.

Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/5da2da1c45d24bd89a90d920fd698681
Requested by: @nicoburns

@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

nicoburns and others added 6 commits September 3, 2026 12:19
Adds long-single-line benchmarks to measure cases where performance is
`O(line length)`
These have been used to test
linebender#762

**LLM Contributions**: Generated with Fable 5.1 Low

**Changelog**: None
<!-- Please ensure that you have reviewed our LLM ("AI") policy at
https://linebender.org/wiki/llm-policy/.

If you did not use any LLM tools, please replace `Unspecified` with
`None`. -->
LLM Contributions: Mostly generated.

Follow-up to
linebender#738 (comment).

This is also what Gecko and Blink do (with whitespace collapsing off).
Compare:
https://developer.mozilla.org/en-US/play?id=gilITaZ%2B0hCJVuNWyCoME9xqzkpiKGs0u2alPNKuvKXYzUEm2XX1efjm7j5qJPFZdiEZU%2FYl7eSQxZlN.

<!--
If our users need to know about this change, please describe that in the
quote block below.
What you write here will be edited by us later - it doesn't need to be
perfect.
If this change doesn't need a changelog entry, please replace the next
line with `**Changelog: None**`.
-->
**Changelog: None**
Signed-off-by: Nico Burns <nico@nicoburns.com>
Co-authored-by: Daniel McNab <36049421+DJMcNab@users.noreply.github.com>
@nicoburns
nicoburns force-pushed the devin/1786652166-inline-box-after-newline-content-width branch from b2e94d9 to 9f725ed Compare September 3, 2026 13:20
Signed-off-by: Nico Burns <nico@nicoburns.com>
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.

2 participants