Skip to content

Commit

Permalink
style: Add ToShmem impl for FontFamilyList.
Browse files Browse the repository at this point in the history
  • Loading branch information
heycam authored and emilio committed Apr 12, 2019
1 parent 1f96653 commit 128c6ae
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion components/style/values/computed/font.rs
Expand Up @@ -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};
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 128c6ae

Please sign in to comment.