diff --git a/components/style/gecko/url.rs b/components/style/gecko/url.rs index 1b5bc424e4d..a0ecfc7b381 100644 --- a/components/style/gecko/url.rs +++ b/components/style/gecko/url.rs @@ -15,7 +15,7 @@ use malloc_size_of::{MallocSizeOf, MallocSizeOfOps}; use parser::{Parse, ParserContext}; use servo_arc::{Arc, RawOffsetArc}; use std::mem; -use style_traits::ParseError; +use style_traits::{ParseError, SpecifiedValueInfo}; /// A CSS url() value for gecko. #[css(function = "url")] @@ -120,8 +120,10 @@ impl MallocSizeOf for CssUrl { } } +impl SpecifiedValueInfo for CssUrl {} + /// A specified url() value for general usage. -#[derive(Clone, Debug, ToComputedValue, ToCss)] +#[derive(Clone, Debug, SpecifiedValueInfo, ToComputedValue, ToCss)] pub struct SpecifiedUrl { /// The specified url value. pub url: CssUrl, @@ -179,7 +181,7 @@ impl MallocSizeOf for SpecifiedUrl { /// A specified url() value for image. /// /// This exists so that we can construct `ImageValue` and reuse it. -#[derive(Clone, Debug, ToComputedValue, ToCss)] +#[derive(Clone, Debug, SpecifiedValueInfo, ToComputedValue, ToCss)] pub struct SpecifiedImageUrl { /// The specified url value. pub url: CssUrl, diff --git a/components/style/gecko_string_cache/mod.rs b/components/style/gecko_string_cache/mod.rs index ead705fa231..297599e2080 100644 --- a/components/style/gecko_string_cache/mod.rs +++ b/components/style/gecko_string_cache/mod.rs @@ -20,6 +20,7 @@ use std::fmt::{self, Write}; use std::hash::{Hash, Hasher}; use std::iter::Cloned; use std::ops::Deref; +use style_traits::SpecifiedValueInfo; #[macro_use] #[allow(improper_ctypes, non_camel_case_types, missing_docs)] @@ -415,3 +416,5 @@ impl From for Atom { } malloc_size_of_is_0!(Atom); + +impl SpecifiedValueInfo for Atom {} diff --git a/components/style/macros.rs b/components/style/macros.rs index f8f4759c148..671ba35b8bc 100644 --- a/components/style/macros.rs +++ b/components/style/macros.rs @@ -68,8 +68,9 @@ macro_rules! try_match_ident_ignore_ascii_case { macro_rules! define_keyword_type { ($name:ident, $css:expr) => { #[allow(missing_docs)] - #[derive(Animate, Clone, ComputeSquaredDistance, Copy, MallocSizeOf, PartialEq, - ToAnimatedValue, ToAnimatedZero, ToComputedValue, ToCss)] + #[derive(Animate, Clone, ComputeSquaredDistance, Copy, MallocSizeOf, + PartialEq, SpecifiedValueInfo, ToAnimatedValue, ToAnimatedZero, + ToComputedValue, ToCss)] pub struct $name; impl fmt::Debug for $name { diff --git a/components/style/properties/helpers.mako.rs b/components/style/properties/helpers.mako.rs index 90e070d03c4..3c5bb762e1f 100644 --- a/components/style/properties/helpers.mako.rs +++ b/components/style/properties/helpers.mako.rs @@ -164,7 +164,7 @@ % if separator == "Comma": #[css(comma)] % endif - #[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)] + #[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss)] pub struct SpecifiedValue( % if not allow_empty: #[css(iterable)] @@ -396,8 +396,8 @@ pub mod computed_value { #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] - #[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Parse)] - #[derive(PartialEq, ToCss)] + #[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Parse, + PartialEq, SpecifiedValueInfo, ToCss)] pub enum T { % for value in keyword.values_for(product): ${to_camel_case(value)}, @@ -408,7 +408,7 @@ } #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] - #[derive(Clone, Copy, Debug, Eq, PartialEq, ToCss)] + #[derive(Clone, Copy, Debug, Eq, PartialEq, SpecifiedValueInfo, ToCss)] pub enum SpecifiedValue { Keyword(computed_value::T), System(SystemFont), @@ -558,7 +558,8 @@ % if extra_specified: #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] - #[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToCss)] + #[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, + SpecifiedValueInfo, ToCss)] pub enum SpecifiedValue { ${variants(keyword.values_for(product) + extra_specified.split(), bool(extra_specified))} } @@ -569,7 +570,7 @@ #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] #[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, ToCss)] % if not extra_specified: - #[derive(Parse, ToComputedValue)] + #[derive(Parse, SpecifiedValueInfo, ToComputedValue)] % endif pub enum T { ${variants(data.longhands_by_name[name].keyword.values_for(product), not extra_specified)} @@ -634,7 +635,7 @@ #[allow(unused_imports)] use style_traits::{ParseError, StyleParseErrorKind}; #[allow(unused_imports)] - use style_traits::{CssWriter, ToCss}; + use style_traits::{CssWriter, SpecifiedValueInfo, ToCss}; pub struct Longhands { % for sub_property in shorthand.sub_properties: @@ -742,6 +743,26 @@ }) } + <% + sub_properties_for_value_info = shorthand.sub_properties + if shorthand.name == "border": + # border-image subproperties are simply reset by border + # shorthand, so border cannot accept values of them. + # XXX We may want a better mechanism for this, but this + # is probably fine for now. + sub_properties_for_value_info = [ + subprop for subprop in shorthand.sub_properties + if not subprop.name.startswith("border-image") + ] + %> + impl SpecifiedValueInfo for Longhands { + const SUPPORTED_TYPES: u8 = 0 + % for subprop in sub_properties_for_value_info: + | ::SUPPORTED_TYPES + % endfor + ; + } + ${caller.body()} } % endif diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs index e2d15139128..059d5a51c1b 100644 --- a/components/style/properties/helpers/animated_properties.mako.rs +++ b/components/style/properties/helpers/animated_properties.mako.rs @@ -27,7 +27,7 @@ use smallvec::SmallVec; use std::{cmp, ptr}; use std::mem::{self, ManuallyDrop}; #[cfg(feature = "gecko")] use hash::FnvHashMap; -use style_traits::ParseError; +use style_traits::{ParseError, SpecifiedValueInfo}; use super::ComputedValues; use values::{CSSFloat, CustomIdent, Either}; use values::animated::{Animate, Procedure, ToAnimatedValue, ToAnimatedZero}; @@ -172,6 +172,8 @@ impl From for TransitionProperty { } } +impl SpecifiedValueInfo for TransitionProperty {} + /// Returns true if this nsCSSPropertyID is one of the transitionable properties. #[cfg(feature = "gecko")] pub fn nscsspropertyid_is_transitionable(property: nsCSSPropertyID) -> bool { diff --git a/components/style/properties/longhand/font.mako.rs b/components/style/properties/longhand/font.mako.rs index 0477a2cd0d5..3cd10daf96b 100644 --- a/components/style/properties/longhand/font.mako.rs +++ b/components/style/properties/longhand/font.mako.rs @@ -296,7 +296,8 @@ ${helpers.predefined_type("-x-text-zoom", kw_cast = """font_variant_caps font_kerning font_variant_position font_optical_sizing""".split() %> - #[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToCss)] + #[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq, + SpecifiedValueInfo, ToCss)] pub enum SystemFont { % for font in system_fonts: ${to_camel_case(font)}, diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 1f9c3b49513..da1bbb9f149 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -42,7 +42,8 @@ use selector_parser::PseudoElement; use selectors::parser::SelectorParseErrorKind; #[cfg(feature = "servo")] use servo_config::prefs::PREFS; use shared_lock::StylesheetGuards; -use style_traits::{CssWriter, ParseError, ParsingMode, StyleParseErrorKind, ToCss}; +use style_traits::{CssWriter, ParseError, ParsingMode}; +use style_traits::{SpecifiedValueInfo, StyleParseErrorKind, ToCss}; use stylesheets::{CssRuleType, Origin, UrlExtraData}; #[cfg(feature = "servo")] use values::Either; use values::generics::text::LineHeight; @@ -541,6 +542,24 @@ impl NonCustomPropertyId { false } + + /// The supported types of this property. The return value should be + /// style_traits::CssType when it can become a bitflags type. + fn supported_types(&self) -> u8 { + const SUPPORTED_TYPES: [u8; ${len(data.longhands) + len(data.shorthands)}] = [ + % for prop in data.longhands: + <${prop.specified_type()} as SpecifiedValueInfo>::SUPPORTED_TYPES, + % endfor + % for prop in data.shorthands: + % if prop.name == "all": + 0, // 'all' accepts no value other than CSS-wide keywords + % else: + ::SUPPORTED_TYPES, + % endif + % endfor + ]; + SUPPORTED_TYPES[self.0] + } } impl From for NonCustomPropertyId { @@ -1713,6 +1732,19 @@ impl PropertyId { }; id.allowed_in(context) } + + /// Whether the property supports the given CSS type. + /// `ty` should a bitflags of constants in style_traits::CssType. + pub fn supports_type(&self, ty: u8) -> bool { + let non_custom_id: NonCustomPropertyId = match *self { + PropertyId::Custom(_) => return false, + PropertyId::Shorthand(id) => id.into(), + PropertyId::Longhand(id) => id.into(), + PropertyId::ShorthandAlias(id, _) => id.into(), + PropertyId::LonghandAlias(id, _) => id.into(), + }; + non_custom_id.supported_types() & ty != 0 + } } /// A declaration using a CSS-wide keyword. diff --git a/components/style/values/computed/length.rs b/components/style/values/computed/length.rs index fd63ec7e666..beb33553d7f 100644 --- a/components/style/values/computed/length.rs +++ b/components/style/values/computed/length.rs @@ -916,7 +916,8 @@ pub type NonNegativeLengthOrPercentageOrNormal = Either { /// ` ` Explicit { diff --git a/components/style/values/generics/basic_shape.rs b/components/style/values/generics/basic_shape.rs index 0da3b53f2c8..80375ad8ffa 100644 --- a/components/style/values/generics/basic_shape.rs +++ b/components/style/values/generics/basic_shape.rs @@ -18,7 +18,8 @@ pub type ClippingShape = ShapeSource #[allow(missing_docs)] -#[derive(Animate, Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] +#[derive(Animate, Clone, Copy, Debug, MallocSizeOf, PartialEq, + SpecifiedValueInfo, ToComputedValue, ToCss)] pub enum GeometryBox { FillBox, StrokeBox, @@ -32,7 +33,8 @@ pub type FloatAreaShape = ShapeSource { #[animation(error)] ImageOrUrl(ImageOrUrl), @@ -55,8 +58,8 @@ pub enum ShapeSource { } #[allow(missing_docs)] -#[derive(Animate, Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq, ToComputedValue, - ToCss)] +#[derive(Animate, Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq, + SpecifiedValueInfo, ToComputedValue, ToCss)] pub enum BasicShape { Inset(#[css(field_bound)] InsetRect), Circle(#[css(field_bound)] Circle), @@ -66,7 +69,8 @@ pub enum BasicShape { /// #[allow(missing_docs)] -#[derive(Animate, Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq, ToComputedValue)] +#[derive(Animate, Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq, + SpecifiedValueInfo, ToComputedValue)] pub struct InsetRect { pub rect: Rect, pub round: Option>, @@ -74,8 +78,8 @@ pub struct InsetRect { /// #[allow(missing_docs)] -#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, - ToComputedValue)] +#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, + PartialEq, SpecifiedValueInfo, ToComputedValue)] pub struct Circle { pub position: Position, pub radius: ShapeRadius, @@ -83,8 +87,8 @@ pub struct Circle { /// #[allow(missing_docs)] -#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, - ToComputedValue)] +#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, + PartialEq, SpecifiedValueInfo, ToComputedValue)] pub struct Ellipse { pub position: Position, pub semiaxis_x: ShapeRadius, @@ -93,8 +97,8 @@ pub struct Ellipse { /// #[allow(missing_docs)] -#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, - ToComputedValue, ToCss)] +#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, + PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss)] pub enum ShapeRadius { Length(LengthOrPercentage), #[animation(error)] @@ -106,7 +110,8 @@ pub enum ShapeRadius { /// A generic type for representing the `polygon()` function /// /// -#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue)] +#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue)] pub struct Polygon { /// The filling rule for a polygon. pub fill: FillRule, @@ -120,7 +125,8 @@ pub struct Polygon { // says that it can also be `inherit` #[allow(missing_docs)] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] -#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, + SpecifiedValueInfo, ToComputedValue, ToCss)] pub enum FillRule { Nonzero, Evenodd, diff --git a/components/style/values/generics/border.rs b/components/style/values/generics/border.rs index e4442ffdc51..79c8713bfba 100644 --- a/components/style/values/generics/border.rs +++ b/components/style/values/generics/border.rs @@ -10,7 +10,8 @@ use values::generics::rect::Rect; use values::generics::size::Size; /// A generic value for a single side of a `border-image-width` property. -#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue, ToCss)] pub enum BorderImageSideWidth { /// `` Length(LengthOrPercentage), @@ -21,7 +22,8 @@ pub enum BorderImageSideWidth { } /// A generic value for the `border-image-slice` property. -#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue)] +#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue)] pub struct BorderImageSlice { /// The offsets. pub offsets: Rect, @@ -30,8 +32,8 @@ pub struct BorderImageSlice { } /// A generic value for the `border-*-radius` longhand properties. -#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, - ToComputedValue, ToCss)] +#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, + PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss)] pub struct BorderCornerRadius(#[css(field_bound)] pub Size); impl BorderCornerRadius { @@ -42,8 +44,9 @@ impl BorderCornerRadius { } /// A generic value for the `border-spacing` property. -#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, - ToAnimatedValue, ToAnimatedZero, ToComputedValue, ToCss)] +#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, + PartialEq, SpecifiedValueInfo, ToAnimatedValue, ToAnimatedZero, + ToComputedValue, ToCss)] pub struct BorderSpacing(#[css(field_bound)] pub Size); impl BorderSpacing { @@ -56,8 +59,8 @@ impl BorderSpacing { /// A generic value for `border-radius`, `outline-radius` and `inset()`. /// /// -#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, - ToComputedValue)] +#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, + PartialEq, SpecifiedValueInfo, ToComputedValue)] pub struct BorderRadius { /// The top left radius. pub top_left: BorderCornerRadius, diff --git a/components/style/values/generics/box.rs b/components/style/values/generics/box.rs index 3c780ea9899..ea79e98eefb 100644 --- a/components/style/values/generics/box.rs +++ b/components/style/values/generics/box.rs @@ -7,8 +7,8 @@ use values::animated::ToAnimatedZero; /// A generic value for the `vertical-align` property. -#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, - ToComputedValue, ToCss)] +#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, + PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss)] pub enum VerticalAlign { /// `baseline` Baseline, @@ -48,7 +48,8 @@ impl ToAnimatedZero for VerticalAlign { } /// https://drafts.csswg.org/css-animations/#animation-iteration-count -#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue, ToCss)] pub enum AnimationIterationCount { /// A `` value. Number(Number), @@ -57,8 +58,9 @@ pub enum AnimationIterationCount { } /// A generic value for the `perspective` property. -#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, - ToAnimatedValue, ToAnimatedZero, ToComputedValue, ToCss)] +#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, + PartialEq, SpecifiedValueInfo, ToAnimatedValue, ToAnimatedZero, + ToComputedValue, ToCss)] pub enum Perspective { /// A non-negative length. Length(NonNegativeLength), diff --git a/components/style/values/generics/column.rs b/components/style/values/generics/column.rs index 936349b8786..1d76f6cb552 100644 --- a/components/style/values/generics/column.rs +++ b/components/style/values/generics/column.rs @@ -5,8 +5,9 @@ //! Generic types for the column properties. /// A generic type for `column-count` values. -#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, - ToAnimatedValue, ToAnimatedZero, ToComputedValue, ToCss)] +#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, + PartialEq, SpecifiedValueInfo, ToAnimatedValue, ToAnimatedZero, + ToComputedValue, ToCss)] pub enum ColumnCount { /// A positive integer. Integer(PositiveInteger), diff --git a/components/style/values/generics/counters.rs b/components/style/values/generics/counters.rs index e47a120b1d5..037834abf6e 100644 --- a/components/style/values/generics/counters.rs +++ b/components/style/values/generics/counters.rs @@ -11,7 +11,8 @@ use style_traits::{CssWriter, ToCss}; use values::CustomIdent; /// A generic value for the `counter-increment` property. -#[derive(Clone, Debug, Default, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Debug, Default, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue, ToCss)] pub struct CounterIncrement(Counters); impl CounterIncrement { @@ -32,7 +33,8 @@ impl Deref for CounterIncrement { } /// A generic value for the `counter-reset` property. -#[derive(Clone, Debug, Default, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Debug, Default, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue, ToCss)] pub struct CounterReset(Counters); impl CounterReset { @@ -55,7 +57,8 @@ impl Deref for CounterReset { /// A generic value for lists of counters. /// /// Keyword `none` is represented by an empty vector. -#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue)] +#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue)] pub struct Counters(Box<[(CustomIdent, I)]>); impl Default for Counters { diff --git a/components/style/values/generics/effects.rs b/components/style/values/generics/effects.rs index e306699eeb2..136f45635c1 100644 --- a/components/style/values/generics/effects.rs +++ b/components/style/values/generics/effects.rs @@ -10,7 +10,8 @@ use style_traits::values::{CssWriter, SequenceWriter, ToCss}; use values::specified::url::SpecifiedUrl; /// A generic value for a single `box-shadow`. -#[derive(Animate, Clone, Debug, MallocSizeOf, PartialEq, ToAnimatedValue, ToAnimatedZero)] +#[derive(Animate, Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToAnimatedValue, ToAnimatedZero)] pub struct BoxShadow { /// The base shadow. pub base: SimpleShadow, @@ -23,8 +24,8 @@ pub struct BoxShadow { /// A generic value for a single `filter`. #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] -#[derive(Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq, ToAnimatedValue, - ToComputedValue, ToCss)] +#[derive(Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq, + SpecifiedValueInfo, ToAnimatedValue, ToComputedValue, ToCss)] pub enum Filter { /// `blur()` #[css(function)] @@ -66,8 +67,8 @@ pub enum Filter { /// /// Contrary to the canonical order from the spec, the color is serialised /// first, like in Gecko and Webkit. -#[derive(Animate, Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq, ToAnimatedValue, - ToAnimatedZero, ToCss)] +#[derive(Animate, Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq, + SpecifiedValueInfo, ToAnimatedValue, ToAnimatedZero, ToCss)] pub struct SimpleShadow { /// Color. pub color: Color, diff --git a/components/style/values/generics/flex.rs b/components/style/values/generics/flex.rs index e1747410f12..1ab53233c44 100644 --- a/components/style/values/generics/flex.rs +++ b/components/style/values/generics/flex.rs @@ -6,8 +6,9 @@ /// A generic value for the `flex-basis` property. #[cfg_attr(feature = "servo", derive(MallocSizeOf))] -#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, PartialEq, ToAnimatedValue, - ToAnimatedZero, ToComputedValue, ToCss)] +#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, PartialEq, + SpecifiedValueInfo, ToAnimatedValue, ToAnimatedZero, ToComputedValue, + ToCss)] pub enum FlexBasis { /// `content` Content, diff --git a/components/style/values/generics/font.rs b/components/style/values/generics/font.rs index cbcd64502c4..738a40a7844 100644 --- a/components/style/values/generics/font.rs +++ b/components/style/values/generics/font.rs @@ -11,11 +11,12 @@ use num_traits::One; use parser::{Parse, ParserContext}; use std::fmt::{self, Write}; use std::io::Cursor; -use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; +use style_traits::{CssWriter, ParseError, SpecifiedValueInfo, StyleParseErrorKind, ToCss}; use values::distance::{ComputeSquaredDistance, SquaredDistance}; /// https://drafts.csswg.org/css-fonts-4/#feature-tag-value -#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue)] +#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue)] pub struct FeatureTagValue { /// A four-character tag, packed into a u32 (one byte per character). pub tag: FontTag, @@ -45,7 +46,8 @@ where /// Variation setting for a single feature, see: /// /// https://drafts.csswg.org/css-fonts-4/#font-variation-settings-def -#[derive(Animate, Clone, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] +#[derive(Animate, Clone, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue, ToCss)] pub struct VariationValue { /// A four-character tag, packed into a u32 (one byte per character). #[animation(constant)] @@ -69,7 +71,8 @@ where /// A value both for font-variation-settings and font-feature-settings. #[css(comma)] -#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue, ToCss)] pub struct FontSettings(#[css(if_empty = "normal", iterable)] pub Box<[T]>); impl FontSettings { @@ -105,7 +108,8 @@ impl Parse for FontSettings { /// https://drafts.csswg.org/css-fonts-4/#font-variation-settings-def /// https://drafts.csswg.org/css-fonts-4/#descdef-font-face-font-feature-settings /// -#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue)] +#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue)] pub struct FontTag(pub u32); impl ToCss for FontTag { @@ -177,9 +181,13 @@ where } } +impl SpecifiedValueInfo for KeywordInfo { + const SUPPORTED_TYPES: u8 = ::SUPPORTED_TYPES; +} + /// CSS font keywords #[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, - ToAnimatedValue, ToAnimatedZero)] + ToAnimatedValue, ToAnimatedZero, SpecifiedValueInfo)] #[allow(missing_docs)] pub enum KeywordSize { XXSmall, diff --git a/components/style/values/generics/gecko.rs b/components/style/values/generics/gecko.rs index 1591afbfd97..72a8b71d073 100644 --- a/components/style/values/generics/gecko.rs +++ b/components/style/values/generics/gecko.rs @@ -7,7 +7,8 @@ /// A generic value for scroll snap points. #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[derive(Clone, Copy, Debug, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Copy, Debug, PartialEq, SpecifiedValueInfo, ToComputedValue, + ToCss)] pub enum ScrollSnapPoint { /// `none` None, diff --git a/components/style/values/generics/grid.rs b/components/style/values/generics/grid.rs index eae06fe58b4..d805fb5e0d0 100644 --- a/components/style/values/generics/grid.rs +++ b/components/style/values/generics/grid.rs @@ -18,7 +18,8 @@ use values::specified::grid::parse_line_names; /// A `` type. /// /// -#[derive(Clone, Debug, Default, MallocSizeOf, PartialEq, ToComputedValue)] +#[derive(Clone, Debug, Default, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue)] pub struct GridLine { /// Flag to check whether it's a `span` keyword. pub is_span: bool, @@ -148,7 +149,8 @@ impl Parse for GridLine { #[allow(missing_docs)] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] -#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, + SpecifiedValueInfo, ToComputedValue, ToCss)] pub enum TrackKeyword { Auto, MaxContent, @@ -159,7 +161,8 @@ pub enum TrackKeyword { /// avoid re-implementing it for the computed type. /// /// -#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue, ToCss)] pub enum TrackBreadth { /// The generic type is almost always a non-negative `` Breadth(L), @@ -187,7 +190,7 @@ impl TrackBreadth { /// generic only to avoid code bloat. It only takes `` /// /// -#[derive(Clone, Debug, MallocSizeOf, PartialEq)] +#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo)] pub enum TrackSize { /// A flexible `` Breadth(TrackBreadth), @@ -343,7 +346,8 @@ where /// The initial argument of the `repeat` function. /// /// -#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue, ToCss)] pub enum RepeatCount { /// A positive integer. This is allowed only for `` and `` Number(Integer), @@ -378,7 +382,8 @@ impl Parse for RepeatCount { /// /// It can also hold `repeat()` function parameters, which expands into the respective /// values in its computed form. -#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue)] +#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue)] pub struct TrackRepeat { /// The number of times for the value to be repeated (could also be `auto-fit` or `auto-fill`) pub count: RepeatCount, @@ -464,7 +469,8 @@ impl TrackRepeat { } /// Track list values. Can be or -#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue, ToCss)] pub enum TrackListValue { /// A value. TrackSize(TrackSize), @@ -475,7 +481,8 @@ pub enum TrackListValue { /// The type of a `` as determined during parsing. /// /// -#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue)] +#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue)] pub enum TrackListType { /// [``](https://drafts.csswg.org/css-grid/#typedef-auto-track-list) /// @@ -497,7 +504,7 @@ pub enum TrackListType { /// A grid `` type. /// /// -#[derive(Clone, Debug, MallocSizeOf, PartialEq)] +#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo)] pub struct TrackList { /// The type of this `` (auto, explicit or general). /// @@ -569,7 +576,8 @@ impl ToCss for TrackList { /// /// `subgrid [ | repeat( | auto-fill, +) ]+` /// Old spec: https://www.w3.org/TR/2015/WD-css-grid-1-20150917/#typedef-line-name-list -#[derive(Clone, Debug, Default, MallocSizeOf, PartialEq, ToComputedValue)] +#[derive(Clone, Debug, Default, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue)] pub struct LineNameList { /// The optional `` pub names: Box<[Box<[CustomIdent]>]>, @@ -672,7 +680,8 @@ impl ToCss for LineNameList { /// Variants for ` | ` /// Subgrid deferred to Level 2 spec due to lack of implementation. /// But it's implemented in gecko, so we have to as well. -#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue, ToCss)] pub enum GridTemplateComponent { /// `none` value. None, diff --git a/components/style/values/generics/image.rs b/components/style/values/generics/image.rs index 2cbb8b14112..4501f94433f 100644 --- a/components/style/values/generics/image.rs +++ b/components/style/values/generics/image.rs @@ -16,7 +16,7 @@ use values::serialize_atom_identifier; /// An [image]. /// /// [image]: https://drafts.csswg.org/css-images/#image-values -#[derive(Clone, MallocSizeOf, PartialEq, ToComputedValue)] +#[derive(Clone, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue)] pub enum Image { /// A `` image. Url(ImageUrl), @@ -164,7 +164,8 @@ impl ToCss for PaintWorklet { /// `-moz-image-rect(, top, right, bottom, left);` #[allow(missing_docs)] #[css(comma, function)] -#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue, ToCss)] pub struct MozImageRect { pub url: MozImageRectUrl, pub top: NumberOrPercentage, diff --git a/components/style/values/generics/mod.rs b/components/style/values/generics/mod.rs index 03df2c69278..f47b2f29b89 100644 --- a/components/style/values/generics/mod.rs +++ b/components/style/values/generics/mod.rs @@ -79,7 +79,8 @@ impl SymbolsType { /// Since wherever is used, 'none' is a valid value as /// well, we combine them into one type to make code simpler. #[cfg_attr(feature = "gecko", derive(MallocSizeOf))] -#[derive(Clone, Debug, Eq, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Debug, Eq, PartialEq, SpecifiedValueInfo, ToComputedValue, + ToCss)] pub enum CounterStyleOrNone { /// `none` None, @@ -139,12 +140,14 @@ impl Parse for CounterStyleOrNone { /// A wrapper of Non-negative values. #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] -#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, - PartialOrd, ToAnimatedZero, ToComputedValue, ToCss)] +#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, + PartialEq, PartialOrd, SpecifiedValueInfo, ToAnimatedZero, + ToComputedValue, ToCss)] pub struct NonNegative(pub T); /// A wrapper of greater-than-or-equal-to-one values. #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] -#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, - PartialOrd, ToAnimatedZero, ToComputedValue, ToCss)] +#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, + PartialEq, PartialOrd, SpecifiedValueInfo, ToAnimatedZero, + ToComputedValue, ToCss)] pub struct GreaterThanOrEqualToOne(pub T); diff --git a/components/style/values/generics/pointing.rs b/components/style/values/generics/pointing.rs index f84e70b7bfa..9d9ec031225 100644 --- a/components/style/values/generics/pointing.rs +++ b/components/style/values/generics/pointing.rs @@ -9,8 +9,9 @@ use style_traits::{CssWriter, ToCss}; use style_traits::cursor::CursorKind; /// A generic value for the `caret-color` property. -#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, - ToAnimatedValue, ToAnimatedZero, ToComputedValue, ToCss)] +#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, + PartialEq, SpecifiedValueInfo, ToAnimatedValue, ToAnimatedZero, + ToComputedValue, ToCss)] pub enum CaretColor { /// An explicit color. Color(Color), @@ -21,7 +22,8 @@ pub enum CaretColor { /// A generic value for the `cursor` property. /// /// https://drafts.csswg.org/css-ui/#cursor -#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue)] +#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue)] pub struct Cursor { /// The parsed images for the cursor. pub images: Box<[Image]>, @@ -54,7 +56,8 @@ impl ToCss for Cursor { } /// A generic value for item of `image cursors`. -#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue)] +#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue)] pub struct CursorImage { /// The url to parse images from. pub url: ImageUrl, diff --git a/components/style/values/generics/position.rs b/components/style/values/generics/position.rs index aef2d233fd5..67c167c41ab 100644 --- a/components/style/values/generics/position.rs +++ b/components/style/values/generics/position.rs @@ -6,8 +6,8 @@ //! [`position`](https://drafts.csswg.org/css-backgrounds-3/#position) /// A generic type for representing a CSS [position](https://drafts.csswg.org/css-values/#position). -#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, - ToAnimatedZero, ToComputedValue)] +#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, + PartialEq, SpecifiedValueInfo, ToAnimatedZero, ToComputedValue)] pub struct Position { /// The horizontal component of position. pub horizontal: H, @@ -26,8 +26,8 @@ impl Position { } /// A generic value for the `z-index` property. -#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, - ToAnimatedZero, ToComputedValue, ToCss)] +#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, + PartialEq, SpecifiedValueInfo, ToAnimatedZero, ToComputedValue, ToCss)] pub enum ZIndex { /// An integer value. Integer(Integer), diff --git a/components/style/values/generics/rect.rs b/components/style/values/generics/rect.rs index f45ac32ba91..fb67e48a395 100644 --- a/components/style/values/generics/rect.rs +++ b/components/style/values/generics/rect.rs @@ -11,8 +11,8 @@ use style_traits::{CssWriter, ParseError, ToCss}; /// A CSS value made of four components, where its `ToCss` impl will try to /// serialize as few components as possible, like for example in `border-width`. -#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, - ToComputedValue)] +#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, + PartialEq, SpecifiedValueInfo, ToComputedValue)] pub struct Rect(pub T, pub T, pub T, pub T); impl Rect { diff --git a/components/style/values/generics/size.rs b/components/style/values/generics/size.rs index e3632c1075d..ad93b94e65e 100644 --- a/components/style/values/generics/size.rs +++ b/components/style/values/generics/size.rs @@ -8,7 +8,7 @@ use cssparser::Parser; use euclid::Size2D; use parser::ParserContext; use std::fmt::{self, Write}; -use style_traits::{CssWriter, ParseError, ToCss}; +use style_traits::{CssWriter, ParseError, SpecifiedValueInfo, ToCss}; use values::animated::ToAnimatedValue; /// A generic size, for `border-*-radius` longhand properties, or @@ -93,3 +93,7 @@ where )) } } + +impl SpecifiedValueInfo for Size { + const SUPPORTED_TYPES: u8 = L::SUPPORTED_TYPES; +} diff --git a/components/style/values/generics/svg.rs b/components/style/values/generics/svg.rs index 7bc4c6b61eb..9246175068c 100644 --- a/components/style/values/generics/svg.rs +++ b/components/style/values/generics/svg.rs @@ -16,8 +16,8 @@ use values::distance::{ComputeSquaredDistance, SquaredDistance}; /// /// #[animation(no_bound(UrlPaintServer))] -#[derive(Animate, Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq, ToAnimatedValue, - ToComputedValue, ToCss)] +#[derive(Animate, Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq, + SpecifiedValueInfo, ToAnimatedValue, ToComputedValue, ToCss)] pub struct SVGPaint { /// The paint source pub kind: SVGPaintKind, @@ -31,8 +31,9 @@ pub struct SVGPaint { /// to have a fallback, Gecko lets the context /// properties have a fallback as well. #[animation(no_bound(UrlPaintServer))] -#[derive(Animate, Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq, ToAnimatedValue, - ToAnimatedZero, ToComputedValue, ToCss)] +#[derive(Animate, Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq, + SpecifiedValueInfo, ToAnimatedValue, ToAnimatedZero, ToComputedValue, + ToCss)] pub enum SVGPaintKind { /// `none` #[animation(error)] @@ -112,8 +113,8 @@ impl Parse for SVGPaint | | for svg which allow unitless length. /// -#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToAnimatedValue, ToAnimatedZero, - ToComputedValue, ToCss)] +#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToAnimatedValue, ToAnimatedZero, ToComputedValue, ToCss)] pub enum SvgLengthOrPercentageOrNumber { /// | LengthOrPercentage(LengthOrPercentage), @@ -190,8 +191,9 @@ impl Parse } /// An SVG length value supports `context-value` in addition to length. -#[derive(Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, ToAnimatedValue, - ToAnimatedZero, ToComputedValue, ToCss)] +#[derive(Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, + SpecifiedValueInfo, ToAnimatedValue, ToAnimatedZero, ToComputedValue, + ToCss)] pub enum SVGLength { /// ` | | ` Length(LengthType), @@ -200,8 +202,8 @@ pub enum SVGLength { } /// Generic value for stroke-dasharray. -#[derive(Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq, ToAnimatedValue, - ToComputedValue, ToCss)] +#[derive(Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq, + SpecifiedValueInfo, ToAnimatedValue, ToComputedValue, ToCss)] pub enum SVGStrokeDashArray { /// `[ | | ]#` #[css(comma)] @@ -216,8 +218,8 @@ pub enum SVGStrokeDashArray { /// An SVG opacity value accepts `context-{fill,stroke}-opacity` in /// addition to opacity value. -#[derive(Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, ToAnimatedZero, - ToComputedValue, ToCss)] +#[derive(Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, + SpecifiedValueInfo, ToAnimatedZero, ToComputedValue, ToCss)] pub enum SVGOpacity { /// `` Opacity(OpacityType), diff --git a/components/style/values/generics/text.rs b/components/style/values/generics/text.rs index 28a0adc385a..6cc5caaac77 100644 --- a/components/style/values/generics/text.rs +++ b/components/style/values/generics/text.rs @@ -12,7 +12,8 @@ use values::animated::{Animate, Procedure, ToAnimatedZero}; use values::distance::{ComputeSquaredDistance, SquaredDistance}; /// A generic value for the `initial-letter` property. -#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue, ToCss)] pub enum InitialLetter { /// `normal` Normal, @@ -29,7 +30,8 @@ impl InitialLetter { } /// A generic spacing value for the `letter-spacing` and `word-spacing` properties. -#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue, ToCss)] pub enum Spacing { /// `normal` Normal, @@ -110,8 +112,8 @@ where } /// A generic value for the `line-height` property. -#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, - ToAnimatedValue, ToCss)] +#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, + PartialEq, SpecifiedValueInfo, ToAnimatedValue, ToCss)] pub enum LineHeight { /// `normal` Normal, @@ -140,8 +142,9 @@ impl LineHeight { } /// A generic value for the `-moz-tab-size` property. -#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, - ToAnimatedValue, ToAnimatedZero, ToComputedValue, ToCss)] +#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, + PartialEq, SpecifiedValueInfo, ToAnimatedValue, ToAnimatedZero, + ToComputedValue, ToCss)] pub enum MozTabSize { /// A number. Number(Number), diff --git a/components/style/values/generics/transform.rs b/components/style/values/generics/transform.rs index 7c82eea5e1c..2c671541ea4 100644 --- a/components/style/values/generics/transform.rs +++ b/components/style/values/generics/transform.rs @@ -15,7 +15,8 @@ use values::specified::length::LengthOrPercentage as SpecifiedLengthOrPercentage /// A generic 2D transformation matrix. #[allow(missing_docs)] -#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue, ToCss)] #[css(comma, function)] pub struct Matrix { pub a: T, @@ -29,7 +30,8 @@ pub struct Matrix { #[allow(missing_docs)] #[cfg_attr(rustfmt, rustfmt_skip)] #[css(comma, function = "matrix3d")] -#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue, ToCss)] pub struct Matrix3D { pub m11: T, pub m12: T, pub m13: T, pub m14: T, pub m21: T, pub m22: T, pub m23: T, pub m24: T, @@ -64,8 +66,8 @@ impl> From> for Transform3D { } /// A generic transform origin. -#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, - ToAnimatedZero, ToComputedValue, ToCss)] +#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, + PartialEq, SpecifiedValueInfo, ToAnimatedZero, ToComputedValue, ToCss)] pub struct TransformOrigin { /// The horizontal origin. pub horizontal: H, @@ -157,7 +159,8 @@ impl TimingKeyword { } } -#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue, ToCss)] /// A single operation in the list of a `transform` value pub enum TransformOperation { /// Represents a 2D 2x3 matrix. @@ -261,7 +264,8 @@ pub enum TransformOperation }, } -#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue, ToCss)] /// A value of the `transform` property pub struct Transform(#[css(if_empty = "none", iterable)] pub Vec); @@ -554,8 +558,8 @@ pub fn get_normalized_vector_and_angle( } } -#[derive(Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, ToAnimatedZero, - ToComputedValue, ToCss)] +#[derive(Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, + SpecifiedValueInfo, ToAnimatedZero, ToComputedValue, ToCss)] /// A value of the `Rotate` property /// /// @@ -568,8 +572,8 @@ pub enum Rotate { Rotate3D(Number, Number, Number, Angle), } -#[derive(Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, ToAnimatedZero, - ToComputedValue, ToCss)] +#[derive(Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, + SpecifiedValueInfo, ToAnimatedZero, ToComputedValue, ToCss)] /// A value of the `Scale` property /// /// @@ -584,8 +588,8 @@ pub enum Scale { Scale3D(Number, Number, Number), } -#[derive(Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq, ToAnimatedZero, - ToComputedValue, ToCss)] +#[derive(Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq, + SpecifiedValueInfo, ToAnimatedZero, ToComputedValue, ToCss)] /// A value of the `Translate` property /// /// @@ -601,7 +605,8 @@ pub enum Translate { } #[allow(missing_docs)] -#[derive(Clone, Copy, Debug, MallocSizeOf, Parse, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Copy, Debug, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo, + ToComputedValue, ToCss)] pub enum TransformStyle { #[cfg(feature = "servo")] Auto, diff --git a/components/style/values/generics/url.rs b/components/style/values/generics/url.rs index a05c28b1f46..5da74a7b087 100644 --- a/components/style/values/generics/url.rs +++ b/components/style/values/generics/url.rs @@ -9,8 +9,9 @@ use parser::{Parse, ParserContext}; use style_traits::ParseError; /// An image url or none, used for example in list-style-image -#[derive(Animate, Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq, ToAnimatedValue, - ToAnimatedZero, ToComputedValue, ToCss)] +#[derive(Animate, Clone, ComputeSquaredDistance, Debug, MallocSizeOf, PartialEq, + SpecifiedValueInfo, ToAnimatedValue, ToAnimatedZero, ToComputedValue, + ToCss)] pub enum UrlOrNone { /// `none` None, diff --git a/components/style/values/mod.rs b/components/style/values/mod.rs index 2f4104a08b0..a61b774bdbf 100644 --- a/components/style/values/mod.rs +++ b/components/style/values/mod.rs @@ -93,8 +93,9 @@ impl Parse for Impossible { } /// A struct representing one of two kinds of values. -#[derive(Animate, Clone, ComputeSquaredDistance, Copy, MallocSizeOf, PartialEq, ToAnimatedValue, - ToAnimatedZero, ToComputedValue, ToCss)] +#[derive(Animate, Clone, ComputeSquaredDistance, Copy, MallocSizeOf, PartialEq, + SpecifiedValueInfo, ToAnimatedValue, ToAnimatedZero, ToComputedValue, + ToCss)] pub enum Either { /// The first value. First(A), @@ -125,7 +126,8 @@ impl Parse for Either { } /// -#[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToComputedValue)] +#[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue)] pub struct CustomIdent(pub Atom); impl CustomIdent { @@ -160,7 +162,7 @@ impl ToCss for CustomIdent { } /// -#[derive(Clone, Debug, MallocSizeOf, ToComputedValue)] +#[derive(Clone, Debug, MallocSizeOf, ToComputedValue, SpecifiedValueInfo)] pub enum KeyframesName { /// Ident(CustomIdent), diff --git a/components/style/values/specified/align.rs b/components/style/values/specified/align.rs index 7b9b003a50c..a92ca52c8b4 100644 --- a/components/style/values/specified/align.rs +++ b/components/style/values/specified/align.rs @@ -16,7 +16,7 @@ bitflags! { /// Constants shared by multiple CSS Box Alignment properties /// /// These constants match Gecko's `NS_STYLE_ALIGN_*` constants. - #[derive(MallocSizeOf, ToComputedValue)] + #[derive(MallocSizeOf, SpecifiedValueInfo, ToComputedValue)] pub struct AlignFlags: u8 { // Enumeration stored in the lower 5 bits: /// 'auto' @@ -135,7 +135,8 @@ pub enum AxisDirection { /// Shared value for the `align-content` and `justify-content` properties. /// /// -#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue, ToCss)] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] pub struct ContentDistribution { primary: AlignFlags, @@ -232,7 +233,8 @@ impl ContentDistribution { /// Value for the `align-content` property. /// /// -#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue, ToCss)] pub struct AlignContent(pub ContentDistribution); impl Parse for AlignContent { @@ -264,7 +266,8 @@ impl From for u16 { /// Value for the `justify-content` property. /// /// -#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue, ToCss)] pub struct JustifyContent(pub ContentDistribution); impl Parse for JustifyContent { @@ -294,7 +297,8 @@ impl From for u16 { } /// -#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue, ToCss)] pub struct SelfAlignment(pub AlignFlags); impl SelfAlignment { @@ -344,7 +348,8 @@ impl SelfAlignment { /// The specified value of the align-self property. /// /// -#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue, ToCss)] pub struct AlignSelf(pub SelfAlignment); impl Parse for AlignSelf { @@ -374,7 +379,8 @@ impl From for u8 { /// The specified value of the justify-self property. /// /// -#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue, ToCss)] pub struct JustifySelf(pub SelfAlignment); impl Parse for JustifySelf { @@ -404,7 +410,8 @@ impl From for u8 { /// Value of the `align-items` property /// /// -#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue, ToCss)] pub struct AlignItems(pub AlignFlags); impl AlignItems { @@ -443,7 +450,8 @@ impl Parse for AlignItems { /// Value of the `justify-items` property /// /// -#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, ToCss)] +#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToCss)] pub struct JustifyItems(pub AlignFlags); impl JustifyItems { diff --git a/components/style/values/specified/angle.rs b/components/style/values/specified/angle.rs index 3f49862e406..040ea9d9a7c 100644 --- a/components/style/values/specified/angle.rs +++ b/components/style/values/specified/angle.rs @@ -7,7 +7,7 @@ use cssparser::{Parser, Token}; use parser::{Parse, ParserContext}; use std::fmt::{self, Write}; -use style_traits::{CssWriter, ParseError, ToCss}; +use style_traits::{CssWriter, ParseError, SpecifiedValueInfo, ToCss}; use values::CSSFloat; use values::computed::{Context, ToComputedValue}; use values::computed::angle::Angle as ComputedAngle; @@ -203,3 +203,5 @@ impl Angle { }.map_err(|()| input.new_unexpected_token_error(token.clone())) } } + +impl SpecifiedValueInfo for Angle {} diff --git a/components/style/values/specified/background.rs b/components/style/values/specified/background.rs index 88dbe8a158f..b9feb8b8e27 100644 --- a/components/style/values/specified/background.rs +++ b/components/style/values/specified/background.rs @@ -48,7 +48,8 @@ impl BackgroundSize { } /// One of the keywords for `background-repeat`. -#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, + SpecifiedValueInfo, ToComputedValue, ToCss)] #[allow(missing_docs)] pub enum BackgroundRepeatKeyword { Repeat, @@ -60,7 +61,8 @@ pub enum BackgroundRepeatKeyword { /// The specified value for the `background-repeat` property. /// /// https://drafts.csswg.org/css-backgrounds/#the-background-repeat -#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToCss)] +#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToCss)] pub enum BackgroundRepeat { /// `repeat-x` RepeatX, diff --git a/components/style/values/specified/border.rs b/components/style/values/specified/border.rs index 4b24b6bb6c4..0713ed99eb9 100644 --- a/components/style/values/specified/border.rs +++ b/components/style/values/specified/border.rs @@ -20,7 +20,7 @@ use values::specified::{AllowQuirks, Number, NumberOrPercentage}; use values::specified::length::{Length, LengthOrPercentage, NonNegativeLength}; /// A specified value for a single side of the `border-width` property. -#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)] +#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss)] pub enum BorderSideWidth { /// `thin` Thin, @@ -189,7 +189,8 @@ impl Parse for BorderSpacing { /// A single border-image-repeat keyword. #[allow(missing_docs)] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] -#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToCss)] +#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, + SpecifiedValueInfo, ToCss)] pub enum BorderImageRepeatKeyword { Stretch, Repeat, @@ -200,7 +201,8 @@ pub enum BorderImageRepeatKeyword { /// The specified value for the `border-image-repeat` property. /// /// https://drafts.csswg.org/css-backgrounds/#the-border-image-repeat -#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToComputedValue)] +#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue)] pub struct BorderImageRepeat(pub BorderImageRepeatKeyword, pub BorderImageRepeatKeyword); impl ToCss for BorderImageRepeat { diff --git a/components/style/values/specified/box.rs b/components/style/values/specified/box.rs index 0609b6d8607..e26d82c8f67 100644 --- a/components/style/values/specified/box.rs +++ b/components/style/values/specified/box.rs @@ -9,9 +9,8 @@ use cssparser::Parser; use parser::{Parse, ParserContext}; use selectors::parser::SelectorParseErrorKind; use std::fmt::{self, Write}; -use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; -use values::CustomIdent; -use values::KeyframesName; +use style_traits::{CssWriter, ParseError, SpecifiedValueInfo, StyleParseErrorKind, ToCss}; +use values::{CustomIdent, KeyframesName}; use values::generics::box_::AnimationIterationCount as GenericAnimationIterationCount; use values::generics::box_::Perspective as GenericPerspective; use values::generics::box_::VerticalAlign as GenericVerticalAlign; @@ -19,7 +18,8 @@ use values::specified::{AllowQuirks, Number}; use values::specified::length::{LengthOrPercentage, NonNegativeLength}; #[allow(missing_docs)] -#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Parse, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Parse, PartialEq, + SpecifiedValueInfo, ToComputedValue, ToCss)] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] /// Defines an element’s display type, which consists of /// the two basic qualities of how an element generates boxes @@ -296,7 +296,8 @@ impl AnimationIterationCount { } /// A value for the `animation-name` property. -#[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToComputedValue)] +#[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue)] pub struct AnimationName(pub Option); impl AnimationName { @@ -339,7 +340,8 @@ impl Parse for AnimationName { #[allow(missing_docs)] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] -#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, + SpecifiedValueInfo, ToComputedValue, ToCss)] pub enum ScrollSnapType { None, Mandatory, @@ -348,7 +350,8 @@ pub enum ScrollSnapType { #[allow(missing_docs)] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] -#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, + SpecifiedValueInfo, ToComputedValue, ToCss)] pub enum OverscrollBehavior { Auto, Contain, @@ -357,13 +360,15 @@ pub enum OverscrollBehavior { #[allow(missing_docs)] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] -#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, + SpecifiedValueInfo, ToComputedValue, ToCss)] pub enum OverflowClipBox { PaddingBox, ContentBox, } -#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToComputedValue, ToCss)] +#[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, + ToComputedValue, ToCss)] /// Provides a rendering hint to the user agent, /// stating what kinds of changes the author expects /// to perform on the element @@ -488,6 +493,8 @@ impl Parse for TouchAction { } } +impl SpecifiedValueInfo for TouchAction {} + #[cfg(feature = "gecko")] impl_bitflags_conversions!(TouchAction); @@ -598,6 +605,8 @@ impl Parse for Contain { } } +impl SpecifiedValueInfo for Contain {} + /// A specified value for the `perspective` property. pub type Perspective = GenericPerspective; diff --git a/components/style/values/specified/calc.rs b/components/style/values/specified/calc.rs index 45aa3b27145..06c1dba2955 100644 --- a/components/style/values/specified/calc.rs +++ b/components/style/values/specified/calc.rs @@ -9,7 +9,7 @@ use cssparser::{AngleOrNumber, NumberOrPercentage, Parser, Token}; use parser::ParserContext; use std::fmt::{self, Write}; -use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss}; +use style_traits::{CssWriter, ParseError, SpecifiedValueInfo, StyleParseErrorKind, ToCss}; use style_traits::values::specified::AllowedNumericType; use values::{CSSFloat, CSSInteger}; use values::computed; @@ -150,6 +150,8 @@ impl ToCss for CalcLengthOrPercentage { } } +impl SpecifiedValueInfo for CalcLengthOrPercentage {} + impl CalcNode { /// Tries to parse a single element in the expression, that is, a /// ``, ``, `