Chromium Code Reviews| Index: chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm |
| diff --git a/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm b/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm |
| index a2952039b42c22629a30f2bda87fd7fa038feef4..b6edcf93330a3dc6b9922a93e7e7fc6aa4e5e154 100644 |
| --- a/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm |
| +++ b/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm |
| @@ -283,13 +283,6 @@ const CGFloat kAnimationDuration = 0.2; |
| [self addToolTipRect:aRect owner:tooltip userData:nil]; |
| } |
| -- (void)setGrayTextAutocompletion:(NSString*)suggestText |
| - textColor:(NSColor*)suggestColor { |
| - [self setNeedsDisplay:YES]; |
| - suggestText_.reset([suggestText retain]); |
|
Peter Kasting
2016/11/21 21:11:43
I would assume suggestText_ and suggestColor_, and
Marc Treib
2016/11/22 10:35:30
Done.
|
| - suggestColor_.reset([suggestColor retain]); |
| -} |
| - |
| - (NSString*)suggestText { |
| return suggestText_; |
| } |
| @@ -493,16 +486,6 @@ const CGFloat kAnimationDuration = 0.2; |
| return doResign; |
| } |
| -- (void)drawRect:(NSRect)rect { |
| - [super drawRect:rect]; |
| - autocomplete_text_field::DrawGrayTextAutocompletion( |
| - [self attributedStringValue], |
| - suggestText_, |
| - suggestColor_, |
| - self, |
| - [[self cell] drawingRectForBounds:[self bounds]]); |
| -} |
| - |
| // (URLDropTarget protocol) |
| - (id<URLDropTargetController>)urlDropController { |
| BrowserWindowController* windowController = |
| @@ -563,42 +546,3 @@ const CGFloat kAnimationDuration = 0.2; |
| } |
| @end |
| - |
| -namespace autocomplete_text_field { |
| - |
| -void DrawGrayTextAutocompletion(NSAttributedString* mainText, |
| - NSString* suggestText, |
| - NSColor* suggestColor, |
| - NSView* controlView, |
| - NSRect frame) { |
| - if (![suggestText length]) |
| - return; |
| - |
| - base::scoped_nsobject<NSTextFieldCell> cell( |
| - [[NSTextFieldCell alloc] initTextCell:@""]); |
| - [cell setBordered:NO]; |
| - [cell setDrawsBackground:NO]; |
| - [cell setEditable:NO]; |
| - |
| - base::scoped_nsobject<NSMutableAttributedString> combinedText( |
| - [[NSMutableAttributedString alloc] initWithAttributedString:mainText]); |
| - NSRange range = NSMakeRange([combinedText length], 0); |
| - [combinedText replaceCharactersInRange:range withString:suggestText]; |
| - [combinedText addAttribute:NSForegroundColorAttributeName |
| - value:suggestColor |
| - range:NSMakeRange(range.location, [suggestText length])]; |
| - [cell setAttributedStringValue:combinedText]; |
| - |
| - CGFloat mainTextWidth = [mainText size].width; |
| - CGFloat suggestWidth = NSWidth(frame) - mainTextWidth; |
| - NSRect suggestRect = NSMakeRect(NSMinX(frame) + mainTextWidth, |
| - NSMinY(frame), |
| - suggestWidth, |
| - NSHeight(frame)); |
| - |
| - gfx::ScopedNSGraphicsContextSaveGState saveGState; |
| - NSRectClip(suggestRect); |
| - [cell drawInteriorWithFrame:frame inView:controlView]; |
| -} |
| - |
| -} // namespace autocomplete_text_field |