| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |