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

Unified Diff: chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm

Issue 9419043: Revert 122412 - Enabled pressing TAB to traverse through the Omnibox results (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm
===================================================================
--- chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm (revision 122471)
+++ chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm (working copy)
@@ -329,8 +329,11 @@
model_->SetUserText(text);
// TODO(shess): TODO below from gtk.
// TODO(deanm): something about selection / focus change here.
- SetWindowTextAndCaretPos(display_text, display_text.length(), update_popup,
- true);
+ SetText(display_text);
+ if (update_popup) {
+ UpdatePopup();
+ }
+ model_->OnChanged();
}
NSRange OmniboxViewMac::GetSelectedRange() const {
@@ -361,17 +364,9 @@
}
void OmniboxViewMac::SetWindowTextAndCaretPos(const string16& text,
- size_t caret_pos,
- bool update_popup,
- bool notify_text_changed) {
+ size_t caret_pos) {
DCHECK_LE(caret_pos, text.size());
SetTextAndSelectedRange(text, NSMakeRange(caret_pos, caret_pos));
-
- if (update_popup)
- UpdatePopup();
-
- if (notify_text_changed)
- TextChanged();
}
void OmniboxViewMac::SetForcedQuery() {
@@ -537,11 +532,6 @@
}
}
-void OmniboxViewMac::TextChanged() {
- EmphasizeURLComponents();
- model_->OnChanged();
-}
-
void OmniboxViewMac::ApplyTextAttributes(const string16& display_text,
NSMutableAttributedString* as) {
NSUInteger as_length = [as length];
@@ -616,7 +606,7 @@
saved_temporary_selection_ = GetSelectedRange();
suggest_text_length_ = 0;
- SetWindowTextAndCaretPos(display_text, display_text.size(), false, false);
+ SetWindowTextAndCaretPos(display_text, display_text.size());
model_->OnChanged();
[field_ clearUndoChain];
}
@@ -708,7 +698,8 @@
// Linux watches for something_changed && text_differs, but that
// fails for us in case you copy the URL and paste the identical URL
// back (we'll lose the styling).
- TextChanged();
+ EmphasizeURLComponents();
+ model_->OnChanged();
delete_was_pressed_ = false;
@@ -802,7 +793,7 @@
if (cmd == @selector(deleteForward:))
delete_was_pressed_ = true;
- // Don't intercept up/down-arrow or backtab if the popup isn't open.
+ // Don't intercept up/down-arrow if the popup isn't open.
if (popup_view_->IsOpen()) {
if (cmd == @selector(moveDown:)) {
model_->OnUpOrDownKeyPressed(1);
@@ -813,13 +804,6 @@
model_->OnUpOrDownKeyPressed(-1);
return true;
}
-
- if (cmd == @selector(insertBacktab:) &&
- model_->popup_model()->selected_line_state() ==
- AutocompletePopupModel::KEYWORD) {
- model_->ClearKeyword(GetText());
- return true;
- }
}
if (cmd == @selector(moveRight:)) {
@@ -845,10 +829,26 @@
return model_->OnEscapeKeyPressed();
}
- if ((cmd == @selector(insertTab:) ||
- cmd == @selector(insertTabIgnoringFieldEditor:)) &&
- model_->is_keyword_hint()) {
- return model_->AcceptKeyword();
+ if (cmd == @selector(insertTab:) ||
+ cmd == @selector(insertTabIgnoringFieldEditor:)) {
+ if (model_->is_keyword_hint())
+ return model_->AcceptKeyword();
+
+ if (suggest_text_length_ > 0) {
+ model_->CommitSuggestedText(true);
+ return true;
+ }
+
+ if (!IsCaretAtEnd()) {
+ PlaceCaretAt(GetTextLength());
+ // OnDidChange() will not be triggered when setting selected range in this
+ // method, so we need to call it explicitly.
+ OnDidChange();
+ return true;
+ }
+
+ if (model_->AcceptCurrentInstantPreview())
+ return true;
}
// |-noop:| is sent when the user presses Cmd+Return. Override the no-op
« no previous file with comments | « chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h ('k') | chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698