Index: chrome/android/java/src/org/chromium/chrome/browser/omnibox/UrlBar.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/omnibox/UrlBar.java b/chrome/android/java/src/org/chromium/chrome/browser/omnibox/UrlBar.java |
index 596d18a48075b6aa0170168e46c1e502f938b914..919809bcb22e566088a99d73773d285efa200e8d 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/omnibox/UrlBar.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/omnibox/UrlBar.java |
@@ -437,6 +437,19 @@ public class UrlBar extends VerticallyFixedEditText { |
} |
if (focused) StartupMetrics.getInstance().recordFocusedOmnibox(); |
+ |
+ // When unfocused, force left-to-right rendering at the paragraph level (which is desired |
+ // for URLs). Right-to-left runs are still rendered RTL, but will not flip the whole URL |
+ // around. This is consistent with OmniboxViewViews on desktop. When focused, render text |
+ // normally (to allow users to make non-URL searches and to avoid showing Android's split |
+ // insertion point when an RTL user enters RTL text). |
+ if (focused) { |
+ ApiCompatibilityUtils.setTextDirection(this, TEXT_DIRECTION_INHERIT); |
+ } else { |
+ ApiCompatibilityUtils.setTextDirection(this, TEXT_DIRECTION_LTR); |
+ } |
+ // Always align to the same as the paragraph direction (LTR = left, RTL = right). |
+ ApiCompatibilityUtils.setTextAlignment(this, TEXT_ALIGNMENT_TEXT_START); |
} |
/** |