Replace NoViewportPercentage with a macro

This commit is contained in:
Nazım Can Altınova 2017-02-08 12:29:41 +03:00 committed by Simon Sapin
parent 9204f2aaad
commit abc40f61c0
19 changed files with 104 additions and 103 deletions

View file

@ -47,6 +47,19 @@ macro_rules! define_numbered_css_keyword_enum {
}
}
/// A macro used to implement HasViewportPercentage trait
/// for a given type that may never contain viewport units.
macro_rules! no_viewport_percentage {
($name: ident) => {
impl HasViewportPercentage for $name {
#[inline]
fn has_viewport_percentage(&self) -> bool {
false
}
}
};
}
pub mod computed;
pub mod specified;
@ -62,18 +75,7 @@ pub trait HasViewportPercentage {
fn has_viewport_percentage(&self) -> bool;
}
/// A trait used as a marker to represent that a given type may never contain
/// viewport units.
pub trait NoViewportPercentage {}
impl<T> HasViewportPercentage for T
where T: NoViewportPercentage,
{
#[inline]
fn has_viewport_percentage(&self) -> bool {
false
}
}
use self::computed::ComputedValueAsSpecified;
@ -103,7 +105,7 @@ macro_rules! define_keyword_type {
}
impl ComputedValueAsSpecified for $name {}
impl NoViewportPercentage for $name {}
no_viewport_percentage!($name);
};
}