| 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" |
| 11 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
| 12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 13 #include "base/strings/sys_string_conversions.h" | 13 #include "base/strings/sys_string_conversions.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" | 15 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
| 16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/search/search.h" | 17 #include "chrome/browser/search/search.h" |
| 18 #include "chrome/browser/themes/theme_service.h" | 18 #include "chrome/browser/themes/theme_service.h" |
| 19 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 19 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 20 #include "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" | 20 #import "chrome/browser/ui/cocoa/l10n_util.h" |
| 21 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" |
| 21 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h" | 22 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h" |
| 22 #include "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h" | 23 #include "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h" |
| 23 #include "chrome/browser/ui/omnibox/chrome_omnibox_client.h" | 24 #include "chrome/browser/ui/omnibox/chrome_omnibox_client.h" |
| 24 #include "chrome/browser/ui/omnibox/clipboard_utils.h" | 25 #include "chrome/browser/ui/omnibox/clipboard_utils.h" |
| 25 #include "chrome/grit/generated_resources.h" | 26 #include "chrome/grit/generated_resources.h" |
| 26 #include "chrome/grit/theme_resources.h" | 27 #include "chrome/grit/theme_resources.h" |
| 27 #include "components/grit/components_scaled_resources.h" | 28 #include "components/grit/components_scaled_resources.h" |
| 28 #include "components/omnibox/browser/autocomplete_input.h" | 29 #include "components/omnibox/browser/autocomplete_input.h" |
| 29 #include "components/omnibox/browser/autocomplete_match.h" | 30 #include "components/omnibox/browser/autocomplete_match.h" |
| 30 #include "components/omnibox/browser/omnibox_edit_controller.h" | 31 #include "components/omnibox/browser/omnibox_edit_controller.h" |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 range:NSMakeRange(0, [attributedString length])]; | 524 range:NSMakeRange(0, [attributedString length])]; |
| 524 | 525 |
| 525 // Make a paragraph style locking in the standard line height as the maximum, | 526 // Make a paragraph style locking in the standard line height as the maximum, |
| 526 // otherwise the baseline may shift "downwards". | 527 // otherwise the baseline may shift "downwards". |
| 527 base::scoped_nsobject<NSMutableParagraphStyle> paragraph_style( | 528 base::scoped_nsobject<NSMutableParagraphStyle> paragraph_style( |
| 528 [[NSMutableParagraphStyle alloc] init]); | 529 [[NSMutableParagraphStyle alloc] init]); |
| 529 CGFloat line_height = [[field_ cell] lineHeight]; | 530 CGFloat line_height = [[field_ cell] lineHeight]; |
| 530 [paragraph_style setMaximumLineHeight:line_height]; | 531 [paragraph_style setMaximumLineHeight:line_height]; |
| 531 [paragraph_style setMinimumLineHeight:line_height]; | 532 [paragraph_style setMinimumLineHeight:line_height]; |
| 532 [paragraph_style setLineBreakMode:NSLineBreakByTruncatingTail]; | 533 [paragraph_style setLineBreakMode:NSLineBreakByTruncatingTail]; |
| 534 // Set an explicit alignment so it isn't implied from writing direction. |
| 535 [paragraph_style setAlignment:cocoa_l10n_util::ShouldDoExperimentalRTLLayout() |
| 536 ? NSRightTextAlignment |
| 537 : NSLeftTextAlignment]; |
| 533 // If this is a URL, set the top-level paragraph direction to LTR (avoids RTL | 538 // If this is a URL, set the top-level paragraph direction to LTR (avoids RTL |
| 534 // characters from making the URL render from right to left, as per RFC 3987 | 539 // characters from making the URL render from right to left, as per RFC 3987 |
| 535 // Section 4.1). | 540 // Section 4.1). |
| 536 if (model()->CurrentTextIsURL()) | 541 if (model()->CurrentTextIsURL()) |
| 537 [paragraph_style setBaseWritingDirection:NSWritingDirectionLeftToRight]; | 542 [paragraph_style setBaseWritingDirection:NSWritingDirectionLeftToRight]; |
| 538 [attributedString addAttribute:NSParagraphStyleAttributeName | 543 [attributedString addAttribute:NSParagraphStyleAttributeName |
| 539 value:paragraph_style | 544 value:paragraph_style |
| 540 range:NSMakeRange(0, [attributedString length])]; | 545 range:NSMakeRange(0, [attributedString length])]; |
| 541 } | 546 } |
| 542 | 547 |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1083 display_text); | 1088 display_text); |
| 1084 NSDictionary* notification_info = @{ | 1089 NSDictionary* notification_info = @{ |
| 1085 NSAccessibilityAnnouncementKey : announcement, | 1090 NSAccessibilityAnnouncementKey : announcement, |
| 1086 NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh) | 1091 NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh) |
| 1087 }; | 1092 }; |
| 1088 NSAccessibilityPostNotificationWithUserInfo( | 1093 NSAccessibilityPostNotificationWithUserInfo( |
| 1089 [field_ window], | 1094 [field_ window], |
| 1090 NSAccessibilityAnnouncementRequestedNotification, | 1095 NSAccessibilityAnnouncementRequestedNotification, |
| 1091 notification_info); | 1096 notification_info); |
| 1092 } | 1097 } |
| OLD | NEW |