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

Side by Side Diff: chrome/browser/ui/views/autofill/autofill_popup_view_views.cc

Issue 2152243002: [Autofill] Tweak credit card signin promo visually. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: transparent color Created 4 years, 5 months 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/autofill/autofill_popup_view_views.h" 5 #include "chrome/browser/ui/views/autofill/autofill_popup_view_views.h"
6 6
7 #include "chrome/browser/ui/autofill/autofill_popup_controller.h" 7 #include "chrome/browser/ui/autofill/autofill_popup_controller.h"
8 #include "chrome/browser/ui/autofill/autofill_popup_layout_model.h" 8 #include "chrome/browser/ui/autofill/autofill_popup_layout_model.h"
9 #include "chrome/browser/ui/autofill/popup_constants.h"
9 #include "components/autofill/core/browser/popup_item_ids.h" 10 #include "components/autofill/core/browser/popup_item_ids.h"
10 #include "components/autofill/core/browser/suggestion.h" 11 #include "components/autofill/core/browser/suggestion.h"
11 #include "ui/base/resource/resource_bundle.h" 12 #include "ui/base/resource/resource_bundle.h"
12 #include "ui/events/keycodes/keyboard_codes.h" 13 #include "ui/events/keycodes/keyboard_codes.h"
13 #include "ui/gfx/canvas.h" 14 #include "ui/gfx/canvas.h"
14 #include "ui/gfx/geometry/point.h" 15 #include "ui/gfx/geometry/point.h"
15 #include "ui/gfx/geometry/rect.h" 16 #include "ui/gfx/geometry/rect.h"
16 #include "ui/gfx/image/image.h" 17 #include "ui/gfx/image/image.h"
17 #include "ui/gfx/native_widget_types.h" 18 #include "ui/gfx/native_widget_types.h"
18 #include "ui/gfx/text_utils.h" 19 #include "ui/gfx/text_utils.h"
(...skipping 30 matching lines...) Expand all
49 return; 50 return;
50 51
51 canvas->DrawColor(kPopupBackground); 52 canvas->DrawColor(kPopupBackground);
52 OnPaintBorder(canvas); 53 OnPaintBorder(canvas);
53 54
54 for (size_t i = 0; i < controller_->GetLineCount(); ++i) { 55 for (size_t i = 0; i < controller_->GetLineCount(); ++i) {
55 gfx::Rect line_rect = controller_->layout_model().GetRowBounds(i); 56 gfx::Rect line_rect = controller_->layout_model().GetRowBounds(i);
56 57
57 if (controller_->GetSuggestionAt(i).frontend_id == 58 if (controller_->GetSuggestionAt(i).frontend_id ==
58 POPUP_ITEM_ID_SEPARATOR) { 59 POPUP_ITEM_ID_SEPARATOR) {
59 canvas->FillRect(line_rect, kItemTextColor); 60 canvas->FillRect(line_rect, kLabelTextColor);
60 } else { 61 } else {
61 DrawAutofillEntry(canvas, i, line_rect); 62 DrawAutofillEntry(canvas, i, line_rect);
62 } 63 }
63 } 64 }
64 } 65 }
65 66
66 void AutofillPopupViewViews::InvalidateRow(size_t row) { 67 void AutofillPopupViewViews::InvalidateRow(size_t row) {
67 SchedulePaintInRect(controller_->layout_model().GetRowBounds(row)); 68 SchedulePaintInRect(controller_->layout_model().GetRowBounds(row));
68 } 69 }
69 70
70 void AutofillPopupViewViews::DrawAutofillEntry(gfx::Canvas* canvas, 71 void AutofillPopupViewViews::DrawAutofillEntry(gfx::Canvas* canvas,
71 int index, 72 int index,
72 const gfx::Rect& entry_rect) { 73 const gfx::Rect& entry_rect) {
73 if (controller_->selected_line() == index) 74 // Controller chooses the background color depending on the state of the row
74 canvas->FillRect(entry_rect, kHoveredBackgroundColor); 75 // at |index|.
Evan Stade 2016/07/18 18:13:08 nit: comment is unnecessary
Mathieu 2016/07/18 18:45:13 Done.
76 canvas->FillRect(entry_rect, controller_->GetBackgroundColorForRow(index));
75 77
76 const bool is_rtl = controller_->IsRTL(); 78 const bool is_rtl = controller_->IsRTL();
77 const int text_align = 79 const int text_align =
78 is_rtl ? gfx::Canvas::TEXT_ALIGN_RIGHT : gfx::Canvas::TEXT_ALIGN_LEFT; 80 is_rtl ? gfx::Canvas::TEXT_ALIGN_RIGHT : gfx::Canvas::TEXT_ALIGN_LEFT;
79 gfx::Rect value_rect = entry_rect; 81 gfx::Rect value_rect = entry_rect;
80 value_rect.Inset(AutofillPopupLayoutModel::kEndPadding, 0); 82 value_rect.Inset(AutofillPopupLayoutModel::kEndPadding, 0);
81 canvas->DrawStringRectWithFlags( 83 canvas->DrawStringRectWithFlags(
82 controller_->GetElidedValueAt(index), 84 controller_->GetElidedValueAt(index),
83 controller_->GetValueFontListForRow(index), 85 controller_->GetValueFontListForRow(index),
84 controller_->IsWarning(index) ? kWarningTextColor : kValueTextColor, 86 controller_->IsWarning(index) ? kWarningTextColor : kValueTextColor,
(...skipping 25 matching lines...) Expand all
110 112
111 // Draw the label text. 113 // Draw the label text.
112 const int label_width = 114 const int label_width =
113 gfx::GetStringWidth(controller_->GetElidedLabelAt(index), 115 gfx::GetStringWidth(controller_->GetElidedLabelAt(index),
114 controller_->GetLabelFontList()); 116 controller_->GetLabelFontList());
115 if (!is_rtl) 117 if (!is_rtl)
116 x_align_left -= label_width; 118 x_align_left -= label_width;
117 119
118 canvas->DrawStringRectWithFlags( 120 canvas->DrawStringRectWithFlags(
119 controller_->GetElidedLabelAt(index), controller_->GetLabelFontList(), 121 controller_->GetElidedLabelAt(index), controller_->GetLabelFontList(),
120 kItemTextColor, 122 kLabelTextColor,
121 gfx::Rect(x_align_left, entry_rect.y(), label_width, entry_rect.height()), 123 gfx::Rect(x_align_left, entry_rect.y(), label_width, entry_rect.height()),
122 text_align); 124 text_align);
123 } 125 }
124 126
125 AutofillPopupView* AutofillPopupView::Create( 127 AutofillPopupView* AutofillPopupView::Create(
126 AutofillPopupController* controller) { 128 AutofillPopupController* controller) {
127 views::Widget* observing_widget = 129 views::Widget* observing_widget =
128 views::Widget::GetTopLevelWidgetForNativeView( 130 views::Widget::GetTopLevelWidgetForNativeView(
129 controller->container_view()); 131 controller->container_view());
130 132
131 // If the top level widget can't be found, cancel the popup since we can't 133 // If the top level widget can't be found, cancel the popup since we can't
132 // fully set it up. 134 // fully set it up.
133 if (!observing_widget) 135 if (!observing_widget)
134 return NULL; 136 return NULL;
135 137
136 return new AutofillPopupViewViews(controller, observing_widget); 138 return new AutofillPopupViewViews(controller, observing_widget);
137 } 139 }
138 140
139 } // namespace autofill 141 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698