Skip to content

Keep trailing spaces on their line; expose Style::parent and Line::style_baseline - #23

Open
nicoburns wants to merge 5 commits into
devin/1788393297-font-cachefrom
devin/1788438223-vertical-align-fixes-762
Open

nicoburns wants to merge 5 commits into
devin/1788393297-font-cachefrom
devin/1788438223-vertical-align-fixes-762

Conversation

@nicoburns

@nicoburns nicoburns commented Sep 3, 2026

Copy link
Copy Markdown
Member

LLM Contributions: Devin (Cognition) authored the code and this description under human direction.

Replaces #20. Stacked on #18#19, which are now themselves based on linebender#762 (1218f0d), so this PR contains only the fixes below.

Trailing spaces (line_break.rs)

linebender#762 decides which trailing whitespace hangs (in finish_line), but the breaker still unconditionally start_new_lines after appending an overflowing hanging space. Consequences: "AAA " at the end of the layout produces a second, empty line (layout.len() == 2, still reproducible on linebender#762 and upstream main), and "XXXX XX" under pre-wrap breaks after the first hanging space instead of hanging both.

Now, after appending an overflowing hanging space, the breaker continues while the next character in the layout is another hangable space (U+0020 or tab — matching linebender#762's is_space set), or when there is nothing after it; otherwise it starts the new line as before. The lookahead uses the global character list so it also works when the spaces are split across runs (a style change inside the trailing spaces), and an inline box following the space still breaks. NBSP is not chained (it doesn't hang under linebender#762's rules; the nbsp snapshot is updated for that).

Regression test: trailing_whitespace_does_not_add_line (single space, multiple spaces, NBSP, hard wrap, soft wrap, and two cases with a font-size change on the middle of three trailing spaces at a width where the first space already overflows).

Public Style::parent() and Line::style_baseline()

Renderers need to draw text decorations at the baseline of the decorating inline box, not at the (possibly shifted) baseline of each glyph run. Line::style_baseline(style_index) was pub(crate); it is now pub, plus a Style::parent() accessor so the renderer can walk from a run's style to the style that owns the decoration. Test: vertical_align_style_baseline.

Blitz WPT (8 dirs, 4188 run) with this pin: 2533 pass vs 2523 for #20 — the +10 is linebender#762's own gains (justification / trailing-space tests) minus the two line-break-anywhere-overrides-uax-behavior-004/006 accidental passes linebender#762's description already notes.

Changelog

Added

  • Style::parent() and Line::style_baseline() expose the inline style tree and per-style baselines for decoration painting.

Fixed

  • Trailing spaces no longer create an empty final line, and consecutive overflowing spaces hang on the same line.

Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/da7669e341814cc7976e4ebf32b7eacb
Open in Devin Desktop: https://dioxus.staging.devinenterprise.com/desktop/session/da7669e341814cc7976e4ebf32b7eacb?variant=devin-insiders
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

@staging-devin-ai-integration
staging-devin-ai-integration Bot force-pushed the devin/1788438223-vertical-align-fixes-762 branch from e555c3d to 4ab20f7 Compare September 3, 2026 14:16
@staging-devin-ai-integration
staging-devin-ai-integration Bot changed the base branch from devin/1788383056-vertical-align to devin/1788393297-font-cache September 3, 2026 14:16
@staging-devin-ai-integration staging-devin-ai-integration Bot changed the title Keep trailing spaces on their line; expose Style::parent and Line::style_baseline (on top of linebender#762) Keep trailing spaces on their line; expose Style::parent and Line::style_baseline Sep 3, 2026
@staging-devin-ai-integration
staging-devin-ai-integration Bot force-pushed the devin/1788438223-vertical-align-fixes-762 branch 2 times, most recently from 8f09a12 to a24bee4 Compare September 3, 2026 15:41
@staging-devin-ai-integration
staging-devin-ai-integration Bot force-pushed the devin/1788438223-vertical-align-fixes-762 branch from a24bee4 to df9b848 Compare September 3, 2026 15:47
@staging-devin-ai-integration
staging-devin-ai-integration Bot force-pushed the devin/1788438223-vertical-align-fixes-762 branch from df9b848 to 3a57739 Compare September 3, 2026 17:05
@staging-devin-ai-integration
staging-devin-ai-integration Bot force-pushed the devin/1788438223-vertical-align-fixes-762 branch 2 times, most recently from 7c30135 to bf0e37a Compare September 3, 2026 17:38
@staging-devin-ai-integration
staging-devin-ai-integration Bot force-pushed the devin/1788438223-vertical-align-fixes-762 branch from bf0e37a to 3d56c99 Compare September 3, 2026 17:54
@staging-devin-ai-integration
staging-devin-ai-integration Bot force-pushed the devin/1788438223-vertical-align-fixes-762 branch from 3d56c99 to f5bb8ff Compare September 7, 2026 18:29
@staging-devin-ai-integration
staging-devin-ai-integration Bot force-pushed the devin/1788438223-vertical-align-fixes-762 branch from f5bb8ff to f43d251 Compare September 8, 2026 14:36
@staging-devin-ai-integration
staging-devin-ai-integration Bot force-pushed the devin/1788438223-vertical-align-fixes-762 branch from f43d251 to 75702f5 Compare September 8, 2026 14:42
@staging-devin-ai-integration
staging-devin-ai-integration Bot force-pushed the devin/1788438223-vertical-align-fixes-762 branch from 75702f5 to d58806c Compare September 8, 2026 15:59
@staging-devin-ai-integration
staging-devin-ai-integration Bot force-pushed the devin/1788438223-vertical-align-fixes-762 branch 2 times, most recently from 7580be8 to 873cb68 Compare September 14, 2026 17:22
@staging-devin-ai-integration
staging-devin-ai-integration Bot force-pushed the devin/1788438223-vertical-align-fixes-762 branch from 873cb68 to 79e5b83 Compare September 16, 2026 10:43
@staging-devin-ai-integration
staging-devin-ai-integration Bot force-pushed the devin/1788438223-vertical-align-fixes-762 branch from 79e5b83 to 0a9a773 Compare September 16, 2026 10:55
@staging-devin-ai-integration
staging-devin-ai-integration Bot force-pushed the devin/1788438223-vertical-align-fixes-762 branch from 0a9a773 to 63d5506 Compare September 16, 2026 11:36
@staging-devin-ai-integration
staging-devin-ai-integration Bot force-pushed the devin/1788438223-vertical-align-fixes-762 branch from 63d5506 to e86cb0b Compare September 16, 2026 11:43
@staging-devin-ai-integration
staging-devin-ai-integration Bot force-pushed the devin/1788438223-vertical-align-fixes-762 branch from e86cb0b to 7d79f95 Compare September 16, 2026 11:56
@staging-devin-ai-integration
staging-devin-ai-integration Bot force-pushed the devin/1788438223-vertical-align-fixes-762 branch 2 times, most recently from 486c6db to 9a9be7d Compare September 16, 2026 12:25
@staging-devin-ai-integration
staging-devin-ai-integration Bot force-pushed the devin/1788438223-vertical-align-fixes-762 branch from 9a9be7d to 9447e55 Compare September 16, 2026 12:27
@staging-devin-ai-integration
staging-devin-ai-integration Bot force-pushed the devin/1788438223-vertical-align-fixes-762 branch from 9447e55 to 5bed76c Compare September 16, 2026 12:34
@staging-devin-ai-integration
staging-devin-ai-integration Bot force-pushed the devin/1788438223-vertical-align-fixes-762 branch from 5bed76c to 9dc8721 Compare September 16, 2026 12:43
@staging-devin-ai-integration
staging-devin-ai-integration Bot force-pushed the devin/1788438223-vertical-align-fixes-762 branch from 9dc8721 to 7518658 Compare September 16, 2026 19:14
…yle_baseline

A hanging space that overflowed the line always started a new line, so text ending in
spaces (or NBSP) got an extra empty line. Consecutive spaces now stay together and spaces
that end the layout no longer open an empty line.

Style::parent and Line::style_baseline are made public so consumers can find the baseline
of a decorating ancestor box (text-decoration must be drawn at the decorating box's
baseline, not at the shifted baseline of a vertical-aligned descendant).
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