mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Replace NoViewportPercentage with a macro
This commit is contained in:
parent
9204f2aaad
commit
abc40f61c0
19 changed files with 104 additions and 103 deletions
|
@ -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);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue