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

Unified Diff: chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm

Issue 920243002: Mac: Fix omnibox hint text is 1px lower than typed text. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dragging-window-drawing
Patch Set: Created 5 years, 10 months 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
« no previous file with comments | « chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm
diff --git a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm
index d08a756a49c74f383743b22209859e8775cd595d..48b7cc905df833ae28fdb1d63bc693a4d7eabc5c 100644
--- a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm
+++ b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm
@@ -241,13 +241,13 @@ void OmniboxViewMac::UpdatePlaceholderText() {
if (chrome::ShouldDisplayOriginChip() ||
OmniboxFieldTrial::DisplayHintTextWhenPossible()) {
NSDictionary* placeholder_attributes = @{
- NSFontAttributeName : GetFieldFont(gfx::Font::NORMAL),
NSForegroundColorAttributeName : [NSColor disabledControlTextColor]
};
base::scoped_nsobject<NSMutableAttributedString> placeholder_text(
[[NSMutableAttributedString alloc]
initWithString:base::SysUTF16ToNSString(GetHintText())
attributes:placeholder_attributes]);
+ ApplyTextStyle(placeholder_text);
[[field_ cell] setPlaceholderAttributedString:placeholder_text];
}
}
@@ -481,18 +481,9 @@ void OmniboxViewMac::EmphasizeURLComponents() {
}
}
-void OmniboxViewMac::ApplyTextAttributes(const base::string16& display_text,
- NSMutableAttributedString* as) {
- NSUInteger as_length = [as length];
- NSRange as_entire_string = NSMakeRange(0, as_length);
-
+void OmniboxViewMac::ApplyTextStyle(NSMutableAttributedString* as) {
[as addAttribute:NSFontAttributeName value:GetFieldFont(gfx::Font::NORMAL)
- range:as_entire_string];
-
- // A kinda hacky way to add breaking at periods. This is what Safari does.
- // This works for IDNs too, despite the "en_US".
- [as addAttribute:@"NSLanguage" value:@"en_US_POSIX"
- range:as_entire_string];
+ range:NSMakeRange(0, [as length])];
// Make a paragraph style locking in the standard line height as the maximum,
// otherwise the baseline may shift "downwards".
@@ -503,6 +494,19 @@ void OmniboxViewMac::ApplyTextAttributes(const base::string16& display_text,
[paragraph_style setMinimumLineHeight:line_height];
[paragraph_style setLineBreakMode:NSLineBreakByTruncatingTail];
[as addAttribute:NSParagraphStyleAttributeName value:paragraph_style
+ range:NSMakeRange(0, [as length])];
+}
+
+void OmniboxViewMac::ApplyTextAttributes(const base::string16& display_text,
+ NSMutableAttributedString* as) {
+ NSUInteger as_length = [as length];
+ NSRange as_entire_string = NSMakeRange(0, as_length);
+
+ ApplyTextStyle(as);
+
+ // A kinda hacky way to add breaking at periods. This is what Safari does.
+ // This works for IDNs too, despite the "en_US".
+ [as addAttribute:@"NSLanguage" value:@"en_US_POSIX"
range:as_entire_string];
url::Component scheme, host;
« no previous file with comments | « chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698