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<'i, 't>(
124 context: &ParserContext,
125 input: &mut Parser<'i, 't>,
126 ) -> Result<Self, ParseError<'i>> {
127 let kind = SVGPaintKind::parse(context, input)?;
128 if matches!(kind, SVGPaintKind::None | SVGPaintKind::Color(..)) {
129 return Ok(SVGPaint {
130 kind,
131 fallback: SVGPaintFallback::Unset,
132 });
133 }
134 let fallback = input
135 .try_parse(|i| SVGPaintFallback::parse(context, i))
136 .unwrap_or(SVGPaintFallback::Unset);
137 Ok(SVGPaint { kind, fallback })
138 }
139}
140
141#[derive(
143 Animate,
144 Clone,
145 ComputeSquaredDistance,
146 Copy,
147 Debug,
148 MallocSizeOf,
149 PartialEq,
150 SpecifiedValueInfo,
151 ToAnimatedValue,
152 ToAnimatedZero,
153 ToComputedValue,
154 ToCss,
155 ToResolvedValue,
156 ToShmem,
157 ToTyped,
158)]
159#[repr(C, u8)]
160#[typed(todo_derive_fields)]
161pub enum GenericSVGLength<L> {
162 LengthPercentage(L),
164 #[animation(error)]
166 ContextValue,
167}
168
169pub use self::GenericSVGLength as SVGLength;
170
171#[derive(
173 Clone,
174 Debug,
175 MallocSizeOf,
176 PartialEq,
177 SpecifiedValueInfo,
178 ToAnimatedValue,
179 ToAnimatedZero,
180 ToComputedValue,
181 ToCss,
182 ToResolvedValue,
183 ToShmem,
184 ToTyped,
185)]
186#[repr(C, u8)]
187#[typed(todo_derive_fields)]
188pub enum GenericSVGStrokeDashArray<L> {
189 #[css(comma)]
191 Values(#[css(if_empty = "none", iterable)] crate::OwnedSlice<L>),
192 ContextValue,
194}
195
196pub use self::GenericSVGStrokeDashArray as SVGStrokeDashArray;
197
198#[derive(
201 Animate,
202 Clone,
203 ComputeSquaredDistance,
204 Copy,
205 Debug,
206 MallocSizeOf,
207 PartialEq,
208 Parse,
209 SpecifiedValueInfo,
210 ToAnimatedValue,
211 ToAnimatedZero,
212 ToComputedValue,
213 ToCss,
214 ToResolvedValue,
215 ToShmem,
216 ToTyped,
217)]
218#[repr(C, u8)]
219#[typed(todo_derive_fields)]
220pub enum GenericSVGOpacity<OpacityType> {
221 Opacity(OpacityType),
223 #[animation(error)]
225 ContextFillOpacity,
226 #[animation(error)]
228 ContextStrokeOpacity,
229}
230
231pub use self::GenericSVGOpacity as SVGOpacity;