diff --git a/components/style/macros.rs b/components/style/macros.rs index 654053c140f..22f1966071b 100644 --- a/components/style/macros.rs +++ b/components/style/macros.rs @@ -80,6 +80,7 @@ macro_rules! define_keyword_type { ToAnimatedZero, ToComputedValue, ToCss, + ToResolvedValue, ToShmem, )] pub struct $name; diff --git a/components/style/properties/helpers.mako.rs b/components/style/properties/helpers.mako.rs index 06ffc2ebc41..c441268975d 100644 --- a/components/style/properties/helpers.mako.rs +++ b/components/style/properties/helpers.mako.rs @@ -128,8 +128,15 @@ % if separator == "Comma": #[css(comma)] % endif - #[derive(Clone, Debug, MallocSizeOf, PartialEq, ToAnimatedValue, - ToCss)] + #[derive( + Clone, + Debug, + MallocSizeOf, + PartialEq, + ToAnimatedValue, + ToResolvedValue, + ToCss, + )] pub struct List( % if not allow_empty: #[css(iterable)] @@ -425,8 +432,20 @@ pub mod computed_value { #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] - #[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Parse, - PartialEq, SpecifiedValueInfo, ToCss, ToShmem)] + #[derive( + Clone, + Copy, + Debug, + Eq, + Hash, + MallocSizeOf, + Parse, + PartialEq, + SpecifiedValueInfo, + ToCss, + ToResolvedValue, + ToShmem, + )] pub enum T { % for value in keyword.values_for(product): ${to_camel_case(value)}, @@ -588,8 +607,18 @@ % if extra_specified: #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] - #[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, - SpecifiedValueInfo, ToCss, ToShmem)] + #[derive( + Clone, + Copy, + Debug, + Eq, + MallocSizeOf, + Parse, + PartialEq, + SpecifiedValueInfo, + ToCss, + ToShmem, + )] pub enum SpecifiedValue { ${variants(keyword.values_for(product) + extra_specified.split(), bool(extra_specified))} } @@ -598,7 +627,7 @@ % endif pub mod computed_value { #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] - #[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, ToCss)] + #[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, ToCss, ToResolvedValue)] % if not extra_specified: #[derive(Parse, SpecifiedValueInfo, ToComputedValue, ToShmem)] % endif diff --git a/components/style/values/computed/align.rs b/components/style/values/computed/align.rs index 739b70c765a..ea6088db5d5 100644 --- a/components/style/values/computed/align.rs +++ b/components/style/values/computed/align.rs @@ -33,7 +33,7 @@ pub use super::specified::{AlignSelf, JustifySelf}; /// sucks :(. /// /// See the discussion in https://bugzil.la/1384542. -#[derive(Clone, Copy, Debug, Eq, PartialEq, ToCss)] +#[derive(Clone, Copy, Debug, Eq, PartialEq, ToCss, ToResolvedValue)] pub struct JustifyItems { /// The specified value for the property. Can contain the bare `legacy` /// keyword. diff --git a/components/style/values/computed/angle.rs b/components/style/values/computed/angle.rs index 76e44575dfb..1ce1a7fd34d 100644 --- a/components/style/values/computed/angle.rs +++ b/components/style/values/computed/angle.rs @@ -14,7 +14,7 @@ use style_traits::{CssWriter, ToCss}; /// A computed angle in degrees. #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] -#[derive(Add, Animate, Clone, Copy, Debug, MallocSizeOf, PartialEq, PartialOrd, ToAnimatedZero)] +#[derive(Add, Animate, Clone, Copy, Debug, MallocSizeOf, PartialEq, PartialOrd, ToAnimatedZero, ToResolvedValue)] pub struct Angle(CSSFloat); impl ToCss for Angle { diff --git a/components/style/values/computed/box.rs b/components/style/values/computed/box.rs index decba9f342f..1fb92bec13a 100644 --- a/components/style/values/computed/box.rs +++ b/components/style/values/computed/box.rs @@ -49,6 +49,7 @@ pub type Perspective = GenericPerspective; PartialEq, SpecifiedValueInfo, ToCss, + ToResolvedValue, )] #[repr(u8)] /// A computed value for the `float` property. @@ -118,6 +119,7 @@ impl ToComputedValue for SpecifiedFloat { PartialEq, SpecifiedValueInfo, ToCss, + ToResolvedValue, )] /// A computed value for the `clear` property. pub enum Clear { @@ -178,7 +180,7 @@ impl ToComputedValue for SpecifiedClear { /// A computed value for the `resize` property. #[allow(missing_docs)] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] -#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Parse, PartialEq, ToCss)] +#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Parse, PartialEq, ToCss, ToResolvedValue)] #[repr(u8)] pub enum Resize { None, diff --git a/components/style/values/computed/font.rs b/components/style/values/computed/font.rs index d332cf4d873..152bbcc0d4b 100644 --- a/components/style/values/computed/font.rs +++ b/components/style/values/computed/font.rs @@ -40,7 +40,7 @@ pub use crate::values::specified::font::{XLang, XTextZoom}; /// https://drafts.csswg.org/css-fonts-4/#propdef-font-weight /// /// This is effectively just a `Number`. -#[derive(Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, ToCss)] +#[derive(Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, ToCss, ToResolvedValue)] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] pub struct FontWeight(pub Number); @@ -74,6 +74,7 @@ impl ToAnimatedValue for FontWeight { PartialEq, ToAnimatedZero, ToCss, + ToResolvedValue, )] /// The computed value of font-size pub struct FontSize { @@ -174,7 +175,7 @@ impl ToAnimatedValue for FontSize { } } -#[derive(Clone, Debug, Eq, PartialEq)] +#[derive(Clone, Debug, Eq, PartialEq, ToResolvedValue)] #[cfg_attr(feature = "servo", derive(Hash, MallocSizeOf))] /// Specifies a prioritized list of font family names or generic family names. pub struct FontFamily { @@ -221,7 +222,7 @@ impl ToCss for FontFamily { } } -#[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToShmem)] +#[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToResolvedValue, ToShmem)] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] /// The name of a font family of choice pub struct FamilyName { @@ -264,7 +265,7 @@ impl ToCss for FamilyName { } } -#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToShmem)] +#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToResolvedValue, ToShmem)] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] /// Font family names must either be given quoted as strings, /// or unquoted as a sequence of one or more identifiers. @@ -279,7 +280,7 @@ pub enum FontFamilyNameSyntax { Identifiers, } -#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, ToCss)] +#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, ToCss, ToResolvedValue)] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize, Hash))] /// A set of faces that vary in weight, width or slope. pub enum SingleFontFamily { @@ -294,7 +295,7 @@ pub enum SingleFontFamily { /// The order here is important, if you change it make sure that /// `gfxPlatformFontList.h`s ranged array and `gfxFontFamilyList`'s /// sSingleGenerics are updated as well. -#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq, Parse, ToCss)] +#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq, Parse, ToCss, ToResolvedValue)] #[repr(u8)] #[allow(missing_docs)] pub enum GenericFontFamily { @@ -384,7 +385,7 @@ impl SingleFontFamily { } #[cfg(feature = "servo")] -#[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq)] +#[derive(Clone, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToResolvedValue)] /// A list of SingleFontFamily pub struct FontFamilyList(Box<[SingleFontFamily]>); @@ -546,7 +547,7 @@ impl<'a> Iterator for FontFamilyNameIter<'a> { } /// Preserve the readability of text when font fallback occurs -#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, ToCss)] +#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, ToCss, ToResolvedValue)] pub enum FontSizeAdjust { #[animation(error)] /// None variant @@ -627,7 +628,7 @@ pub type FontVariationSettings = FontSettings>; /// OpenType "language system" tag, so we should be able to compute /// it and store it as a 32-bit integer /// (see http://www.microsoft.com/typography/otspec/languagetags.htm). -#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq)] +#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, ToResolvedValue)] #[repr(C)] pub struct FontLanguageOverride(pub u32); @@ -733,7 +734,7 @@ impl ToComputedValue for specified::MozScriptLevel { /// A wrapper over an `Angle`, that handles clamping to the appropriate range /// for `font-style` animation. -#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToCss)] +#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToCss, ToResolvedValue)] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] pub struct FontStyleAngle(pub Angle); @@ -830,7 +831,7 @@ impl ToCss for FontStyle { /// A value for the font-stretch property per: /// /// https://drafts.csswg.org/css-fonts-4/#propdef-font-stretch -#[derive(Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, ToCss)] +#[derive(Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, ToCss, ToResolvedValue)] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] pub struct FontStretch(pub NonNegativePercentage); diff --git a/components/style/values/computed/image.rs b/components/style/values/computed/image.rs index a77da59dda3..4070e51815a 100644 --- a/components/style/values/computed/image.rs +++ b/components/style/values/computed/image.rs @@ -36,7 +36,7 @@ pub type GradientKind = generic::GradientKind; /// A computed gradient line direction. -#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq)] +#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, ToResolvedValue)] pub enum LineDirection { /// An angle. Angle(Angle), diff --git a/components/style/values/computed/length.rs b/components/style/values/computed/length.rs index 0fd624b5c55..92215541e8a 100644 --- a/components/style/values/computed/length.rs +++ b/components/style/values/computed/length.rs @@ -75,7 +75,7 @@ impl ToComputedValue for specified::Length { /// /// https://drafts.csswg.org/css-values-4/#typedef-length-percentage #[allow(missing_docs)] -#[derive(Clone, Copy, Debug, MallocSizeOf, ToAnimatedZero)] +#[derive(Clone, Copy, Debug, MallocSizeOf, ToAnimatedZero, ToResolvedValue)] #[repr(C)] pub struct LengthPercentage { length: Length, @@ -608,6 +608,7 @@ impl Size { PartialOrd, ToAnimatedValue, ToAnimatedZero, + ToResolvedValue, ToShmem, )] #[repr(C)] @@ -804,6 +805,7 @@ pub type NonNegativeLengthOrNumber = GenericLengthOrNumber for CSSFloat { } #[allow(missing_docs)] -#[derive(Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, ToCss)] +#[derive(Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq, ToCss, ToResolvedValue)] #[repr(C, u8)] pub enum NumberOrPercentage { Percentage(Percentage), diff --git a/components/style/values/computed/percentage.rs b/components/style/values/computed/percentage.rs index 68579f95fb4..c22f8ed5683 100644 --- a/components/style/values/computed/percentage.rs +++ b/components/style/values/computed/percentage.rs @@ -27,6 +27,7 @@ use style_traits::{CssWriter, ToCss}; ToAnimatedValue, ToAnimatedZero, ToComputedValue, + ToResolvedValue, ToShmem, )] #[repr(C)] diff --git a/components/style/values/computed/text.rs b/components/style/values/computed/text.rs index db56a16a82d..2fdb1e48c4f 100644 --- a/components/style/values/computed/text.rs +++ b/components/style/values/computed/text.rs @@ -37,6 +37,7 @@ pub type InitialLetter = GenericInitialLetter; PartialEq, ToAnimatedValue, ToAnimatedZero, + ToResolvedValue, )] pub struct LetterSpacing(pub Length); @@ -102,7 +103,7 @@ impl ToComputedValue for specified::WordSpacing { /// A computed value for the `line-height` property. pub type LineHeight = GenericLineHeight; -#[derive(Clone, Debug, MallocSizeOf, PartialEq)] +#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToResolvedValue)] /// text-overflow. /// When the specified value only has one side, that's the "second" /// side, and the sides are logical, so "second" means "end". The @@ -155,7 +156,7 @@ impl ToCss for TextOverflow { /// and similar stuff when we implement it. /// /// FIXME(emilio): Also, should be just a bitfield instead of three bytes. -#[derive(Clone, Copy, Debug, Default, MallocSizeOf, PartialEq)] +#[derive(Clone, Copy, Debug, Default, MallocSizeOf, PartialEq, ToResolvedValue)] pub struct TextDecorationsInEffect { /// Whether an underline is in effect. pub underline: bool, @@ -193,7 +194,7 @@ impl TextDecorationsInEffect { } /// computed value for the text-emphasis-style property -#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)] +#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss, ToResolvedValue)] pub enum TextEmphasisStyle { /// Keyword value for the text-emphasis-style property (`filled` `open`) Keyword(TextEmphasisKeywordValue), @@ -204,7 +205,7 @@ pub enum TextEmphasisStyle { } /// Keyword value for the text-emphasis-style property -#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss)] +#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss, ToResolvedValue)] pub struct TextEmphasisKeywordValue { /// fill for the text-emphasis-style property pub fill: TextEmphasisFillMode, diff --git a/components/style/values/computed/time.rs b/components/style/values/computed/time.rs index be16a5939bb..5681f6fab5e 100644 --- a/components/style/values/computed/time.rs +++ b/components/style/values/computed/time.rs @@ -9,7 +9,7 @@ use std::fmt::{self, Write}; use style_traits::{CssWriter, ToCss}; /// A computed `