Commit 37547d00 authored by avi@chromium.org's avatar avi@chromium.org

Make selection in omnibox break at periods.

BUG=28145
TEST=as in bug

Review URL: http://codereview.chromium.org/7108024

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88639 0039d316-1c4b-4281-b951-d872f2087c98
parent cf9aa046
...@@ -532,8 +532,16 @@ void OmniboxViewMac::EmphasizeURLComponents() { ...@@ -532,8 +532,16 @@ void OmniboxViewMac::EmphasizeURLComponents() {
void OmniboxViewMac::ApplyTextAttributes(const string16& display_text, void OmniboxViewMac::ApplyTextAttributes(const string16& display_text,
NSMutableAttributedString* as) { NSMutableAttributedString* as) {
NSUInteger as_length = [as length];
NSRange as_entire_string = NSMakeRange(0, as_length);
[as addAttribute:NSFontAttributeName value:GetFieldFont() [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, // Make a paragraph style locking in the standard line height as the maximum,
// otherwise the baseline may shift "downwards". // otherwise the baseline may shift "downwards".
...@@ -541,11 +549,11 @@ void OmniboxViewMac::ApplyTextAttributes(const string16& display_text, ...@@ -541,11 +549,11 @@ void OmniboxViewMac::ApplyTextAttributes(const string16& display_text,
paragraph_style([[NSMutableParagraphStyle alloc] init]); paragraph_style([[NSMutableParagraphStyle alloc] init]);
[paragraph_style setMaximumLineHeight:line_height_]; [paragraph_style setMaximumLineHeight:line_height_];
[as addAttribute:NSParagraphStyleAttributeName value:paragraph_style [as addAttribute:NSParagraphStyleAttributeName value:paragraph_style
range:NSMakeRange(0, [as length])]; range:as_entire_string];
// Grey out the suggest text. // Grey out the suggest text.
[as addAttribute:NSForegroundColorAttributeName value:SuggestTextColor() [as addAttribute:NSForegroundColorAttributeName value:SuggestTextColor()
range:NSMakeRange([as length] - suggest_text_length_, range:NSMakeRange(as_length - suggest_text_length_,
suggest_text_length_)]; suggest_text_length_)];
url_parse::Component scheme, host; url_parse::Component scheme, host;
...@@ -554,7 +562,7 @@ void OmniboxViewMac::ApplyTextAttributes(const string16& display_text, ...@@ -554,7 +562,7 @@ void OmniboxViewMac::ApplyTextAttributes(const string16& display_text,
const bool emphasize = model_->CurrentTextIsURL() && (host.len > 0); const bool emphasize = model_->CurrentTextIsURL() && (host.len > 0);
if (emphasize) { if (emphasize) {
[as addAttribute:NSForegroundColorAttributeName value:BaseTextColor() [as addAttribute:NSForegroundColorAttributeName value:BaseTextColor()
range:NSMakeRange(0, [as length])]; range:as_entire_string];
[as addAttribute:NSForegroundColorAttributeName value:HostTextColor() [as addAttribute:NSForegroundColorAttributeName value:HostTextColor()
range:ComponentToNSRange(host)]; range:ComponentToNSRange(host)];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment