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