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

Side by Side Diff: chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h

Issue 2478673002: [Mac] Hover/Pressed background for the Omnibox decorations (Closed)
Patch Set: Popup padding Created 4 years, 1 month 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 (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include <vector> 5 #include <vector>
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/mac/scoped_nsobject.h" 9 #include "base/mac/scoped_nsobject.h"
10 #import "chrome/browser/ui/cocoa/styled_text_field_cell.h" 10 #import "chrome/browser/ui/cocoa/styled_text_field_cell.h"
11 11
12 @class AutocompleteTextField; 12 @class AutocompleteTextField;
13 @class CrTrackingArea;
Robert Sesek 2016/11/11 19:35:07 Unused in this file?
spqchan 2016/11/12 00:36:19 Done.
13 class LocationBarDecoration; 14 class LocationBarDecoration;
14 15
15 // AutocompleteTextFieldCell extends StyledTextFieldCell to provide support for 16 // AutocompleteTextFieldCell extends StyledTextFieldCell to provide support for
16 // certain decorations to be applied to the field. These are the search hint 17 // certain decorations to be applied to the field. These are the search hint
17 // ("Type to search" on the right-hand side), the keyword hint ("Press [Tab] to 18 // ("Type to search" on the right-hand side), the keyword hint ("Press [Tab] to
18 // search Engine" on the right-hand side), and keyword mode ("Search Engine:" in 19 // search Engine" on the right-hand side), and keyword mode ("Search Engine:" in
19 // a button-like token on the left-hand side). 20 // a button-like token on the left-hand side).
20 @interface AutocompleteTextFieldCell : StyledTextFieldCell { 21 @interface AutocompleteTextFieldCell : StyledTextFieldCell {
21 @private 22 @private
22 // Decorations which live to the left and right of the text, ordered 23 // Decorations which live to the left and right of the text, ordered
23 // from outside in. Decorations are owned by |LocationBarViewMac|. 24 // from outside in. Decorations are owned by |LocationBarViewMac|.
24 std::vector<LocationBarDecoration*> leftDecorations_; 25 std::vector<LocationBarDecoration*> leftDecorations_;
25 std::vector<LocationBarDecoration*> rightDecorations_; 26 std::vector<LocationBarDecoration*> rightDecorations_;
26 27
28 // Decorations with tracking areas attached to the AutocompleteTextField.
29 std::vector<LocationBarDecoration*> mouseTrackingDecorations_;
30
27 // If YES then the text field will not draw a focus ring or show the insertion 31 // If YES then the text field will not draw a focus ring or show the insertion
28 // pointer. 32 // pointer.
29 BOOL hideFocusState_; 33 BOOL hideFocusState_;
30 34
31 // YES if this field is shown in a popup window. 35 // YES if this field is shown in a popup window.
32 BOOL isPopupMode_; 36 BOOL isPopupMode_;
33 37
34 // Retains the NSEvent that caused the controlView to become firstResponder. 38 // Retains the NSEvent that caused the controlView to become firstResponder.
35 base::scoped_nsobject<NSEvent> focusEvent_; 39 base::scoped_nsobject<NSEvent> focusEvent_;
36 40
37 // The coordinate system line width that draws a single pixel line. 41 // The coordinate system line width that draws a single pixel line.
38 CGFloat singlePixelLineWidth_; 42 CGFloat singlePixelLineWidth_;
39 } 43 }
40 44
41 @property(assign, nonatomic) BOOL isPopupMode; 45 @property(assign, nonatomic) BOOL isPopupMode;
42 @property(assign, nonatomic) CGFloat singlePixelLineWidth; 46 @property(assign, nonatomic) CGFloat singlePixelLineWidth;
43 47
44 // Line height used for text in this cell. 48 // Line height used for text in this cell.
45 - (CGFloat)lineHeight; 49 - (CGFloat)lineHeight;
46 50
51 // Remove all of the tracking areas.
52 - (void)clearTrackingArea;
53
47 // Clear |leftDecorations_| and |rightDecorations_|. 54 // Clear |leftDecorations_| and |rightDecorations_|.
48 - (void)clearDecorations; 55 - (void)clearDecorations;
49 56
50 // Add a new left-side decoration to the right of the existing 57 // Add a new left-side decoration to the right of the existing
51 // left-side decorations. 58 // left-side decorations.
52 - (void)addLeftDecoration:(LocationBarDecoration*)decoration; 59 - (void)addLeftDecoration:(LocationBarDecoration*)decoration;
53 60
54 // Add a new right-side decoration to the left of the existing 61 // Add a new right-side decoration to the left of the existing
55 // right-side decorations. 62 // right-side decorations.
56 - (void)addRightDecoration:(LocationBarDecoration*)decoration; 63 - (void)addRightDecoration:(LocationBarDecoration*)decoration;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 - (NSMenu*)decorationMenuForEvent:(NSEvent*)theEvent 95 - (NSMenu*)decorationMenuForEvent:(NSEvent*)theEvent
89 inRect:(NSRect)cellFrame 96 inRect:(NSRect)cellFrame
90 ofView:(AutocompleteTextField*)controlView; 97 ofView:(AutocompleteTextField*)controlView;
91 98
92 // Called by |AutocompleteTextField| to let page actions intercept 99 // Called by |AutocompleteTextField| to let page actions intercept
93 // clicks. Returns |YES| if the click has been intercepted. 100 // clicks. Returns |YES| if the click has been intercepted.
94 - (BOOL)mouseDown:(NSEvent*)theEvent 101 - (BOOL)mouseDown:(NSEvent*)theEvent
95 inRect:(NSRect)cellFrame 102 inRect:(NSRect)cellFrame
96 ofView:(AutocompleteTextField*)controlView; 103 ofView:(AutocompleteTextField*)controlView;
97 104
105 // Called by |AutocompleteTextField| to pass the mouse up event to the omnibox
106 // decorations.
107 - (void)mouseUp:(NSEvent*)theEvent
108 inRect:(NSRect)cellFrame
109 ofView:(AutocompleteTextField*)controlView;
110
98 // Overridden from StyledTextFieldCell to include decorations adjacent 111 // Overridden from StyledTextFieldCell to include decorations adjacent
99 // to the text area which don't handle mouse clicks themselves. 112 // to the text area which don't handle mouse clicks themselves.
100 // Keyword-search bubble, for instance. 113 // Keyword-search bubble, for instance.
101 - (NSRect)textCursorFrameForFrame:(NSRect)cellFrame; 114 - (NSRect)textCursorFrameForFrame:(NSRect)cellFrame;
102 115
103 // Setup decoration tooltips on |controlView| by calling 116 // Setup decoration tooltips and mouse tracking on |controlView| by calling
104 // |-addToolTip:forRect:|. 117 // |-addToolTip:forRect:| and |SetupTrackingArea()|.
105 - (void)updateToolTipsInRect:(NSRect)cellFrame 118 - (void)updateMouseTrackingAndToolTipsInRect:(NSRect)cellFrame
106 ofView:(AutocompleteTextField*)controlView; 119 ofView:
120 (AutocompleteTextField*)controlView;
107 121
108 // Gets and sets |hideFocusState|. This allows the text field to have focus but 122 // Gets and sets |hideFocusState|. This allows the text field to have focus but
109 // to appear unfocused. 123 // to appear unfocused.
110 - (BOOL)hideFocusState; 124 - (BOOL)hideFocusState;
111 - (void)setHideFocusState:(BOOL)hideFocusState 125 - (void)setHideFocusState:(BOOL)hideFocusState
112 ofView:(AutocompleteTextField*)controlView; 126 ofView:(AutocompleteTextField*)controlView;
113 127
114 // Handles the |event| that caused |controlView| to become firstResponder. 128 // Handles the |event| that caused |controlView| to become firstResponder.
115 - (void)handleFocusEvent:(NSEvent*)event 129 - (void)handleFocusEvent:(NSEvent*)event
116 ofView:(AutocompleteTextField*)controlView; 130 ofView:(AutocompleteTextField*)controlView;
117 @end 131 @end
132
133 // Methods which are either only for testing, or only public for testing.
134 @interface AutocompleteTextFieldCell (TestingAPI)
135
136 // Returns |mouseTrackingDecorations_|.
137 - (std::vector<LocationBarDecoration*>)mouseTrackingDecorations;
Robert Sesek 2016/11/11 19:35:07 Return as const& ?
spqchan 2016/11/12 00:36:19 Done.
138
139 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698