OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 return true; | 384 return true; |
385 const NSRange all_range = NSMakeRange(0, GetTextLength()); | 385 const NSRange all_range = NSMakeRange(0, GetTextLength()); |
386 return NSEqualRanges(all_range, GetSelectedRange()); | 386 return NSEqualRanges(all_range, GetSelectedRange()); |
387 } | 387 } |
388 | 388 |
389 bool OmniboxViewMac::DeleteAtEndPressed() { | 389 bool OmniboxViewMac::DeleteAtEndPressed() { |
390 return delete_at_end_pressed_; | 390 return delete_at_end_pressed_; |
391 } | 391 } |
392 | 392 |
393 void OmniboxViewMac::GetSelectionBounds(string16::size_type* start, | 393 void OmniboxViewMac::GetSelectionBounds(string16::size_type* start, |
394 string16::size_type* end) { | 394 string16::size_type* end) const { |
395 if (![field_ currentEditor]) { | 395 if (![field_ currentEditor]) { |
396 *start = *end = 0; | 396 *start = *end = 0; |
397 return; | 397 return; |
398 } | 398 } |
399 | 399 |
400 const NSRange selected_range = GetSelectedRange(); | 400 const NSRange selected_range = GetSelectedRange(); |
401 *start = static_cast<size_t>(selected_range.location); | 401 *start = static_cast<size_t>(selected_range.location); |
402 *end = static_cast<size_t>(NSMaxRange(selected_range)); | 402 *end = static_cast<size_t>(NSMaxRange(selected_range)); |
403 } | 403 } |
404 | 404 |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1121 | 1121 |
1122 void OmniboxViewMac::PlaceCaretAt(NSUInteger pos) { | 1122 void OmniboxViewMac::PlaceCaretAt(NSUInteger pos) { |
1123 DCHECK(pos <= GetTextLength()); | 1123 DCHECK(pos <= GetTextLength()); |
1124 SetSelectedRange(NSMakeRange(pos, pos)); | 1124 SetSelectedRange(NSMakeRange(pos, pos)); |
1125 } | 1125 } |
1126 | 1126 |
1127 bool OmniboxViewMac::IsCaretAtEnd() const { | 1127 bool OmniboxViewMac::IsCaretAtEnd() const { |
1128 const NSRange selection = GetSelectedRange(); | 1128 const NSRange selection = GetSelectedRange(); |
1129 return selection.length == 0 && selection.location == GetTextLength(); | 1129 return selection.length == 0 && selection.location == GetTextLength(); |
1130 } | 1130 } |
OLD | NEW |