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

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

Issue 184783007: [rAC, OSX] Fix Omnibox font issue (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Oops. Removed two extraneous lines Created 6 years, 9 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/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 NSTextStorage* storage = [editor textStorage]; 408 NSTextStorage* storage = [editor textStorage];
409 [storage beginEditing]; 409 [storage beginEditing];
410 410
411 // Clear the existing attributes from the text storage, then 411 // Clear the existing attributes from the text storage, then
412 // overlay the appropriate Omnibox attributes. 412 // overlay the appropriate Omnibox attributes.
413 [storage setAttributes:[NSDictionary dictionary] 413 [storage setAttributes:[NSDictionary dictionary]
414 range:NSMakeRange(0, [storage length])]; 414 range:NSMakeRange(0, [storage length])];
415 ApplyTextAttributes(GetText(), storage); 415 ApplyTextAttributes(GetText(), storage);
416 416
417 [storage endEditing]; 417 [storage endEditing];
418
419 // This function can be called during the editor's -resignFirstResponder. If
420 // that happens, |storage| and |field_| will not be synced automatically any
421 // more. Calling -stringValue ensures that |field_| reflects the changes to
422 // |storage|.
423 [field_ stringValue];
418 } else { 424 } else {
419 SetText(GetText()); 425 SetText(GetText());
420 } 426 }
421 } 427 }
422 428
423 void OmniboxViewMac::ApplyTextAttributes(const base::string16& display_text, 429 void OmniboxViewMac::ApplyTextAttributes(const base::string16& display_text,
424 NSMutableAttributedString* as) { 430 NSMutableAttributedString* as) {
425 NSUInteger as_length = [as length]; 431 NSUInteger as_length = [as length];
426 NSRange as_entire_string = NSMakeRange(0, as_length); 432 NSRange as_entire_string = NSMakeRange(0, as_length);
427 433
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 983
978 NSUInteger OmniboxViewMac::GetTextLength() const { 984 NSUInteger OmniboxViewMac::GetTextLength() const {
979 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] : 985 return [field_ currentEditor] ? [[[field_ currentEditor] string] length] :
980 [[field_ stringValue] length]; 986 [[field_ stringValue] length];
981 } 987 }
982 988
983 bool OmniboxViewMac::IsCaretAtEnd() const { 989 bool OmniboxViewMac::IsCaretAtEnd() const {
984 const NSRange selection = GetSelectedRange(); 990 const NSRange selection = GetSelectedRange();
985 return NSMaxRange(selection) == GetTextLength(); 991 return NSMaxRange(selection) == GetTextLength();
986 } 992 }
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