OLD | NEW |
---|---|
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" | 15 #include "skia/ext/skia_utils_mac.h" |
16 #include "third_party/skia/include/core/SkColor.h" | 16 #include "third_party/skia/include/core/SkColor.h" |
17 #include "ui/base/cocoa/window_size_constants.h" | 17 #include "ui/base/cocoa/window_size_constants.h" |
18 #include "ui/base/resource/resource_bundle.h" | 18 #include "ui/base/resource/resource_bundle.h" |
19 #include "ui/gfx/color_palette.h" | |
19 #include "ui/gfx/font_list.h" | 20 #include "ui/gfx/font_list.h" |
20 #include "ui/gfx/geometry/point.h" | 21 #include "ui/gfx/geometry/point.h" |
21 #include "ui/gfx/geometry/rect.h" | 22 #include "ui/gfx/geometry/rect.h" |
22 #include "ui/gfx/image/image.h" | 23 #include "ui/gfx/image/image.h" |
23 | 24 |
24 using autofill::AutofillPopupView; | 25 using autofill::AutofillPopupView; |
25 using autofill::AutofillPopupLayoutModel; | 26 using autofill::AutofillPopupLayoutModel; |
26 | 27 |
27 @interface AutofillPopupViewCocoa () | 28 @interface AutofillPopupViewCocoa () |
28 | 29 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
190 bounds:bounds | 191 bounds:bounds |
191 textYOffset:textYOffset]; | 192 textYOffset:textYOffset]; |
192 } | 193 } |
193 | 194 |
194 - (CGFloat)drawName:(NSString*)name | 195 - (CGFloat)drawName:(NSString*)name |
195 atX:(CGFloat)x | 196 atX:(CGFloat)x |
196 index:(size_t)index | 197 index:(size_t)index |
197 rightAlign:(BOOL)rightAlign | 198 rightAlign:(BOOL)rightAlign |
198 bounds:(NSRect)bounds | 199 bounds:(NSRect)bounds |
199 textYOffset:(CGFloat)textYOffset { | 200 textYOffset:(CGFloat)textYOffset { |
200 // TODO(crbug.com/666189): Use | 201 SkColor skColor = controller_->layout_model().GetValueFontColorForRow(index); |
201 // AutofillPopupLayoutModel::GetValueFontColorForRow() instead and remove | 202 NSColor* nameColor = nil; |
Mathieu
2016/12/13 15:45:10
Have a look at https://cs.chromium.org/chromium/sr
| |
202 // IsWarning() method. | 203 if (skColor == autofill::kLabelTextColor || skColor == gfx::kGoogleRed700) |
203 NSColor* nameColor = | 204 nameColor = [self warningColor]; |
204 controller_->IsWarning(index) ? [self warningColor] : [self nameColor]; | 205 else |
206 nameColor = [self nameColor]; | |
205 NSDictionary* nameAttributes = [NSDictionary | 207 NSDictionary* nameAttributes = [NSDictionary |
206 dictionaryWithObjectsAndKeys:controller_->layout_model() | 208 dictionaryWithObjectsAndKeys:controller_->layout_model() |
207 .GetValueFontListForRow(index) | 209 .GetValueFontListForRow(index) |
208 .GetPrimaryFont() | 210 .GetPrimaryFont() |
209 .GetNativeFont(), | 211 .GetNativeFont(), |
210 NSFontAttributeName, nameColor, | 212 NSFontAttributeName, nameColor, |
211 NSForegroundColorAttributeName, nil]; | 213 NSForegroundColorAttributeName, nil]; |
212 NSSize nameSize = [name sizeWithAttributes:nameAttributes]; | 214 NSSize nameSize = [name sizeWithAttributes:nameAttributes]; |
213 x -= rightAlign ? nameSize.width : 0; | 215 x -= rightAlign ? nameSize.width : 0; |
214 CGFloat y = bounds.origin.y + (bounds.size.height - nameSize.height) / 2; | 216 CGFloat y = bounds.origin.y + (bounds.size.height - nameSize.height) / 2; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
271 return nil; | 273 return nil; |
272 | 274 |
273 int iconId = delegate_->GetIconResourceID(icon); | 275 int iconId = delegate_->GetIconResourceID(icon); |
274 DCHECK_NE(-1, iconId); | 276 DCHECK_NE(-1, iconId); |
275 | 277 |
276 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 278 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
277 return rb.GetNativeImageNamed(iconId).ToNSImage(); | 279 return rb.GetNativeImageNamed(iconId).ToNSImage(); |
278 } | 280 } |
279 | 281 |
280 @end | 282 @end |
OLD | NEW |