Bug 1474793 - Part 10.7: Add ToShmem impl for FontFamilyList. r=emilio

Depends on D17195

Differential Revision: https://phabricator.services.mozilla.com/D17196

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Cameron McCormack 2019-03-30 00:16:23 +00:00
Родитель ca6083b00d
Коммит 2883bbaaea
1 изменённых файлов: 20 добавлений и 1 удалений

Просмотреть файл

@ -25,10 +25,11 @@ use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
use std::fmt::{self, Write};
use std::hash::{Hash, Hasher};
#[cfg(feature = "gecko")]
use std::mem;
use std::mem::{self, ManuallyDrop};
#[cfg(feature = "servo")]
use std::slice;
use style_traits::{CssWriter, ParseError, ToCss};
use to_shmem::{SharedMemoryBuilder, ToShmem};
pub use crate::values::computed::Length as MozScriptMinSize;
pub use crate::values::specified::font::{FontSynthesis, MozScriptSizeMultiplier};
@ -508,6 +509,24 @@ pub enum FontFamilyList {
Generic(structs::FontFamilyType),
}
#[cfg(feature = "gecko")]
impl ToShmem for FontFamilyList {
fn to_shmem(&self, _builder: &mut SharedMemoryBuilder) -> ManuallyDrop<Self> {
// In practice, the only SharedFontList objects we create from shared
// style sheets are ones with a single generic entry.
ManuallyDrop::new(match self {
FontFamilyList::SharedFontList(r) => {
assert!(
r.mNames.len() == 1 && r.mNames[0].mName.mRawPtr.is_null(),
"ToShmem failed for FontFamilyList: cannot handle non-generic families",
);
FontFamilyList::Generic(r.mNames[0].mType)
},
FontFamilyList::Generic(t) => FontFamilyList::Generic(*t),
})
}
}
#[cfg(feature = "gecko")]
impl Hash for FontFamilyList {
fn hash<H>(&self, state: &mut H)