OLD | NEW |
---|---|
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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 } | 96 } |
97 static NSColor* URLTextColor() { | 97 static NSColor* URLTextColor() { |
98 return [NSColor colorWithCalibratedRed:0.0 green:0.55 blue:0.0 alpha:1.0]; | 98 return [NSColor colorWithCalibratedRed:0.0 green:0.55 blue:0.0 alpha:1.0]; |
99 } | 99 } |
100 } // namespace | 100 } // namespace |
101 | 101 |
102 // Helper for MatchText() to allow sharing code between the contents | 102 // Helper for MatchText() to allow sharing code between the contents |
103 // and description cases. Returns NSMutableAttributedString as a | 103 // and description cases. Returns NSMutableAttributedString as a |
104 // convenience for MatchText(). | 104 // convenience for MatchText(). |
105 NSMutableAttributedString* OmniboxPopupViewMac::DecorateMatchedString( | 105 NSMutableAttributedString* OmniboxPopupViewMac::DecorateMatchedString( |
106 const string16 &matchString, | 106 const string16& matchStringIn, |
107 const AutocompleteMatch::ACMatchClassifications &classifications, | 107 const AutocompleteMatch::ACMatchClassifications &classifications, |
108 NSColor* textColor, NSColor* dimTextColor, gfx::Font& font) { | 108 NSColor* textColor, NSColor* dimTextColor, gfx::Font& font) { |
109 // Cache for on-demand computation of the bold version of |font|. | 109 // Cache for on-demand computation of the bold version of |font|. |
110 NSFont* boldFont = nil; | 110 NSFont* boldFont = nil; |
111 | 111 |
112 string16 matchString; | |
113 const char16 kNewlineChar[] = { '\n', '\0' }; | |
114 RemoveChars(matchStringIn, kNewlineChar, &matchString); | |
Scott Hess - ex-Googler
2011/10/20 19:54:03
Should this remove the newline, or convert it to a
| |
115 | |
112 // Start out with a string using the default style info. | 116 // Start out with a string using the default style info. |
113 NSString* s = base::SysUTF16ToNSString(matchString); | 117 NSString* s = base::SysUTF16ToNSString(matchString); |
114 NSDictionary* attributes = [NSDictionary dictionaryWithObjectsAndKeys: | 118 NSDictionary* attributes = [NSDictionary dictionaryWithObjectsAndKeys: |
115 font.GetNativeFont(), NSFontAttributeName, | 119 font.GetNativeFont(), NSFontAttributeName, |
116 textColor, NSForegroundColorAttributeName, | 120 textColor, NSForegroundColorAttributeName, |
117 nil]; | 121 nil]; |
118 NSMutableAttributedString* as = | 122 NSMutableAttributedString* as = |
119 [[[NSMutableAttributedString alloc] initWithString:s | 123 [[[NSMutableAttributedString alloc] initWithString:s |
120 attributes:attributes] | 124 attributes:attributes] |
121 autorelease]; | 125 autorelease]; |
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
824 bottomLeftCornerRadius:kPopupRoundingRadius | 828 bottomLeftCornerRadius:kPopupRoundingRadius |
825 bottomRightCornerRadius:kPopupRoundingRadius]; | 829 bottomRightCornerRadius:kPopupRoundingRadius]; |
826 | 830 |
827 // Draw the matrix clipped to our border. | 831 // Draw the matrix clipped to our border. |
828 gfx::ScopedNSGraphicsContextSaveGState scopedGState; | 832 gfx::ScopedNSGraphicsContextSaveGState scopedGState; |
829 [path addClip]; | 833 [path addClip]; |
830 [super drawRect:rect]; | 834 [super drawRect:rect]; |
831 } | 835 } |
832 | 836 |
833 @end | 837 @end |
OLD | NEW |