mirror of
https://github.com/servo/servo.git
synced 2025-08-09 07:25:35 +01:00
Add unit structs for representing keywords: auto, none, normal
This commit is contained in:
parent
f36a573d2d
commit
5df250bc05
1 changed files with 35 additions and 0 deletions
|
@ -63,6 +63,41 @@ impl<T> HasViewportPercentage for T where T: NoViewportPercentage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
use self::computed::ComputedValueAsSpecified;
|
||||||
|
|
||||||
|
macro_rules! define_keyword_type {
|
||||||
|
($name: ident, $css: expr) => {
|
||||||
|
#[derive(Clone, PartialEq, Copy)]
|
||||||
|
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||||
|
pub struct $name;
|
||||||
|
|
||||||
|
impl ::style_traits::ToCss for $name {
|
||||||
|
fn to_css<W>(&self, dest: &mut W) -> ::std::fmt::Result where W: ::std::fmt::Write {
|
||||||
|
write!(dest, $css)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Debug for $name {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
write!(f, $css)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Parse for $name {
|
||||||
|
fn parse(input: &mut ::cssparser::Parser) -> Result<$name, ()> {
|
||||||
|
input.expect_ident_matching($css).map(|_| $name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ComputedValueAsSpecified for $name {}
|
||||||
|
impl NoViewportPercentage for $name {}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
define_keyword_type!(None_, "none");
|
||||||
|
define_keyword_type!(Auto, "auto");
|
||||||
|
define_keyword_type!(Normal, "normal");
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Copy)]
|
#[derive(Clone, PartialEq, Copy)]
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||||
pub enum Either<A, B> {
|
pub enum Either<A, B> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue