Chromium Code Reviews| Index: chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.mm |
| diff --git a/chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.mm b/chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.mm |
| index 693ef769066bf8a0d1a04a57c0c23069142b8bb1..60f770988fb336260023aed05ce7add37bd47275 100644 |
| --- a/chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.mm |
| +++ b/chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.mm |
| @@ -152,6 +152,17 @@ NSFont* SmallFont() { |
| return OmniboxViewMac::GetSmallFont(); |
| } |
| +void SetTextDirectionForRange(NSMutableAttributedString* attributedString, |
|
tapted
2016/07/21 04:37:05
This should be something like SetURLTextDirection,
Matt Giuca
2016/07/21 04:55:37
It isn't necessarily setting the text direction fo
|
| + NSWritingDirection direction, |
| + NSRange range) { |
| + base::scoped_nsobject<NSMutableParagraphStyle> paragraph_style( |
| + [[NSMutableParagraphStyle alloc] init]); |
| + [paragraph_style setBaseWritingDirection:direction]; |
| + [attributedString addAttribute:NSParagraphStyleAttributeName |
| + value:paragraph_style |
| + range:range]; |
| +} |
|
tapted
2016/07/21 04:37:05
nit: any reason to have this declared up here, rat
Matt Giuca
2016/07/21 04:55:37
Well kind of along similar lines, it isn't specifi
|
| + |
| NSAttributedString* CreateAnswerStringHelper(const base::string16& text, |
| NSInteger style_type, |
| bool is_bold, |
| @@ -363,6 +374,10 @@ NSAttributedString* CreateClassifiedAttributedString( |
| } |
| if (0 != (i->style & ACMatchClassification::URL)) { |
| + // 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). |
| + SetTextDirectionForRange(attributedString, NSWritingDirectionLeftToRight, |
| + range); |
| [attributedString addAttribute:NSForegroundColorAttributeName |
| value:URLTextColor(is_dark_theme) |
| range:range]; |