| OLD | NEW |
| 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/autofill/autofill_popup_view_gtk.h" | 5 #include "chrome/browser/ui/gtk/autofill/autofill_popup_view_gtk.h" |
| 6 | 6 |
| 7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "chrome/browser/ui/autofill/autofill_popup_controller.h" | 11 #include "chrome/browser/ui/autofill/autofill_popup_controller.h" |
| 12 #include "chrome/browser/ui/gtk/gtk_util.h" | 12 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 13 #include "grit/ui_resources.h" | 13 #include "grit/ui_resources.h" |
| 14 #include "third_party/WebKit/public/web/WebAutofillClient.h" | 14 #include "third_party/WebKit/public/web/WebAutofillClient.h" |
| 15 #include "ui/base/gtk/gtk_hig_constants.h" | 15 #include "ui/base/gtk/gtk_hig_constants.h" |
| 16 #include "ui/base/gtk/gtk_windowing.h" | 16 #include "ui/base/gtk/gtk_windowing.h" |
| 17 #include "ui/base/resource/resource_bundle.h" | 17 #include "ui/base/resource/resource_bundle.h" |
| 18 #include "ui/gfx/gtk_compat.h" | 18 #include "ui/gfx/gtk_compat.h" |
| 19 #include "ui/gfx/image/image.h" | 19 #include "ui/gfx/image/image.h" |
| 20 #include "ui/gfx/native_widget_types.h" | 20 #include "ui/gfx/native_widget_types.h" |
| 21 #include "ui/gfx/pango_util.h" | 21 #include "ui/gfx/pango_util.h" |
| 22 #include "ui/gfx/rect.h" | 22 #include "ui/gfx/rect.h" |
| 23 #include "ui/gfx/rect_conversions.h" |
| 23 | 24 |
| 24 using WebKit::WebAutofillClient; | 25 using WebKit::WebAutofillClient; |
| 25 | 26 |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 28 const GdkColor kBorderColor = GDK_COLOR_RGB(0xc7, 0xca, 0xce); | 29 const GdkColor kBorderColor = GDK_COLOR_RGB(0xc7, 0xca, 0xce); |
| 29 const GdkColor kHoveredBackgroundColor = GDK_COLOR_RGB(0xcd, 0xcd, 0xcd); | 30 const GdkColor kHoveredBackgroundColor = GDK_COLOR_RGB(0xcd, 0xcd, 0xcd); |
| 30 const GdkColor kNameColor = GDK_COLOR_RGB(0x00, 0x00, 0x00); | 31 const GdkColor kNameColor = GDK_COLOR_RGB(0x00, 0x00, 0x00); |
| 31 const GdkColor kWarningColor = GDK_COLOR_RGB(0x7f, 0x7f, 0x7f); | 32 const GdkColor kWarningColor = GDK_COLOR_RGB(0x7f, 0x7f, 0x7f); |
| 32 const GdkColor kSubtextColor = GDK_COLOR_RGB(0x7f, 0x7f, 0x7f); | 33 const GdkColor kSubtextColor = GDK_COLOR_RGB(0x7f, 0x7f, 0x7f); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 UpdateBoundsAndRedrawPopup(); | 80 UpdateBoundsAndRedrawPopup(); |
| 80 | 81 |
| 81 gtk_widget_show(window_); | 82 gtk_widget_show(window_); |
| 82 | 83 |
| 83 GtkWidget* parent_window = | 84 GtkWidget* parent_window = |
| 84 gtk_widget_get_toplevel(controller_->container_view()); | 85 gtk_widget_get_toplevel(controller_->container_view()); |
| 85 ui::StackPopupWindow(window_, parent_window); | 86 ui::StackPopupWindow(window_, parent_window); |
| 86 } | 87 } |
| 87 | 88 |
| 88 void AutofillPopupViewGtk::InvalidateRow(size_t row) { | 89 void AutofillPopupViewGtk::InvalidateRow(size_t row) { |
| 89 GdkRectangle row_rect = controller_->GetRowBounds(row).ToGdkRectangle(); | 90 GdkRectangle row_rect = |
| 91 gfx::ToEnclosingRect(controller_->GetRowBounds(row)).ToGdkRectangle(); |
| 90 GdkWindow* gdk_window = gtk_widget_get_window(window_); | 92 GdkWindow* gdk_window = gtk_widget_get_window(window_); |
| 91 gdk_window_invalidate_rect(gdk_window, &row_rect, FALSE); | 93 gdk_window_invalidate_rect(gdk_window, &row_rect, FALSE); |
| 92 } | 94 } |
| 93 | 95 |
| 94 void AutofillPopupViewGtk::UpdateBoundsAndRedrawPopup() { | 96 void AutofillPopupViewGtk::UpdateBoundsAndRedrawPopup() { |
| 95 gtk_widget_set_size_request(window_, | 97 gtk_widget_set_size_request(window_, |
| 96 controller_->popup_bounds().width(), | 98 controller_->popup_bounds().width(), |
| 97 controller_->popup_bounds().height()); | 99 controller_->popup_bounds().height()); |
| 98 gtk_window_move(GTK_WINDOW(window_), | 100 gtk_window_move(GTK_WINDOW(window_), |
| 99 controller_->popup_bounds().x(), | 101 controller_->popup_bounds().x(), |
| 100 controller_->popup_bounds().y()); | 102 controller_->popup_bounds().y()); |
| 101 | 103 |
| 102 GdkWindow* gdk_window = gtk_widget_get_window(window_); | 104 GdkWindow* gdk_window = gtk_widget_get_window(window_); |
| 103 GdkRectangle popup_rect = controller_->popup_bounds().ToGdkRectangle(); | 105 GdkRectangle popup_rect = |
| 106 gfx::ToEnclosingRect(controller_->popup_bounds()).ToGdkRectangle(); |
| 104 if (gdk_window != NULL) | 107 if (gdk_window != NULL) |
| 105 gdk_window_invalidate_rect(gdk_window, &popup_rect, FALSE); | 108 gdk_window_invalidate_rect(gdk_window, &popup_rect, FALSE); |
| 106 } | 109 } |
| 107 | 110 |
| 108 gboolean AutofillPopupViewGtk::HandleConfigure(GtkWidget* widget, | 111 gboolean AutofillPopupViewGtk::HandleConfigure(GtkWidget* widget, |
| 109 GdkEventConfigure* event) { | 112 GdkEventConfigure* event) { |
| 110 controller_->Hide(); | 113 controller_->Hide(); |
| 111 return FALSE; | 114 return FALSE; |
| 112 } | 115 } |
| 113 | 116 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 133 DCHECK_EQ(1, kBorderThickness); | 136 DCHECK_EQ(1, kBorderThickness); |
| 134 // Draw the 1px border around the entire window. | 137 // Draw the 1px border around the entire window. |
| 135 gdk_cairo_set_source_color(cr, &kBorderColor); | 138 gdk_cairo_set_source_color(cr, &kBorderColor); |
| 136 gdk_cairo_rectangle(cr, &widget->allocation); | 139 gdk_cairo_rectangle(cr, &widget->allocation); |
| 137 cairo_stroke(cr); | 140 cairo_stroke(cr); |
| 138 SetUpLayout(); | 141 SetUpLayout(); |
| 139 | 142 |
| 140 gfx::Rect damage_rect(event->area); | 143 gfx::Rect damage_rect(event->area); |
| 141 | 144 |
| 142 for (size_t i = 0; i < controller_->names().size(); ++i) { | 145 for (size_t i = 0; i < controller_->names().size(); ++i) { |
| 143 gfx::Rect line_rect = controller_->GetRowBounds(i); | 146 gfx::Rect line_rect = gfx::ToEnclosingRect(controller_->GetRowBounds(i)); |
| 144 // Only repaint and layout damaged lines. | 147 // Only repaint and layout damaged lines. |
| 145 if (!line_rect.Intersects(damage_rect)) | 148 if (!line_rect.Intersects(damage_rect)) |
| 146 continue; | 149 continue; |
| 147 | 150 |
| 148 if (controller_->identifiers()[i] == WebAutofillClient::MenuItemIDSeparator) | 151 if (controller_->identifiers()[i] == WebAutofillClient::MenuItemIDSeparator) |
| 149 DrawSeparator(cr, line_rect); | 152 DrawSeparator(cr, line_rect); |
| 150 else | 153 else |
| 151 DrawAutofillEntry(cr, i, line_rect); | 154 DrawAutofillEntry(cr, i, line_rect); |
| 152 } | 155 } |
| 153 | 156 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 pango_cairo_show_layout(cairo_context, layout_); | 288 pango_cairo_show_layout(cairo_context, layout_); |
| 286 cairo_restore(cairo_context); | 289 cairo_restore(cairo_context); |
| 287 } | 290 } |
| 288 | 291 |
| 289 AutofillPopupView* AutofillPopupView::Create( | 292 AutofillPopupView* AutofillPopupView::Create( |
| 290 AutofillPopupController* controller) { | 293 AutofillPopupController* controller) { |
| 291 return new AutofillPopupViewGtk(controller); | 294 return new AutofillPopupViewGtk(controller); |
| 292 } | 295 } |
| 293 | 296 |
| 294 } // namespace autofill | 297 } // namespace autofill |
| OLD | NEW |