1use crate::derives::*;
8use crate::parser::{Parse, ParserContext};
9use cssparser::Parser;
10use style_traits::ParseError;
11
12#[derive(
14 Animate,
15 Clone,
16 ComputeSquaredDistance,
17 Debug,
18 MallocSizeOf,
19 PartialEq,
20 Parse,
21 SpecifiedValueInfo,
22 ToAnimatedValue,
23 ToAnimatedZero,
24 ToComputedValue,
25 ToCss,
26 ToResolvedValue,
27 ToShmem,
28)]
29#[repr(C, u8)]
30pub enum GenericSVGPaintFallback<C> {
31 None,
33 #[css(skip)]
36 Unset,
37 Color(C),
39}
40
41pub use self::GenericSVGPaintFallback as SVGPaintFallback;
42
43#[derive(
47 Animate,
48 Clone,
49 ComputeSquaredDistance,
50 Debug,
51 MallocSizeOf,
52 PartialEq,
53 SpecifiedValueInfo,
54 ToAnimatedValue,
55 ToAnimatedZero,
56 ToComputedValue,
57 ToCss,
58 ToResolvedValue,
59 ToShmem,
60 ToTyped,
61)]
62#[animation(no_bound(Url))]
63#[repr(C)]
64#[typed(todo_derive_fields)]
65pub struct GenericSVGPaint<Color, Url> {
66 pub kind: GenericSVGPaintKind<Color, Url>,
68 pub fallback: GenericSVGPaintFallback<Color>,
70}
71
72pub use self::GenericSVGPaint as SVGPaint;
73
74impl<C, U> Default for SVGPaint<C, U> {
75 fn default() -> Self {
76 Self {
77 kind: SVGPaintKind::None,
78 fallback: SVGPaintFallback::Unset,
79 }
80 }
81}
82
83#[derive(
88 Animate,
89 Clone,
90 ComputeSquaredDistance,
91 Debug,
92 MallocSizeOf,
93 PartialEq,
94 Parse,
95 SpecifiedValueInfo,
96 ToAnimatedValue,
97 ToAnimatedZero,
98 ToComputedValue,
99 ToCss,
100 ToResolvedValue,
101 ToShmem,
102)]
103#[animation(no_bound(U))]
104#[repr(C, u8)]
105pub enum GenericSVGPaintKind<C, U> {
106 #[animation(error)]
108 None,
109 Color(C),
111 #[animation(error)]
113 PaintServer(U),
114 ContextFill,
116 ContextStroke,
118}
119
120pub use self::GenericSVGPaintKind as SVGPaintKind;
121
122impl<C: Parse, U: Parse> Parse for SVGPaint<C, U> {
123 fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ParseError> {
124 let kind = SVGPaintKind::parse(context, input)?;
125 if matches!(kind, SVGPaintKind::None | SVGPaintKind::Color(..)) {
126 return Ok(SVGPaint {
127 kind,
128 fallback: SVGPaintFallback::Unset,
129 });
130 }
131 let fallback = input
132 .try_parse(|i| SVGPaintFallback::parse(context, i))
133 .unwrap_or(SVGPaintFallback::Unset);
134 Ok(SVGPaint { kind, fallback })
135 }
136}
137
138#[derive(
140 Animate,
141 Clone,
142 ComputeSquaredDistance,
143 Copy,
144 Debug,
145 MallocSizeOf,
146 PartialEq,
147 SpecifiedValueInfo,
148 ToAnimatedValue,
149 ToAnimatedZero,
150 ToComputedValue,
151 ToCss,
152 ToResolvedValue,
153 ToShmem,
154 ToTyped,
155)]
156#[repr(C, u8)]
157pub enum GenericSVGLength<L> {
158 LengthPercentage(L),
160 #[animation(error)]
162 ContextValue,
163}
164
165pub use self::GenericSVGLength as SVGLength;
166
167#[derive(
169 Clone,
170 Debug,
171 MallocSizeOf,
172 PartialEq,
173 SpecifiedValueInfo,
174 ToAnimatedValue,
175 ToAnimatedZero,
176 ToComputedValue,
177 ToCss,
178 ToResolvedValue,
179 ToShmem,
180 ToTyped,
181)]
182#[repr(C, u8)]
183pub enum GenericSVGStrokeDashArray<L> {
184 #[css(comma)]
186 #[typed(no_multiple_values)]
187 Values(#[css(if_empty = "none", iterable)] crate::OwnedSlice<L>),
188 ContextValue,
190}
191
192pub use self::GenericSVGStrokeDashArray as SVGStrokeDashArray;
193
194#[derive(
197 Animate,
198 Clone,
199 ComputeSquaredDistance,
200 Copy,
201 Debug,
202 MallocSizeOf,
203 PartialEq,
204 Parse,
205 SpecifiedValueInfo,
206 ToAnimatedValue,
207 ToAnimatedZero,
208 ToComputedValue,
209 ToCss,
210 ToResolvedValue,
211 ToShmem,
212 ToTyped,
213)]
214#[repr(C, u8)]
215pub enum GenericSVGOpacity<OpacityType> {
216 Opacity(OpacityType),
218 #[animation(error)]
220 ContextFillOpacity,
221 #[animation(error)]
223 ContextStrokeOpacity,
224}
225
226pub use self::GenericSVGOpacity as SVGOpacity;