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

Side by Side Diff: chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm

Issue 23441027: Set line break mode for omnibox field editor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" 5 #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h"
6 6
7 #include <Carbon/Carbon.h> // kVK_Return 7 #include <Carbon/Carbon.h> // kVK_Return
8 8
9 #include "base/mac/foundation_util.h" 9 #include "base/mac/foundation_util.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 [as addAttribute:@"NSLanguage" value:@"en_US_POSIX" 423 [as addAttribute:@"NSLanguage" value:@"en_US_POSIX"
424 range:as_entire_string]; 424 range:as_entire_string];
425 425
426 // Make a paragraph style locking in the standard line height as the maximum, 426 // Make a paragraph style locking in the standard line height as the maximum,
427 // otherwise the baseline may shift "downwards". 427 // otherwise the baseline may shift "downwards".
428 base::scoped_nsobject<NSMutableParagraphStyle> paragraph_style( 428 base::scoped_nsobject<NSMutableParagraphStyle> paragraph_style(
429 [[NSMutableParagraphStyle alloc] init]); 429 [[NSMutableParagraphStyle alloc] init]);
430 CGFloat line_height = [[field_ cell] lineHeight]; 430 CGFloat line_height = [[field_ cell] lineHeight];
431 [paragraph_style setMaximumLineHeight:line_height]; 431 [paragraph_style setMaximumLineHeight:line_height];
432 [paragraph_style setMinimumLineHeight:line_height]; 432 [paragraph_style setMinimumLineHeight:line_height];
433 [paragraph_style setLineBreakMode:NSLineBreakByTruncatingTail];
433 [as addAttribute:NSParagraphStyleAttributeName value:paragraph_style 434 [as addAttribute:NSParagraphStyleAttributeName value:paragraph_style
434 range:as_entire_string]; 435 range:as_entire_string];
435 436
436 url_parse::Component scheme, host; 437 url_parse::Component scheme, host;
437 AutocompleteInput::ParseForEmphasizeComponents( 438 AutocompleteInput::ParseForEmphasizeComponents(
438 display_text, &scheme, &host); 439 display_text, &scheme, &host);
439 bool grey_out_url = display_text.substr(scheme.begin, scheme.len) == 440 bool grey_out_url = display_text.substr(scheme.begin, scheme.len) ==
440 UTF8ToUTF16(extensions::kExtensionScheme); 441 UTF8ToUTF16(extensions::kExtensionScheme);
441 if (model()->CurrentTextIsURL() && 442 if (model()->CurrentTextIsURL() &&
442 (host.is_nonempty() || grey_out_url)) { 443 (host.is_nonempty() || grey_out_url)) {
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 942
942 NSUInteger OmniboxViewMac::GetTextLength() const { 943 NSUInteger OmniboxViewMac::GetTextLength() const {
943 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : 944 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] :
944 [[field_ stringValue] length]; 945 [[field_ stringValue] length];
945 } 946 }
946 947
947 bool OmniboxViewMac::IsCaretAtEnd() const { 948 bool OmniboxViewMac::IsCaretAtEnd() const {
948 const NSRange selection = GetSelectedRange(); 949 const NSRange selection = GetSelectedRange();
949 return NSMaxRange(selection) == GetTextLength(); 950 return NSMaxRange(selection) == GetTextLength();
950 } 951 }
OLDNEW
« 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