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

Side by Side Diff: chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.mm

Issue 8917011: Change signature of |ui::ElideText()|. Add a truncate mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h" 5 #include "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/sys_string_conversions.h" 10 #include "base/sys_string_conversions.h"
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 NSMutableAttributedString* aString, 157 NSMutableAttributedString* aString,
158 const string16 originalString, 158 const string16 originalString,
159 const gfx::Font& font, 159 const gfx::Font& font,
160 const float width) { 160 const float width) {
161 // If it already fits, nothing to be done. 161 // If it already fits, nothing to be done.
162 if ([aString size].width <= width) { 162 if ([aString size].width <= width) {
163 return aString; 163 return aString;
164 } 164 }
165 165
166 // If ElideText() decides to do nothing, nothing to be done. 166 // If ElideText() decides to do nothing, nothing to be done.
167 const string16 elided = ui::ElideText(originalString, font, width, false); 167 const string16 elided =
168 ui::ElideText(originalString, font, width, ui::ELIDE_AT_END);
168 if (0 == elided.compare(originalString)) { 169 if (0 == elided.compare(originalString)) {
169 return aString; 170 return aString;
170 } 171 }
171 172
172 // If everything was elided away, clear the string. 173 // If everything was elided away, clear the string.
173 if (elided.empty()) { 174 if (elided.empty()) {
174 [aString deleteCharactersInRange:NSMakeRange(0, [aString length])]; 175 [aString deleteCharactersInRange:NSMakeRange(0, [aString length])];
175 return aString; 176 return aString;
176 } 177 }
177 178
(...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 bottomLeftCornerRadius:kPopupRoundingRadius 825 bottomLeftCornerRadius:kPopupRoundingRadius
825 bottomRightCornerRadius:kPopupRoundingRadius]; 826 bottomRightCornerRadius:kPopupRoundingRadius];
826 827
827 // Draw the matrix clipped to our border. 828 // Draw the matrix clipped to our border.
828 gfx::ScopedNSGraphicsContextSaveGState scopedGState; 829 gfx::ScopedNSGraphicsContextSaveGState scopedGState;
829 [path addClip]; 830 [path addClip];
830 [super drawRect:rect]; 831 [super drawRect:rect];
831 } 832 }
832 833
833 @end 834 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698