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..5a553e89f629a7d0fbdc9420df0949421d123314 100644 |
--- a/chrome/browser/ui/gtk/autofill/autofill_popup_view_gtk.cc |
+++ b/chrome/browser/ui/gtk/autofill/autofill_popup_view_gtk.cc |
@@ -25,15 +25,11 @@ |
using WebKit::WebAutofillClient; |
namespace { |
+ |
const GdkColor kBorderColor = GDK_COLOR_RGB(0xc7, 0xca, 0xce); |
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)); |
-} |
+const GdkColor kNameColor = GDK_COLOR_RGB(0x00, 0x00, 0x00); |
+const GdkColor kSubtextColor = GDK_COLOR_RGB(0x7f, 0x7f, 0x7f); |
} // namespace |
@@ -85,9 +81,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 +106,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 +122,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_->names().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 +149,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 +213,18 @@ void AutofillPopupViewGtk::DrawAutofillEntry(cairo_t* cairo_context, |
} |
// Draw the value. |
- SetLayoutText(controller_->autofill_values()[index], |
- controller_->value_font(), |
- kValueTextColor); |
- int value_text_width = controller_->value_font().GetStringWidth( |
- controller_->autofill_values()[index]); |
+ SetLayoutText(controller_->names()[index], |
+ controller_->name_font(), |
+ kNameColor); |
+ int value_text_width = |
+ controller_->name_font().GetStringWidth(controller_->names()[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_->name_font().GetHeight()) / 2); |
bool is_rtl = base::i18n::IsRTL(); |
int value_content_x = is_rtl ? |
@@ -250,7 +241,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 +269,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; |
@@ -297,23 +287,23 @@ void AutofillPopupViewGtk::DrawAutofillEntry(cairo_t* cairo_context, |
x_align_left += is_rtl ? kAutofillIconWidth + kIconPadding : -kIconPadding; |
} |
- // Draw the label text. |
- SetLayoutText(controller_->autofill_labels()[index], |
- controller_->label_font(), |
- kLabelTextColor); |
+ // Draw the subtext. |
+ SetLayoutText(controller_->subtexts()[index], |
+ controller_->subtext_font(), |
+ kSubtextColor); |
if (!is_rtl) { |
- x_align_left -= controller_->label_font().GetStringWidth( |
- controller_->autofill_labels()[index]); |
+ x_align_left -= controller_->subtext_font().GetStringWidth( |
+ controller_->subtexts()[index]); |
} |
// Center the text within the line. |
- int label_content_y = std::max( |
+ int subtext_content_y = std::max( |
entry_rect.y(), |
entry_rect.y() + |
- (row_height - controller_->label_font().GetHeight()) / 2); |
+ (row_height - controller_->subtext_font().GetHeight()) / 2); |
cairo_save(cairo_context); |
- cairo_move_to(cairo_context, x_align_left, label_content_y); |
+ cairo_move_to(cairo_context, x_align_left, subtext_content_y); |
pango_cairo_show_layout(cairo_context, layout_); |
cairo_restore(cairo_context); |
} |