From 5e136a7a05906f626508a9e83a134061d0e16ac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sat, 9 Sep 2017 13:40:57 +0200 Subject: [PATCH] style: Get rid of ComputedValueAsSpecified in box.mako.rs. --- .../style/properties/longhand/box.mako.rs | 46 ++++++++----------- components/style/values/mod.rs | 2 +- 2 files changed, 19 insertions(+), 29 deletions(-) diff --git a/components/style/properties/longhand/box.mako.rs b/components/style/properties/longhand/box.mako.rs index 72a26d3f43f..b30a11c50fe 100644 --- a/components/style/properties/longhand/box.mako.rs +++ b/components/style/properties/longhand/box.mako.rs @@ -34,7 +34,6 @@ -moz-grid-group -moz-grid-line -moz-stack -moz-inline-stack -moz-deck -moz-popup -moz-groupbox""".split() %> - use values::computed::ComputedValueAsSpecified; use style_traits::ToCss; pub mod computed_value { @@ -137,7 +136,7 @@ } #[allow(non_camel_case_types)] - #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] + #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, ToComputedValue)] #[cfg_attr(feature = "servo", derive(HeapSizeOf, Deserialize, Serialize))] pub enum SpecifiedValue { % for value in values: @@ -180,8 +179,6 @@ } } - impl ComputedValueAsSpecified for SpecifiedValue {} - % if product == "servo": fn cascade_property_custom(_declaration: &PropertyDeclaration, context: &mut computed::Context) { @@ -403,14 +400,13 @@ ${helpers.predefined_type("transition-delay", use Atom; use std::fmt; use style_traits::ToCss; - use values::computed::ComputedValueAsSpecified; use values::KeyframesName; pub mod computed_value { pub use super::SpecifiedValue as T; } - #[derive(Clone, Debug, Eq, Hash, PartialEq)] + #[derive(Clone, Debug, Eq, Hash, PartialEq, ToComputedValue)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct SpecifiedValue(pub Option); @@ -448,8 +444,10 @@ ${helpers.predefined_type("transition-delay", } impl Parse for SpecifiedValue { - fn parse<'i, 't>(context: &ParserContext, input: &mut ::cssparser::Parser<'i, 't>) - -> Result> { + fn parse<'i, 't>( + context: &ParserContext, + input: &mut ::cssparser::Parser<'i, 't> + ) -> Result> { if let Ok(name) = input.try(|input| KeyframesName::parse(context, input)) { Ok(SpecifiedValue(Some(name))) } else { @@ -458,12 +456,13 @@ ${helpers.predefined_type("transition-delay", } } - pub fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) - -> Result> { + pub fn parse<'i, 't>( + context: &ParserContext, + input: &mut Parser<'i, 't>, + ) -> Result> { SpecifiedValue::parse(context, input) } - impl ComputedValueAsSpecified for SpecifiedValue {} ${helpers.predefined_type("animation-duration", @@ -496,15 +495,13 @@ ${helpers.predefined_type("animation-timing-function", extra_prefixes="moz webkit" spec="https://drafts.csswg.org/css-animations/#propdef-animation-iteration-count", allowed_in_keyframe_block="False"> - use values::computed::ComputedValueAsSpecified; - pub mod computed_value { pub use super::SpecifiedValue as T; } // https://drafts.csswg.org/css-animations/#animation-iteration-count #[cfg_attr(feature = "servo", derive(HeapSizeOf))] - #[derive(Clone, Debug, PartialEq, ToCss)] + #[derive(Clone, Debug, PartialEq, ToCss, ToComputedValue)] pub enum SpecifiedValue { Number(f32), Infinite, @@ -538,12 +535,12 @@ ${helpers.predefined_type("animation-timing-function", } #[inline] - pub fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) - -> Result> { + pub fn parse<'i, 't>( + context: &ParserContext, + input: &mut Parser<'i, 't>, + ) -> Result> { SpecifiedValue::parse(context, input) } - - impl ComputedValueAsSpecified for SpecifiedValue {} <% animation_direction_custom_consts = { "alternate-reverse": "Alternate_reverse" } %> @@ -1626,15 +1623,13 @@ ${helpers.predefined_type("transform-origin", spec="https://drafts.csswg.org/css-contain/#contain-property"> use std::fmt; use style_traits::ToCss; - use values::computed::ComputedValueAsSpecified; - - impl ComputedValueAsSpecified for SpecifiedValue {} pub mod computed_value { pub type T = super::SpecifiedValue; } bitflags! { + #[derive(ToComputedValue)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub flags SpecifiedValue: u8 { const LAYOUT = 0x01, @@ -1770,15 +1765,12 @@ ${helpers.single_keyword("-moz-orient", use std::fmt; use style_traits::ToCss; use values::CustomIdent; - use values::computed::ComputedValueAsSpecified; - - impl ComputedValueAsSpecified for SpecifiedValue {} pub mod computed_value { pub use super::SpecifiedValue as T; } - #[derive(Clone, Debug, PartialEq)] + #[derive(Clone, Debug, PartialEq, ToComputedValue)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum SpecifiedValue { Auto, @@ -1843,9 +1835,6 @@ ${helpers.predefined_type( use gecko_bindings::structs; use std::fmt; use style_traits::ToCss; - use values::computed::ComputedValueAsSpecified; - - impl ComputedValueAsSpecified for SpecifiedValue {} pub mod computed_value { pub use super::SpecifiedValue as T; @@ -1853,6 +1842,7 @@ ${helpers.predefined_type( bitflags! { /// These constants match Gecko's `NS_STYLE_TOUCH_ACTION_*` constants. + #[derive(ToComputedValue)] pub flags SpecifiedValue: u8 { const TOUCH_ACTION_NONE = structs::NS_STYLE_TOUCH_ACTION_NONE as u8, const TOUCH_ACTION_AUTO = structs::NS_STYLE_TOUCH_ACTION_AUTO as u8, diff --git a/components/style/values/mod.rs b/components/style/values/mod.rs index 076e52de6af..5d093160b9e 100644 --- a/components/style/values/mod.rs +++ b/components/style/values/mod.rs @@ -127,7 +127,7 @@ impl ToCss for CustomIdent { } /// https://drafts.csswg.org/css-animations/#typedef-keyframes-name -#[derive(Clone, Debug)] +#[derive(Clone, Debug, ToComputedValue)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum KeyframesName { ///