Skip to content
Permalink
Browse files

style: Add ToShmem impl for FontFamilyList.

  • Loading branch information...
heycam authored and emilio committed Mar 30, 2019
1 parent 1f96653 commit 128c6ae94aec7b9df26544c46816158aacd8eb59
Showing with 20 additions and 1 deletion.
  1. +20 −1 components/style/values/computed/font.rs
@@ -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)

0 comments on commit 128c6ae

Please sign in to comment.
You can’t perform that action at this time.