Collapse white space across style span and inline box boundaries - #25
Open
nicoburns wants to merge 9 commits into
Open
Collapse white space across style span and inline box boundaries#25nicoburns wants to merge 9 commits into
nicoburns wants to merge 9 commits into
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
nicoburns
force-pushed
the
devin/1788524905-collapse-whitespace-across-spans
branch
2 times, most recently
from
September 8, 2026 15:56
37f28d0 to
27e98c8
Compare
Remove collapsible whitespace immediately before and after a preserved segment break, while keeping collapsible whitespace that follows a preserved space or tab. Flush pending text when the white space mode changes so it is processed with the mode in effect when it was pushed.
Split collapsible text into whitespace and non-whitespace runs and commit the non-whitespace runs directly, rather than building a per-span copy of the text with its whitespace collapsed.
Soft wrap opportunities are determined before white space collapsing, so a collapsed space is a wrap opportunity if any of the whitespace it collapses comes from a span that allows wrapping, even though the space itself is attributed to the span it started in.
staging-devin-ai-integration
Bot
force-pushed
the
devin/1788524905-collapse-whitespace-across-spans
branch
from
September 10, 2026 20:35
b4ff4f0 to
ba6037d
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.
LLM Contributions: Unspecified.
Reworks phase-I white space processing in
TreeStyleBuilderso collapsing happens over the whole inline formatting context, rather than independently per style span.Current state vs. main
On main,
push_uncommitted_textprocesses each span's text in isolation: it trims the start when the span is first (or the previous committed text ended in whitespace) and trims the end when the span is closing. A collapsible space at a span boundary therefore disappears, so<span>Hello </span>worldbuilds asHelloworld.The trimming is replaced with a single carried piece of state,
pending_whitespace: Option<usize>(the span the whitespace came from). A collapsible whitespace run is not committed when it is seen; it is committed as a single space only once following content proves it renders, so it survives span and inline box boundaries but is still dropped where CSS Text says it should be:is_segment_break— this is what makes collapsible whitespace around<br>(a preserved"\n") disappear;<span style="white-space:pre">a </span> bis two spaces wide.The committed space keeps the style of the span it came from, matching how browsers paint a boundary space, and adjacent runs with the same style are now merged instead of emitting a
StyleRunper commit. Since soft wrap opportunities are determined before white space collapsing,pending_whitespacealso records whether any of the collapsed white space came from a span that allows wrapping; if so the committed space uses that span's style withTextWrapMode::Wrap, so<span style="white-space:nowrap">AA </span> BBcan still break where browsers break it.Two supporting changes:
set_white_space_modecommits buffered text before switching, so text is processed under the mode in effect when it was pushed rather than the most recent one.push_inline_boxflushes pending whitespace (the box is the content the space collapses into, and the space must land before the box's index) and marks the last item kind, so whitespace after a leading box is not treated as start-of-IFC whitespace.The collapse path also no longer builds a per-span
String: it walks whitespace/non-whitespace runs and commits non-whitespace slices straight out of the buffer.Out of scope:
<br>is still encoded as a preserved"\n"rather than a dedicated forced-break item, phase-II trimming of collapsible whitespace at soft wrap points is unchanged, and hanging modes are untouched.Changelog
Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/a9f0131145654530a87ad078d0d3c42b
Open in Devin Desktop: https://dioxus.staging.devinenterprise.com/desktop/session/a9f0131145654530a87ad078d0d3c42b?variant=devin-insiders
Requested by: @nicoburns