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

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

Issue 7108024: Make selection in omnibox break at periods. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 9 years, 6 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 | « no previous file | 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 bb565a35a09adc72e95c7dd96071cdc1f6ff24a1..810d875c9931cf9085cbc98273c2a078d28851a4 100644
--- a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm
+++ b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm
@@ -532,8 +532,16 @@ void OmniboxViewMac::EmphasizeURLComponents() {
void OmniboxViewMac::ApplyTextAttributes(const string16& display_text,
NSMutableAttributedString* as) {
+ NSUInteger as_length = [as length];
+ NSRange as_entire_string = NSMakeRange(0, as_length);
+
[as addAttribute:NSFontAttributeName value:GetFieldFont()
- range:NSMakeRange(0, [as length])];
+ 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];
// Make a paragraph style locking in the standard line height as the maximum,
// otherwise the baseline may shift "downwards".
@@ -541,11 +549,11 @@ void OmniboxViewMac::ApplyTextAttributes(const string16& display_text,
paragraph_style([[NSMutableParagraphStyle alloc] init]);
[paragraph_style setMaximumLineHeight:line_height_];
[as addAttribute:NSParagraphStyleAttributeName value:paragraph_style
- range:NSMakeRange(0, [as length])];
+ range:as_entire_string];
// Grey out the suggest text.
[as addAttribute:NSForegroundColorAttributeName value:SuggestTextColor()
- range:NSMakeRange([as length] - suggest_text_length_,
+ range:NSMakeRange(as_length - suggest_text_length_,
suggest_text_length_)];
url_parse::Component scheme, host;
@@ -554,7 +562,7 @@ void OmniboxViewMac::ApplyTextAttributes(const string16& display_text,
const bool emphasize = model_->CurrentTextIsURL() && (host.len > 0);
if (emphasize) {
[as addAttribute:NSForegroundColorAttributeName value:BaseTextColor()
- range:NSMakeRange(0, [as length])];
+ range:as_entire_string];
[as addAttribute:NSForegroundColorAttributeName value:HostTextColor()
range:ComponentToNSRange(host)];
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698