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

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

Issue 17593006: mac: Update clients of scoped_nsobject.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: iwyu, scoped_nsprotocol Created 7 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 unified diff | Download patch | Annotate | Revision Log
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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 popup_view_(OmniboxPopupViewMac::Create(this, model(), field)), 142 popup_view_(OmniboxPopupViewMac::Create(this, model(), field)),
143 field_(field), 143 field_(field),
144 delete_was_pressed_(false), 144 delete_was_pressed_(false),
145 delete_at_end_pressed_(false) { 145 delete_at_end_pressed_(false) {
146 [field_ setObserver:this]; 146 [field_ setObserver:this];
147 147
148 // Needed so that editing doesn't lose the styling. 148 // Needed so that editing doesn't lose the styling.
149 [field_ setAllowsEditingTextAttributes:YES]; 149 [field_ setAllowsEditingTextAttributes:YES];
150 150
151 // Get the appropriate line height for the font that we use. 151 // Get the appropriate line height for the font that we use.
152 scoped_nsobject<NSLayoutManager> 152 base::scoped_nsobject<NSLayoutManager> layoutManager(
153 layoutManager([[NSLayoutManager alloc] init]); 153 [[NSLayoutManager alloc] init]);
154 [layoutManager setUsesScreenFonts:YES]; 154 [layoutManager setUsesScreenFonts:YES];
155 } 155 }
156 156
157 OmniboxViewMac::~OmniboxViewMac() { 157 OmniboxViewMac::~OmniboxViewMac() {
158 // Destroy popup view before this object in case it tries to call us 158 // Destroy popup view before this object in case it tries to call us
159 // back in the destructor. 159 // back in the destructor.
160 popup_view_.reset(); 160 popup_view_.reset();
161 161
162 // Disconnect from |field_|, it outlives this object. 162 // Disconnect from |field_|, it outlives this object.
163 [field_ setObserver:NULL]; 163 [field_ setObserver:NULL];
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 [as addAttribute:NSFontAttributeName value:GetFieldFont() 428 [as addAttribute:NSFontAttributeName value:GetFieldFont()
429 range:as_entire_string]; 429 range:as_entire_string];
430 430
431 // A kinda hacky way to add breaking at periods. This is what Safari does. 431 // A kinda hacky way to add breaking at periods. This is what Safari does.
432 // This works for IDNs too, despite the "en_US". 432 // This works for IDNs too, despite the "en_US".
433 [as addAttribute:@"NSLanguage" value:@"en_US_POSIX" 433 [as addAttribute:@"NSLanguage" value:@"en_US_POSIX"
434 range:as_entire_string]; 434 range:as_entire_string];
435 435
436 // Make a paragraph style locking in the standard line height as the maximum, 436 // Make a paragraph style locking in the standard line height as the maximum,
437 // otherwise the baseline may shift "downwards". 437 // otherwise the baseline may shift "downwards".
438 scoped_nsobject<NSMutableParagraphStyle> 438 base::scoped_nsobject<NSMutableParagraphStyle> paragraph_style(
439 paragraph_style([[NSMutableParagraphStyle alloc] init]); 439 [[NSMutableParagraphStyle alloc] init]);
440 CGFloat line_height = [[field_ cell] lineHeight]; 440 CGFloat line_height = [[field_ cell] lineHeight];
441 [paragraph_style setMaximumLineHeight:line_height]; 441 [paragraph_style setMaximumLineHeight:line_height];
442 [paragraph_style setMinimumLineHeight:line_height]; 442 [paragraph_style setMinimumLineHeight:line_height];
443 [as addAttribute:NSParagraphStyleAttributeName value:paragraph_style 443 [as addAttribute:NSParagraphStyleAttributeName value:paragraph_style
444 range:as_entire_string]; 444 range:as_entire_string];
445 445
446 url_parse::Component scheme, host; 446 url_parse::Component scheme, host;
447 AutocompleteInput::ParseForEmphasizeComponents( 447 AutocompleteInput::ParseForEmphasizeComponents(
448 display_text, &scheme, &host); 448 display_text, &scheme, &host);
449 bool grey_out_url = display_text.substr(scheme.begin, scheme.len) == 449 bool grey_out_url = display_text.substr(scheme.begin, scheme.len) ==
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 963
964 NSUInteger OmniboxViewMac::GetTextLength() const { 964 NSUInteger OmniboxViewMac::GetTextLength() const {
965 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : 965 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] :
966 [[field_ stringValue] length]; 966 [[field_ stringValue] length];
967 } 967 }
968 968
969 bool OmniboxViewMac::IsCaretAtEnd() const { 969 bool OmniboxViewMac::IsCaretAtEnd() const {
970 const NSRange selection = GetSelectedRange(); 970 const NSRange selection = GetSelectedRange();
971 return NSMaxRange(selection) == GetTextLength(); 971 return NSMaxRange(selection) == GetTextLength();
972 } 972 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698