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

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

Issue 18112007: [rAC] added popup highlighting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import "chrome/browser/ui/cocoa/autofill/autofill_pop_up_button.h"
6
7 #include "base/mac/scoped_nsobject.h"
8
9 @implementation AutofillPopUpCell
sail 2013/06/28 03:08:56 Move below implementation of AutofillPopUpButton t
groby-ooo-7-16 2013/06/28 18:49:52 Done.
10
11 @synthesize invalid = invalid_;
12
13 // Draw a bezel that's highlighted.
14 - (void)drawBezelWithFrame:(NSRect)cellFrame inView:(NSView*)controlView {
15 if (invalid_) {
sail 2013/06/28 03:08:56 Do early return? Also comment why you don't need t
groby-ooo-7-16 2013/06/28 18:49:52 Because I stupidly only tested the invalid path -
16 NSRect localFrame = NSZeroRect;
17 localFrame.size = cellFrame.size;
18
19 base::scoped_nsobject<NSImage> bezelImage(
20 [[NSImage alloc] initWithSize:cellFrame.size]);
21
22 // Get a snapshot of the original bezel.
23 [bezelImage lockFocus];
24 [super drawBezelWithFrame:localFrame inView:[NSView focusView]];
sail 2013/06/28 03:08:56 can't you just pass controlView here?
groby-ooo-7-16 2013/06/28 18:49:52 It's moot with the new rendering code, but the doc
25 [bezelImage unlockFocus];
26
27 // Copy bezel.
28 base::scoped_nsobject<NSImage> finalImage([bezelImage copyWithZone:nil]);
sail 2013/06/28 03:08:56 I don't think you need this. You can do everything
groby-ooo-7-16 2013/06/28 18:49:52 I originally misunderstood the grouping here - yes
29
30 // Replace all of bezel with highlight color to get solid-colored bezel.
31 [finalImage lockFocus];
32 [[NSColor redColor] set];
33 NSRectFillUsingOperation(localFrame, NSCompositeSourceAtop);
34
35 // Finally, mix colored area and bezel image.
36 [bezelImage drawAtPoint:NSZeroPoint
37 fromRect:NSZeroRect
38 operation:NSCompositePlusDarker
39 fraction:1];
40 [finalImage unlockFocus];
41
42 // And draw the resulting bezel.
43 [finalImage drawAtPoint:cellFrame.origin
44 fromRect:NSZeroRect
45 operation:NSCompositeSourceOver
46 fraction:1];
47 }
48 }
49
50 - (NSString*)fieldValue {
51 return [self titleOfSelectedItem];
52 }
53
54 - (void)setFieldValue:(NSString*)fieldValue {
55 [self selectItemWithTitle:fieldValue];
56 }
57
58 @end
59
60
61 @implementation AutofillPopUpButton
62
63 + (Class)cellClass {
64 return [AutofillPopUpCell class];
65 }
66
67 - (BOOL)invalid {
68 return [[self cell] invalid];
69 }
70
71 - (void)setInvalid:(BOOL)invalid {
72 [[self cell] setInvalid:invalid];
73 }
74
75 - (NSString*)fieldValue {
76 return [[self cell] fieldValue];
77 }
78
79 - (void)setFieldValue:(NSString*)fieldValue {
80 [[self cell] setFieldValue:fieldValue];
81 }
82
83 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698