style/values/generics/
effects.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5//! Generic types for CSS values related to effects.
6
7/// A generic value for a single `box-shadow`.
8#[derive(
9    Animate,
10    Clone,
11    ComputeSquaredDistance,
12    Debug,
13    MallocSizeOf,
14    PartialEq,
15    SpecifiedValueInfo,
16    ToAnimatedValue,
17    ToAnimatedZero,
18    ToCss,
19    ToResolvedValue,
20    ToShmem,
21)]
22#[repr(C)]
23pub struct GenericBoxShadow<Color, SizeLength, BlurShapeLength, ShapeLength> {
24    /// The base shadow.
25    pub base: GenericSimpleShadow<Color, SizeLength, BlurShapeLength>,
26    /// The spread radius.
27    pub spread: ShapeLength,
28    /// Whether this is an inset box shadow.
29    #[animation(constant)]
30    #[css(represents_keyword)]
31    pub inset: bool,
32}
33
34pub use self::GenericBoxShadow as BoxShadow;
35
36/// A generic value for a single `filter`.
37#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
38#[derive(
39    Clone,
40    ComputeSquaredDistance,
41    Debug,
42    MallocSizeOf,
43    PartialEq,
44    SpecifiedValueInfo,
45    ToAnimatedValue,
46    ToComputedValue,
47    ToCss,
48    ToResolvedValue,
49    ToShmem,
50)]
51#[animation(no_bound(U))]
52#[repr(C, u8)]
53pub enum GenericFilter<Angle, NonNegativeFactor, ZeroToOneFactor, Length, Shadow, U> {
54    /// `blur(<length>)`
55    #[css(function)]
56    Blur(Length),
57    /// `brightness(<factor>)`
58    #[css(function)]
59    Brightness(NonNegativeFactor),
60    /// `contrast(<factor>)`
61    #[css(function)]
62    Contrast(NonNegativeFactor),
63    /// `grayscale(<factor>)`
64    #[css(function)]
65    Grayscale(ZeroToOneFactor),
66    /// `hue-rotate(<angle>)`
67    #[css(function)]
68    HueRotate(Angle),
69    /// `invert(<factor>)`
70    #[css(function)]
71    Invert(ZeroToOneFactor),
72    /// `opacity(<factor>)`
73    #[css(function)]
74    Opacity(ZeroToOneFactor),
75    /// `saturate(<factor>)`
76    #[css(function)]
77    Saturate(NonNegativeFactor),
78    /// `sepia(<factor>)`
79    #[css(function)]
80    Sepia(ZeroToOneFactor),
81    /// `drop-shadow(...)`
82    #[css(function)]
83    DropShadow(Shadow),
84    /// `<url>`
85    #[animation(error)]
86    Url(U),
87}
88
89pub use self::GenericFilter as Filter;
90
91/// A generic value for the `drop-shadow()` filter and the `text-shadow` property.
92///
93/// Contrary to the canonical order from the spec, the color is serialised
94/// first, like in Gecko and Webkit.
95#[derive(
96    Animate,
97    Clone,
98    ComputeSquaredDistance,
99    Debug,
100    MallocSizeOf,
101    PartialEq,
102    SpecifiedValueInfo,
103    ToAnimatedValue,
104    ToAnimatedZero,
105    ToCss,
106    ToResolvedValue,
107    ToShmem,
108)]
109#[repr(C)]
110pub struct GenericSimpleShadow<Color, SizeLength, ShapeLength> {
111    /// Color.
112    pub color: Color,
113    /// Horizontal radius.
114    pub horizontal: SizeLength,
115    /// Vertical radius.
116    pub vertical: SizeLength,
117    /// Blur radius.
118    pub blur: ShapeLength,
119}
120
121pub use self::GenericSimpleShadow as SimpleShadow;