Chromium Code Reviews| Index: chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.mm |
| diff --git a/chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.mm b/chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.mm |
| index df7b00d3bc6b1c315e1189e80962b1cd23eb322c..ce3701117f6847949c294c20d1f6f5e1c45bbf3c 100644 |
| --- a/chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.mm |
| +++ b/chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.mm |
| @@ -155,18 +155,16 @@ NSAttributedString* CreateClassifiedAttributedString( |
| } // namespace |
| +@implementation AutocompleteMatchWrapper |
| +@end |
| + |
| @implementation OmniboxPopupCell |
| +@synthesize attributedTitle; |
| + |
| - (id)init { |
| self = [super init]; |
| if (self) { |
| - [self setImagePosition:NSImageLeft]; |
| - [self setBordered:NO]; |
| - [self setButtonType:NSRadioButton]; |
| - |
| - // Without this highlighting messes up white areas of images. |
| - [self setHighlightsBy:NSNoCellMask]; |
| - |
| const base::string16& raw_separator = |
| l10n_util::GetStringUTF16(IDS_AUTOCOMPLETE_MATCH_DESCRIPTION_SEPARATOR); |
| separator_.reset( |
| @@ -205,6 +203,23 @@ NSAttributedString* CreateClassifiedAttributedString( |
| } |
| } |
| +- (id)copyWithZone:(NSZone*)zone { |
| + NSAttributedString* separator = separator_.release(); |
| + NSAttributedString* description = description_.release(); |
| + NSAttributedString* prefix = prefix_.release(); |
|
Scott Hess - ex-Googler
2015/05/07 22:35:42
This is an unexpected approach. Why do you need t
groby-ooo-7-16
2015/05/08 03:24:08
This is here due to NSCopyObject. NSCell uses that
Scott Hess - ex-Googler
2015/05/08 04:11:48
W. T. F.
In that case, might I suggest:
scope
groby-ooo-7-16
2015/05/08 05:08:29
I hate to be the contrarian, but...
Assume a sep
Scott Hess - ex-Googler
2015/05/08 06:00:13
Alternative 3:
scoped_nsobject<NSAttributedStrin
groby-ooo-7-16
2015/05/08 06:20:43
I like the symmetry of #3. I'm reasonably certain
Scott Hess - ex-Googler
2015/05/08 18:25:49
Another option which just occurred to me would be
|
| + OmniboxPopupCell* copy = [super copyWithZone:zone]; |
| + copy->match_ = match_; |
| + copy->separator_.reset([separator copy]); |
|
groby-ooo-7-16
2015/05/08 03:24:08
You technically don't need to copy the NSAttribute
Scott Hess - ex-Googler
2015/05/08 04:11:48
If they aren't mutable, then -copy should be imple
|
| + copy->description_.reset([description copy]); |
| + copy->prefix_.reset([prefix copy]); |
| + copy->maxMatchContentsWidth_ = maxMatchContentsWidth_; |
| + copy->contentsOffset_ = contentsOffset_; |
| + separator_.reset(separator); |
| + description_.reset(description); |
| + prefix_.reset(prefix); |
| + return copy; |
| +} |
| + |
| - (void)setMaxMatchContentsWidth:(CGFloat)maxMatchContentsWidth { |
| maxMatchContentsWidth_ = maxMatchContentsWidth; |
| } |
| @@ -353,10 +368,11 @@ NSAttributedString* CreateClassifiedAttributedString( |
| NSRect renderRect = ShiftRect(cellFrame, offset); |
| renderRect.size.width = |
| std::min(NSWidth(renderRect), static_cast<CGFloat>(maxWidth)); |
| + NSRect textRect = [as boundingRectWithSize:renderRect.size options:nil]; |
| + renderRect.origin.y += std::floor((NSHeight(cellFrame) - NSHeight(textRect)) |
| + / 2.0); |
|
Scott Hess - ex-Googler
2015/05/07 22:35:42
As long as you're on two lines, just pull everythi
dschuyler
2015/05/13 01:41:11
Done.
|
| if (renderRect.size.width != 0) { |
| - [self drawTitle:as |
| - withFrame:FlipIfRTL(renderRect, cellFrame) |
| - inView:controlView]; |
| + [as drawInRect:FlipIfRTL(renderRect, cellFrame)]; |
|
Scott Hess - ex-Googler
2015/05/07 22:35:42
I think the style in here is to drop the {} when i
dschuyler
2015/05/13 01:41:11
Done.
|
| } |
| return NSWidth(renderRect); |
| } |