Chromium Code Reviews| OLD | NEW | 
|---|---|
| 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 | 14 | 
| 15 @interface AutocompleteMatchWrapper : NSObject { | |
| 16 @public | |
| 17 AutocompleteMatch match_; | |
| 18 } | |
| 19 @end | |
| 20 | |
| 15 // OmniboxPopupCell overrides how backgrounds are displayed to | 21 // OmniboxPopupCell overrides how backgrounds are displayed to | 
| 16 // handle hover versus selected. So long as we're in there, it also | 22 // handle hover versus selected. So long as we're in there, it also | 
| 17 // provides some default initialization. | 23 // provides some default initialization. | 
| 18 @interface OmniboxPopupCell : NSButtonCell { | 24 @interface OmniboxPopupCell : NSCell { | 
| 
 
groby-ooo-7-16
2015/05/07 02:39:58
We don't need any of NSButtonCell's behavior any m
 
dschuyler
2015/05/07 20:53:09
It doesn't seem so.  I'm going by Jayson's advice
 
 | |
| 19 @private | 25 @private | 
| 20 // The popup view parent of this cell. | 26 // The popup view parent of this cell. | 
| 21 OmniboxPopupViewMac* parent_; | 27 OmniboxPopupViewMac* parent_; | 
| 22 | 28 | 
| 23 // The match which will be rendered for this row in omnibox dropdown. | 29 // The match which will be rendered for this row in omnibox dropdown. | 
| 24 AutocompleteMatch match_; | 30 AutocompleteMatch match_; | 
| 25 | 31 | 
| 26 // NSAttributedString instances for various match components. | 32 // NSAttributedString instances for various match components. | 
| 27 base::scoped_nsobject<NSAttributedString> separator_; | 33 base::scoped_nsobject<NSAttributedString> separator_; | 
| 28 base::scoped_nsobject<NSAttributedString> description_; | 34 base::scoped_nsobject<NSAttributedString> description_; | 
| 29 | 35 | 
| 30 // NOTE: While |prefix_| is used only for postfix suggestions, it still needs | 36 // 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 | 37 // 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 | 38 // to stay alive between the call to |drawTitle| and the actual paint event | 
| 33 // which accesses the |NSAttributedString| instance. | 39 // which accesses the |NSAttributedString| instance. | 
| 34 base::scoped_nsobject<NSAttributedString> prefix_; | 40 base::scoped_nsobject<NSAttributedString> prefix_; | 
| 35 | 41 | 
| 36 // The width of widest match contents in a set of infinite suggestions. | 42 // The width of widest match contents in a set of infinite suggestions. | 
| 37 CGFloat maxMatchContentsWidth_; | 43 CGFloat maxMatchContentsWidth_; | 
| 38 | 44 | 
| 39 // The offset at which the infinite suggesiton contents should be displayed. | 45 // The offset at which the infinite suggesiton contents should be displayed. | 
| 40 CGFloat contentsOffset_; | 46 CGFloat contentsOffset_; | 
| 41 } | 47 } | 
| 42 | 48 | 
| 49 @property(nonatomic, readwrite, retain) NSAttributedString* attributedTitle; | |
| 
 
groby-ooo-7-16
2015/05/07 02:39:58
No need to specify readwrite - it's default.
 
dschuyler
2015/05/07 20:53:09
Done.
 
 | |
| 50 | |
| 43 - (void)setMatch:(const AutocompleteMatch&)match; | 51 - (void)setMatch:(const AutocompleteMatch&)match; | 
| 44 | 52 | 
| 45 - (void)setMaxMatchContentsWidth:(CGFloat)maxMatchContentsWidth; | 53 - (void)setMaxMatchContentsWidth:(CGFloat)maxMatchContentsWidth; | 
| 46 | 54 | 
| 47 - (void)setContentsOffset:(CGFloat)contentsOffset; | 55 - (void)setContentsOffset:(CGFloat)contentsOffset; | 
| 48 | 56 | 
| 49 // Returns the width of the match contents. | 57 // Returns the width of the match contents. | 
| 50 - (CGFloat)getMatchContentsWidth; | 58 - (CGFloat)getMatchContentsWidth; | 
| 51 | 59 | 
| 52 // Returns the offset of the start of the contents in the input text for the | 60 // 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 | 61 // given match. It is costly to compute this offset, so it is computed once and | 
| 54 // shared by all OmniboxPopupCell instances through OmniboxPopupViewMac parent. | 62 // shared by all OmniboxPopupCell instances through OmniboxPopupViewMac parent. | 
| 55 + (CGFloat)computeContentsOffset:(const AutocompleteMatch&)match; | 63 + (CGFloat)computeContentsOffset:(const AutocompleteMatch&)match; | 
| 56 | 64 | 
| 57 @end | 65 @end | 
| 58 | 66 | 
| 59 #endif // CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_CELL_H_ | 67 #endif // CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_POPUP_CELL_H_ | 
| OLD | NEW |