Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1683)

Unified Diff: chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm

Issue 2510373003: Cleanup: Remove "gray text" logic from Omnibox (Closed)
Patch Set: mac Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698