mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Add add_impls_for_keyword_enum macro for implementing necessary traits
This commit is contained in:
parent
6bd3469e28
commit
76df67fc7b
2 changed files with 23 additions and 1 deletions
|
@ -60,6 +60,27 @@ macro_rules! no_viewport_percentage {
|
|||
};
|
||||
}
|
||||
|
||||
/// A macro for implementing `ComputedValueAsSpecified`, `Parse`
|
||||
/// and `HasViewportPercentage` traits for the enums defined
|
||||
/// using `define_css_keyword_enum` macro.
|
||||
///
|
||||
/// NOTE: We should either move `Parse` trait to `style_traits`
|
||||
/// or `define_css_keyword_enum` macro to this crate, but that
|
||||
/// may involve significant cleanup in both the crates.
|
||||
macro_rules! add_impls_for_keyword_enum {
|
||||
($name:ident) => {
|
||||
impl Parse for $name {
|
||||
#[inline]
|
||||
fn parse(_context: &ParserContext, input: &mut ::cssparser::Parser) -> Result<Self, ()> {
|
||||
$name::parse(input)
|
||||
}
|
||||
}
|
||||
|
||||
impl ComputedValueAsSpecified for $name {}
|
||||
no_viewport_percentage!($name);
|
||||
};
|
||||
}
|
||||
|
||||
pub mod computed;
|
||||
pub mod specified;
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ use properties::shorthands::{parse_four_sides, serialize_four_sides};
|
|||
use std::ascii::AsciiExt;
|
||||
use std::fmt;
|
||||
use style_traits::ToCss;
|
||||
use values::HasViewportPercentage;
|
||||
use values::computed::{ComputedValueAsSpecified, Context, ToComputedValue};
|
||||
use values::computed::basic_shape as computed_basic_shape;
|
||||
use values::specified::{BorderRadiusSize, LengthOrPercentage, Percentage};
|
||||
|
@ -861,4 +862,4 @@ define_css_keyword_enum!(ShapeBox:
|
|||
"content-box" => ContentBox
|
||||
);
|
||||
|
||||
impl ComputedValueAsSpecified for ShapeBox {}
|
||||
add_impls_for_keyword_enum!(ShapeBox);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue