Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2784)

Unified Diff: chrome/browser/ui/views/autofill/autofill_popup_view_views.cc

Issue 11636040: AutofillPopupController clarifications + simplifications. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ilya review Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/autofill/autofill_popup_view_views.cc
diff --git a/chrome/browser/ui/views/autofill/autofill_popup_view_views.cc b/chrome/browser/ui/views/autofill/autofill_popup_view_views.cc
index 224ca81b7c0ebe312b26f9d8136fe4d6bc553c65..46a1bd36501b769ff09fd25d751e9b0325af7d1c 100644
--- a/chrome/browser/ui/views/autofill/autofill_popup_view_views.cc
+++ b/chrome/browser/ui/views/autofill/autofill_popup_view_views.cc
@@ -55,10 +55,10 @@ void AutofillPopupViewViews::OnPaint(gfx::Canvas* canvas) {
canvas->DrawColor(kPopupBackground);
OnPaintBorder(canvas);
- for (size_t i = 0; i < controller_->autofill_values().size(); ++i) {
- gfx::Rect line_rect = controller_->GetRectForRow(i, width());
+ for (size_t i = 0; i < controller_->labels().size(); ++i) {
+ gfx::Rect line_rect = controller_->GetRowBounds(i);
- if (controller_->autofill_unique_ids()[i] ==
+ if (controller_->identifiers()[i] ==
WebAutofillClient::MenuItemIDSeparator) {
canvas->DrawRect(line_rect, kLabelTextColor);
} else {
@@ -68,12 +68,12 @@ void AutofillPopupViewViews::OnPaint(gfx::Canvas* canvas) {
}
void AutofillPopupViewViews::OnMouseCaptureLost() {
- controller_->ClearSelectedLine();
+ controller_->MouseExitedPopup();
}
bool AutofillPopupViewViews::OnMouseDragged(const ui::MouseEvent& event) {
if (HitTestPoint(gfx::Point(event.x(), event.y()))) {
- controller_->SetSelectedPosition(event.x(), event.y());
+ controller_->MouseHovered(event.x(), event.y());
// We must return true in order to get future OnMouseDragged and
// OnMouseReleased events.
@@ -81,16 +81,16 @@ bool AutofillPopupViewViews::OnMouseDragged(const ui::MouseEvent& event) {
}
// If we move off of the popup, we lose the selection.
- controller_->ClearSelectedLine();
+ controller_->MouseExitedPopup();
return false;
}
void AutofillPopupViewViews::OnMouseExited(const ui::MouseEvent& event) {
- controller_->ClearSelectedLine();
+ controller_->MouseExitedPopup();
}
void AutofillPopupViewViews::OnMouseMoved(const ui::MouseEvent& event) {
- controller_->SetSelectedPosition(event.x(), event.y());
+ controller_->MouseHovered(event.x(), event.y());
}
bool AutofillPopupViewViews::OnMousePressed(const ui::MouseEvent& event) {
@@ -102,7 +102,7 @@ void AutofillPopupViewViews::OnMouseReleased(const ui::MouseEvent& event) {
// We only care about the left click.
if (event.IsOnlyLeftMouseButton() &&
HitTestPoint(gfx::Point(event.x(), event.y())))
- controller_->AcceptSelectedPosition(event.x(), event.y());
+ controller_->MouseClicked(event.x(), event.y());
}
void AutofillPopupViewViews::OnWidgetBoundsChanged(
@@ -146,7 +146,7 @@ void AutofillPopupViewViews::Show() {
}
void AutofillPopupViewViews::InvalidateRow(size_t row) {
- SchedulePaintInRect(controller_->GetRectForRow(row, width()));
+ SchedulePaintInRect(controller_->GetRowBounds(row));
}
void AutofillPopupViewViews::UpdateBoundsAndRedrawPopup() {
@@ -163,13 +163,13 @@ void AutofillPopupViewViews::DrawAutofillEntry(gfx::Canvas* canvas,
canvas->FillRect(entry_rect, kHoveredBackgroundColor);
canvas->DrawStringInt(
- controller_->autofill_values()[index],
- controller_->value_font(),
+ controller_->labels()[index],
+ controller_->label_font(),
kValueTextColor,
kEndPadding,
entry_rect.y(),
- canvas->GetStringWidth(controller_->autofill_values()[index],
- controller_->value_font()),
+ canvas->GetStringWidth(controller_->labels()[index],
+ controller_->label_font()),
entry_rect.height(),
gfx::Canvas::TEXT_ALIGN_CENTER);
@@ -178,9 +178,8 @@ void AutofillPopupViewViews::DrawAutofillEntry(gfx::Canvas* canvas,
// Draw the delete icon, if one is needed.
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- int row_height = controller_->GetRowHeightFromId(
- controller_->autofill_unique_ids()[index]);
- if (controller_->CanDelete(controller_->autofill_unique_ids()[index])) {
+ int row_height = controller_->GetRowBounds(index).height();
+ if (controller_->CanDelete(index)) {
x_align_left -= kDeleteIconWidth;
// TODO(csharp): Create a custom resource for the delete icon.
@@ -188,15 +187,14 @@ void AutofillPopupViewViews::DrawAutofillEntry(gfx::Canvas* canvas,
canvas->DrawImageInt(
*rb.GetImageSkiaNamed(IDR_CLOSE_BAR),
x_align_left,
- entry_rect.y() + ((row_height - kDeleteIconHeight) / 2));
+ entry_rect.y() + (row_height - kDeleteIconHeight) / 2);
x_align_left -= kIconPadding;
}
// 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;
@@ -208,17 +206,17 @@ void AutofillPopupViewViews::DrawAutofillEntry(gfx::Canvas* canvas,
}
// Draw the label text.
- x_align_left -= canvas->GetStringWidth(controller_->autofill_labels()[index],
- controller_->label_font());
+ x_align_left -= canvas->GetStringWidth(controller_->sub_labels()[index],
+ controller_->sub_label_font());
canvas->DrawStringInt(
- controller_->autofill_labels()[index],
- controller_->label_font(),
+ controller_->sub_labels()[index],
+ controller_->sub_label_font(),
kLabelTextColor,
x_align_left + kEndPadding,
entry_rect.y(),
- canvas->GetStringWidth(controller_->autofill_labels()[index],
- controller_->label_font()),
+ canvas->GetStringWidth(controller_->sub_labels()[index],
+ controller_->sub_label_font()),
entry_rect.height(),
gfx::Canvas::TEXT_ALIGN_CENTER);
}

Powered by Google App Engine
This is Rietveld 408576698