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

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

Issue 1522563002: Modernize autofill popup design (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 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 "components/autofill/core/browser/popup_item_ids.h" 8 #include "components/autofill/core/browser/popup_item_ids.h"
9 #include "components/autofill/core/browser/suggestion.h" 9 #include "components/autofill/core/browser/suggestion.h"
10 #include "ui/base/resource/material_design/material_design_controller.h"
10 #include "ui/base/resource/resource_bundle.h" 11 #include "ui/base/resource/resource_bundle.h"
11 #include "ui/events/keycodes/keyboard_codes.h" 12 #include "ui/events/keycodes/keyboard_codes.h"
12 #include "ui/gfx/canvas.h" 13 #include "ui/gfx/canvas.h"
13 #include "ui/gfx/geometry/point.h" 14 #include "ui/gfx/geometry/point.h"
14 #include "ui/gfx/geometry/rect.h" 15 #include "ui/gfx/geometry/rect.h"
15 #include "ui/gfx/image/image.h" 16 #include "ui/gfx/image/image.h"
16 #include "ui/gfx/native_widget_types.h" 17 #include "ui/gfx/native_widget_types.h"
17 #include "ui/gfx/text_utils.h" 18 #include "ui/gfx/text_utils.h"
18 #include "ui/views/border.h" 19 #include "ui/views/border.h"
19 #include "ui/views/widget/widget.h" 20 #include "ui/views/widget/widget.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 void AutofillPopupViewViews::InvalidateRow(size_t row) { 66 void AutofillPopupViewViews::InvalidateRow(size_t row) {
66 SchedulePaintInRect(controller_->GetRowBounds(row)); 67 SchedulePaintInRect(controller_->GetRowBounds(row));
67 } 68 }
68 69
69 void AutofillPopupViewViews::DrawAutofillEntry(gfx::Canvas* canvas, 70 void AutofillPopupViewViews::DrawAutofillEntry(gfx::Canvas* canvas,
70 int index, 71 int index,
71 const gfx::Rect& entry_rect) { 72 const gfx::Rect& entry_rect) {
72 if (controller_->selected_line() == index) 73 if (controller_->selected_line() == index)
73 canvas->FillRect(entry_rect, kHoveredBackgroundColor); 74 canvas->FillRect(entry_rect, kHoveredBackgroundColor);
74 75
76 int end_padding = ui::MaterialDesignController::IsModeMaterial()
77 ? kMaterialEndPadding
78 : kEndPadding;
75 const bool is_rtl = controller_->IsRTL(); 79 const bool is_rtl = controller_->IsRTL();
76 const int text_align = 80 const int text_align =
77 is_rtl ? gfx::Canvas::TEXT_ALIGN_RIGHT : gfx::Canvas::TEXT_ALIGN_LEFT; 81 is_rtl ? gfx::Canvas::TEXT_ALIGN_RIGHT : gfx::Canvas::TEXT_ALIGN_LEFT;
78 gfx::Rect value_rect = entry_rect; 82 gfx::Rect value_rect = entry_rect;
79 value_rect.Inset(kEndPadding, 0); 83 value_rect.Inset(end_padding, 0);
80 canvas->DrawStringRectWithFlags( 84 canvas->DrawStringRectWithFlags(
81 controller_->GetElidedValueAt(index), 85 controller_->GetElidedValueAt(index),
82 controller_->GetValueFontListForRow(index), 86 controller_->GetValueFontListForRow(index),
83 controller_->IsWarning(index) ? kWarningTextColor : kValueTextColor, 87 controller_->IsWarning(index) ? kWarningTextColor : kValueTextColor,
84 value_rect, text_align); 88 value_rect, text_align);
85 89
86 // Use this to figure out where all the other Autofill items should be placed. 90 // Use this to figure out where all the other Autofill items should be placed.
87 int x_align_left = is_rtl ? kEndPadding : entry_rect.right() - kEndPadding; 91 int x_align_left = is_rtl ? end_padding : entry_rect.right() - end_padding;
88 92
89 // Draw the Autofill icon, if one exists 93 // Draw the Autofill icon, if one exists
90 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 94 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
91 int row_height = controller_->GetRowBounds(index).height(); 95 int row_height = controller_->GetRowBounds(index).height();
92 if (!controller_->GetSuggestionAt(index).icon.empty()) { 96 if (!controller_->GetSuggestionAt(index).icon.empty()) {
93 int icon = controller_->GetIconResourceID( 97 int icon = controller_->GetIconResourceID(
94 controller_->GetSuggestionAt(index).icon); 98 controller_->GetSuggestionAt(index).icon);
95 DCHECK_NE(-1, icon); 99 DCHECK_NE(-1, icon);
96 const gfx::ImageSkia* image = rb.GetImageSkiaNamed(icon); 100 const gfx::ImageSkia* image = rb.GetImageSkiaNamed(icon);
97 int icon_y = entry_rect.y() + (row_height - image->height()) / 2; 101 int icon_y = entry_rect.y() + (row_height - image->height()) / 2;
(...skipping 27 matching lines...) Expand all
125 129
126 // If the top level widget can't be found, cancel the popup since we can't 130 // If the top level widget can't be found, cancel the popup since we can't
127 // fully set it up. 131 // fully set it up.
128 if (!observing_widget) 132 if (!observing_widget)
129 return NULL; 133 return NULL;
130 134
131 return new AutofillPopupViewViews(controller, observing_widget); 135 return new AutofillPopupViewViews(controller, observing_widget);
132 } 136 }
133 137
134 } // namespace autofill 138 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698