diff --git a/components/style/properties/longhand/inherited_svg.mako.rs b/components/style/properties/longhand/inherited_svg.mako.rs index 9b05707f33c..3d3b82541fc 100644 --- a/components/style/properties/longhand/inherited_svg.mako.rs +++ b/components/style/properties/longhand/inherited_svg.mako.rs @@ -268,10 +268,6 @@ ${helpers.predefined_type("marker-end", "UrlOrNone", "Either::Second(None_)", spec="Nonstandard (Internal-only)" allow_empty="True"> use values::CustomIdent; - use values::computed::ComputedValueAsSpecified; - - - impl ComputedValueAsSpecified for SpecifiedValue { } pub type SpecifiedValue = CustomIdent; diff --git a/components/style/properties/longhand/inherited_text.mako.rs b/components/style/properties/longhand/inherited_text.mako.rs index 346d864b3bb..29483ba43f7 100644 --- a/components/style/properties/longhand/inherited_text.mako.rs +++ b/components/style/properties/longhand/inherited_text.mako.rs @@ -255,9 +255,8 @@ ${helpers.single_keyword("text-align-last", } } % else: - use values::computed::ComputedValueAsSpecified; - impl ComputedValueAsSpecified for SpecifiedValue {} pub use self::computed_value::T as SpecifiedValue; + add_impls_for_keyword_enum!(SpecifiedValue); pub fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>) -> Result> { computed_value::T::parse(input) @@ -287,9 +286,6 @@ ${helpers.predefined_type("word-spacing", use cssparser::RGBA; use std::fmt; use style_traits::ToCss; - use values::computed::ComputedValueAsSpecified; - - impl ComputedValueAsSpecified for SpecifiedValue {} #[derive(Clone, Copy, Debug, PartialEq)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] @@ -299,6 +295,8 @@ ${helpers.predefined_type("word-spacing", pub line_through: Option, } + trivial_to_computed_value!(SpecifiedValue); + pub mod computed_value { pub type T = super::SpecifiedValue; } @@ -374,9 +372,7 @@ ${helpers.predefined_type("word-spacing", // !important. flags="APPLIES_TO_PLACEHOLDER" spec="https://drafts.csswg.org/css-text/#propdef-white-space"> - use values::computed::ComputedValueAsSpecified; - impl ComputedValueAsSpecified for SpecifiedValue {} - + trivial_to_computed_value!(SpecifiedValue); % if product != "gecko": impl SpecifiedValue { pub fn allow_wrap(&self) -> bool { @@ -433,8 +429,8 @@ ${helpers.predefined_type( pub mod computed_value { - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[derive(Clone, Debug, PartialEq, ToCss)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf, ToComputedValue))] pub enum T { Keyword(KeywordValue), None, @@ -449,8 +445,8 @@ ${helpers.predefined_type( } } - #[cfg_attr(feature = "servo", derive(HeapSizeOf))] #[derive(Clone, Debug, PartialEq, ToCss)] + #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub enum SpecifiedValue { Keyword(KeywordValue), None, @@ -614,26 +610,25 @@ ${helpers.predefined_type( <%helpers:longhand name="text-emphasis-position" animation_value_type="discrete" products="gecko" spec="https://drafts.csswg.org/css-text-decor/#propdef-text-emphasis-position"> - use values::computed::ComputedValueAsSpecified; use style_traits::ToCss; define_css_keyword_enum!(HorizontalWritingModeValue: "over" => Over, "under" => Under); + add_impls_for_keyword_enum!(VerticalWritingModeValue); define_css_keyword_enum!(VerticalWritingModeValue: "right" => Right, "left" => Left); + add_impls_for_keyword_enum!(HorizontalWritingModeValue); #[cfg_attr(feature = "servo", derive(HeapSizeOf))] - #[derive(Clone, Debug, PartialEq, ToCss)] + #[derive(Clone, Debug, PartialEq, ToComputedValue, ToCss)] pub struct SpecifiedValue(pub HorizontalWritingModeValue, pub VerticalWritingModeValue); pub mod computed_value { pub type T = super::SpecifiedValue; } - impl ComputedValueAsSpecified for SpecifiedValue {} - pub fn get_initial_value() -> computed_value::T { SpecifiedValue(HorizontalWritingModeValue::Over, VerticalWritingModeValue::Right) } diff --git a/components/style/values/mod.rs b/components/style/values/mod.rs index 5d093160b9e..c1f533dd5d4 100644 --- a/components/style/values/mod.rs +++ b/components/style/values/mod.rs @@ -98,7 +98,7 @@ impl Parse for Either { } /// https://drafts.csswg.org/css-values-4/#custom-idents -#[derive(Clone, Debug, Eq, Hash, PartialEq)] +#[derive(Clone, Debug, Eq, Hash, PartialEq, ToComputedValue)] #[cfg_attr(feature = "servo", derive(HeapSizeOf))] pub struct CustomIdent(pub Atom);