Closed Bug 1961757 Opened 1 year ago Closed 1 year ago

toDisplayUrl in URLStringUtils returns String when the URL is RTL

Categories

(Firefox for Android :: Tooling, defect)

All
Android
defect

Tracking

()

RESOLVED FIXED
141 Branch
Tracking Status
firefox141 --- fixed

People

(Reporter: michel, Assigned: michel)

References

(Regressed 1 open bug)

Details

Attachments

(1 external file)

This is something that I missed in https://bugzilla.mozilla.org/show_bug.cgi?id=1954340. When the URL is RTL, toDisplayUrl does "\u200E" + strippedText effectively converting the CharSequence to a string and stripping all markup.

I see that the logic of prepending the LTR mark was added in https://github.com/mozilla-mobile/android-components/pull/10599 following https://bugzilla.mozilla.org/show_bug.cgi?id=1704422.

Is there a reason why this approach was preferred over setting textDirection on the TextView with a patch like:

--- a/mobile/android/android-components/components/browser/toolbar/src/main/java/mozilla/components/browser/toolbar/display/OriginView.kt
+++ b/mobile/android/android-components/components/browser/toolbar/src/main/java/mozilla/components/browser/toolbar/display/OriginView.kt
@@ -48,6 +48,8 @@ internal class OriginView @JvmOverloads 
         isClickable = true
         isFocusable = true
 
+        textDirection = View.TEXT_DIRECTION_LTR
+
         setOnClickListener {
             if (onUrlClicked()) {
                 toolbar.editMode()
Flags: needinfo?(petru)
See Also: → 1856384

(In reply to Michel Le Bihan from comment #2)

I see that the logic of prepending the LTR mark was added in https://github.com/mozilla-mobile/android-components/pull/10599 following https://bugzilla.mozilla.org/show_bug.cgi?id=1704422.

Is there a reason why this approach was preferred over setting textDirection on the TextView with a patch like:

Think the response (and a test case) is in bug 1704422 comment 5.
No matter the textDirection we set if the text starts with RTL characters then the TextView will render them at the right.

Flags: needinfo?(petru)

The referenced issue and comment do not mention attempting to set textDirection. Do you remember how you were setting it? When I apply the diff from https://bugzilla.mozilla.org/show_bug.cgi?id=1961757#c2, all test URLs display correctly for me.

Flags: needinfo?(petru)

Indeed.
Tested the scenario from bug 1704422 with LTR set for urlView after removing \u200E from toDisplayUrl and all looks good so seems like we can stop using \u200E.

Flags: needinfo?(petru)
Attachment #9480206 - Attachment description: Bug 1961757 - Fix handling of RTL SpannableStringBuilder in URLStringUtils toDisplayUrl Android component. r=tthibaud → Bug 1961757 - Set text direction in Android toolbar instead of adding directional marks. r=tthibaud,petru

The severity field is not set for this bug.
:007, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(nbond)
Severity: -- → S3
Flags: needinfo?(nbond)

Could you please look at the linked revision?

Flags: needinfo?(petru)

(In reply to Michel Le Bihan from comment #7)

Could you please look at the linked revision?

Testing it I see that the issue from bug 1704422#c5 does not reproduce so I do appreciate the simplified overall code, thanks!

Flags: needinfo?(petru)
Pushed by tthibaud@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/4b0be69146de Set text direction in Android toolbar instead of adding directional marks. r=tthibaud,android-reviewers,petru
Status: NEW → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 141 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: