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

Unified Diff: chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc

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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc
===================================================================
--- chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc (revision 117892)
+++ chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc (working copy)
@@ -555,16 +555,22 @@
bool update_popup) {
model_->SetUserText(text);
// TODO(deanm): something about selection / focus change here.
- SetWindowTextAndCaretPos(display_text, display_text.length());
- if (update_popup)
- UpdatePopup();
- TextChanged();
+ SetWindowTextAndCaretPos(display_text, display_text.length(), update_popup,
+ true);
}
void OmniboxViewGtk::SetWindowTextAndCaretPos(const string16& text,
- size_t caret_pos) {
+ size_t caret_pos,
+ bool update_popup,
+ bool notify_text_changed) {
CharRange range(static_cast<int>(caret_pos), static_cast<int>(caret_pos));
SetTextAndSelectedRange(text, range);
+
+ if (update_popup)
+ UpdatePopup();
+
+ if (notify_text_changed)
+ TextChanged();
}
void OmniboxViewGtk::SetForcedQuery() {
@@ -639,7 +645,7 @@
saved_temporary_selection_ = GetSelection();
StartUpdatingHighlightedText();
- SetWindowTextAndCaretPos(display_text, display_text.length());
+ SetWindowTextAndCaretPos(display_text, display_text.length(), false, false);
FinishUpdatingHighlightedText();
TextChanged();
}
@@ -1078,7 +1084,8 @@
// if IME did not handle it then "move-focus" signal will be emitted by the
// default signal handler of |text_view_|. So we can intercept "move-focus"
// signal of |text_view_| to know if a Tab key press event was handled by IME,
- // and trigger Tab to search behavior when necessary in the signal handler.
+ // and trigger Tab to search or result traversal behavior when necessary in
+ // the signal handler.
//
// But for Enter key, if IME did not handle the key event, the default signal
// handler will delete current selection range and insert '\n' and always
@@ -1120,8 +1127,10 @@
tab_was_pressed_ = (event->keyval == GDK_Tab ||
event->keyval == GDK_ISO_Left_Tab ||
event->keyval == GDK_KP_Tab) &&
- !(event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK));
+ !(event->state & GDK_CONTROL_MASK);
+ shift_was_pressed_ = event->state & GDK_SHIFT_MASK;
+
delete_was_pressed_ = event->keyval == GDK_Delete ||
event->keyval == GDK_KP_Delete;
@@ -1716,8 +1725,19 @@
bool handled = false;
// Trigger Tab to search behavior only when Tab key is pressed.
- if (model_->is_keyword_hint())
+ if (model_->is_keyword_hint() && !shift_was_pressed_) {
handled = model_->AcceptKeyword();
+ } else if (model_->popup_model()->IsOpen()) {
+ if (shift_was_pressed_ &&
+ model_->popup_model()->selected_line_state() ==
+ AutocompletePopupModel::KEYWORD) {
+ model_->ClearKeyword(GetText());
+ handled = true;
Peter Kasting 2012/01/24 19:14:44 Nit: Factor this line down below the conditional s
+ } else {
+ model_->OnUpOrDownKeyPressed(shift_was_pressed_ ? -1 : 1);
+ handled = true;
+ }
+ }
if (supports_pre_edit_ && !handled && !pre_edit_.empty())
handled = true;
@@ -1725,15 +1745,6 @@
if (!handled && gtk_widget_get_visible(instant_view_))
handled = model_->CommitSuggestedText(true);
- if (!handled) {
- if (!IsCaretAtEnd()) {
- OnBeforePossibleChange();
- PlaceCaretAt(GetTextLength());
- OnAfterPossibleChange();
- handled = true;
- }
- }
-
if (!handled)
handled = model_->AcceptCurrentInstantPreview();

Powered by Google App Engine
This is Rietveld 408576698