Closed Bug 1615811 Opened 5 years ago Closed 5 years ago

Elements with text-overflow: ellipsis; do not remove the dots when their content shortens via javascript

Categories

(Core :: Web Painting, defect)

72 Branch
x86_64
All
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla75
Tracking Status
firefox-esr68 --- wontfix
firefox73 --- wontfix
firefox74 --- wontfix
firefox75 --- fixed

People

(Reporter: hier-bei-mir, Assigned: emilio)

References

(Regression)

Details

(Keywords: regression)

Attachments

(3 files)

Attached file truncate.html β€”

Suppose there is an element p with overflowing text truncated by displaying the three dots using text-overflow:ellipsis. Now the textual contents of p changes (either by changing the innerHTML or the text node's nodeValue) and the new text is shorter than the available space.

Actual Behaviour:
The three dots do not dissappear. They only do after somehow another redraw of that region is triggered e.g. by hovering over a scrollbar or by resizing the window.

Expected Behaviour:
The three dots should disappear when the text is updated.

See also the attached minimal example and gif animation (attached as comment) demonstrating the problem.
I can reproduce the issue on Windows 7 and Linux x64_64.

Any workaround to let the dots disappear using javascript is highly appreciated, as this is a big issue for me at the moment.

kind regards

Attached image demonstration of the problem β€”

This one is an interesting one. Ellipsis is just a paint-time effect, and I think we're not invalidating them properly.

Anything that causes a repaint of the block (like changing color or something of that sort) "fixes" it.

It'd be interesting to know if this is a regression, but I can't run mozregression right now due to bandwidth limitations.

Status: UNCONFIRMED → NEW
Component: DOM: CSS Object Model → Layout
Ever confirmed: true

Regression window:
https://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=47752e9824da5125cb99c9d8160795b59adcc407&tochange=fc194660762d1b92e1679d860a8bf41116d0f54f

Regressed by: Bug 1416055

I can reproduce the issue on Nightly75.0a1(20200215095617)
And I confirmed that set layout.display-list.retain to false fixes the issue.

Has Regression Range: --- → yes

Thank you Alice, you're awesome :)

I'm not quite sure how to better invalidate this... It seems we have to invalidate the block when the overflow area becomes less than the frame size or such... Matt / Miko do we invalidate frames in response to overflow changes already somewhere? If so, where? I suspect this'd be a pretty simple change.

Component: Layout → Web Painting
Flags: needinfo?(mikokm)
Flags: needinfo?(matt.woodrow)

We don't rebuild display items when overflow changes, since overflow frequently changes on the ancestor of the modified frame, and then we'd rebuild items for all descendants of that ancestor. Generally, that's a lot more than what actually changed.

text-overflow:ellipsis is a weird special case where the painting of the ancestor block depends on changes from descendants (the text content).

I think we could detect when overflow changes (FinishAndStoreOverflow returns this), we're a block with text-overflow:ellipsis and then use something like nsFrame::DiscardOldItems.

That'll mark the individual items created by the block as being invalid, but won't trigger rebuilding of that whole subtree. If we've changed overflow, then building must descend through the current frame to get to the modified descendant, so we should be guaranteed that we'll rebuild the items for the current frame if needed.

Flags: needinfo?(matt.woodrow)

Alright, that's great, thanks!

Will give something like that a shot.

Assignee: nobody → emilio
Flags: needinfo?(emilio)
Flags: needinfo?(emilio)

The suggested change by Matt in the revision breaks the testcase again, so I have to dig tomorrow to figure out why. Some chat copy-paste for my own benefit tomorrow:

emilio mattwoodrow: passing false for aFrameChanged breaks the text-overflow test again, so that won't fly :-/
mattwoodrow emilio: Aww :( Do you know why?
My expectation is the text frame descendant itself is modified, so DL building will descend through the block to build the new text items
emilio mattwoodrow: I don't, but I can dig tomorrow if you tell me what to look for... What do you expect that should happen?
mattwoodrow The existing ellipsis items have been individually marked as to be discarded, so those should be dropped
emilio (ok, midaired, sorry :))
mattwoodrow and the block won't build new one, since we no longer need them given the new overflow
emilio Ok, will look at why that's not happening tomorrow, thanks!
mattwoodrow RetainedDisplayList builder has some commented out dumps that show you the new partial list (which should not contain ellipsis items, but should have the new text)
emilio Cool, noted, thanks again :)
Flags: needinfo?(emilio)
Flags: needinfo?(mikokm)
Flags: needinfo?(emilio)
Pushed by ealvarez@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/3b85097d2d63
Invalidate old display items if overflow changes on an element that can display ellipsis. r=mattwoodrow
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/21939 for changes under testing/web-platform/tests
Upstream web-platform-tests status checks passed, PR will merge once commit reaches central.
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla75
Upstream PR merged by moz-wptsync-bot
Regressions: 1644264
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: