Skip to content

Implement white space collapsing - #176

Merged
afishhh merged 6 commits into
masterfrom
whitespace-collapse
Jun 20, 2026
Merged

Implement white space collapsing#176
afishhh merged 6 commits into
masterfrom
whitespace-collapse

Conversation

@afishhh

@afishhh afishhh commented May 22, 2026

Copy link
Copy Markdown
Owner

See https://drafts.csswg.org/css-text-4/#white-space-phase-1
See doc comment of subrandr::layout::inline::WhiteSpaceCollapseInternalDoc for implementation sketch.

TODO:

  • Implement preserve-spaces and use it for WebVTT.

White space hanging is future work but I already have a prototype locally.

Note that white-space-collapse: collapse does not have an internal use, it's here as part of my goal of supporting CSS defaults so that a future layout (C) API can use actual CSS defaults as a default ComputedStyle.

@afishhh
afishhh force-pushed the whitespace-collapse branch 3 times, most recently from 9b9e34c to b854416 Compare May 23, 2026 11:58
@afishhh
afishhh marked this pull request as ready for review May 23, 2026 12:26
@afishhh
afishhh force-pushed the whitespace-collapse branch from b854416 to 6ebe476 Compare May 23, 2026 22:52
afishhh added 3 commits June 18, 2026 23:03
Storing span length gets problematic if one wants to start modifying the
item list while building it (like when collapsing whitespace).

Instead signal the end of a span with a separate `SpanEnd` item.
This actually slightly simplifies the iteration code and makes spans
smaller so is probably worth doing anyway.
@afishhh
afishhh force-pushed the whitespace-collapse branch from 6ebe476 to 6ab41a7 Compare June 20, 2026 16:06
@afishhh

afishhh commented Jun 20, 2026

Copy link
Copy Markdown
Owner Author

Last commit switches the module organization to something that actually makes sense. I would love to have it (moving builder to builder.rs) before the white-space-collapse implementation but I don't want to spend an hour merging that so we'll have to trade some commit history cleanliness for my sanity here.

@afishhh
afishhh force-pushed the whitespace-collapse branch from 74cf817 to f476403 Compare June 20, 2026 17:43
@afishhh
afishhh force-pushed the whitespace-collapse branch from f476403 to 7539b47 Compare June 20, 2026 17:53
@afishhh
afishhh merged commit 7539b47 into master Jun 20, 2026
8 checks passed
@afishhh
afishhh deleted the whitespace-collapse branch June 20, 2026 18:28
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