Incorrect rendering of directionality in mixed LTR and RTL texts

RESOLVED FIXED

Status

()

Core
Layout: Text
RESOLVED FIXED
7 years ago
6 years ago

People

(Reporter: Huji, Assigned: smontagu)

Tracking

Trunk
x86
All
Points:
---
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(3 attachments, 1 obsolete attachment)

(Reporter)

Description

7 years ago
User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6

If you have a textarea which is in RTL layout, and you put in a piece of text which is a mixture of RTL and LTR content, if the LTR content starts with specific characters (like braces, curly braces or < or >), the directionality of the character is affected by the text "before" it, not the text on the same line. This causes confusion.

Reproducible: Always

Steps to Reproduce:
1. Create a page in RTL layout nd put a textarea in it which also flows from right to left. As a shortcut, you can use Persian Wikipedia's Edit Box ( http://fa.wikipedia.org/w/index.php?title=testpage&action=edit&section=new )
2. Inside the text area, paste this sample text:

Blah blah
فلان فلان
<ref>ooo</ref>
<references />


Actual Results:  
The opening < for the REF tag and the REFERENCES tag is not shown in the desired place.


See this screenshot please: http://upload.wikimedia.org/wikipedia/test/e/ed/Rtlproblem2.png

The top two windows belong to IE and Google Chrome (latest versions), and the bottom box belongs to Firefox. You can clearly get the difference in the rendering of the text.

This bug has been present in Firefox at least since version 2.5 (IIRC), and apparently no one has bothered to report it.
Is this bug and bug 505685 duplicate?

Updated

7 years ago
Version: unspecified → 3.6 Branch

Comment 2

6 years ago
i know this was related to Bug 263359 that today fixed :)
Reporter, are you still seeing this issue with Firefox 4.0.1 or later in safe mode or a fresh profile? If not, please close. These links can help you in your testing.
http://support.mozilla.com/kb/Safe+Mode
http://support.mozilla.com/kb/Managing+profiles

Comment 4

6 years ago
Sadly, bug 263359 is backed out so this can be seen again, (in versions this was committed you couldn't find that, same "Gecko/20110413 Firefox/6.0a1")

Comment 5

6 years ago
Created attachment 531560 [details]
Correct rendering

about above comment

Updated

6 years ago
Depends on: 263359
Version: 3.6 Branch → Trunk
(Reporter)

Comment 6

6 years ago
(In reply to comment #3)
> Reporter, are you still seeing this issue with Firefox 4.0.1 or later in
> safe mode or a fresh profile? If not, please close. These links can help you
> in your testing.
> http://support.mozilla.com/kb/Safe+Mode
> http://support.mozilla.com/kb/Managing+profiles

Yes, the bug is still present in Firefox 4.0.1 in safe mode and using a fresh profile.

Updated

6 years ago
Version: Trunk → 4.0 Branch
This bug was reported using a pre-release version of Firefox 4. Now that Firefox 4.0.1 final has been released, can you please update and retest your bug? A fresh profile would be a good starting place to test, 
http://support.mozilla.com/kb/Managing+profiles. If you continue to see the issue, can you please update this bug with your results?

Filter: firefox4prebugsunco
(Reporter)

Comment 8

6 years ago
Tested with a clean profile on Firefox 4.0.1 in Ubuntu and in Win, and the bug still persists.
OS: Windows XP → All
Can you please try it in the latest nightly now that bug 263359 is fixed?

Comment 10

6 years ago
Ehsan, I downloaded last nightly, it is generally fixed but in this testcase:
data:text/html;charset=utf-8,<textarea style="direction:rtl">فارسی%0A[[en:Farsi]]%0A</textarea>
please do a backspace in last line of textarea (remove last enter of textarea), something going wrong I thing. it is too much better from previous Firefox, but i think this little problem can be fixed also
(Reporter)

Comment 11

6 years ago
I also see another problem. Using the original example:

Blah blah
فلان فلان
<ref>ooo</ref>
<references />

If you put the cursor at the end of the last line, hit BACKSPACE once (so the > will be removed) and then type ">" again, it will not be shown correctly.
I can reproduce both comment 10 and 11.  Simon, I think that dynamic changes somehow screw up the bidi calculations here...
Status: UNCONFIRMED → NEW
Component: General → Layout: Text
Ever confirmed: true
Product: Firefox → Core
QA Contact: general → layout.fonts-and-text
Version: 4.0 Branch → Trunk
(Assignee)

Updated

6 years ago
Assignee: nobody → smontagu
(Assignee)

Comment 13

6 years ago
Created attachment 539146 [details] [diff] [review]
Patch
Attachment #539146 - Flags: review?(roc)
(Assignee)

Comment 14

6 years ago
Created attachment 539147 [details] [diff] [review]
Mochitests
Attachment #539147 - Flags: review?(roc)
Comment on attachment 539146 [details] [diff] [review]
Patch

Review of attachment 539146 [details] [diff] [review]:
-----------------------------------------------------------------

::: layout/base/nsBidiPresUtils.cpp
@@ +650,5 @@
>      || !aFrame->IsFrameOfType(nsIFrame::eBidiInlineContainer);
>  }
>  
>  void
> +nsBidiPresUtils::AppendFrameAndAdvance(nsIFrame*& aFrame,

Shouldn't this be called AdvanceAndAppendFrame?

I think aFrame and aNextSibling should be nsIFrame** so that it's clear in the callers that the frame references are modified.
Comment on attachment 539147 [details] [diff] [review]
Mochitests

Review of attachment 539147 [details] [diff] [review]:
-----------------------------------------------------------------
Attachment #539147 - Flags: review?(roc) → review+
(Assignee)

Comment 17

6 years ago
http://hg.mozilla.org/mozilla-central/rev/ec3718e17035
http://hg.mozilla.org/mozilla-central/rev/dcc03e00b32a
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
(Assignee)

Comment 18

6 years ago
Created attachment 539803 [details] [diff] [review]
Patch with comments addressed

Oops, I thought you had marked this as r+ with comments, and I checked it in already. Can you r+ it retroactively (or not, and I'll back out)?
Attachment #539146 - Attachment is obsolete: true
Attachment #539803 - Flags: review?(roc)
Attachment #539146 - Flags: review?(roc)
Comment on attachment 539803 [details] [diff] [review]
Patch with comments addressed

Review of attachment 539803 [details] [diff] [review]:
-----------------------------------------------------------------
Attachment #539803 - Flags: review?(roc) → review+
You need to log in before you can comment on or make changes to this bug.