diff options
author | Simon Sapin <simon.sapin@exyr.org> | 2014-12-29 21:52:12 +0100 |
---|---|---|
committer | Simon Sapin <simon.sapin@exyr.org> | 2014-12-29 21:52:12 +0100 |
commit | a29cb0e5d0292a812c28d9143565b9936c57f39e (patch) | |
tree | aee13fc22cd09f89e6346026d17234baa386ae9d | |
parent | 5e08e96e38cd3b9f6d81657f505ad785e6606e0b (diff) | |
download | servo-a29cb0e5d0292a812c28d9143565b9936c57f39e.tar.gz servo-a29cb0e5d0292a812c28d9143565b9936c57f39e.zip |
Move the define_css_keyword_enum macro to the style crate.
-rw-r--r-- | components/plugins/lib.rs | 46 | ||||
-rw-r--r-- | components/style/properties/common_types.rs | 47 |
2 files changed, 47 insertions, 46 deletions
diff --git a/components/plugins/lib.rs b/components/plugins/lib.rs index 69f823c2d91..9017958ea39 100644 --- a/components/plugins/lib.rs +++ b/components/plugins/lib.rs @@ -52,52 +52,6 @@ pub fn plugin_registrar(reg: &mut Registry) { #[macro_export] -macro_rules! define_css_keyword_enum { - ($name: ident: $( $css: expr => $variant: ident ),+,) => { - define_css_keyword_enum!($name: $( $css => $variant ),+) - }; - ($name: ident: $( $css: expr => $variant: ident ),+) => { - #[allow(non_camel_case_types)] - #[deriving(Clone, Eq, PartialEq, FromPrimitive)] - pub enum $name { - $( $variant ),+ - } - - impl $name { - pub fn parse(component_value: &::cssparser::ast::ComponentValue) -> Result<$name, ()> { - match component_value { - &::cssparser::ast::Ident(ref value) => { - match_ignore_ascii_case! { value: - $( $css => Ok($name::$variant) ),+ - _ => Err(()) - } - } - _ => Err(()) - } - } - } - - impl ::std::fmt::Show for $name { - #[inline] - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - use cssparser::ToCss; - self.fmt_to_css(f) - } - } - - impl ::cssparser::ToCss for $name { - fn to_css<W>(&self, dest: &mut W) -> ::text_writer::Result - where W: ::text_writer::TextWriter { - match self { - $( &$name::$variant => dest.write_str($css) ),+ - } - } - } - } -} - - -#[macro_export] macro_rules! match_ignore_ascii_case { ( $value: expr: $( $string: expr => $result: expr ),+ _ => $fallback: expr, ) => { match_ignore_ascii_case! { $value: diff --git a/components/style/properties/common_types.rs b/components/style/properties/common_types.rs index 52a0fb3be40..f55d9ee7fb2 100644 --- a/components/style/properties/common_types.rs +++ b/components/style/properties/common_types.rs @@ -3,11 +3,58 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #![allow(non_camel_case_types)] +#![macro_escape] use url::{Url, UrlParser}; pub use servo_util::geometry::Au; + +macro_rules! define_css_keyword_enum { + ($name: ident: $( $css: expr => $variant: ident ),+,) => { + define_css_keyword_enum!($name: $( $css => $variant ),+) + }; + ($name: ident: $( $css: expr => $variant: ident ),+) => { + #[allow(non_camel_case_types)] + #[deriving(Clone, Eq, PartialEq, FromPrimitive)] + pub enum $name { + $( $variant ),+ + } + + impl $name { + pub fn parse(component_value: &::cssparser::ast::ComponentValue) -> Result<$name, ()> { + match component_value { + &::cssparser::ast::Ident(ref value) => { + match_ignore_ascii_case! { value: + $( $css => Ok($name::$variant) ),+ + _ => Err(()) + } + } + _ => Err(()) + } + } + } + + impl ::std::fmt::Show for $name { + #[inline] + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + use cssparser::ToCss; + self.fmt_to_css(f) + } + } + + impl ::cssparser::ToCss for $name { + fn to_css<W>(&self, dest: &mut W) -> ::text_writer::Result + where W: ::text_writer::TextWriter { + match self { + $( &$name::$variant => dest.write_str($css) ),+ + } + } + } + } +} + + pub type CSSFloat = f64; pub mod specified { |