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

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

Issue 2517843002: Http Bad: Put icon on the left of http warning message on Views (Closed)
Patch Set: merge two Draw methods and add ascii art Created 4 years, 1 month 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
« no previous file with comments | « chrome/browser/ui/autofill/autofill_popup_layout_model_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 44cb516869e0c3c887a38410464d108fc1485350..08df3fcacece0e530ef725acb9b970349c78d4b8 100644
--- a/chrome/browser/ui/views/autofill/autofill_popup_view_views.cc
+++ b/chrome/browser/ui/views/autofill/autofill_popup_view_views.cc
@@ -67,26 +67,42 @@ void AutofillPopupViewViews::InvalidateRow(size_t row) {
SchedulePaintInRect(controller_->layout_model().GetRowBounds(row));
}
+/**
+* Autofill entries in ltr.
+*
+* ............................................................................
+* . ICON | HTTP WARNING MESSAGE VALUE | LABEL .
+* ............................................................................
+* . OTHER AUTOFILL ENTRY VALUE | LABEL | ICON .
+* ............................................................................
+*
+* Autofill entries in rtl.
+*
+* ............................................................................
+* . LABEL | HTTP WARNING MESSAGE VALUE | ICON .
+* ............................................................................
+* . ICON | LABEL | OTHER AUTOFILL ENTRY VALUE .
+* ............................................................................
Mathieu 2016/11/28 15:01:35 Thanks, I would add a note in this comment for the
lshang 2016/11/29 10:44:30 Done.
+*/
void AutofillPopupViewViews::DrawAutofillEntry(gfx::Canvas* canvas,
int index,
const gfx::Rect& entry_rect) {
canvas->FillRect(entry_rect, controller_->GetBackgroundColorForRow(index));
+ const bool is_http_warning =
+ (controller_->GetSuggestionAt(index).frontend_id ==
+ POPUP_ITEM_ID_HTTP_NOT_SECURE_WARNING_MESSAGE);
const bool is_rtl = controller_->IsRTL();
const int text_align =
is_rtl ? gfx::Canvas::TEXT_ALIGN_RIGHT : gfx::Canvas::TEXT_ALIGN_LEFT;
gfx::Rect value_rect = entry_rect;
value_rect.Inset(AutofillPopupLayoutModel::kEndPadding, 0);
- canvas->DrawStringRectWithFlags(
- controller_->GetElidedValueAt(index),
- controller_->layout_model().GetValueFontListForRow(index),
- controller_->layout_model().GetValueFontColorForRow(index), value_rect,
- text_align);
- // Use this to figure out where all the other Autofill items should be placed.
- int x_align_left =
- is_rtl ? AutofillPopupLayoutModel::kEndPadding
- : entry_rect.right() - AutofillPopupLayoutModel::kEndPadding;
+ int icon_x_align_left = 0;
Mathieu 2016/11/28 15:01:35 would change to icon_x_align_start, so that it's c
lshang 2016/11/29 10:44:30 Not for this case I think. RTL or LTR decides wher
+ if ((is_http_warning && !is_rtl) || (!is_http_warning && is_rtl))
+ icon_x_align_left = value_rect.x();
+ else
+ icon_x_align_left = value_rect.right();
// Draw the Autofill icon, if one exists
int row_height = controller_->layout_model().GetRowBounds(index).height();
@@ -95,27 +111,63 @@ void AutofillPopupViewViews::DrawAutofillEntry(gfx::Canvas* canvas,
controller_->layout_model().GetIconImage(index);
int icon_y = entry_rect.y() + (row_height - image.height()) / 2;
- x_align_left += is_rtl ? 0 : -image.width();
+ if (icon_x_align_left == value_rect.right())
+ icon_x_align_left -= image.width();
- canvas->DrawImageInt(image, x_align_left, icon_y);
+ canvas->DrawImageInt(image, icon_x_align_left, icon_y);
- x_align_left += is_rtl
- ? image.width() + AutofillPopupLayoutModel::kIconPadding
- : -AutofillPopupLayoutModel::kIconPadding;
+ if (is_http_warning) {
Mathieu 2016/11/28 15:01:35 I would add a comment to the reader such as // An
lshang 2016/11/29 10:44:30 Done.
+ icon_x_align_left +=
+ is_rtl ? -AutofillPopupLayoutModel::kHttpWarningIconPadding
+ : image.width() +
+ AutofillPopupLayoutModel::kHttpWarningIconPadding;
+ } else {
+ icon_x_align_left +=
+ is_rtl ? image.width() + AutofillPopupLayoutModel::kIconPadding
+ : -AutofillPopupLayoutModel::kIconPadding;
+ }
}
- // Draw the label text.
- const int label_width =
- gfx::GetStringWidth(controller_->GetElidedLabelAt(index),
- controller_->layout_model().GetLabelFontList());
- if (!is_rtl)
- x_align_left -= label_width;
+ // Draw the value text
+ const int value_width = gfx::GetStringWidth(
+ controller_->GetElidedValueAt(index),
+ controller_->layout_model().GetValueFontListForRow(index));
+ int value_x_align_left = icon_x_align_left;
+
+ if (is_http_warning)
Mathieu 2016/11/28 15:01:35 I would add {} here
lshang 2016/11/29 10:44:30 Done.
+ value_x_align_left += is_rtl ? -value_width : 0;
+ else
+ value_x_align_left =
+ is_rtl ? value_rect.right() - value_width : value_rect.x();
canvas->DrawStringRectWithFlags(
- controller_->GetElidedLabelAt(index),
- controller_->layout_model().GetLabelFontList(), kLabelTextColor,
- gfx::Rect(x_align_left, entry_rect.y(), label_width, entry_rect.height()),
+ controller_->GetElidedValueAt(index),
+ controller_->layout_model().GetValueFontListForRow(index),
+ controller_->layout_model().GetValueFontColorForRow(index),
+ gfx::Rect(value_x_align_left, value_rect.y(), value_width,
+ value_rect.height()),
text_align);
+
+ // Draw the label text, if one exists.
+ if (!controller_->GetSuggestionAt(index).label.empty()) {
+ const int label_width = gfx::GetStringWidth(
+ controller_->GetElidedLabelAt(index),
+ controller_->layout_model().GetLabelFontListForRow(index));
+ int label_x_align_left = icon_x_align_left;
+
+ if (is_http_warning)
Mathieu 2016/11/28 15:01:35 I would add {} around the blocks
lshang 2016/11/29 10:44:30 Done.
+ label_x_align_left =
+ is_rtl ? value_rect.x() : value_rect.right() - label_width;
+ else
+ label_x_align_left += is_rtl ? 0 : -label_width;
+
+ canvas->DrawStringRectWithFlags(
+ controller_->GetElidedLabelAt(index),
+ controller_->layout_model().GetLabelFontListForRow(index),
+ kLabelTextColor, gfx::Rect(label_x_align_left, entry_rect.y(),
+ label_width, entry_rect.height()),
+ text_align);
+ }
}
AutofillPopupView* AutofillPopupView::Create(
« no previous file with comments | « chrome/browser/ui/autofill/autofill_popup_layout_model_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698