Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(427)

Unified Diff: ios/chrome/browser/ui/omnibox/truncating_attributed_label.mm

Issue 2854893002: Force URLs in omnibox suggestions to layout LTR. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ios/chrome/browser/ui/omnibox/truncating_attributed_label.mm
diff --git a/ios/chrome/browser/ui/omnibox/truncating_attributed_label.mm b/ios/chrome/browser/ui/omnibox/truncating_attributed_label.mm
index 213a0f61b57c584144340b3813b20d4003125cbf..328c55db0c0e0267f2ee4ce3be00d407c90a6d66 100644
--- a/ios/chrome/browser/ui/omnibox/truncating_attributed_label.mm
+++ b/ios/chrome/browser/ui/omnibox/truncating_attributed_label.mm
@@ -23,6 +23,7 @@
}
@synthesize truncateMode = truncateMode_;
+@synthesize displayAsURL = displayAsURL_;
- (void)setup {
self.backgroundColor = [UIColor clearColor];
@@ -70,6 +71,10 @@
[[NSParagraphStyle defaultParagraphStyle] mutableCopy];
textStyle.lineBreakMode = self.lineBreakMode;
textStyle.alignment = self.textAlignment;
+ // URLs have their text direction set to to LTR (avoids RTL characters
+ // making the URL render from right to left, as per RFC 3987 Section 4.1).
+ if (self.displayAsURL)
+ textStyle.baseWritingDirection = NSWritingDirectionLeftToRight;
[attributedString addAttribute:NSParagraphStyleAttributeName
value:textStyle
range:NSMakeRange(0, [self.text length])];

Powered by Google App Engine
This is Rietveld 408576698