mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
style: Add ToShmem impl for FontFamilyList.
Differential Revision: https://phabricator.services.mozilla.com/D17196
This commit is contained in:
parent
1f966535ac
commit
128c6ae94a
1 changed files with 20 additions and 1 deletions
|
@ -25,10 +25,11 @@ use malloc_size_of::{MallocSizeOf, MallocSizeOfOps};
|
||||||
use std::fmt::{self, Write};
|
use std::fmt::{self, Write};
|
||||||
use std::hash::{Hash, Hasher};
|
use std::hash::{Hash, Hasher};
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
use std::mem;
|
use std::mem::{self, ManuallyDrop};
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
use std::slice;
|
use std::slice;
|
||||||
use style_traits::{CssWriter, ParseError, ToCss};
|
use style_traits::{CssWriter, ParseError, ToCss};
|
||||||
|
use to_shmem::{SharedMemoryBuilder, ToShmem};
|
||||||
|
|
||||||
pub use crate::values::computed::Length as MozScriptMinSize;
|
pub use crate::values::computed::Length as MozScriptMinSize;
|
||||||
pub use crate::values::specified::font::{FontSynthesis, MozScriptSizeMultiplier};
|
pub use crate::values::specified::font::{FontSynthesis, MozScriptSizeMultiplier};
|
||||||
|
@ -508,6 +509,24 @@ pub enum FontFamilyList {
|
||||||
Generic(structs::FontFamilyType),
|
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")]
|
#[cfg(feature = "gecko")]
|
||||||
impl Hash for FontFamilyList {
|
impl Hash for FontFamilyList {
|
||||||
fn hash<H>(&self, state: &mut H)
|
fn hash<H>(&self, state: &mut H)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue