Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm

Issue 6731036: Enabled pressing TAB to cycle through the Omnibox results. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/property_bag.h" 9 #include "base/property_bag.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 357
358 // TODO(shess): What if it didn't get first responder, and there is 358 // TODO(shess): What if it didn't get first responder, and there is
359 // no field editor? This will do nothing. Well, at least it won't 359 // no field editor? This will do nothing. Well, at least it won't
360 // crash. Think of something more productive to do, or prove that 360 // crash. Think of something more productive to do, or prove that
361 // it cannot occur and DCHECK appropriately. 361 // it cannot occur and DCHECK appropriately.
362 [[field_ currentEditor] setSelectedRange:range]; 362 [[field_ currentEditor] setSelectedRange:range];
363 } 363 }
364 } 364 }
365 365
366 void OmniboxViewMac::SetWindowTextAndCaretPos(const string16& text, 366 void OmniboxViewMac::SetWindowTextAndCaretPos(const string16& text,
367 size_t caret_pos) { 367 size_t caret_pos,
368 bool update_popup,
369 bool notify_text_changed) {
368 DCHECK_LE(caret_pos, text.size()); 370 DCHECK_LE(caret_pos, text.size());
369 SetTextAndSelectedRange(text, NSMakeRange(caret_pos, caret_pos)); 371 SetTextAndSelectedRange(text, NSMakeRange(caret_pos, caret_pos));
370 } 372 }
371 373
372 void OmniboxViewMac::SetForcedQuery() { 374 void OmniboxViewMac::SetForcedQuery() {
373 // We need to do this first, else |SetSelectedRange()| won't work. 375 // We need to do this first, else |SetSelectedRange()| won't work.
374 FocusLocation(true); 376 FocusLocation(true);
375 377
376 const string16 current_text(GetText()); 378 const string16 current_text(GetText());
377 const size_t start = current_text.find_first_not_of(kWhitespaceUTF16); 379 const size_t start = current_text.find_first_not_of(kWhitespaceUTF16);
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 range:ComponentToNSRange(scheme)]; 601 range:ComponentToNSRange(scheme)];
600 } 602 }
601 } 603 }
602 604
603 void OmniboxViewMac::OnTemporaryTextMaybeChanged(const string16& display_text, 605 void OmniboxViewMac::OnTemporaryTextMaybeChanged(const string16& display_text,
604 bool save_original_selection) { 606 bool save_original_selection) {
605 if (save_original_selection) 607 if (save_original_selection)
606 saved_temporary_selection_ = GetSelectedRange(); 608 saved_temporary_selection_ = GetSelectedRange();
607 609
608 suggest_text_length_ = 0; 610 suggest_text_length_ = 0;
609 SetWindowTextAndCaretPos(display_text, display_text.size()); 611 SetWindowTextAndCaretPos(display_text, display_text.size(), false, false);
610 model_->OnChanged(); 612 model_->OnChanged();
611 [field_ clearUndoChain]; 613 [field_ clearUndoChain];
612 } 614 }
613 615
614 void OmniboxViewMac::OnStartingIME() { 616 void OmniboxViewMac::OnStartingIME() {
615 // Reset the suggest text just before starting an IME composition session, 617 // Reset the suggest text just before starting an IME composition session,
616 // otherwise the IME composition may be interrupted when the suggest text 618 // otherwise the IME composition may be interrupted when the suggest text
617 // gets reset by the IME composition change. 619 // gets reset by the IME composition change.
618 SetInstantSuggestion(string16(), false); 620 SetInstantSuggestion(string16(), false);
619 } 621 }
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 model_->OnUpOrDownKeyPressed(-model_->result().size()); 826 model_->OnUpOrDownKeyPressed(-model_->result().size());
825 return true; 827 return true;
826 } 828 }
827 829
828 if (cmd == @selector(cancelOperation:)) { 830 if (cmd == @selector(cancelOperation:)) {
829 return model_->OnEscapeKeyPressed(); 831 return model_->OnEscapeKeyPressed();
830 } 832 }
831 833
832 if (cmd == @selector(insertTab:) || 834 if (cmd == @selector(insertTab:) ||
833 cmd == @selector(insertTabIgnoringFieldEditor:)) { 835 cmd == @selector(insertTabIgnoringFieldEditor:)) {
834 if (model_->is_keyword_hint()) 836 if (model_->is_keyword_hint())
aaron.randolph 2012/01/19 23:13:36 Needs a check for SHIFT to clear keyword or logic
835 return model_->AcceptKeyword(); 837 return model_->AcceptKeyword();
836 838
837 if (suggest_text_length_ > 0) { 839 if (suggest_text_length_ > 0) {
838 model_->CommitSuggestedText(true); 840 model_->CommitSuggestedText(true);
839 return true; 841 return true;
840 } 842 }
841 843
842 if (!IsCaretAtEnd()) { 844 if (!IsCaretAtEnd()) {
aaron.randolph 2012/01/19 23:13:36 This if statement and body need to be removed.
843 PlaceCaretAt(GetTextLength()); 845 PlaceCaretAt(GetTextLength());
844 // OnDidChange() will not be triggered when setting selected range in this 846 // OnDidChange() will not be triggered when setting selected range in this
845 // method, so we need to call it explicitly. 847 // method, so we need to call it explicitly.
846 OnDidChange(); 848 OnDidChange();
847 return true; 849 return true;
848 } 850 }
849 851
850 if (model_->AcceptCurrentInstantPreview()) 852 if (model_->AcceptCurrentInstantPreview())
851 return true; 853 return true;
852 } 854 }
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 1127
1126 void OmniboxViewMac::PlaceCaretAt(NSUInteger pos) { 1128 void OmniboxViewMac::PlaceCaretAt(NSUInteger pos) {
1127 DCHECK(pos <= GetTextLength()); 1129 DCHECK(pos <= GetTextLength());
1128 SetSelectedRange(NSMakeRange(pos, pos)); 1130 SetSelectedRange(NSMakeRange(pos, pos));
1129 } 1131 }
1130 1132
1131 bool OmniboxViewMac::IsCaretAtEnd() const { 1133 bool OmniboxViewMac::IsCaretAtEnd() const {
1132 const NSRange selection = GetSelectedRange(); 1134 const NSRange selection = GetSelectedRange();
1133 return selection.length == 0 && selection.location == GetTextLength(); 1135 return selection.length == 0 && selection.location == GetTextLength();
1134 } 1136 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698