Open Bug 1909120 Opened 2 years ago Updated 2 years ago

Unicode Bidirectional Algorithm support

Categories

(Core :: DOM: Editor, defect)

Firefox 128
defect

Tracking

()

UNCONFIRMED

People

(Reporter: avidseeker, Unassigned)

Details

Attachments

(3 files)

User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36

Steps to reproduce:

1. Create test.html with content: <html><textarea cols="80" rows="20"></textarea </html>`
2. Open test.html in Firefox
3. Paste Bidi-mixed text. E.g:

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

قِفَا نَبْكِ مِنْ ذِكْرَى حَبِيبٍ ومَنْزِلِ، بِسِقْطِ اللِّوَى بَيْنَ الدَّخُول فَحَوْمَلِ. فَتُوْضِحَ فَالمِقْراةِ لمْ يَعْفُ رَسْمُها، لِمَا نَسَجَتْهَا مِنْ جَنُوبٍ وشَمْألِ. تَرَى بَعَرَ الأرْآمِ فِي عَرَصَاتِهَا، وَقِيْعَانِهَا كَأنَّهُ حَبُّ فُلْفُلِ. كَأنِّي غَدَاةَ البَيْنِ يَوْمَ تَحَمَّلُوا، لَدَى سَمُرَاتِ الحَيِّ نَاقِفُ حَنْظَلِ. وُقُوْفًا بِهَا صَحْبِي عَليَّ مَطِيَّهُمُ، يَقُوْلُوْنَ: لا تَهْلِكْ أَسًى وَتَجَمَّلِ. وإِنَّ شِفائِيَ عَبْرَةٌ مُهْرَاقَةٌ، فَهَلْ عِنْدَ رَسْمٍ دَارِسٍ مِنْ مُعَوَّلِ؟. كَدَأْبِكَ مِنْ أُمِّ الحُوَيْرِثِ قَبْلَهَا، وَجَارَتِهَا أُمِّ الرَّبَابِ بِمَأْسَلِ. إِذَا قَامَتَا تَضَوَّعَ المِسْكُ مِنْهُمَا، نَسِيْمَ الصَّبَا جَاءَتْ بِرَيَّا القَرَنْفُلِ. فَفَاضَتْ دُمُوْعُ العَيْنِ مِنِّي صَبَابَةً، عَلَى النَّحْرِ حَتَّى بَلَّ دَمْعِيَ مِحْمَلِي.


Unicode specifies Unicode Bidirectional Algorithm (UBA) for programs to automatically detect the directionality of each paragraph. See: https://www.unicode.org/reports/tr9/

GTK-based editors implements UBA. If the following sample text is pasted in a GTK text editor, it will automatically align text accordingly. This is not the case with Chromium. Chromium offers setting "Writing Direction" manually through context menu, which is known as "forcing text direction". This is different from UBA.

Actual results:

Result: all text aligned to the left.

Expected results:

Expected: have Arabic text aligned to the right.

The Bugbug bot thinks this bug should belong to the 'Core::DOM: Editor' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → DOM: Editor
Product: Firefox → Core

Added a test case, can confirm the behavior. Looks like Firefox behaves similarly to Chrome (minus the context menu option).

Masayuki, can you give a bit more context here? Thank you!

Severity: -- → S3
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(masayuki)

Yeah, me too. In <textarea>, there is no idea about paragraphs, it just treat a long character sequence which may contain line breakers. Don't you talking about contenteditable or something?

Status: NEW → UNCONFIRMED
Ever confirmed: false
Flags: needinfo?(masayuki) → needinfo?(avidseeker7)

Well, but even in contenteditable, Chrome does not treat the paragraph only containing Arabic text as RTL...

Chrome could change the behavior from the language settings of OS or something?

There is an option issue for this on Chromium: https://issues.chromium.org/issues/354513199

Note that it is possible on Firefox to force text direction, and while this is helpful, it is not the same thing as UBA support.

Flags: needinfo?(avidseeker7)

dir="auto" gives the results you want

I see. In that case I see two problems.

  1. dir="auto" text boxes have a bug: resizing using the left drag area is jittery and has to be dragged to the opposite direction of where resizing is.
  2. My request would be to set this as the default behavior

(In reply to AvidSeeker from comment #8)

  1. dir="auto" text boxes have a bug: resizing using the left drag area is jittery and has to be dragged to the opposite direction of where resizing is.

That's a bug with all RTL textareas, whether set by dir="rtl" or dir="auto", or by "Switch text direction" from the context menuץ See bug 817363,

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: