mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Derive ToCss for FontSettings<T>
This commit is contained in:
parent
91e12563eb
commit
36db6f9cdd
1 changed files with 3 additions and 26 deletions
|
@ -68,8 +68,9 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A value both for font-variation-settings and font-feature-settings.
|
/// A value both for font-variation-settings and font-feature-settings.
|
||||||
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue)]
|
#[css(comma)]
|
||||||
pub struct FontSettings<T>(pub Box<[T]>);
|
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToCss)]
|
||||||
|
pub struct FontSettings<T>(#[css(if_empty = "normal", iterable)] pub Box<[T]>);
|
||||||
|
|
||||||
impl<T> FontSettings<T> {
|
impl<T> FontSettings<T> {
|
||||||
/// Default value of font settings as `normal`.
|
/// Default value of font settings as `normal`.
|
||||||
|
@ -96,30 +97,6 @@ impl<T: Parse> Parse for FontSettings<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: ToCss> ToCss for FontSettings<T> {
|
|
||||||
/// https://drafts.csswg.org/css-fonts-4/#descdef-font-face-font-feature-settings
|
|
||||||
/// https://drafts.csswg.org/css-fonts-4/#font-variation-settings-def
|
|
||||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
|
||||||
where
|
|
||||||
W: Write,
|
|
||||||
{
|
|
||||||
if self.0.is_empty() {
|
|
||||||
return dest.write_str("normal");
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut first = true;
|
|
||||||
for item in self.0.iter() {
|
|
||||||
if !first {
|
|
||||||
dest.write_str(", ")?;
|
|
||||||
}
|
|
||||||
first = false;
|
|
||||||
item.to_css(dest)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A font four-character tag, represented as a u32 for convenience.
|
/// A font four-character tag, represented as a u32 for convenience.
|
||||||
///
|
///
|
||||||
/// See:
|
/// See:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue