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

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

Issue 124383010: [rAC] Allow clickthrough for SuggestionView (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added unit test. Created 6 years, 11 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_suggestion_container.h" 5 #import "chrome/browser/ui/cocoa/autofill/autofill_suggestion_container.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 CGFloat baseline_; // The cell's baseline adjustment. 47 CGFloat baseline_; // The cell's baseline adjustment.
48 } 48 }
49 49
50 // Adjust the cell's baseline so that the lower edge of the image aligns with 50 // Adjust the cell's baseline so that the lower edge of the image aligns with
51 // the longest descender, not the font baseline 51 // the longest descender, not the font baseline
52 - (void)adjustBaselineForFont:(NSFont*)font; 52 - (void)adjustBaselineForFont:(NSFont*)font;
53 53
54 @end 54 @end
55 55
56 56
57 @interface AutofillSuggestionView : NSView {
58 @private
59 // The main input field - only view not ignoring mouse events.
60 NSView* inputField_;
61 }
62
63 @property (assign, nonatomic) NSView* inputField;
64
65 @end
66
67
68 // The suggestion container should ignore any mouse events unless they occur
69 // within the bounds of an editable field.
70 @implementation AutofillSuggestionView
71
72 @synthesize inputField = inputField_;
73
74 - (NSView*)hitTest:(NSPoint)point {
75 NSView* hitView = [super hitTest:point];
76 if ([hitView isDescendantOf:inputField_])
77 return hitView;
78
79 return nil;
80 }
81
82 @end
83
84
57 @implementation IconAttachmentCell 85 @implementation IconAttachmentCell
58 86
59 - (NSPoint)cellBaselineOffset { 87 - (NSPoint)cellBaselineOffset {
60 return NSMakePoint(0.0, baseline_); 88 return NSMakePoint(0.0, baseline_);
61 } 89 }
62 90
63 // Ensure proper padding between text and icon. 91 // Ensure proper padding between text and icon.
64 - (NSSize)cellSize { 92 - (NSSize)cellSize {
65 NSSize size = [super cellSize]; 93 NSSize size = [super cellSize];
66 size.width += kAroundTextPadding; 94 size.width += kAroundTextPadding;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 [paragraphStyle setLineSpacing:0.5 * [[label_ font] pointSize]]; 151 [paragraphStyle setLineSpacing:0.5 * [[label_ font] pointSize]];
124 [label_ setDefaultParagraphStyle:paragraphStyle]; 152 [label_ setDefaultParagraphStyle:paragraphStyle];
125 153
126 inputField_.reset([[AutofillTextField alloc] initWithFrame:NSZeroRect]); 154 inputField_.reset([[AutofillTextField alloc] initWithFrame:NSZeroRect]);
127 [inputField_ setHidden:YES]; 155 [inputField_ setHidden:YES];
128 156
129 spacer_.reset([[NSBox alloc] initWithFrame:NSZeroRect]); 157 spacer_.reset([[NSBox alloc] initWithFrame:NSZeroRect]);
130 [spacer_ setBoxType:NSBoxSeparator]; 158 [spacer_ setBoxType:NSBoxSeparator];
131 [spacer_ setBorderType:NSLineBorder]; 159 [spacer_ setBorderType:NSLineBorder];
132 160
133 base::scoped_nsobject<NSView> view([[NSView alloc] initWithFrame:NSZeroRect]); 161 base::scoped_nsobject<AutofillSuggestionView> view(
162 [[AutofillSuggestionView alloc] initWithFrame:NSZeroRect]);
134 [view setSubviews: 163 [view setSubviews:
135 @[ label_, inputField_, spacer_ ]]; 164 @[ label_, inputField_, spacer_ ]];
165 [view setInputField:inputField_];
136 [self setView:view]; 166 [self setView:view];
137 } 167 }
138 168
139 - (void)setSuggestionText:(NSString*)line 169 - (void)setSuggestionText:(NSString*)line
140 icon:(NSImage*)icon 170 icon:(NSImage*)icon
141 wrapText:(BOOL)wrapText { 171 wrapText:(BOOL)wrapText {
142 [label_ setString:@""]; 172 [label_ setString:@""];
143 173
144 if ([icon size].width) { 174 if ([icon size].width) {
145 base::scoped_nsobject<IconAttachmentCell> cell( 175 base::scoped_nsobject<IconAttachmentCell> cell(
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 // Due to fixed width, fields are guaranteed to not overlap. 274 // Due to fixed width, fields are guaranteed to not overlap.
245 DCHECK_LE(NSMaxX(labelFrame), NSMinX(inputFieldFrame)); 275 DCHECK_LE(NSMaxX(labelFrame), NSMinX(inputFieldFrame));
246 } 276 }
247 277
248 [spacer_ setFrame:spacerFrame]; 278 [spacer_ setFrame:spacerFrame];
249 [label_ setFrame:labelFrame]; 279 [label_ setFrame:labelFrame];
250 [[self view] setFrameSize:preferredContainerSize]; 280 [[self view] setFrameSize:preferredContainerSize];
251 } 281 }
252 282
253 @end 283 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698