Closed Bug 1800437 Opened 3 years ago Closed 3 years ago

Glitch in text-overflow:ellipsis rendering with RTL directionality

Categories

(Core :: Layout: Text and Fonts, defect, P3)

defect

Tracking

()

VERIFIED FIXED
109 Branch
Tracking Status
firefox109 --- verified
firefox110 --- verified

People

(Reporter: jfkthame, Assigned: jfkthame)

Details

Attachments

(2 files)

Testcase: https://codepen.io/jfkthame/pen/RwJgLmK

The exact rendering of the testcase will vary depending on system fonts, but what I'm seeing on all of macOS, Windows and Linux is that several of the RTL examples (right-hand column) show a large gap between the text and the ellipsis, where there would have been room to render an additional character of the text.

Oddly, doing a Select All to highlight the text makes the "missing" characters appear. So the problem doesn't show up in the paint-with-selection codepath. (Even just selecting one of the visible characters in one of the "bad" paragraphs will cause the "missing" character in that block to appear.)

The root of the problem here seems to be the GetClusterLength helper used by nsTextFrame::MeasureCharClippedText, which is returning nonsense results in the RTL case. E.g. in the codepen example, all the content should have cluster lengths of 3 code units (two surrogates for the U+1f310 character, plus the trailing variation selector), but GetClusterLength simply returns 1, and we crop and clip in the wrong place when painting.

As far as I can see, this function doesn't actually need to care about RTL; we're iterating forward through the textrun, regardless of directionality. A simplified version gives us the expected results here.

Assignee: nobody → jfkthame
Status: NEW → ASSIGNED
Pushed by jkew@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/902175624543 Correct behavior of GetClusterLength helper when applying text-overflow:ellipsis in RTL. r=emilio https://hg.mozilla.org/integration/autoland/rev/e2fb54d49160 Add reftest for text-overflow:ellipsis vs emoji in RTL. r=emilio
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 109 Branch
QA Whiteboard: [qa-109b-p2]

Reproducible on Firefox 108.0.1(build ID: 20221215175817, ar-locale) on macOS 12.
Verified as fixed on Firefox 109.0b6(build ID: 20221222190305, ar-locale) and Nightly 110.0a1(build ID: 20221226154927, ar-locale) on macOS 12, Windows 10, Ubuntu 22.

Status: RESOLVED → VERIFIED
QA Whiteboard: [qa-109b-p2]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: