| 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 "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
| 10 #include "app/text_elider.h" | 10 #include "app/text_elider.h" |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 popup_.reset(nil); | 442 popup_.reset(nil); |
| 443 | 443 |
| 444 return; | 444 return; |
| 445 } | 445 } |
| 446 | 446 |
| 447 CreatePopupIfNeeded(); | 447 CreatePopupIfNeeded(); |
| 448 | 448 |
| 449 // The popup's font is a slightly smaller version of the field's. | 449 // The popup's font is a slightly smaller version of the field's. |
| 450 NSFont* fieldFont = AutocompleteEditViewMac::GetFieldFont(); | 450 NSFont* fieldFont = AutocompleteEditViewMac::GetFieldFont(); |
| 451 const CGFloat resultFontSize = [fieldFont pointSize] + kEditFontAdjust; | 451 const CGFloat resultFontSize = [fieldFont pointSize] + kEditFontAdjust; |
| 452 gfx::Font resultFont(base::SysNSStringToWide([fieldFont fontName]), | 452 gfx::Font resultFont(base::SysNSStringToUTF16([fieldFont fontName]), |
| 453 static_cast<int>(resultFontSize)); | 453 static_cast<int>(resultFontSize)); |
| 454 | 454 |
| 455 AutocompleteMatrix* matrix = GetAutocompleteMatrix(); | 455 AutocompleteMatrix* matrix = GetAutocompleteMatrix(); |
| 456 | 456 |
| 457 // Calculate the width of the matrix based on backing out the | 457 // Calculate the width of the matrix based on backing out the |
| 458 // popup's border from the width of the field. Would prefer to use | 458 // popup's border from the width of the field. Would prefer to use |
| 459 // [matrix convertSize:fromView:] for converting from screen size, | 459 // [matrix convertSize:fromView:] for converting from screen size, |
| 460 // but that doesn't work until the popup is on-screen (bug?). | 460 // but that doesn't work until the popup is on-screen (bug?). |
| 461 const NSRect fieldRectBase = [field_ convertRect:[field_ bounds] toView:nil]; | 461 const NSRect fieldRectBase = [field_ convertRect:[field_ bounds] toView:nil]; |
| 462 const CGFloat popupWidth = NSWidth(fieldRectBase) - 2 * kWindowBorderWidth; | 462 const CGFloat popupWidth = NSWidth(fieldRectBase) - 2 * kWindowBorderWidth; |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 bottomRightCornerRadius:kPopupRoundingRadius]; | 827 bottomRightCornerRadius:kPopupRoundingRadius]; |
| 828 | 828 |
| 829 // Draw the matrix clipped to our border. | 829 // Draw the matrix clipped to our border. |
| 830 [NSGraphicsContext saveGraphicsState]; | 830 [NSGraphicsContext saveGraphicsState]; |
| 831 [path addClip]; | 831 [path addClip]; |
| 832 [super drawRect:rect]; | 832 [super drawRect:rect]; |
| 833 [NSGraphicsContext restoreGraphicsState]; | 833 [NSGraphicsContext restoreGraphicsState]; |
| 834 } | 834 } |
| 835 | 835 |
| 836 @end | 836 @end |
| OLD | NEW |