mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
style: Fix servo build, and appease tidy / fmt.
This commit is contained in:
parent
8c004c0858
commit
49842f5031
23 changed files with 165 additions and 53 deletions
|
@ -29,6 +29,7 @@ use std::mem::{self, ManuallyDrop};
|
|||
#[cfg(feature = "servo")]
|
||||
use std::slice;
|
||||
use style_traits::{CssWriter, ParseError, ToCss};
|
||||
#[cfg(feature = "gecko")]
|
||||
use to_shmem::{SharedMemoryBuilder, ToShmem};
|
||||
|
||||
pub use crate::values::computed::Length as MozScriptMinSize;
|
||||
|
@ -284,7 +285,7 @@ pub enum FontFamilyNameSyntax {
|
|||
Identifiers,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, ToCss, ToResolvedValue)]
|
||||
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, ToCss, ToResolvedValue, ToShmem)]
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize, Hash))]
|
||||
/// A set of faces that vary in weight, width or slope.
|
||||
pub enum SingleFontFamily {
|
||||
|
@ -299,7 +300,10 @@ pub enum SingleFontFamily {
|
|||
/// The order here is important, if you change it make sure that
|
||||
/// `gfxPlatformFontList.h`s ranged array and `gfxFontFamilyList`'s
|
||||
/// sSingleGenerics are updated as well.
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq, Parse, ToCss, ToResolvedValue)]
|
||||
#[derive(
|
||||
Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq, Parse, ToCss, ToResolvedValue, ToShmem,
|
||||
)]
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||
#[repr(u8)]
|
||||
#[allow(missing_docs)]
|
||||
pub enum GenericFontFamily {
|
||||
|
@ -373,6 +377,35 @@ impl SingleFontFamily {
|
|||
}))
|
||||
}
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
/// Get the corresponding font-family with Atom
|
||||
pub fn from_atom(input: Atom) -> SingleFontFamily {
|
||||
match input {
|
||||
atom!("serif") => return SingleFontFamily::Generic(GenericFontFamily::Serif),
|
||||
atom!("sans-serif") => return SingleFontFamily::Generic(GenericFontFamily::SansSerif),
|
||||
atom!("cursive") => return SingleFontFamily::Generic(GenericFontFamily::Cursive),
|
||||
atom!("fantasy") => return SingleFontFamily::Generic(GenericFontFamily::Fantasy),
|
||||
atom!("monospace") => return SingleFontFamily::Generic(GenericFontFamily::Monospace),
|
||||
_ => {},
|
||||
}
|
||||
|
||||
match_ignore_ascii_case! { &input,
|
||||
"serif" => return SingleFontFamily::Generic(GenericFontFamily::Serif),
|
||||
"sans-serif" => return SingleFontFamily::Generic(GenericFontFamily::SansSerif),
|
||||
"cursive" => return SingleFontFamily::Generic(GenericFontFamily::Cursive),
|
||||
"fantasy" => return SingleFontFamily::Generic(GenericFontFamily::Fantasy),
|
||||
"monospace" => return SingleFontFamily::Generic(GenericFontFamily::Monospace),
|
||||
_ => {}
|
||||
}
|
||||
|
||||
// We don't know if it's quoted or not. So we set it to
|
||||
// quoted by default.
|
||||
SingleFontFamily::FamilyName(FamilyName {
|
||||
name: input,
|
||||
syntax: FontFamilyNameSyntax::Quoted,
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
/// Get the corresponding font-family with family name
|
||||
fn from_font_family_name(family: &structs::FontFamilyName) -> SingleFontFamily {
|
||||
|
@ -389,7 +422,7 @@ impl SingleFontFamily {
|
|||
}
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
#[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToResolvedValue)]
|
||||
#[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToResolvedValue, ToShmem)]
|
||||
/// A list of SingleFontFamily
|
||||
pub struct FontFamilyList(Box<[SingleFontFamily]>);
|
||||
|
||||
|
@ -501,7 +534,7 @@ impl FontFamilyList {
|
|||
let mut iter = self.iter();
|
||||
if let Some(SingleFontFamily::Generic(f)) = iter.next() {
|
||||
if iter.next().is_none() {
|
||||
return Some(f);
|
||||
return Some(f.clone());
|
||||
}
|
||||
}
|
||||
None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue