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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 if (do_coalesced_range_update_) | 317 if (do_coalesced_range_update_) |
318 SetSelectedRange(coalesced_range_update_); | 318 SetSelectedRange(coalesced_range_update_); |
319 do_coalesced_range_update_ = false; | 319 do_coalesced_range_update_ = false; |
320 } | 320 } |
321 | 321 |
322 base::string16 OmniboxViewMac::GetText() const { | 322 base::string16 OmniboxViewMac::GetText() const { |
323 return base::SysNSStringToUTF16([field_ stringValue]); | 323 return base::SysNSStringToUTF16([field_ stringValue]); |
324 } | 324 } |
325 | 325 |
326 NSRange OmniboxViewMac::GetSelectedRange() const { | 326 NSRange OmniboxViewMac::GetSelectedRange() const { |
327 return [[field_ currentEditor] selectedRange]; | 327 AutocompleteTextFieldEditor* editor = |
| 328 base::mac::ObjCCastStrict<AutocompleteTextFieldEditor>( |
| 329 [field_ currentEditor]); |
| 330 return editor.actualSelectedRange; |
328 } | 331 } |
329 | 332 |
330 NSRange OmniboxViewMac::GetMarkedRange() const { | 333 NSRange OmniboxViewMac::GetMarkedRange() const { |
331 DCHECK([field_ currentEditor]); | 334 DCHECK([field_ currentEditor]); |
332 return [(NSTextView*)[field_ currentEditor] markedRange]; | 335 return [(NSTextView*)[field_ currentEditor] markedRange]; |
333 } | 336 } |
334 | 337 |
335 void OmniboxViewMac::SetSelectedRange(const NSRange range) { | 338 void OmniboxViewMac::SetSelectedRange(const NSRange range) { |
336 if (in_coalesced_update_block_) { | 339 if (in_coalesced_update_block_) { |
337 do_coalesced_range_update_ = true; | 340 do_coalesced_range_update_ = true; |
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1114 display_text); | 1117 display_text); |
1115 NSDictionary* notification_info = @{ | 1118 NSDictionary* notification_info = @{ |
1116 NSAccessibilityAnnouncementKey : announcement, | 1119 NSAccessibilityAnnouncementKey : announcement, |
1117 NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh) | 1120 NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh) |
1118 }; | 1121 }; |
1119 NSAccessibilityPostNotificationWithUserInfo( | 1122 NSAccessibilityPostNotificationWithUserInfo( |
1120 [field_ window], | 1123 [field_ window], |
1121 NSAccessibilityAnnouncementRequestedNotification, | 1124 NSAccessibilityAnnouncementRequestedNotification, |
1122 notification_info); | 1125 notification_info); |
1123 } | 1126 } |
OLD | NEW |