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

Side by Side Diff: chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc

Issue 15003002: Omnibox refactor. Move StartAutocomplete and DoInstant to controller. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: FIxed NIT Created 7 years, 6 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 // We have a selection and start / end are in ascending order. 1163 // We have a selection and start / end are in ascending order.
1164 // Cursor placement will remove the selection, so we need inform 1164 // Cursor placement will remove the selection, so we need inform
1165 // model() about this change by 1165 // model() about this change by
1166 // calling On{Before|After}PossibleChange() methods. 1166 // calling On{Before|After}PossibleChange() methods.
1167 OnBeforePossibleChange(); 1167 OnBeforePossibleChange();
1168 gtk_text_buffer_place_cursor( 1168 gtk_text_buffer_place_cursor(
1169 text_buffer_, count == count_towards_end ? &sel_end : &sel_start); 1169 text_buffer_, count == count_towards_end ? &sel_end : &sel_start);
1170 OnAfterPossibleChange(); 1170 OnAfterPossibleChange();
1171 handled = true; 1171 handled = true;
1172 } else if (count == count_towards_end && !IsCaretAtEnd()) { 1172 } else if (count == count_towards_end && !IsCaretAtEnd()) {
1173 handled = model()->CommitSuggestedText(true); 1173 handled = model()->CommitSuggestedText();
1174 } 1174 }
1175 } else if (step == GTK_MOVEMENT_PAGES) { // Page up and down. 1175 } else if (step == GTK_MOVEMENT_PAGES) { // Page up and down.
1176 // Multiply by count for the direction (if we move too much that's ok). 1176 // Multiply by count for the direction (if we move too much that's ok).
1177 model()->OnUpOrDownKeyPressed(model()->result().size() * count); 1177 model()->OnUpOrDownKeyPressed(model()->result().size() * count);
1178 handled = true; 1178 handled = true;
1179 } else if (step == GTK_MOVEMENT_DISPLAY_LINES) { // Arrow up and down. 1179 } else if (step == GTK_MOVEMENT_DISPLAY_LINES) { // Arrow up and down.
1180 model()->OnUpOrDownKeyPressed(count); 1180 model()->OnUpOrDownKeyPressed(count);
1181 handled = true; 1181 handled = true;
1182 } 1182 }
1183 1183
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 else 1542 else
1543 model()->OnUpOrDownKeyPressed(shift_was_pressed_ ? -1 : 1); 1543 model()->OnUpOrDownKeyPressed(shift_was_pressed_ ? -1 : 1);
1544 1544
1545 handled = true; 1545 handled = true;
1546 } 1546 }
1547 1547
1548 if (supports_pre_edit_ && !handled && !pre_edit_.empty()) 1548 if (supports_pre_edit_ && !handled && !pre_edit_.empty())
1549 handled = true; 1549 handled = true;
1550 1550
1551 if (!handled && gtk_widget_get_visible(instant_view_)) 1551 if (!handled && gtk_widget_get_visible(instant_view_))
1552 handled = model()->CommitSuggestedText(true); 1552 handled = model()->CommitSuggestedText();
1553 1553
1554 if (handled) { 1554 if (handled) {
1555 static guint signal_id = g_signal_lookup("move-focus", GTK_TYPE_WIDGET); 1555 static guint signal_id = g_signal_lookup("move-focus", GTK_TYPE_WIDGET);
1556 g_signal_stop_emission(widget, signal_id, 0); 1556 g_signal_stop_emission(widget, signal_id, 0);
1557 } 1557 }
1558 } 1558 }
1559 1559
1560 void OmniboxViewGtk::HandleCopyClipboard(GtkWidget* sender) { 1560 void OmniboxViewGtk::HandleCopyClipboard(GtkWidget* sender) {
1561 HandleCopyOrCutClipboard(true); 1561 HandleCopyOrCutClipboard(true);
1562 } 1562 }
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
2145 void OmniboxViewGtk::AdjustVerticalAlignmentOfInstantView() { 2145 void OmniboxViewGtk::AdjustVerticalAlignmentOfInstantView() {
2146 // By default, GtkTextView layouts an anchored child widget just above the 2146 // By default, GtkTextView layouts an anchored child widget just above the
2147 // baseline, so we need to move the |instant_view_| down to make sure it 2147 // baseline, so we need to move the |instant_view_| down to make sure it
2148 // has the same baseline as the |text_view_|. 2148 // has the same baseline as the |text_view_|.
2149 PangoLayout* layout = gtk_label_get_layout(GTK_LABEL(instant_view_)); 2149 PangoLayout* layout = gtk_label_get_layout(GTK_LABEL(instant_view_));
2150 int height; 2150 int height;
2151 pango_layout_get_size(layout, NULL, &height); 2151 pango_layout_get_size(layout, NULL, &height);
2152 int baseline = pango_layout_get_baseline(layout); 2152 int baseline = pango_layout_get_baseline(layout);
2153 g_object_set(instant_anchor_tag_, "rise", baseline - height, NULL); 2153 g_object_set(instant_anchor_tag_, "rise", baseline - height, NULL);
2154 } 2154 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm ('k') | chrome/browser/ui/omnibox/omnibox_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698