style: Preserve font-family identifier sequence when serializing.

This commit is contained in:
Cameron McCormack 2017-07-30 13:32:40 +08:00
parent 097e36beb1
commit 4f525f6fa0
2 changed files with 47 additions and 19 deletions

View file

@ -1782,7 +1782,7 @@ 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 properties::longhands::font_family::computed_value::{FontFamily, FamilyNameSyntax};
let list = &mut self.gecko.mFont.fontlist;
unsafe { Gecko_FontFamilyList_Clear(list); }
@ -1792,7 +1792,8 @@ fn static_assert() {
for family in &v.0 {
match *family {
FontFamily::FamilyName(ref f) => {
unsafe { Gecko_FontFamilyList_AppendNamed(list, f.name.as_ptr(), f.quoted); }
let quoted = matches!(f.syntax, FamilyNameSyntax::Quoted);
unsafe { Gecko_FontFamilyList_AppendNamed(list, f.name.as_ptr(), quoted); }
}
FontFamily::Generic(ref name) => {
let (family_type, generic) = FontFamily::generic(name);
@ -1819,7 +1820,7 @@ fn static_assert() {
}
pub fn clone_font_family(&self) -> longhands::font_family::computed_value::T {
use properties::longhands::font_family::computed_value::{FontFamily, FamilyName};
use properties::longhands::font_family::computed_value::{FontFamily, FamilyName, FamilyNameSyntax};
use gecko_bindings::structs::FontFamilyType;
use gecko_string_cache::Atom;
@ -1832,13 +1833,16 @@ fn static_assert() {
FontFamilyType::eFamily_cursive => FontFamily::Generic(atom!("cursive")),
FontFamilyType::eFamily_fantasy => FontFamily::Generic(atom!("fantasy")),
FontFamilyType::eFamily_moz_fixed => FontFamily::Generic(Atom::from("-moz-fixed")),
FontFamilyType::eFamily_named => FontFamily::FamilyName(FamilyName {
name: (&*gecko_font_family_name.mName).into(),
quoted: false
}),
FontFamilyType::eFamily_named => {
let name = Atom::from(&*gecko_font_family_name.mName);
FontFamily::FamilyName(FamilyName {
name: name.clone(),
syntax: FamilyNameSyntax::Identifiers(vec![name]),
})
},
FontFamilyType::eFamily_named_quoted => FontFamily::FamilyName(FamilyName {
name: (&*gecko_font_family_name.mName).into(),
quoted: true
syntax: FamilyNameSyntax::Quoted,
}),
x => panic!("Found unexpected font FontFamilyType: {:?}", x),
}