| 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 793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 847 } | 849 } |
| 848 | 850 |
| 849 // static | 851 // static |
| 850 AutocompleteEditView* AutocompleteEditViewGtk::Create( | 852 AutocompleteEditView* AutocompleteEditViewGtk::Create( |
| 851 AutocompleteEditController* controller, | 853 AutocompleteEditController* controller, |
| 852 ToolbarModel* toolbar_model, | 854 ToolbarModel* toolbar_model, |
| 853 Profile* profile, | 855 Profile* profile, |
| 854 CommandUpdater* command_updater, | 856 CommandUpdater* command_updater, |
| 855 bool popup_window_mode, | 857 bool popup_window_mode, |
| 856 const views::View* location_bar) { | 858 const views::View* location_bar) { |
| 859 if (views::NativeTextfieldViews::IsTextfieldViewsEnabled()) { |
| 860 AutocompleteEditViewViews* autocomplete = |
| 861 new AutocompleteEditViewViews(controller, |
| 862 toolbar_model, |
| 863 profile, |
| 864 command_updater, |
| 865 popup_window_mode, |
| 866 location_bar); |
| 867 autocomplete->Init(); |
| 868 return autocomplete; |
| 869 } |
| 870 |
| 857 AutocompleteEditViewGtk* autocomplete = | 871 AutocompleteEditViewGtk* autocomplete = |
| 858 new AutocompleteEditViewGtk(controller, | 872 new AutocompleteEditViewGtk(controller, |
| 859 toolbar_model, | 873 toolbar_model, |
| 860 profile, | 874 profile, |
| 861 command_updater, | 875 command_updater, |
| 862 popup_window_mode, | 876 popup_window_mode, |
| 863 location_bar); | 877 location_bar); |
| 864 autocomplete->Init(); | 878 autocomplete->Init(); |
| 865 | 879 |
| 866 // Make all the children of the widget visible. NOTE: this won't display | 880 // Make all the children of the widget visible. NOTE: this won't display |
| (...skipping 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2205 // baseline, so we need to move the |instant_view_| down to make sure it | 2219 // baseline, so we need to move the |instant_view_| down to make sure it |
| 2206 // has the same baseline as the |text_view_|. | 2220 // has the same baseline as the |text_view_|. |
| 2207 PangoLayout* layout = gtk_label_get_layout(GTK_LABEL(instant_view_)); | 2221 PangoLayout* layout = gtk_label_get_layout(GTK_LABEL(instant_view_)); |
| 2208 int height; | 2222 int height; |
| 2209 pango_layout_get_size(layout, NULL, &height); | 2223 pango_layout_get_size(layout, NULL, &height); |
| 2210 PangoLayoutIter* iter = pango_layout_get_iter(layout); | 2224 PangoLayoutIter* iter = pango_layout_get_iter(layout); |
| 2211 int baseline = pango_layout_iter_get_baseline(iter); | 2225 int baseline = pango_layout_iter_get_baseline(iter); |
| 2212 pango_layout_iter_free(iter); | 2226 pango_layout_iter_free(iter); |
| 2213 g_object_set(instant_anchor_tag_, "rise", baseline - height, NULL); | 2227 g_object_set(instant_anchor_tag_, "rise", baseline - height, NULL); |
| 2214 } | 2228 } |
| OLD | NEW |