Auto merge of #17211 - Manishearth:stylo-single-generic, r=heycam

stylo: Prefill default font when a single generic is set

r=heycam https://bugzilla.mozilla.org/show_bug.cgi?id=1370734

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17211)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-06-07 10:53:25 -07:00 committed by GitHub
commit eaefcbe551
4 changed files with 113 additions and 35 deletions

View file

@ -221,6 +221,9 @@ impl ${style_struct.gecko_struct_name} {
pub fn gecko(&self) -> &${style_struct.gecko_ffi_name} {
&self.gecko
}
pub fn gecko_mut(&mut self) -> &mut ${style_struct.gecko_ffi_name} {
&mut self.gecko
}
}
</%def>
@ -1587,7 +1590,6 @@ fn static_assert() {
pub fn set_font_family(&mut self, v: longhands::font_family::computed_value::T) {
use properties::longhands::font_family::computed_value::FontFamily;
use gecko_bindings::structs::FontFamilyType;
let list = &mut self.gecko.mFont.fontlist;
unsafe { Gecko_FontFamilyList_Clear(list); }
@ -1600,28 +1602,7 @@ fn static_assert() {
unsafe { Gecko_FontFamilyList_AppendNamed(list, f.name.as_ptr(), f.quoted); }
}
FontFamily::Generic(ref name) => {
let (family_type, generic) =
if name == &atom!("serif") {
(FontFamilyType::eFamily_serif,
structs::kGenericFont_serif)
} else if name == &atom!("sans-serif") {
(FontFamilyType::eFamily_sans_serif,
structs::kGenericFont_sans_serif)
} else if name == &atom!("cursive") {
(FontFamilyType::eFamily_cursive,
structs::kGenericFont_cursive)
} else if name == &atom!("fantasy") {
(FontFamilyType::eFamily_fantasy,
structs::kGenericFont_fantasy)
} else if name == &atom!("monospace") {
(FontFamilyType::eFamily_monospace,
structs::kGenericFont_monospace)
} else if name == &atom!("-moz-fixed") {
(FontFamilyType::eFamily_moz_fixed,
structs::kGenericFont_moz_fixed)
} else {
panic!("Unknown generic font family")
};
let (family_type, generic) = FontFamily::generic(name);
if v.0.len() == 1 {
self.gecko.mGenericID = generic;
}