| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" | 5 #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" |
| 6 | 6 |
| 7 #include <Carbon/Carbon.h> // kVK_Return | 7 #include <Carbon/Carbon.h> // kVK_Return |
| 8 | 8 |
| 9 #include "base/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 range:NSMakeRange(0, [attributedString length])]; | 555 range:NSMakeRange(0, [attributedString length])]; |
| 556 | 556 |
| 557 // Make a paragraph style locking in the standard line height as the maximum, | 557 // Make a paragraph style locking in the standard line height as the maximum, |
| 558 // otherwise the baseline may shift "downwards". | 558 // otherwise the baseline may shift "downwards". |
| 559 base::scoped_nsobject<NSMutableParagraphStyle> paragraph_style( | 559 base::scoped_nsobject<NSMutableParagraphStyle> paragraph_style( |
| 560 [[NSMutableParagraphStyle alloc] init]); | 560 [[NSMutableParagraphStyle alloc] init]); |
| 561 CGFloat line_height = [[field_ cell] lineHeight]; | 561 CGFloat line_height = [[field_ cell] lineHeight]; |
| 562 [paragraph_style setMaximumLineHeight:line_height]; | 562 [paragraph_style setMaximumLineHeight:line_height]; |
| 563 [paragraph_style setMinimumLineHeight:line_height]; | 563 [paragraph_style setMinimumLineHeight:line_height]; |
| 564 [paragraph_style setLineBreakMode:NSLineBreakByTruncatingTail]; | 564 [paragraph_style setLineBreakMode:NSLineBreakByTruncatingTail]; |
| 565 // If this is a URL, set the top-level paragraph direction to LTR (avoids RTL |
| 566 // characters from making the URL render from right to left, as per RFC 3987 |
| 567 // Section 4.1). |
| 568 if (model()->CurrentTextIsURL()) |
| 569 [paragraph_style setBaseWritingDirection:NSWritingDirectionLeftToRight]; |
| 565 [attributedString addAttribute:NSParagraphStyleAttributeName | 570 [attributedString addAttribute:NSParagraphStyleAttributeName |
| 566 value:paragraph_style | 571 value:paragraph_style |
| 567 range:NSMakeRange(0, [attributedString length])]; | 572 range:NSMakeRange(0, [attributedString length])]; |
| 568 } | 573 } |
| 569 | 574 |
| 570 void OmniboxViewMac::ApplyTextAttributes( | 575 void OmniboxViewMac::ApplyTextAttributes( |
| 571 const base::string16& display_text, | 576 const base::string16& display_text, |
| 572 NSMutableAttributedString* attributedString) { | 577 NSMutableAttributedString* attributedString) { |
| 573 NSUInteger as_length = [attributedString length]; | 578 NSUInteger as_length = [attributedString length]; |
| 574 if (as_length == 0) { | 579 if (as_length == 0) { |
| (...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1157 display_text); | 1162 display_text); |
| 1158 NSDictionary* notification_info = @{ | 1163 NSDictionary* notification_info = @{ |
| 1159 NSAccessibilityAnnouncementKey : announcement, | 1164 NSAccessibilityAnnouncementKey : announcement, |
| 1160 NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh) | 1165 NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh) |
| 1161 }; | 1166 }; |
| 1162 NSAccessibilityPostNotificationWithUserInfo( | 1167 NSAccessibilityPostNotificationWithUserInfo( |
| 1163 [field_ window], | 1168 [field_ window], |
| 1164 NSAccessibilityAnnouncementRequestedNotification, | 1169 NSAccessibilityAnnouncementRequestedNotification, |
| 1165 notification_info); | 1170 notification_info); |
| 1166 } | 1171 } |
| OLD | NEW |