Skip to content
Permalink
Browse files

style: Derive ToResolvedValue.

  • Loading branch information...
emilio committed Apr 10, 2019
1 parent 6ac777e commit a47dcb570713b44a9782024a29de1aba1e6726e4
Showing with 359 additions and 108 deletions.
  1. +1 −0 components/style/macros.rs
  2. +36 −7 components/style/properties/helpers.mako.rs
  3. +1 −1 components/style/values/computed/align.rs
  4. +1 −1 components/style/values/computed/angle.rs
  5. +3 −1 components/style/values/computed/box.rs
  6. +12 −11 components/style/values/computed/font.rs
  7. +1 −1 components/style/values/computed/image.rs
  8. +3 −1 components/style/values/computed/length.rs
  9. +1 −1 components/style/values/computed/mod.rs
  10. +1 −0 components/style/values/computed/percentage.rs
  11. +5 −4 components/style/values/computed/text.rs
  12. +1 −1 components/style/values/computed/time.rs
  13. +1 −0 components/style/values/generics/background.rs
  14. +12 −0 components/style/values/generics/basic_shape.rs
  15. +5 −0 components/style/values/generics/border.rs
  16. +11 −1 components/style/values/generics/box.rs
  17. +1 −0 components/style/values/generics/color.rs
  18. +1 −0 components/style/values/generics/column.rs
  19. +32 −4 components/style/values/generics/counters.rs
  20. +13 −1 components/style/values/generics/easing.rs
  21. +3 −0 components/style/values/generics/effects.rs
  22. +1 −0 components/style/values/generics/flex.rs
  23. +31 −3 components/style/values/generics/font.rs
  24. +12 −2 components/style/values/generics/gecko.rs
  25. +28 −7 components/style/values/generics/grid.rs
  26. +11 −11 components/style/values/generics/image.rs
  27. +4 −0 components/style/values/generics/length.rs
  28. +5 −2 components/style/values/generics/mod.rs
  29. +2 −0 components/style/values/generics/position.rs
  30. +1 −0 components/style/values/generics/rect.rs
  31. +1 −0 components/style/values/generics/size.rs
  32. +5 −0 components/style/values/generics/svg.rs
  33. +2 −0 components/style/values/generics/text.rs
  34. +20 −4 components/style/values/generics/transform.rs
  35. +3 −2 components/style/values/generics/ui.rs
  36. +1 −0 components/style/values/generics/url.rs
  37. +5 −3 components/style/values/mod.rs
  38. +8 −8 components/style/values/specified/align.rs
  39. +2 −1 components/style/values/specified/background.rs
  40. +2 −1 components/style/values/specified/border.rs
  41. +26 −8 components/style/values/specified/box.rs
  42. +9 −8 components/style/values/specified/font.rs
  43. +4 −3 components/style/values/specified/list.rs
  44. +1 −1 components/style/values/specified/mod.rs
  45. +1 −0 components/style/values/specified/motion.rs
  46. +1 −0 components/style/values/specified/outline.rs
  47. +7 −5 components/style/values/specified/position.rs
  48. +2 −2 components/style/values/specified/svg.rs
  49. +1 −0 components/style/values/specified/svg_path.rs
  50. +1 −0 components/style/values/specified/table.rs
  51. +7 −1 components/style/values/specified/text.rs
  52. +3 −1 components/style/values/specified/ui.rs
  53. +7 −0 components/style_derive/lib.rs
@@ -80,6 +80,7 @@ macro_rules! define_keyword_type {
ToAnimatedZero,
ToComputedValue,
ToCss,
ToResolvedValue,
ToShmem,
)]
pub struct $name;
@@ -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<T>(
% 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 @@
</%def>
% 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
@@ -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.
@@ -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 {
@@ -49,6 +49,7 @@ pub type Perspective = GenericPerspective<NonNegativeLength>;
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,
@@ -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<VariationValue<Number>>;
/// 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);

@@ -36,7 +36,7 @@ pub type GradientKind =
generic::GradientKind<LineDirection, Length, LengthPercentage, Position, Angle>;

/// 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),
@@ -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<NonNegativeLength, No
ToAnimatedZero,
ToComputedValue,
ToCss,
ToResolvedValue,
ToShmem,
)]
#[repr(u8)]
@@ -534,7 +534,7 @@ impl From<GreaterThanOrEqualToOneNumber> 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),
@@ -27,6 +27,7 @@ use style_traits::{CssWriter, ToCss};
ToAnimatedValue,
ToAnimatedZero,
ToComputedValue,
ToResolvedValue,
ToShmem,
)]
#[repr(C)]
@@ -37,6 +37,7 @@ pub type InitialLetter = GenericInitialLetter<CSSFloat, CSSInteger>;
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<NonNegativeNumber, NonNegativeLength>;

#[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,
@@ -9,7 +9,7 @@ use std::fmt::{self, Write};
use style_traits::{CssWriter, ToCss};

/// A computed `<time>` value.
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, PartialOrd)]
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, PartialOrd, ToResolvedValue)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
pub struct Time {
seconds: CSSFloat,
@@ -27,6 +27,7 @@ fn width_and_height_are_auto<L>(
ToAnimatedZero,
ToComputedValue,
ToCss,
ToResolvedValue,
ToShmem,
)]
#[repr(C, u8)]
Oops, something went wrong.

0 comments on commit a47dcb5

Please sign in to comment.
You can’t perform that action at this time.