| Index: chrome/browser/ui/gtk/autofill/autofill_popup_view_gtk.cc
|
| diff --git a/chrome/browser/ui/gtk/autofill/autofill_popup_view_gtk.cc b/chrome/browser/ui/gtk/autofill/autofill_popup_view_gtk.cc
|
| index 109b30ba49dff0ca3b7d89e52098cfb1a5256422..42a89c6445a46a24f241b0f9edd8ae50298eafc2 100644
|
| --- a/chrome/browser/ui/gtk/autofill/autofill_popup_view_gtk.cc
|
| +++ b/chrome/browser/ui/gtk/autofill/autofill_popup_view_gtk.cc
|
| @@ -30,11 +30,6 @@ const GdkColor kHoveredBackgroundColor = GDK_COLOR_RGB(0xcd, 0xcd, 0xcd);
|
| const GdkColor kValueTextColor = GDK_COLOR_RGB(0x00, 0x00, 0x00);
|
| const GdkColor kLabelTextColor = GDK_COLOR_RGB(0x7f, 0x7f, 0x7f);
|
|
|
| -gfx::Rect GetWindowRect(GdkWindow* window) {
|
| - return gfx::Rect(gdk_window_get_width(window),
|
| - gdk_window_get_height(window));
|
| -}
|
| -
|
| } // namespace
|
|
|
| AutofillPopupViewGtk::AutofillPopupViewGtk(
|
| @@ -85,9 +80,7 @@ void AutofillPopupViewGtk::Show() {
|
| }
|
|
|
| void AutofillPopupViewGtk::InvalidateRow(size_t row) {
|
| - GdkRectangle row_rect = controller_->GetRectForRow(
|
| - row,
|
| - controller_->popup_bounds().width()).ToGdkRectangle();
|
| + GdkRectangle row_rect = controller_->GetRowBounds(row).ToGdkRectangle();
|
| GdkWindow* gdk_window = gtk_widget_get_window(window_);
|
| gdk_window_invalidate_rect(gdk_window, &row_rect, FALSE);
|
| }
|
| @@ -112,15 +105,12 @@ gboolean AutofillPopupViewGtk::HandleButtonRelease(GtkWidget* widget,
|
| if (event->button != 1)
|
| return FALSE;
|
|
|
| - controller_->AcceptSelectedPosition(event->x, event->y);
|
| + controller_->MouseClicked(event->x, event->y);
|
| return TRUE;
|
| }
|
|
|
| gboolean AutofillPopupViewGtk::HandleExpose(GtkWidget* widget,
|
| GdkEventExpose* event) {
|
| - gfx::Rect window_rect = GetWindowRect(event->window);
|
| - gfx::Rect damage_rect = gfx::Rect(event->area);
|
| -
|
| cairo_t* cr = gdk_cairo_create(GDK_DRAWABLE(gtk_widget_get_window(widget)));
|
| gdk_cairo_rectangle(cr, &event->area);
|
| cairo_clip(cr);
|
| @@ -131,18 +121,19 @@ gboolean AutofillPopupViewGtk::HandleExpose(GtkWidget* widget,
|
| DCHECK_EQ(1, kBorderThickness);
|
| // Draw the 1px border around the entire window.
|
| gdk_cairo_set_source_color(cr, &kBorderColor);
|
| - cairo_rectangle(cr, 0, 0, window_rect.width(), window_rect.height());
|
| + gdk_cairo_rectangle(cr, &widget->allocation);
|
| cairo_stroke(cr);
|
| + SetUpLayout();
|
|
|
| - SetupLayout(window_rect);
|
| + gfx::Rect damage_rect(event->area);
|
|
|
| - for (size_t i = 0; i < controller_->autofill_values().size(); ++i) {
|
| - gfx::Rect line_rect = controller_->GetRectForRow(i, window_rect.width());
|
| + for (size_t i = 0; i < controller_->labels().size(); ++i) {
|
| + gfx::Rect line_rect = controller_->GetRowBounds(i);
|
| // Only repaint and layout damaged lines.
|
| if (!line_rect.Intersects(damage_rect))
|
| continue;
|
|
|
| - if (controller_->autofill_unique_ids()[i] ==
|
| + if (controller_->identifiers()[i] ==
|
| WebAutofillClient::MenuItemIDSeparator) {
|
| DrawSeparator(cr, line_rect);
|
| } else {
|
| @@ -157,21 +148,21 @@ gboolean AutofillPopupViewGtk::HandleExpose(GtkWidget* widget,
|
|
|
| gboolean AutofillPopupViewGtk::HandleLeave(GtkWidget* widget,
|
| GdkEventCrossing* event) {
|
| - controller_->ClearSelectedLine();
|
| + controller_->MouseExitedPopup();
|
|
|
| return FALSE;
|
| }
|
|
|
| gboolean AutofillPopupViewGtk::HandleMotion(GtkWidget* widget,
|
| GdkEventMotion* event) {
|
| - controller_->SetSelectedPosition(event->x, event->y);
|
| + controller_->MouseHovered(event->x, event->y);
|
|
|
| return TRUE;
|
| }
|
|
|
| -void AutofillPopupViewGtk::SetupLayout(const gfx::Rect& window_rect) {
|
| - pango_layout_set_width(layout_, window_rect.width() * PANGO_SCALE);
|
| - pango_layout_set_height(layout_, window_rect.height() * PANGO_SCALE);
|
| +void AutofillPopupViewGtk::SetupLayout() {
|
| + pango_layout_set_width(layout_, window_->allocation.width * PANGO_SCALE);
|
| + pango_layout_set_height(layout_, window_->allocation.height * PANGO_SCALE);
|
| }
|
|
|
| void AutofillPopupViewGtk::SetLayoutText(const string16& text,
|
| @@ -221,19 +212,18 @@ void AutofillPopupViewGtk::DrawAutofillEntry(cairo_t* cairo_context,
|
| }
|
|
|
| // Draw the value.
|
| - SetLayoutText(controller_->autofill_values()[index],
|
| - controller_->value_font(),
|
| + SetLayoutText(controller_->labels()[index],
|
| + controller_->label_font(),
|
| kValueTextColor);
|
| - int value_text_width = controller_->value_font().GetStringWidth(
|
| - controller_->autofill_values()[index]);
|
| + int value_text_width =
|
| + controller_->label_font().GetStringWidth(controller_->labels()[index]);
|
|
|
| // Center the text within the line.
|
| - int row_height = controller_->GetRowHeightFromId(
|
| - controller_->autofill_unique_ids()[index]);
|
| + int row_height = controller_->GetRowBounds(index).height();
|
| int value_content_y = std::max(
|
| entry_rect.y(),
|
| entry_rect.y() +
|
| - (row_height - controller_->value_font().GetHeight()) / 2);
|
| + (row_height - controller_->label_font().GetHeight()) / 2);
|
|
|
| bool is_rtl = base::i18n::IsRTL();
|
| int value_content_x = is_rtl ?
|
| @@ -250,7 +240,7 @@ void AutofillPopupViewGtk::DrawAutofillEntry(cairo_t* cairo_context,
|
| ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
|
|
|
| // Draw the delete icon, if one is needed.
|
| - if (controller_->CanDelete(controller_->autofill_unique_ids()[index])) {
|
| + if (controller_->CanDelete(index)) {
|
| x_align_left += is_rtl ? 0 : -kDeleteIconWidth;
|
|
|
| gfx::Image delete_icon;
|
| @@ -278,9 +268,8 @@ void AutofillPopupViewGtk::DrawAutofillEntry(cairo_t* cairo_context,
|
| }
|
|
|
| // Draw the Autofill icon, if one exists
|
| - if (!controller_->autofill_icons()[index].empty()) {
|
| - int icon =
|
| - controller_->GetIconResourceID(controller_->autofill_icons()[index]);
|
| + if (!controller_->icons()[index].empty()) {
|
| + int icon = controller_->GetIconResourceID(controller_->icons()[index]);
|
| DCHECK_NE(-1, icon);
|
| int icon_y = entry_rect.y() + (row_height - kAutofillIconHeight) / 2;
|
|
|
| @@ -298,19 +287,19 @@ void AutofillPopupViewGtk::DrawAutofillEntry(cairo_t* cairo_context,
|
| }
|
|
|
| // Draw the label text.
|
| - SetLayoutText(controller_->autofill_labels()[index],
|
| - controller_->label_font(),
|
| + SetLayoutText(controller_->sub_labels()[index],
|
| + controller_->sub_label_font(),
|
| kLabelTextColor);
|
| if (!is_rtl) {
|
| - x_align_left -= controller_->label_font().GetStringWidth(
|
| - controller_->autofill_labels()[index]);
|
| + x_align_left -= controller_->sub_label_font().GetStringWidth(
|
| + controller_->sub_labels()[index]);
|
| }
|
|
|
| // Center the text within the line.
|
| int label_content_y = std::max(
|
| entry_rect.y(),
|
| entry_rect.y() +
|
| - (row_height - controller_->label_font().GetHeight()) / 2);
|
| + (row_height - controller_->sub_label_font().GetHeight()) / 2);
|
|
|
| cairo_save(cairo_context);
|
| cairo_move_to(cairo_context, x_align_left, label_content_y);
|
|
|