| OLD | NEW |
| 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/autocomplete/autocomplete_edit_view_gtk.h" | 5 #include "chrome/browser/autocomplete/autocomplete_edit_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 20 matching lines...) Expand all Loading... |
| 31 #include "gfx/font.h" | 31 #include "gfx/font.h" |
| 32 #include "gfx/gtk_util.h" | 32 #include "gfx/gtk_util.h" |
| 33 #include "gfx/skia_utils_gtk.h" | 33 #include "gfx/skia_utils_gtk.h" |
| 34 #include "googleurl/src/gurl.h" | 34 #include "googleurl/src/gurl.h" |
| 35 #include "grit/generated_resources.h" | 35 #include "grit/generated_resources.h" |
| 36 #include "net/base/escape.h" | 36 #include "net/base/escape.h" |
| 37 #include "third_party/undoview/undo_view.h" | 37 #include "third_party/undoview/undo_view.h" |
| 38 #include "ui/base/animation/multi_animation.h" | 38 #include "ui/base/animation/multi_animation.h" |
| 39 | 39 |
| 40 #if defined(TOOLKIT_VIEWS) | 40 #if defined(TOOLKIT_VIEWS) |
| 41 #include "chrome/browser/autocomplete/autocomplete_edit_view_views.h" |
| 41 #include "chrome/browser/ui/gtk/accessible_widget_helper_gtk.h" | 42 #include "chrome/browser/ui/gtk/accessible_widget_helper_gtk.h" |
| 42 #include "chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.
h" | 43 #include "chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.
h" |
| 43 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 44 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 45 #include "views/controls/textfield/native_textfield_views.h" |
| 44 #else | 46 #else |
| 45 #include "chrome/browser/autocomplete/autocomplete_popup_view_gtk.h" | 47 #include "chrome/browser/autocomplete/autocomplete_popup_view_gtk.h" |
| 46 #include "chrome/browser/ui/gtk/gtk_theme_provider.h" | 48 #include "chrome/browser/ui/gtk/gtk_theme_provider.h" |
| 47 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" | 49 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" |
| 48 #include "views/controls/native/native_view_host.h" | 50 #include "views/controls/native/native_view_host.h" |
| 49 #endif | 51 #endif |
| 50 | 52 |
| 51 namespace { | 53 namespace { |
| 52 | 54 |
| 53 const gchar* kAutocompleteEditViewGtkKey = "__ACE_VIEW_GTK__"; | 55 const gchar* kAutocompleteEditViewGtkKey = "__ACE_VIEW_GTK__"; |
| (...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 } | 850 } |
| 849 | 851 |
| 850 // static | 852 // static |
| 851 AutocompleteEditView* AutocompleteEditViewGtk::Create( | 853 AutocompleteEditView* AutocompleteEditViewGtk::Create( |
| 852 AutocompleteEditController* controller, | 854 AutocompleteEditController* controller, |
| 853 ToolbarModel* toolbar_model, | 855 ToolbarModel* toolbar_model, |
| 854 Profile* profile, | 856 Profile* profile, |
| 855 CommandUpdater* command_updater, | 857 CommandUpdater* command_updater, |
| 856 bool popup_window_mode, | 858 bool popup_window_mode, |
| 857 const views::View* location_bar) { | 859 const views::View* location_bar) { |
| 860 if (views::NativeTextfieldViews::IsTextfieldViewsEnabled()) { |
| 861 AutocompleteEditViewViews* autocomplete = |
| 862 new AutocompleteEditViewViews(controller, |
| 863 toolbar_model, |
| 864 profile, |
| 865 command_updater, |
| 866 popup_window_mode, |
| 867 location_bar); |
| 868 autocomplete->Init(); |
| 869 return autocomplete; |
| 870 } |
| 871 |
| 858 AutocompleteEditViewGtk* autocomplete = | 872 AutocompleteEditViewGtk* autocomplete = |
| 859 new AutocompleteEditViewGtk(controller, | 873 new AutocompleteEditViewGtk(controller, |
| 860 toolbar_model, | 874 toolbar_model, |
| 861 profile, | 875 profile, |
| 862 command_updater, | 876 command_updater, |
| 863 popup_window_mode, | 877 popup_window_mode, |
| 864 location_bar); | 878 location_bar); |
| 865 autocomplete->Init(); | 879 autocomplete->Init(); |
| 866 | 880 |
| 867 // Make all the children of the widget visible. NOTE: this won't display | 881 // Make all the children of the widget visible. NOTE: this won't display |
| (...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2211 // baseline, so we need to move the |instant_view_| down to make sure it | 2225 // baseline, so we need to move the |instant_view_| down to make sure it |
| 2212 // has the same baseline as the |text_view_|. | 2226 // has the same baseline as the |text_view_|. |
| 2213 PangoLayout* layout = gtk_label_get_layout(GTK_LABEL(instant_view_)); | 2227 PangoLayout* layout = gtk_label_get_layout(GTK_LABEL(instant_view_)); |
| 2214 int height; | 2228 int height; |
| 2215 pango_layout_get_size(layout, NULL, &height); | 2229 pango_layout_get_size(layout, NULL, &height); |
| 2216 PangoLayoutIter* iter = pango_layout_get_iter(layout); | 2230 PangoLayoutIter* iter = pango_layout_get_iter(layout); |
| 2217 int baseline = pango_layout_iter_get_baseline(iter); | 2231 int baseline = pango_layout_iter_get_baseline(iter); |
| 2218 pango_layout_iter_free(iter); | 2232 pango_layout_iter_free(iter); |
| 2219 g_object_set(instant_anchor_tag_, "rise", baseline - height, NULL); | 2233 g_object_set(instant_anchor_tag_, "rise", baseline - height, NULL); |
| 2220 } | 2234 } |
| OLD | NEW |