| 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/ui/gtk/find_bar_gtk.h" | 5 #include "chrome/browser/ui/gtk/find_bar_gtk.h" |
| 6 | 6 |
| 7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/debug/trace_event.h" |
| 13 #include "base/i18n/rtl.h" | 14 #include "base/i18n/rtl.h" |
| 14 #include "base/string_number_conversions.h" | 15 #include "base/string_number_conversions.h" |
| 15 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 16 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 19 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 20 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
| 20 #include "chrome/browser/ui/find_bar/find_bar_state.h" | 21 #include "chrome/browser/ui/find_bar/find_bar_state.h" |
| 21 #include "chrome/browser/ui/find_bar/find_notification_details.h" | 22 #include "chrome/browser/ui/find_bar/find_notification_details.h" |
| 22 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 23 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
| (...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 FindEntryTextInContents(button == find_next_button_->widget()); | 810 FindEntryTextInContents(button == find_next_button_->widget()); |
| 810 } else { | 811 } else { |
| 811 NOTREACHED(); | 812 NOTREACHED(); |
| 812 } | 813 } |
| 813 } | 814 } |
| 814 | 815 |
| 815 // static | 816 // static |
| 816 gboolean FindBarGtk::OnContentEventBoxExpose(GtkWidget* widget, | 817 gboolean FindBarGtk::OnContentEventBoxExpose(GtkWidget* widget, |
| 817 GdkEventExpose* event, | 818 GdkEventExpose* event, |
| 818 FindBarGtk* bar) { | 819 FindBarGtk* bar) { |
| 820 TRACE_EVENT0("ui::gtk", "FindBarGtk::OnContentEventBoxExpose"); |
| 819 if (bar->theme_service_->UsingNativeTheme()) { | 821 if (bar->theme_service_->UsingNativeTheme()) { |
| 820 // Draw the text entry background around where we input stuff. Note the | 822 // Draw the text entry background around where we input stuff. Note the |
| 821 // decrement to |width|. We do this because some theme engines | 823 // decrement to |width|. We do this because some theme engines |
| 822 // (*cough*Clearlooks*cough*) don't do any blending and use thickness to | 824 // (*cough*Clearlooks*cough*) don't do any blending and use thickness to |
| 823 // make sure that widgets never overlap. | 825 // make sure that widgets never overlap. |
| 824 int padding = gtk_widget_get_style(widget)->xthickness; | 826 int padding = gtk_widget_get_style(widget)->xthickness; |
| 825 GdkRectangle rec; | 827 GdkRectangle rec; |
| 826 gtk_widget_get_allocation(widget, &rec); | 828 gtk_widget_get_allocation(widget, &rec); |
| 827 rec.width -= padding; | 829 rec.width -= padding; |
| 828 | 830 |
| 829 gtk_util::DrawTextEntryBackground(bar->text_entry_, widget, | 831 gtk_util::DrawTextEntryBackground(bar->text_entry_, widget, |
| 830 &event->area, &rec); | 832 &event->area, &rec); |
| 831 } | 833 } |
| 832 | 834 |
| 833 return FALSE; | 835 return FALSE; |
| 834 } | 836 } |
| 835 | 837 |
| 836 // Used to handle custom painting of |container_|. | 838 // Used to handle custom painting of |container_|. |
| 837 gboolean FindBarGtk::OnExpose(GtkWidget* widget, GdkEventExpose* e, | 839 gboolean FindBarGtk::OnExpose(GtkWidget* widget, GdkEventExpose* e, |
| 838 FindBarGtk* bar) { | 840 FindBarGtk* bar) { |
| 841 TRACE_EVENT0("ui::gtk", "FindBarGtk::OnExpose"); |
| 842 |
| 839 GtkAllocation allocation; | 843 GtkAllocation allocation; |
| 840 gtk_widget_get_allocation(widget, &allocation); | 844 gtk_widget_get_allocation(widget, &allocation); |
| 841 | 845 |
| 842 if (bar->theme_service_->UsingNativeTheme()) { | 846 if (bar->theme_service_->UsingNativeTheme()) { |
| 843 if (bar->container_width_ != allocation.width || | 847 if (bar->container_width_ != allocation.width || |
| 844 bar->container_height_ != allocation.height) { | 848 bar->container_height_ != allocation.height) { |
| 845 std::vector<GdkPoint> mask_points = MakeFramePolygonPoints( | 849 std::vector<GdkPoint> mask_points = MakeFramePolygonPoints( |
| 846 allocation.width, allocation.height, FRAME_MASK); | 850 allocation.width, allocation.height, FRAME_MASK); |
| 847 GdkRegion* mask_region = gdk_region_polygon(&mask_points[0], | 851 GdkRegion* mask_region = gdk_region_polygon(&mask_points[0], |
| 848 mask_points.size(), | 852 mask_points.size(), |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 982 return FALSE; // Continue propagation. | 986 return FALSE; // Continue propagation. |
| 983 } | 987 } |
| 984 | 988 |
| 985 gboolean FindBarGtk::OnFocusOut(GtkWidget* entry, GdkEventFocus* event) { | 989 gboolean FindBarGtk::OnFocusOut(GtkWidget* entry, GdkEventFocus* event) { |
| 986 g_signal_handlers_disconnect_by_func( | 990 g_signal_handlers_disconnect_by_func( |
| 987 gdk_keymap_get_for_display(gtk_widget_get_display(entry)), | 991 gdk_keymap_get_for_display(gtk_widget_get_display(entry)), |
| 988 reinterpret_cast<gpointer>(&OnKeymapDirectionChanged), this); | 992 reinterpret_cast<gpointer>(&OnKeymapDirectionChanged), this); |
| 989 | 993 |
| 990 return FALSE; // Continue propagation. | 994 return FALSE; // Continue propagation. |
| 991 } | 995 } |
| OLD | NEW |