summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvi <avi@chromium.org>2015-04-08 10:03:09 -0400
committerAvi <avi@chromium.org>2015-04-08 14:06:13 +0000
commit0206c08af873039b5bd70ca00c64cea890a48136 (patch)
tree49cf544ff8fc7f649dfd6317a0e3d5cd4624eecc
parentefb108913c7210af594fdd88fd957057de4b49cf (diff)
downloadchromium_src-0206c08af873039b5bd70ca00c64cea890a48136.zip
chromium_src-0206c08af873039b5bd70ca00c64cea890a48136.tar.gz
chromium_src-0206c08af873039b5bd70ca00c64cea890a48136.tar.bz2
Don't crash when using IME on an input field with a CSS-specified font.
BUG=471689 TEST=repro in bug 473859 no longer crashes Review URL: https://codereview.chromium.org/1052523006 Cr-Commit-Position: refs/heads/master@{#323971} (cherry picked from commit fcab92b0617293ba2172e86122bc2d7cb273c708) TBR=mark@chromium.org Review URL: https://codereview.chromium.org/1068253002 Cr-Commit-Position: refs/branch-heads/2357@{#16} Cr-Branched-From: 59d4494849b405682265ed5d3f5164573b9a939b-refs/heads/master@{#323860}
-rw-r--r--content/common/mac/attributed_string_coder.mm6
-rw-r--r--content/common/mac/font_descriptor.h4
2 files changed, 7 insertions, 3 deletions
diff --git a/content/common/mac/attributed_string_coder.mm b/content/common/mac/attributed_string_coder.mm
index bcd8b118..ed377bb 100644
--- a/content/common/mac/attributed_string_coder.mm
+++ b/content/common/mac/attributed_string_coder.mm
@@ -100,10 +100,12 @@ AttributedStringCoder::FontAttribute::FontAttribute()
AttributedStringCoder::FontAttribute::~FontAttribute() {
}
-NSDictionary* AttributedStringCoder::FontAttribute::ToAttributesDictionary(
- void) const {
+NSDictionary*
+AttributedStringCoder::FontAttribute::ToAttributesDictionary() const {
DCHECK(ShouldEncode());
NSFont* font = font_descriptor_.ToNSFont();
+ if (!font)
+ return [NSDictionary dictionary];
return [NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName];
}
diff --git a/content/common/mac/font_descriptor.h b/content/common/mac/font_descriptor.h
index 219f1fb..71d555d 100644
--- a/content/common/mac/font_descriptor.h
+++ b/content/common/mac/font_descriptor.h
@@ -21,7 +21,9 @@ struct CONTENT_EXPORT FontDescriptor {
FontDescriptor() : font_point_size(0) {}
- // Return an autoreleased NSFont corresponding to the font description.
+ // Return an autoreleased NSFont corresponding to the font description. Note
+ // that this will return nil if the font specified isn't available in this
+ // process.
NSFont* ToNSFont() const;
// Name of the font.