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

Side by Side Diff: chrome/browser/ui/cocoa/autofill/autofill_popup_view_cocoa.mm

Issue 2167693002: [Autofill] Use AutofillPopupController::GetBackgroundColorForRow on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #import "chrome/browser/ui/cocoa/autofill/autofill_popup_view_cocoa.h" 5 #import "chrome/browser/ui/cocoa/autofill/autofill_popup_view_cocoa.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/sys_string_conversions.h" 8 #include "base/strings/sys_string_conversions.h"
9 #include "chrome/browser/ui/autofill/autofill_popup_controller.h" 9 #include "chrome/browser/ui/autofill/autofill_popup_controller.h"
10 #include "chrome/browser/ui/autofill/autofill_popup_layout_model.h" 10 #include "chrome/browser/ui/autofill/autofill_popup_layout_model.h"
11 #include "chrome/browser/ui/autofill/popup_constants.h" 11 #include "chrome/browser/ui/autofill/popup_constants.h"
12 #include "chrome/browser/ui/cocoa/autofill/autofill_popup_view_bridge.h" 12 #include "chrome/browser/ui/cocoa/autofill/autofill_popup_view_bridge.h"
13 #include "components/autofill/core/browser/popup_item_ids.h" 13 #include "components/autofill/core/browser/popup_item_ids.h"
14 #include "components/autofill/core/browser/suggestion.h" 14 #include "components/autofill/core/browser/suggestion.h"
15 #include "skia/ext/skia_utils_mac.h"
16 #include "third_party/skia/include/core/SkColor.h"
15 #include "ui/base/cocoa/window_size_constants.h" 17 #include "ui/base/cocoa/window_size_constants.h"
16 #include "ui/base/resource/resource_bundle.h" 18 #include "ui/base/resource/resource_bundle.h"
17 #include "ui/gfx/font_list.h" 19 #include "ui/gfx/font_list.h"
18 #include "ui/gfx/geometry/point.h" 20 #include "ui/gfx/geometry/point.h"
19 #include "ui/gfx/geometry/rect.h" 21 #include "ui/gfx/geometry/rect.h"
20 #include "ui/gfx/image/image.h" 22 #include "ui/gfx/image/image.h"
21 23
22 using autofill::AutofillPopupView; 24 using autofill::AutofillPopupView;
23 using autofill::AutofillPopupLayoutModel; 25 using autofill::AutofillPopupLayoutModel;
24 26
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 145
144 #pragma mark - 146 #pragma mark -
145 #pragma mark Private API: 147 #pragma mark Private API:
146 148
147 - (void)drawSuggestionWithName:(NSString*)name 149 - (void)drawSuggestionWithName:(NSString*)name
148 subtext:(NSString*)subtext 150 subtext:(NSString*)subtext
149 index:(size_t)index 151 index:(size_t)index
150 bounds:(NSRect)bounds 152 bounds:(NSRect)bounds
151 selected:(BOOL)isSelected 153 selected:(BOOL)isSelected
152 textYOffset:(CGFloat)textYOffset { 154 textYOffset:(CGFloat)textYOffset {
153 // If this row is selected, highlight it. 155 // If this row is selected, highlight it with this mac system color.
156 // Otherwise the controller may have a specific background color for this
157 // entry.
154 if (isSelected) { 158 if (isSelected) {
155 [[self highlightColor] set]; 159 [[self highlightColor] set];
156 [NSBezierPath fillRect:bounds]; 160 [NSBezierPath fillRect:bounds];
161 } else {
162 SkColor backgroundColor = controller_->GetBackgroundColorForRow(index);
163 [skia::SkColorToSRGBNSColor(backgroundColor) set];
164 [NSBezierPath fillRect:bounds];
157 } 165 }
158 166
159 BOOL isRTL = controller_->IsRTL(); 167 BOOL isRTL = controller_->IsRTL();
160 168
161 // The X values of the left and right borders of the autofill widget. 169 // The X values of the left and right borders of the autofill widget.
162 CGFloat leftX = NSMinX(bounds) + AutofillPopupLayoutModel::kEndPadding; 170 CGFloat leftX = NSMinX(bounds) + AutofillPopupLayoutModel::kEndPadding;
163 CGFloat rightX = NSMaxX(bounds) - AutofillPopupLayoutModel::kEndPadding; 171 CGFloat rightX = NSMaxX(bounds) - AutofillPopupLayoutModel::kEndPadding;
164 172
165 // Draw left side if isRTL == NO, right side if isRTL == YES. 173 // Draw left side if isRTL == NO, right side if isRTL == YES.
166 CGFloat x = isRTL ? rightX : leftX; 174 CGFloat x = isRTL ? rightX : leftX;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 return nil; 264 return nil;
257 265
258 int iconId = delegate_->GetIconResourceID(icon); 266 int iconId = delegate_->GetIconResourceID(icon);
259 DCHECK_NE(-1, iconId); 267 DCHECK_NE(-1, iconId);
260 268
261 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 269 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
262 return rb.GetNativeImageNamed(iconId).ToNSImage(); 270 return rb.GetNativeImageNamed(iconId).ToNSImage();
263 } 271 }
264 272
265 @end 273 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698