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

Side by Side Diff: chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.h

Issue 1099403005: [AiS] changing mac omnibox suggestions form NSMatrix to NSTableView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: unit test fix Created 5 years, 7 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
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 #ifndef CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_CELL_H_ 5 #ifndef CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_CELL_H_
6 #define CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_CELL_H_ 6 #define CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_CELL_H_
7 7
8 #import <Cocoa/Cocoa.h> 8 #import <Cocoa/Cocoa.h>
9 9
10 #include "base/mac/scoped_nsobject.h" 10 #include "base/mac/scoped_nsobject.h"
11 #include "components/omnibox/autocomplete_match.h" 11 #include "components/omnibox/autocomplete_match.h"
12 12
13 class OmniboxPopupViewMac; 13 class OmniboxPopupViewMac;
14 @class OmniboxPopupCell;
14 15
15 // OmniboxPopupCell overrides how backgrounds are displayed to 16 @interface OmniboxPopupCellData : NSObject {
16 // handle hover versus selected. So long as we're in there, it also
17 // provides some default initialization.
18 @interface OmniboxPopupCell : NSButtonCell {
19 @private 17 @private
20 // The popup view parent of this cell.
21 OmniboxPopupViewMac* parent_;
22
23 // The match which will be rendered for this row in omnibox dropdown.
24 AutocompleteMatch match_;
25
26 // NSAttributedString instances for various match components. 18 // NSAttributedString instances for various match components.
19 base::scoped_nsobject<NSAttributedString> contents_;
27 base::scoped_nsobject<NSAttributedString> separator_; 20 base::scoped_nsobject<NSAttributedString> separator_;
28 base::scoped_nsobject<NSAttributedString> description_; 21 base::scoped_nsobject<NSAttributedString> description_;
29 22
30 // NOTE: While |prefix_| is used only for postfix suggestions, it still needs 23 // NOTE: While |prefix_| is used only for postfix suggestions, it still needs
31 // to be a member of the class. This allows the |NSAttributedString| instance 24 // to be a member of the class. This allows the |NSAttributedString| instance
32 // to stay alive between the call to |drawTitle| and the actual paint event 25 // to stay alive between the call to |drawTitle| and the actual paint event
33 // which accesses the |NSAttributedString| instance. 26 // which accesses the |NSAttributedString| instance.
34 base::scoped_nsobject<NSAttributedString> prefix_; 27 base::scoped_nsobject<NSAttributedString> prefix_;
35 28
29 base::scoped_nsobject<NSImage> image_;
30
36 // The width of widest match contents in a set of infinite suggestions. 31 // The width of widest match contents in a set of infinite suggestions.
37 CGFloat maxMatchContentsWidth_; 32 CGFloat maxMatchContentsWidth_;
38 33
39 // The offset at which the infinite suggestion contents should be displayed. 34 // The offset at which the infinite suggestion contents should be displayed.
40 CGFloat contentsOffset_; 35 CGFloat contentsOffset_;
36
37 bool isContentsRTL_;
shrike 2015/05/14 18:02:38 Should this be C++ bool or ObjC BOOL? For ObjC cla
dschuyler 2015/05/14 22:28:19 Done.
Scott Hess - ex-Googler 2015/05/15 00:09:38 I think that in general Objective-C should use BOO
groby-ooo-7-16 2015/05/15 16:53:56 The "accepted way" to go from BOOL to bool is the
dschuyler 2015/05/15 21:52:03 I tried this: changed it to BOOL as well as changi
38 AutocompleteMatch::Type matchType_;
39 NSRect rect_;
41 } 40 }
42 41
43 - (void)setMatch:(const AutocompleteMatch&)match; 42 - (id)initWithMatch:(const AutocompleteMatch&)match;
43
44 - (void)drawMatchWithFrame:(NSRect)cellFrame
45 inCell:(OmniboxPopupCell*)cell
46 inView:(NSView*)controlView;
47
48 - (void)setContents:(NSAttributedString*)contents;
49
50 - (void)setImage:(NSImage*)image;
51
52 - (void)setRect:(NSRect)rect;
shrike 2015/05/14 18:02:39 Should be able to get rid of setRect: and rect dec
dschuyler 2015/05/14 22:28:20 Thanks, I had wondered which way would be preferre
53
54 - (NSRect)rect;
44 55
45 - (void)setMaxMatchContentsWidth:(CGFloat)maxMatchContentsWidth; 56 - (void)setMaxMatchContentsWidth:(CGFloat)maxMatchContentsWidth;
46 57
47 - (void)setContentsOffset:(CGFloat)contentsOffset; 58 - (void)setContentsOffset:(CGFloat)contentsOffset;
48 59
49 // Returns the width of the match contents. 60 // Returns the width of the match contents.
50 - (CGFloat)getMatchContentsWidth; 61 - (CGFloat)getMatchContentsWidth;
51 62
63 @end
64
65 // OmniboxPopupCell overrides how backgrounds are displayed to
66 // handle hover versus selected. So long as we're in there, it also
67 // provides some default initialization.
68 @interface OmniboxPopupCell : NSCell {
69 @private
70 base::scoped_nsobject<OmniboxPopupCellData> cellData_;
71 }
72
73 - (void)setCellData:(OmniboxPopupCellData*)cellData;
74
75 - (CGFloat)drawMatchPart:(NSAttributedString*)attributedString
76 withFrame:(NSRect)cellFrame
77 atOffset:(CGFloat)offset
78 withMaxWidth:(int)maxWidth
79 inView:(NSView*)controlView;
80
52 // Returns the offset of the start of the contents in the input text for the 81 // Returns the offset of the start of the contents in the input text for the
53 // given match. It is costly to compute this offset, so it is computed once and 82 // given match. It is costly to compute this offset, so it is computed once and
54 // shared by all OmniboxPopupCell instances through OmniboxPopupViewMac parent. 83 // shared by all OmniboxPopupCell instances through OmniboxPopupViewMac parent.
55 + (CGFloat)computeContentsOffset:(const AutocompleteMatch&)match; 84 + (CGFloat)computeContentsOffset:(const AutocompleteMatch&)match;
56 85
57 @end 86 @end
58 87
59 #endif // CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_CELL_H_ 88 #endif // CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_CELL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698