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

Side by Side Diff: content/common/mac/attributed_string_coder.mm

Issue 1052523006: Don't crash when using IME on an input field with a CSS-specified font. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « no previous file | content/common/mac/font_descriptor.h » ('j') | 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 "content/common/mac/attributed_string_coder.h" 5 #include "content/common/mac/attributed_string_coder.h"
6 6
7 #include <AppKit/AppKit.h> 7 #include <AppKit/AppKit.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac/scoped_nsobject.h" 10 #include "base/mac/scoped_nsobject.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } 93 }
94 94
95 AttributedStringCoder::FontAttribute::FontAttribute() 95 AttributedStringCoder::FontAttribute::FontAttribute()
96 : font_descriptor_(), 96 : font_descriptor_(),
97 effective_range_() { 97 effective_range_() {
98 } 98 }
99 99
100 AttributedStringCoder::FontAttribute::~FontAttribute() { 100 AttributedStringCoder::FontAttribute::~FontAttribute() {
101 } 101 }
102 102
103 NSDictionary* AttributedStringCoder::FontAttribute::ToAttributesDictionary( 103 NSDictionary*
104 void) const { 104 AttributedStringCoder::FontAttribute::ToAttributesDictionary() const {
105 DCHECK(ShouldEncode()); 105 DCHECK(ShouldEncode());
106 NSFont* font = font_descriptor_.ToNSFont(); 106 NSFont* font = font_descriptor_.ToNSFont();
107 if (!font)
108 return [NSDictionary dictionary];
107 return [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName]; 109 return [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
108 } 110 }
109 111
110 bool AttributedStringCoder::FontAttribute::ShouldEncode() const { 112 bool AttributedStringCoder::FontAttribute::ShouldEncode() const {
111 return !font_descriptor_.font_name.empty(); 113 return !font_descriptor_.font_name.empty();
112 } 114 }
113 115
114 } // namespace mac 116 } // namespace mac
115 117
116 // IPC ParamTraits specialization ////////////////////////////////////////////// 118 // IPC ParamTraits specialization //////////////////////////////////////////////
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 *p = AttributedStringCoder::FontAttribute(font, range); 164 *p = AttributedStringCoder::FontAttribute(font, range);
163 } 165 }
164 return success; 166 return success;
165 } 167 }
166 168
167 void ParamTraits<AttributedStringCoder::FontAttribute>::Log( 169 void ParamTraits<AttributedStringCoder::FontAttribute>::Log(
168 const param_type& p, std::string* l) { 170 const param_type& p, std::string* l) {
169 } 171 }
170 172
171 } // namespace IPC 173 } // namespace IPC
OLDNEW
« no previous file with comments | « no previous file | content/common/mac/font_descriptor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698