OLD | NEW |
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 <cmath> | 5 #include <cmath> |
6 | 6 |
7 #include "chrome/browser/autocomplete/autocomplete_popup_view_mac.h" | 7 #include "chrome/browser/autocomplete/autocomplete_popup_view_mac.h" |
8 | 8 |
9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 return aString; | 162 return aString; |
163 } | 163 } |
164 | 164 |
165 // If ElideText() decides to do nothing, nothing to be done. | 165 // If ElideText() decides to do nothing, nothing to be done. |
166 const string16 elided = ui::ElideText(originalString, font, width, false); | 166 const string16 elided = ui::ElideText(originalString, font, width, false); |
167 if (0 == elided.compare(originalString)) { | 167 if (0 == elided.compare(originalString)) { |
168 return aString; | 168 return aString; |
169 } | 169 } |
170 | 170 |
171 // If everything was elided away, clear the string. | 171 // If everything was elided away, clear the string. |
172 if (elided.size() == 0) { | 172 if (elided.empty()) { |
173 [aString deleteCharactersInRange:NSMakeRange(0, [aString length])]; | 173 [aString deleteCharactersInRange:NSMakeRange(0, [aString length])]; |
174 return aString; | 174 return aString; |
175 } | 175 } |
176 | 176 |
177 // The ellipses should be the last character, and everything before | 177 // The ellipses should be the last character, and everything before |
178 // that should match the original string. | 178 // that should match the original string. |
179 const size_t i(elided.size() - 1); | 179 const size_t i(elided.size() - 1); |
180 DCHECK_NE(0, elided.compare(0, i, originalString)); | 180 DCHECK_NE(0, elided.compare(0, i, originalString)); |
181 | 181 |
182 // Replace the end of |aString| with the ellipses from |elided|. | 182 // Replace the end of |aString| with the ellipses from |elided|. |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 bottomRightCornerRadius:kPopupRoundingRadius]; | 821 bottomRightCornerRadius:kPopupRoundingRadius]; |
822 | 822 |
823 // Draw the matrix clipped to our border. | 823 // Draw the matrix clipped to our border. |
824 [NSGraphicsContext saveGraphicsState]; | 824 [NSGraphicsContext saveGraphicsState]; |
825 [path addClip]; | 825 [path addClip]; |
826 [super drawRect:rect]; | 826 [super drawRect:rect]; |
827 [NSGraphicsContext restoreGraphicsState]; | 827 [NSGraphicsContext restoreGraphicsState]; |
828 } | 828 } |
829 | 829 |
830 @end | 830 @end |
OLD | NEW |