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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/gtk/omnibox/omnibox_view_gtk.h" 5 #include "chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.h"
6 6
7 #include <gdk/gdkkeysyms.h> 7 #include <gdk/gdkkeysyms.h>
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 548
549 void OmniboxViewGtk::SetUserText(const string16& text) { 549 void OmniboxViewGtk::SetUserText(const string16& text) {
550 SetUserText(text, text, true); 550 SetUserText(text, text, true);
551 } 551 }
552 552
553 void OmniboxViewGtk::SetUserText(const string16& text, 553 void OmniboxViewGtk::SetUserText(const string16& text,
554 const string16& display_text, 554 const string16& display_text,
555 bool update_popup) { 555 bool update_popup) {
556 model_->SetUserText(text); 556 model_->SetUserText(text);
557 // TODO(deanm): something about selection / focus change here. 557 // TODO(deanm): something about selection / focus change here.
558 SetWindowTextAndCaretPos(display_text, display_text.length()); 558 SetWindowTextAndCaretPos(display_text, display_text.length(), update_popup,
559 if (update_popup) 559 true);
560 UpdatePopup();
561 TextChanged();
562 } 560 }
563 561
564 void OmniboxViewGtk::SetWindowTextAndCaretPos(const string16& text, 562 void OmniboxViewGtk::SetWindowTextAndCaretPos(const string16& text,
565 size_t caret_pos) { 563 size_t caret_pos,
564 bool update_popup,
565 bool notify_text_changed) {
566 CharRange range(static_cast<int>(caret_pos), static_cast<int>(caret_pos)); 566 CharRange range(static_cast<int>(caret_pos), static_cast<int>(caret_pos));
567 SetTextAndSelectedRange(text, range); 567 SetTextAndSelectedRange(text, range);
568
569 if (update_popup)
570 UpdatePopup();
571
572 if (notify_text_changed)
573 TextChanged();
568 } 574 }
569 575
570 void OmniboxViewGtk::SetForcedQuery() { 576 void OmniboxViewGtk::SetForcedQuery() {
571 const string16 current_text(GetText()); 577 const string16 current_text(GetText());
572 const size_t start = current_text.find_first_not_of(kWhitespaceUTF16); 578 const size_t start = current_text.find_first_not_of(kWhitespaceUTF16);
573 if (start == string16::npos || (current_text[start] != '?')) { 579 if (start == string16::npos || (current_text[start] != '?')) {
574 SetUserText(ASCIIToUTF16("?")); 580 SetUserText(ASCIIToUTF16("?"));
575 } else { 581 } else {
576 StartUpdatingHighlightedText(); 582 StartUpdatingHighlightedText();
577 SetSelectedRange(CharRange(current_text.size(), start + 1)); 583 SetSelectedRange(CharRange(current_text.size(), start + 1));
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 model_->StopAutocomplete(); 638 model_->StopAutocomplete();
633 } 639 }
634 640
635 void OmniboxViewGtk::OnTemporaryTextMaybeChanged( 641 void OmniboxViewGtk::OnTemporaryTextMaybeChanged(
636 const string16& display_text, 642 const string16& display_text,
637 bool save_original_selection) { 643 bool save_original_selection) {
638 if (save_original_selection) 644 if (save_original_selection)
639 saved_temporary_selection_ = GetSelection(); 645 saved_temporary_selection_ = GetSelection();
640 646
641 StartUpdatingHighlightedText(); 647 StartUpdatingHighlightedText();
642 SetWindowTextAndCaretPos(display_text, display_text.length()); 648 SetWindowTextAndCaretPos(display_text, display_text.length(), false, false);
643 FinishUpdatingHighlightedText(); 649 FinishUpdatingHighlightedText();
644 TextChanged(); 650 TextChanged();
645 } 651 }
646 652
647 bool OmniboxViewGtk::OnInlineAutocompleteTextMaybeChanged( 653 bool OmniboxViewGtk::OnInlineAutocompleteTextMaybeChanged(
648 const string16& display_text, 654 const string16& display_text,
649 size_t user_text_length) { 655 size_t user_text_length) {
650 if (display_text == GetText()) 656 if (display_text == GetText())
651 return false; 657 return false;
652 658
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
1113 enter_was_pressed_ = event->keyval == GDK_Return || 1119 enter_was_pressed_ = event->keyval == GDK_Return ||
1114 event->keyval == GDK_ISO_Enter || 1120 event->keyval == GDK_ISO_Enter ||
1115 event->keyval == GDK_KP_Enter; 1121 event->keyval == GDK_KP_Enter;
1116 1122
1117 // Set |tab_was_pressed_| to true if it's a Tab key press event, so that our 1123 // Set |tab_was_pressed_| to true if it's a Tab key press event, so that our
1118 // handler of "move-focus" signal can trigger Tab to search behavior when 1124 // handler of "move-focus" signal can trigger Tab to search behavior when
1119 // necessary. 1125 // necessary.
1120 tab_was_pressed_ = (event->keyval == GDK_Tab || 1126 tab_was_pressed_ = (event->keyval == GDK_Tab ||
1121 event->keyval == GDK_ISO_Left_Tab || 1127 event->keyval == GDK_ISO_Left_Tab ||
1122 event->keyval == GDK_KP_Tab) && 1128 event->keyval == GDK_KP_Tab) &&
1123 !(event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)); 1129 !(event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK));
aaron.randolph 2012/01/19 23:13:36 Needs SHIFT mask removed so that SHIFT+TAB can cle
1124 1130
1125 delete_was_pressed_ = event->keyval == GDK_Delete || 1131 delete_was_pressed_ = event->keyval == GDK_Delete ||
1126 event->keyval == GDK_KP_Delete; 1132 event->keyval == GDK_KP_Delete;
1127 1133
1128 // Reset |enter_was_inserted_|, which may be set in the "insert-text" signal 1134 // Reset |enter_was_inserted_|, which may be set in the "insert-text" signal
1129 // handler, so that we'll know if an Enter key event was handled by IME. 1135 // handler, so that we'll know if an Enter key event was handled by IME.
1130 enter_was_inserted_ = false; 1136 enter_was_inserted_ = false;
1131 1137
1132 // Reset |paste_clipboard_requested_| to make sure we won't misinterpret this 1138 // Reset |paste_clipboard_requested_| to make sure we won't misinterpret this
1133 // key input action as a paste action. 1139 // key input action as a paste action.
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
1708 1714
1709 void OmniboxViewGtk::HandleViewMoveFocus(GtkWidget* widget, 1715 void OmniboxViewGtk::HandleViewMoveFocus(GtkWidget* widget,
1710 GtkDirectionType direction) { 1716 GtkDirectionType direction) {
1711 if (!tab_was_pressed_) 1717 if (!tab_was_pressed_)
1712 return; 1718 return;
1713 1719
1714 // If special behavior is triggered, then stop the signal emission to 1720 // If special behavior is triggered, then stop the signal emission to
1715 // prevent the focus from being moved. 1721 // prevent the focus from being moved.
1716 bool handled = false; 1722 bool handled = false;
1717 1723
1718 // Trigger Tab to search behavior only when Tab key is pressed. 1724 // Trigger Tab to search behavior only when Tab key is pressed.
aaron.randolph 2012/01/19 23:13:36 Needs a check for SHIFT to clear keyword or logic
1719 if (model_->is_keyword_hint()) 1725 if (model_->is_keyword_hint())
1720 handled = model_->AcceptKeyword(); 1726 handled = model_->AcceptKeyword();
1721 1727
1722 if (supports_pre_edit_ && !handled && !pre_edit_.empty()) 1728 if (supports_pre_edit_ && !handled && !pre_edit_.empty())
1723 handled = true; 1729 handled = true;
1724 1730
1725 if (!handled && gtk_widget_get_visible(instant_view_)) 1731 if (!handled && gtk_widget_get_visible(instant_view_))
1726 handled = model_->CommitSuggestedText(true); 1732 handled = model_->CommitSuggestedText(true);
1727 1733
1728 if (!handled) { 1734 if (!handled) {
aaron.randolph 2012/01/19 23:13:36 This statement and body should be removed as this
1729 if (!IsCaretAtEnd()) { 1735 if (!IsCaretAtEnd()) {
1730 OnBeforePossibleChange(); 1736 OnBeforePossibleChange();
1731 PlaceCaretAt(GetTextLength()); 1737 PlaceCaretAt(GetTextLength());
1732 OnAfterPossibleChange(); 1738 OnAfterPossibleChange();
1733 handled = true; 1739 handled = true;
1734 } 1740 }
1735 } 1741 }
1736 1742
1737 if (!handled) 1743 if (!handled)
1738 handled = model_->AcceptCurrentInstantPreview(); 1744 handled = model_->AcceptCurrentInstantPreview();
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
2392 2398
2393 // Make all the children of the widget visible. NOTE: this won't display 2399 // Make all the children of the widget visible. NOTE: this won't display
2394 // anything, it just toggles the visible flag. 2400 // anything, it just toggles the visible flag.
2395 gtk_widget_show_all(omnibox_view->GetNativeView()); 2401 gtk_widget_show_all(omnibox_view->GetNativeView());
2396 // Hide the widget. NativeViewHostGtk will make it visible again as necessary. 2402 // Hide the widget. NativeViewHostGtk will make it visible again as necessary.
2397 gtk_widget_hide(omnibox_view->GetNativeView()); 2403 gtk_widget_hide(omnibox_view->GetNativeView());
2398 2404
2399 return omnibox_view; 2405 return omnibox_view;
2400 } 2406 }
2401 #endif 2407 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698