SVG text anchor regression with embedding marks (U+202C ... U+202C)
Categories
(Core :: SVG, defect)
Tracking
()
Tracking | Status | |
---|---|---|
firefox-esr115 | --- | unaffected |
firefox-esr128 | --- | fixed |
firefox128 | --- | wontfix |
firefox129 | --- | fixed |
firefox130 | --- | fixed |
People
(Reporter: jonathan.olson, Assigned: jfkthame)
References
(Regression)
Details
(Keywords: regression)
Attachments
(6 files, 1 obsolete file)
872 bytes,
image/svg+xml
|
Details | |
2.87 KB,
image/svg+xml
|
Details | |
246.83 KB,
image/png
|
Details | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
phab-bot
:
approval-mozilla-beta+
|
Details | Review |
48 bytes,
text/x-phabricator-request
|
phab-bot
:
approval-mozilla-esr128+
|
Details | Review |
Steps to reproduce:
SVG <text> elements with direction="ltr" whose text starts with the character U+202B (right-to-left embedding) and ends with the character U+202C (pop directional formatting).
Minimal example attached.
Actual results:
Firefox 128 (current), 130.0a1 (nightly):
The text is shifted to the right (by the exact width of the text). It seems like the text-anchor of the text is mis-interpreted as being RTL.
The origin of the text seems shifted to the right, so that it does not match with the text-anchor position.
This resulted in all RTL text in PhET simulations (phet.colorado.edu) being shifted improperly to the right (adding a workaround to adjust the direction and strip embedding marks).
Expected results:
Firefox 127 / Chrome 126,127 / Safari 17:
The text-anchor is NOT shifted for RTL text.
Comment 1•2 months ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::SVG' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
Comment 2•2 months ago
|
||
Can you use mozregression to find a regression range please?
Updated•2 months ago
|
Assignee | ||
Comment 3•2 months ago
|
||
I'm pretty confident this will turn out to be related to the switch from ICU4C to ICU4X/unicode-bidi as the underlying implementation of the Unicode bidi algorithm. This was implemented in bug 1824671 (for Firefox 124, but initially Nightly-only), and enabled for release in bug 1896117 (Firefox 128). Although the resulting layout should be unchanged, the handling of embedding controls (which are invisible in the result) is slightly different, and that must be affecting the SVG behavior, so we need to figure out how/why that happens.
Assignee | ||
Comment 4•2 months ago
|
||
Actually, it seems that in cases with directional-override/embedding controls, there were already discrepancies between Firefox and Chrome behavior, so this was always a problematic area. Then the switch of bidi engine caused a further change, but (unfortunately) didn't simply align our behavior.
Assignee | ||
Comment 5•2 months ago
|
||
Here's a version of the testcase with a couple of additional examples using directional controls.
Comment 6•2 months ago
•
|
||
bug 1824671 does however seem to have fixed bug 1131192 and the odd thing is that bug 1131192 examples have directional controls in them so I guess we need to be careful not to regress that.
Assignee | ||
Comment 7•2 months ago
|
||
Added some more examples to the testcase.
Assignee | ||
Comment 8•2 months ago
|
||
Safari's rendering matches Chrome's (on the left). Middle is Firefox before switching the bidi implementation, so still using ICU4C; right is current Nightly, using ICU4X/unicode-bidi.
Assignee | ||
Comment 9•2 months ago
|
||
(In reply to Robert Longson [:longsonr] from comment #6)
bug 1824671 does however seem to have fixed bug 1131192 and the odd thing is that bug 1131192 examples have directional controls in them so I guess we need to be careful not to regress that.
Ah, interesting - yeah, overall I'd say the new behavior here (as seen in comment 8) is less broken than it used to be; the text all appears correctly, without parts overprinting each other, just the overall anchor alignment is wrong when the text starts with a RTL run. I think this is because ShiftAnchoredChunk assumes the (logical) first character of the chunk is what should be anchored, but that isn't true if bidi-reversal is in play.
Reporter | ||
Comment 10•2 months ago
|
||
The case where it starts with RTL U+202B and has a pop U+202C in the middle is currently something I haven't been able to work around:
Example string: ">pH:Β 7.00" ("\u202bpH\u202c: 7.00")
Neither text-anchor="start" or text-anchor="end" result in a correct result.
Assignee | ||
Comment 11•2 months ago
|
||
The added reftests here failed both prior to and after the bidi-engine update,
although the exact nature of the failures changed due to the engine leaving the
bidi control characters in different places in the reordered text. (This is
explicitly unspecified by the Unicode Bidi Algorithm, because the control codes
are nominally removed after processing; leaving them present but invisible is
an implementation detail.)
The key fix here is that DoGlyphPositioning() anchors the first addressable
character of the text, not necessarily the absolute first codepoint, as that
may be a "deleted" control code whose position is arbitrary.
Updated•2 months ago
|
Comment 12•2 months ago
|
||
Pushed by jkew@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/ad57df08b538 Fix the positioning/anchoring of SVG text runs with bidi control characters. r=longsonr,layout-reviewers,emilio
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/47116 for changes under testing/web-platform/tests
Comment 14•2 months ago
|
||
bugherder |
Updated•2 months ago
|
Upstream PR merged by moz-wptsync-bot
Assignee | ||
Comment 16•2 months ago
|
||
The added reftests here failed both prior to and after the bidi-engine update,
although the exact nature of the failures changed due to the engine leaving the
bidi control characters in different places in the reordered text. (This is
explicitly unspecified by the Unicode Bidi Algorithm, because the control codes
are nominally removed after processing; leaving them present but invisible is
an implementation detail.)
The key fix here is that DoGlyphPositioning() anchors the first addressable
character of the text, not necessarily the absolute first codepoint, as that
may be a "deleted" control code whose position is arbitrary.
Original Revision: https://phabricator.services.mozilla.com/D216400
Updated•2 months ago
|
Comment 17•2 months ago
|
||
beta Uplift Approval Request
- User impact if declined: SVG text involving bidi controls may be misplaced
- Code covered by automated testing: yes
- Fix verified in Nightly: no
- Needs manual QE test: no
- Steps to reproduce for manual QE testing: n/a
- Risk associated with taking this patch: low
- Explanation of risk level: narrowly-targeted change to skip over invisible controls when anchoring svg text run
- String changes made/needed: none
- Is Android affected?: yes
Assignee | ||
Comment 18•2 months ago
|
||
The added reftests here failed both prior to and after the bidi-engine update,
although the exact nature of the failures changed due to the engine leaving the
bidi control characters in different places in the reordered text. (This is
explicitly unspecified by the Unicode Bidi Algorithm, because the control codes
are nominally removed after processing; leaving them present but invisible is
an implementation detail.)
The key fix here is that DoGlyphPositioning() anchors the first addressable
character of the text, not necessarily the absolute first codepoint, as that
may be a "deleted" control code whose position is arbitrary.
Original Revision: https://phabricator.services.mozilla.com/D216400
Updated•2 months ago
|
Comment 19•2 months ago
|
||
esr128 Uplift Approval Request
- User impact if declined: SVG text involving bidi controls may be misplaced
- Code covered by automated testing: yes
- Fix verified in Nightly: no
- Needs manual QE test: no
- Steps to reproduce for manual QE testing: n/a
- Risk associated with taking this patch: low
- Explanation of risk level: narrowly-targeted change to skip over invisible controls when anchoring svg text run
- String changes made/needed: none
- Is Android affected?: yes
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Updated•2 months ago
|
Description
•