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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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.size() == 0) { |
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(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|. |
183 NSString* s = base::SysUTF16ToNSString(elided.substr(i)); | 183 NSString* s = base::SysUTF16ToNSString(elided.substr(i)); |
184 [aString replaceCharactersInRange:NSMakeRange(i, [aString length] - i) | 184 [aString replaceCharactersInRange:NSMakeRange(i, [aString length] - i) |
185 withString:s]; | 185 withString:s]; |
186 | 186 |
187 return aString; | 187 return aString; |
188 } | 188 } |
189 | 189 |
190 // Return the text to show for the match, based on the match's | 190 // Return the text to show for the match, based on the match's |
(...skipping 630 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 |