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/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 // it cannot occur and DCHECK appropriately. | 262 // it cannot occur and DCHECK appropriately. |
263 [[field_ currentEditor] setSelectedRange:range]; | 263 [[field_ currentEditor] setSelectedRange:range]; |
264 } | 264 } |
265 } | 265 } |
266 | 266 |
267 void OmniboxViewMac::SetWindowTextAndCaretPos(const string16& text, | 267 void OmniboxViewMac::SetWindowTextAndCaretPos(const string16& text, |
268 size_t caret_pos, | 268 size_t caret_pos, |
269 bool update_popup, | 269 bool update_popup, |
270 bool notify_text_changed) { | 270 bool notify_text_changed) { |
271 DCHECK_LE(caret_pos, text.size()); | 271 DCHECK_LE(caret_pos, text.size()); |
272 SetTextAndSelectedRange(text, NSMakeRange(caret_pos, caret_pos)); | 272 SetTextAndSelectedRange(text, NSMakeRange(caret_pos, 0)); |
273 | 273 |
274 if (update_popup) | 274 if (update_popup) |
275 UpdatePopup(); | 275 UpdatePopup(); |
276 | 276 |
277 if (notify_text_changed) | 277 if (notify_text_changed) |
278 TextChanged(); | 278 TextChanged(); |
279 } | 279 } |
280 | 280 |
281 void OmniboxViewMac::SetForcedQuery() { | 281 void OmniboxViewMac::SetForcedQuery() { |
282 // We need to do this first, else |SetSelectedRange()| won't work. | 282 // We need to do this first, else |SetSelectedRange()| won't work. |
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1006 NSUInteger OmniboxViewMac::GetTextLength() const { | 1006 NSUInteger OmniboxViewMac::GetTextLength() const { |
1007 return ([field_ currentEditor] ? | 1007 return ([field_ currentEditor] ? |
1008 [[[field_ currentEditor] string] length] : | 1008 [[[field_ currentEditor] string] length] : |
1009 [[field_ stringValue] length]) - suggest_text_length_; | 1009 [[field_ stringValue] length]) - suggest_text_length_; |
1010 } | 1010 } |
1011 | 1011 |
1012 bool OmniboxViewMac::IsCaretAtEnd() const { | 1012 bool OmniboxViewMac::IsCaretAtEnd() const { |
1013 const NSRange selection = GetSelectedRange(); | 1013 const NSRange selection = GetSelectedRange(); |
1014 return selection.length == 0 && selection.location == GetTextLength(); | 1014 return selection.length == 0 && selection.location == GetTextLength(); |
1015 } | 1015 } |
OLD | NEW |