Implement text-overflow - #893
LinuxBoy-96 wants to merge 5 commits into
Conversation
nicoburns
left a comment
There was a problem hiding this comment.
I'm onboard with implementing this in Blitz. However, can we make it run at mostly post-layout time (the marker computation, shaping, and positioning should run in inline.rs, just after the Parley layout has run, and then be stored on the TextLayout in an Option<Box<T>> field.
We will of course need a small amount of paint code to consume this data.
May also be worth consolidating most of the (non-paint) code into it's own module to make it easier to upstream into Parley in future if we decide we want to.
|
Well it still work well on my end. BTW here is the file I have for testing it. |
|
Some AI review comments:
2 and 3 are the most important here (and apologies as 2 partially contradicts my earlier request to do this post-layout, but it's important that scrolling is kept cheap!) |
|
And a couple more:
|
|
It work now I think :') |
|
Some more feedback from digging into why this isn't causing more passing tests. 1 is the big thing that I think we definitely ought to fix. 1. The marker must use the block container's style, not the first run'scss-overflow §5.2: "the ellipsis is styled and baseline-aligned according to the block". Fixing this would flip most of these tests to pass. Suggestion: rather than the 2. Overflow check ignores the line's start offset (
|
|
text-overflow: ellipsis (and the string form)text-overflow
Overflowing lines in a clipping inline root (
overflowother thanvisible)are cut at a glyph boundary and end with the
text-overflowmarker.Design discussed in #<numéro de l'issue ellipsis>: paint-time truncation
(CSS UI §5.2 defines the ellipsis as a rendering effect), confirmed by an
independent implementation in the same thread. The Parley route remains the
long-term home; this is the in-Blitz implementation.
How
blitz-dom:TextLayout::text_overflowrecords the marker for the inlineroot when style asks for one (
construct.rs::text_overflow_marker):Nonefor
clip,"…"forellipsis, the given string otherwise. Stylo keeps asingle value in
second(withsides_are_logical), two values as(start, end):secondis always the inline-end side. When the inline rootis an anonymous block (Blitz wraps inline content inside scroll containers),
the marker and the available width come from the parent element, which is
the one that clips.
blitz-paint::text::stroke_texttakes an optionalTextOverflowClip(content-box width in device pixels + marker). For each line wider than
the content box: glyphs ending past
max_width - marker_advancearedropped, and the marker is drawn once right after the kept glyphs, with the
first run's font, size, colour and synthesis (glyph lookup through
skrifa; fonts without U+2026 fall back to...).scrollWidth,getBoundingClientRect, selection andhit testing keep the full text.
undecorated, as in Chrome.
whole still fills the remaining space glyph by glyph before the marker.
overflow(non-visible) +white-space: nowrap+text-overflow: ellipsis; wrapped text overflows only with unbreakablewords, handled the same way.
Limitations
not glyph runs).
Tests
word, font size, fitting text and wrapped text (in the PR thread).
css/css-overflow/text-overflow-*,css/css-ui/text-overflow-*.WPT results
Subtests: 6 newly passing, 2 newly failing (net +4).
Full diff (8 changed tests)
Generated by the WPT workflow.