| 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 c9192fc577852c51c097fd0d74e2a2c35dc0c57b..0152960b5733c36a656881e2db8c2d80b360e7d4 100644
|
| --- a/chrome/browser/ui/gtk/autofill/autofill_popup_view_gtk.cc
|
| +++ b/chrome/browser/ui/gtk/autofill/autofill_popup_view_gtk.cc
|
| @@ -13,12 +13,15 @@
|
| #include "chrome/browser/ui/gtk/gtk_theme_service.h"
|
| #include "content/public/browser/render_view_host.h"
|
| #include "content/public/browser/web_contents.h"
|
| +#include "third_party/WebKit/Source/WebKit/chromium/public/WebAutofillClient.h"
|
| #include "ui/base/gtk/gtk_compat.h"
|
| #include "ui/base/gtk/gtk_hig_constants.h"
|
| #include "ui/base/gtk/gtk_windowing.h"
|
| #include "ui/gfx/native_widget_types.h"
|
| #include "ui/gfx/rect.h"
|
|
|
| +using WebKit::WebAutofillClient;
|
| +
|
| namespace {
|
| const GdkColor kBorderColor = GDK_COLOR_RGB(0xc7, 0xca, 0xce);
|
| const GdkColor kHoveredBackgroundColor = GDK_COLOR_RGB(0x0CD, 0xCD, 0xCD);
|
| @@ -48,8 +51,8 @@ gfx::Rect GetWindowRect(GdkWindow* window) {
|
| }
|
|
|
| // Returns the rectangle containing the item at position |index| in the popup.
|
| -gfx::Rect GetRectForRow(size_t index, int width) {
|
| - return gfx::Rect(0, (index * kRowHeight), width, kRowHeight);
|
| +gfx::Rect GetRectForRow(size_t row, int width) {
|
| + return gfx::Rect(0, (row * kRowHeight), width, kRowHeight);
|
| }
|
|
|
| } // namespace
|
| @@ -122,7 +125,7 @@ void AutofillPopupViewGtk::ResizePopup() {
|
| gtk_widget_set_size_request(
|
| window_,
|
| GetPopupRequiredWidth(),
|
| - kRowHeight * autofill_values().size());
|
| + kRowHeight * row_count());
|
| }
|
|
|
| gboolean AutofillPopupViewGtk::HandleButtonRelease(GtkWidget* widget,
|
| @@ -163,23 +166,31 @@ gboolean AutofillPopupViewGtk::HandleExpose(GtkWidget* widget,
|
| actual_content_width /= PANGO_SCALE;
|
| actual_content_height /= PANGO_SCALE;
|
|
|
| + int current_row = 0;
|
| for (size_t i = 0; i < autofill_values().size(); ++i) {
|
| - gfx::Rect line_rect = GetRectForRow(i, window_rect.width());
|
| + gfx::Rect line_rect = GetRectForRow(current_row, window_rect.width());
|
| // Only repaint and layout damaged lines.
|
| - if (!line_rect.Intersects(damage_rect))
|
| + if (!line_rect.Intersects(damage_rect)) {
|
| + if (autofill_unique_ids()[i] != WebAutofillClient::MenuItemIDSeparator)
|
| + ++current_row;
|
| continue;
|
| + }
|
|
|
| - if (IsSeparatorIndex(i)) {
|
| - int line_y = i * kRowHeight;
|
| + if (autofill_unique_ids()[i] == WebAutofillClient::MenuItemIDSeparator) {
|
| + int line_y = current_row * kRowHeight;
|
|
|
| cairo_save(cr);
|
| cairo_move_to(cr, 0, line_y);
|
| cairo_line_to(cr, window_rect.width(), line_y);
|
| cairo_stroke(cr);
|
| cairo_restore(cr);
|
| +
|
| + // All the separator index should do is draw the line, move to the next
|
| + // element now.
|
| + continue;
|
| }
|
|
|
| - if (selected_line() == static_cast<int>(i)) {
|
| + if (selected_line() == static_cast<int>(current_row)) {
|
| gdk_cairo_set_source_color(cr, &kHoveredBackgroundColor);
|
| cairo_rectangle(cr, line_rect.x(), line_rect.y(),
|
| line_rect.width(), line_rect.height());
|
| @@ -228,6 +239,9 @@ gboolean AutofillPopupViewGtk::HandleExpose(GtkWidget* widget,
|
| icon_y);
|
| cairo_restore(cr);
|
| }
|
| +
|
| + // Increase the current row.
|
| + ++current_row;
|
| }
|
|
|
| cairo_destroy(cr);
|
| @@ -259,7 +273,7 @@ bool AutofillPopupViewGtk::HandleKeyPressEvent(GdkEventKey* event) {
|
| SetSelectedLine(0);
|
| return true;
|
| case GDK_Page_Down:
|
| - SetSelectedLine(autofill_values().size() - 1);
|
| + SetSelectedLine(row_count() - 1);
|
| return true;
|
| case GDK_Escape:
|
| Hide();
|
| @@ -302,7 +316,7 @@ void AutofillPopupViewGtk::SetBounds() {
|
|
|
| int bottom_of_field = origin_y + element_bounds().y() +
|
| element_bounds().height();
|
| - int popup_size = kRowHeight * autofill_values().size();
|
| + int popup_size = kRowHeight * row_count();
|
|
|
| // Find the correct top position of the popup so that is doesn't go off
|
| // the screen.
|
|
|