Skip to content

Commit 0d360c1

Browse files
author
bors-servo
authored
Auto merge of #1664 - lsalzman:instance-key-fail, r=glennw
don't panic when an invalid font instance key is supplied This is a small modification to my previous FontInstanceKey to allow invalid font instance keys to work around the issue described in https://bugzilla.mozilla.org/show_bug.cgi?id=1396056 There are somewhat legitimate situations where this can occur, so we don't want to panic. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/1664) <!-- Reviewable:end -->
2 parents 01c38a2 + f2ae2ce commit 0d360c1

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

webrender/src/frame.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -567,16 +567,22 @@ impl Frame {
567567
info.image_rendering);
568568
}
569569
SpecificDisplayItem::Text(ref text_info) => {
570-
let instance = context.resource_cache.get_font_instance(text_info.font_key).unwrap();
571-
context.builder.add_text(clip_and_scroll,
572-
reference_frame_relative_offset,
573-
item_rect_with_offset,
574-
&clip_with_offset,
575-
instance,
576-
&text_info.color,
577-
item.glyphs(),
578-
item.display_list().get(item.glyphs()).count(),
579-
text_info.glyph_options);
570+
match context.resource_cache.get_font_instance(text_info.font_key) {
571+
Some(instance) => {
572+
context.builder.add_text(clip_and_scroll,
573+
reference_frame_relative_offset,
574+
item_rect_with_offset,
575+
&clip_with_offset,
576+
instance,
577+
&text_info.color,
578+
item.glyphs(),
579+
item.display_list().get(item.glyphs()).count(),
580+
text_info.glyph_options);
581+
}
582+
None => {
583+
warn!("Unknown font instance key: {:?}", text_info.font_key);
584+
}
585+
}
580586
}
581587
SpecificDisplayItem::Rectangle(ref info) => {
582588
if !self.try_to_add_rectangle_splitting_on_clip(context,

0 commit comments

Comments
 (0)