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

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

Issue 2555783002: [Mac] Ensure Omnibox text is always right-aligned in RTL (Closed)
Patch Set: Friend tests instead of exposing private method Created 4 years 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_VIEW_MAC_H_ 5 #ifndef CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_VIEW_MAC_H_
6 #define CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_VIEW_MAC_H_ 6 #define CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_VIEW_MAC_H_
7 7
8 #import <Cocoa/Cocoa.h> 8 #import <Cocoa/Cocoa.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 10
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 // If |resource_id| has a PDF image which can be used, return it. 126 // If |resource_id| has a PDF image which can be used, return it.
127 // Otherwise return the PNG image from the resource bundle. 127 // Otherwise return the PNG image from the resource bundle.
128 static NSImage* ImageForResource(int resource_id); 128 static NSImage* ImageForResource(int resource_id);
129 129
130 // Color used to draw suggest text. 130 // Color used to draw suggest text.
131 static NSColor* SuggestTextColor(); 131 static NSColor* SuggestTextColor();
132 132
133 AutocompleteTextField* field() const { return field_; } 133 AutocompleteTextField* field() const { return field_; }
134 134
135 private: 135 private:
136 FRIEND_TEST_ALL_PREFIXES(OmniboxViewMacTest,
Mark Mentovai 2016/12/12 17:45:24 #include "base/gtest_prod_util.h" for this macro.
lgrey 2016/12/12 18:13:33 Done.
137 WritingDirectionLTR);
138 FRIEND_TEST_ALL_PREFIXES(OmniboxViewMacTest,
139 WritingDirectionRTL);
136 // Called when the user hits backspace in |field_|. Checks whether 140 // Called when the user hits backspace in |field_|. Checks whether
137 // keyword search is being terminated. Returns true if the 141 // keyword search is being terminated. Returns true if the
138 // backspace should be intercepted (not forwarded on to the standard 142 // backspace should be intercepted (not forwarded on to the standard
139 // machinery). 143 // machinery).
140 bool OnBackspacePressed(); 144 bool OnBackspacePressed();
141 145
142 // Returns the field's currently selected range. Only valid if the 146 // Returns the field's currently selected range. Only valid if the
143 // field has focus. 147 // field has focus.
144 NSRange GetSelectedRange() const; 148 NSRange GetSelectedRange() const;
145 149
(...skipping 20 matching lines...) Expand all
166 170
167 // Update the field with |display_text| and set the selection. 171 // Update the field with |display_text| and set the selection.
168 void SetTextAndSelectedRange(const base::string16& display_text, 172 void SetTextAndSelectedRange(const base::string16& display_text,
169 const NSRange range); 173 const NSRange range);
170 174
171 // Pass the current content of |field_| to SetText(), maintaining 175 // Pass the current content of |field_| to SetText(), maintaining
172 // any selection. Named to be consistent with GTK and Windows, 176 // any selection. Named to be consistent with GTK and Windows,
173 // though here we cannot really do the in-place operation they do. 177 // though here we cannot really do the in-place operation they do.
174 void EmphasizeURLComponents() override; 178 void EmphasizeURLComponents() override;
175 179
176 // Apply our font and paragraph style to |attributedString|.
177 void ApplyTextStyle(NSMutableAttributedString* attributedString);
178
179 // Calculates text attributes according to |display_text| and applies them 180 // Calculates text attributes according to |display_text| and applies them
180 // to the given |attributedString| object. 181 // to the given |attributedString| object.
181 void ApplyTextAttributes(const base::string16& display_text, 182 void ApplyTextAttributes(const base::string16& display_text,
182 NSMutableAttributedString* attributedString); 183 NSMutableAttributedString* attributedString);
183 184
185 // Apply our font and paragraph style to |attributedString|.
186 void ApplyTextStyle(NSMutableAttributedString* attributedString);
Mark Mentovai 2016/12/12 17:45:24 I don’t see why this needs to move.
lgrey 2016/12/12 18:13:33 Accidentally put it back in the wrong place after
187
184 // Return the number of UTF-16 units in the current buffer, excluding the 188 // Return the number of UTF-16 units in the current buffer, excluding the
185 // suggested text. 189 // suggested text.
186 int GetOmniboxTextLength() const override; 190 int GetOmniboxTextLength() const override;
187 NSUInteger GetTextLength() const; 191 NSUInteger GetTextLength() const;
188 192
189 // Returns true if the caret is at the end of the content. 193 // Returns true if the caret is at the end of the content.
190 bool IsCaretAtEnd() const; 194 bool IsCaretAtEnd() const;
191 195
192 // Announce that an inline autocomplete is available for screenreaders. 196 // Announce that an inline autocomplete is available for screenreaders.
193 void AnnounceAutocompleteForScreenReader(const base::string16& text); 197 void AnnounceAutocompleteForScreenReader(const base::string16& text);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 // painted. Used to measure omnibox responsiveness with a histogram. 229 // painted. Used to measure omnibox responsiveness with a histogram.
226 base::TimeTicks insert_char_time_; 230 base::TimeTicks insert_char_time_;
227 231
228 // The time when OnBeforeDrawRect() was called. 232 // The time when OnBeforeDrawRect() was called.
229 base::TimeTicks draw_rect_start_time_; 233 base::TimeTicks draw_rect_start_time_;
230 234
231 DISALLOW_COPY_AND_ASSIGN(OmniboxViewMac); 235 DISALLOW_COPY_AND_ASSIGN(OmniboxViewMac);
232 }; 236 };
233 237
234 #endif // CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_VIEW_MAC_H_ 238 #endif // CHROME_BROWSER_UI_COCOA_OMNIBOX_OMNIBOX_VIEW_MAC_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698