mirror of
https://github.com/servo/servo.git
synced 2025-08-17 11:25:35 +01:00
Derive some more ToCss implementations
This commit is contained in:
parent
21ecf47693
commit
ec289fbe6a
4 changed files with 5 additions and 70 deletions
|
@ -405,8 +405,8 @@ ${helpers.single_keyword_system("font-variant-caps",
|
|||
|
||||
no_viewport_percentage!(SpecifiedValue);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Copy)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, ToCss)]
|
||||
pub enum SpecifiedValue {
|
||||
Normal,
|
||||
Bold,
|
||||
|
@ -416,19 +416,6 @@ ${helpers.single_keyword_system("font-variant-caps",
|
|||
System(SystemFont),
|
||||
}
|
||||
|
||||
impl ToCss for SpecifiedValue {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
match *self {
|
||||
SpecifiedValue::Normal => dest.write_str("normal"),
|
||||
SpecifiedValue::Bold => dest.write_str("bold"),
|
||||
SpecifiedValue::Bolder => dest.write_str("bolder"),
|
||||
SpecifiedValue::Lighter => dest.write_str("lighter"),
|
||||
SpecifiedValue::Weight(weight) => weight.to_css(dest),
|
||||
SpecifiedValue::System(sys) => sys.to_css(dest),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
|
||||
pub fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<SpecifiedValue, ParseError<'i>> {
|
||||
|
@ -1008,7 +995,7 @@ ${helpers.single_keyword_system("font-variant-caps",
|
|||
|
||||
no_viewport_percentage!(SpecifiedValue);
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, ToCss)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub enum SpecifiedValue {
|
||||
None,
|
||||
|
@ -1016,18 +1003,6 @@ ${helpers.single_keyword_system("font-variant-caps",
|
|||
System(SystemFont),
|
||||
}
|
||||
|
||||
impl ToCss for SpecifiedValue {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result
|
||||
where W: fmt::Write,
|
||||
{
|
||||
match *self {
|
||||
SpecifiedValue::None => dest.write_str("none"),
|
||||
SpecifiedValue::Number(number) => number.to_css(dest),
|
||||
SpecifiedValue::System(sys) => sys.to_css(dest),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ToComputedValue for SpecifiedValue {
|
||||
type ComputedValue = computed_value::T;
|
||||
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
String(Box<str>),
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Debug)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
#[derive(Clone, Debug, Eq, PartialEq, ToCss)]
|
||||
pub struct SpecifiedValue {
|
||||
pub first: Side,
|
||||
pub second: Option<Side>
|
||||
|
@ -130,17 +130,6 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ToCss for SpecifiedValue {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
self.first.to_css(dest)?;
|
||||
if let Some(ref second) = self.second {
|
||||
dest.write_str(" ")?;
|
||||
second.to_css(dest)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
</%helpers:longhand>
|
||||
|
||||
${helpers.single_keyword("unicode-bidi",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue