Skip to main content

float_pigment_css/
typing_stringify.rs

1use alloc::{
2    string::{String, ToString},
3    vec::Vec,
4};
5
6use crate::sheet::borrow::Array;
7use crate::typing::*;
8use core::fmt;
9use cssparser::ToCss;
10
11fn generate_array_str<T: fmt::Display>(array: &Array<T>) -> String {
12    let mut str = String::new();
13    for index in 0..array.len() {
14        str.push_str(&array[index].to_string());
15        if index + 1 < array.len() {
16            str.push_str(", ");
17        }
18    }
19    str
20}
21
22impl fmt::Display for CalcExpr {
23    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
24        match self {
25            Self::Number(num) => write!(f, "{num}"),
26            Self::Angle(angle) => write!(f, "{angle}"),
27            Self::Length(length) => write!(f, "{length}"),
28            Self::Div(lhs, rhs) => write!(f, "{lhs}/{rhs}"),
29            Self::Mul(lhs, rhs) => write!(f, "{lhs}*{rhs}"),
30            Self::Plus(lhs, rhs) => write!(f, "{lhs} + {rhs}"),
31            Self::Sub(lhs, rhs) => write!(f, "{lhs} - {rhs}"),
32        }
33    }
34}
35
36impl fmt::Display for Number {
37    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
38        write!(
39            f,
40            "{}",
41            match self {
42                Number::F32(a) => a.to_string(),
43                Number::I32(a) => a.to_string(),
44                Number::Calc(expr) => expr.to_string(),
45            }
46        )
47    }
48}
49impl fmt::Display for Display {
50    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
51        write!(
52            f,
53            "{}",
54            match self {
55                Self::None => "none",
56                Self::Block => "block",
57                Self::Flex => "flex",
58                Self::Inline => "inline",
59                Self::InlineBlock => "inline-block",
60                Self::Grid => "grid",
61                Self::FlowRoot => "flow-root",
62                Self::InlineFlex => "inline-flex",
63                Self::InlineGrid => "inline-grid",
64            }
65        )
66    }
67}
68impl fmt::Display for Color {
69    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
70        let mut color = String::new();
71        write!(
72            f,
73            "{}",
74            match self {
75                Self::Undefined => "undefined",
76                Self::CurrentColor => "currentcolor",
77                Self::Specified(r, g, b, a) => {
78                    let rgba = cssparser_color::RgbaLegacy::new(*r, *g, *b, (*a) as f32 / 255.);
79                    cssparser_color::Color::Rgba(rgba).to_css(&mut color)?;
80                    let str = match color.as_str() {
81                        "rgb(0, 0, 0)" => "black",
82                        "rgb(192, 192, 192)" => "silver",
83                        "rgb(128, 128, 128)" => "gray",
84                        "rgb(255, 255, 255)" => "white",
85                        "rgb(128, 0, 0)" => "maroon",
86                        "rgb(255, 0, 0)" => "red",
87                        "rgb(128, 0, 128)" => "purple",
88                        "rgb(255, 0, 255)" => "fuchsia",
89                        "rgb(0, 128, 0)" => "green",
90                        "rgb(0, 255, 0)" => "lime",
91                        "rgb(128, 128, 0)" => "olive",
92                        "rgb(255, 255, 0)" => "yellow",
93                        "rgb(0, 0, 128)" => "navy",
94                        "rgb(0, 0, 255)" => "blue",
95                        "rgb(0, 128, 128)" => "teal",
96                        "rgb(0, 255, 255)" => "aqua",
97                        "rgb(240, 248, 255)" => "aliceblue",
98                        "rgb(250, 235, 215)" => "antiquewhite",
99                        "rgb(127, 255, 212)" => "aquamarine",
100                        "rgb(240, 255, 255)" => "azure",
101                        "rgb(245, 245, 220)" => "beige",
102                        "rgb(255, 228, 196)" => "bisque",
103                        "rgb(255, 235, 205)" => "blanchedalmond",
104                        "rgb(138, 43, 226)" => "blueviolet",
105                        "rgb(165, 42, 42)" => "brown",
106                        "rgb(222, 184, 135)" => "burlywood",
107                        "rgb(95, 158, 160)" => "cadetblue",
108                        "rgb(127, 255, 0)" => "chartreuse",
109                        "rgb(210, 105, 30)" => "chocolate",
110                        "rgb(255, 127, 80)" => "coral",
111                        "rgb(100, 149, 237)" => "cornflowerblue",
112                        "rgb(255, 248, 220)" => "cornsilk",
113                        "rgb(220, 20, 60)" => "crimson",
114                        // "rgb(0, 255, 255)" => "cyan",
115                        "rgb(0, 0, 139)" => "darkblue",
116                        "rgb(0, 139, 139)" => "darkcyan",
117                        "rgb(184, 134, 11)" => "darkgoldenrod",
118                        "rgb(169, 169, 169)" => "darkgray",
119                        "rgb(0, 100, 0)" => "darkgreen",
120                        // "rgb(169, 169, 169)" => "darkgrey",
121                        "rgb(189, 183, 107)" => "darkkhaki",
122                        "rgb(139, 0, 139)" => "darkmagenta",
123                        "rgb(85, 107, 47)" => "darkolivegreen",
124                        "rgb(255, 140, 0)" => "darkorange",
125                        "rgb(153, 50, 204)" => "darkorchid",
126                        "rgb(139, 0, 0)" => "darkred",
127                        "rgb(233, 150, 122)" => "darksalmon",
128                        "rgb(143, 188, 143)" => "darkseagreen",
129                        "rgb(72, 61, 139)" => "darkslateblue",
130                        "rgb(47, 79, 79)" => "darkslategray",
131                        // "rgb(47, 79, 79)" => "darkslategrey",
132                        "rgb(0, 206, 209)" => "darkturquoise",
133                        "rgb(148, 0, 211)" => "darkviolet",
134                        "rgb(255, 20, 147)" => "deeppink",
135                        "rgb(0, 191, 255)" => "deepskyblue",
136                        "rgb(105, 105, 105)" => "dimgray",
137                        // "rgb(105, 105, 105)" => "dimgrey",
138                        "rgb(30, 144, 255)" => "dodgerblue",
139                        "rgb(178, 34, 34)" => "firebrick",
140                        "rgb(255, 250, 240)" => "floralwhite",
141                        "rgb(34, 139, 34)" => "forestgreen",
142                        "rgb(220, 220, 220)" => "gainsboro",
143                        "rgb(248, 248, 255)" => "ghostwhite",
144                        "rgb(255, 215, 0)" => "gold",
145                        "rgb(218, 165, 32)" => "goldenrod",
146                        "rgb(173, 255, 47)" => "greenyellow",
147                        // "rgb(128, 128, 128)" => "grey",
148                        "rgb(240, 255, 240)" => "honeydew",
149                        "rgb(255, 105, 180)" => "hotpink",
150                        "rgb(205, 92, 92)" => "indianred",
151                        "rgb(75, 0, 130)" => "indigo",
152                        "rgb(255, 255, 240)" => "ivory",
153                        "rgb(240, 230, 140)" => "khaki",
154                        "rgb(230, 230, 250)" => "lavender",
155                        "rgb(255, 240, 245)" => "lavenderblush",
156                        "rgb(124, 252, 0)" => "lawngreen",
157                        "rgb(255, 250, 205)" => "lemonchiffon",
158                        "rgb(173, 216, 230)" => "lightblue",
159                        "rgb(240, 128, 128)" => "lightcoral",
160                        "rgb(224, 255, 255)" => "lightcyan",
161                        "rgb(250, 250, 210)" => "lightgoldenrodyellow",
162                        "rgb(211, 211, 211)" => "lightgray",
163                        "rgb(144, 238, 144)" => "lightgreen",
164                        // "rgb(211, 211, 211)" => "lightgrey",
165                        "rgb(255, 182, 193)" => "lightpink",
166                        "rgb(255, 160, 122)" => "lightsalmon",
167                        "rgb(32, 178, 170)" => "lightseagreen",
168                        "rgb(135, 206, 250)" => "lightskyblue",
169                        // "rgb(119, 136, 153)" => "lightslategray",
170                        "rgb(119, 136, 153)" => "lightslategrey",
171                        "rgb(176, 196, 222)" => "lightsteelblue",
172                        "rgb(255, 255, 224)" => "lightyellow",
173                        "rgb(50, 205, 50)" => "limegreen",
174                        // "rgb(250, 240, 230)" => "linen",
175                        // "rgb(255, 0, 255)" => "magenta",
176                        "rgb(102, 205, 170)" => "mediumaquamarine",
177                        "rgb(0, 0, 205)" => "mediumblue",
178                        "rgb(186, 85, 211)" => "mediumorchid",
179                        "rgb(147, 112, 219)" => "mediumpurple",
180                        "rgb(60, 179, 113)" => "mediumseagreen",
181                        "rgb(123, 104, 238)" => "mediumslateblue",
182                        "rgb(0, 250, 154)" => "mediumspringgreen",
183                        "rgb(72, 209, 204)" => "mediumturquoise",
184                        "rgb(199, 21, 133)" => "mediumvioletred",
185                        "rgb(25, 25, 112)" => "midnightblue",
186                        "rgb(245, 255, 250)" => "mintcream",
187                        "rgb(255, 228, 225)" => "mistyrose",
188                        "rgb(255, 228, 181)" => "moccasin",
189                        "rgb(255, 222, 173)" => "navajowhite",
190                        "rgb(253, 245, 230)" => "oldlace",
191                        "rgb(107, 142, 35)" => "olivedrab",
192                        "rgb(255, 165, 0)" => "orange",
193                        "rgb(255, 69, 0)" => "orangered",
194                        "rgb(218, 112, 214)" => "orchid",
195                        "rgb(238, 232, 170)" => "palegoldenrod",
196                        "rgb(152, 251, 152)" => "palegreen",
197                        "rgb(175, 238, 238)" => "paleturquoise",
198                        "rgb(219, 112, 147)" => "palevioletred",
199                        "rgb(255, 239, 213)" => "papayawhip",
200                        "rgb(255, 218, 185)" => "peachpuff",
201                        "rgb(205, 133, 63)" => "peru",
202                        "rgb(255, 192, 203)" => "pink",
203                        "rgb(221, 160, 221)" => "plum",
204                        "rgb(176, 224, 230)" => "powderblue",
205                        "rgb(102, 51, 153)" => "rebeccapurple",
206                        "rgb(188, 143, 143)" => "rosybrown",
207                        "rgb(65, 105, 225)" => "royalblue",
208                        "rgb(139, 69, 19)" => "saddlebrown",
209                        "rgb(250, 128, 114)" => "salmon",
210                        "rgb(244, 164, 96)" => "sandybrown",
211                        "rgb(46, 139, 87)" => "seagreen",
212                        "rgb(255, 245, 238)" => "seashell",
213                        "rgb(160, 82, 45)" => "sienna",
214                        "rgb(135, 206, 235)" => "skyblue",
215                        "rgb(106, 90, 205)" => "slateblue",
216                        // "rgb(112, 128, 144)" => "slategray",
217                        "rgb(112, 128, 144)" => "slategrey",
218                        "rgb(255, 250, 250)" => "snow",
219                        "rgb(0, 255, 127)" => "springgreen",
220                        "rgb(70, 130, 180)" => "steelblue",
221                        "rgb(210, 180, 140)" => "tan",
222                        "rgb(216, 191, 216)" => "thistle",
223                        "rgb(255, 99, 71)" => "tomato",
224                        "rgb(64, 224, 208)" => "turquoise",
225                        "rgb(238, 130, 238)" => "violet",
226                        "rgb(245, 222, 179)" => "wheat",
227                        "rgb(245, 245, 245)" => "whitesmoke",
228                        "rgb(154, 205, 50)" => "yellowgreen",
229                        x => x,
230                    };
231                    color = str.to_string();
232                    &color
233                }
234            }
235        )
236    }
237}
238impl fmt::Display for Length {
239    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
240        let tmp;
241        write!(
242            f,
243            "{}",
244            match self {
245                Length::Undefined => "null",
246                Length::Auto => "auto",
247                Length::Px(x) => {
248                    tmp = format!("{x}px");
249                    &tmp
250                }
251                Length::Vw(x) => {
252                    tmp = format!("{x}vw");
253                    &tmp
254                }
255                Length::Vh(x) => {
256                    tmp = format!("{x}vh");
257                    &tmp
258                }
259                Length::Rem(x) => {
260                    tmp = format!("{x}rem");
261                    &tmp
262                }
263                Length::Rpx(x) => {
264                    tmp = format!("{x}rpx");
265                    &tmp
266                }
267                Length::Em(x) => {
268                    tmp = format!("{x}em");
269                    &tmp
270                }
271                Length::Ratio(x) => {
272                    tmp = format!("{:.0}%", x * 100.0);
273                    &tmp
274                }
275                Length::Expr(expr) => {
276                    match expr {
277                        LengthExpr::Calc(calc_expr) => {
278                            tmp = calc_expr.to_string();
279                            &tmp
280                        }
281                        _ => "not support",
282                    }
283                }
284                Length::Vmin(x) => {
285                    tmp = format!("{x}vmin");
286                    &tmp
287                }
288                Length::Vmax(x) => {
289                    tmp = format!("{x}vmax");
290                    &tmp
291                }
292            }
293        )
294    }
295}
296
297impl fmt::Display for Position {
298    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
299        write!(
300            f,
301            "{}",
302            match self {
303                Position::Static => "static",
304                Position::Relative => "relative",
305                Position::Absolute => "absolute",
306                Position::Fixed => "fixed",
307                Position::Sticky => "sticky",
308            }
309        )
310    }
311}
312impl fmt::Display for Angle {
313    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
314        write!(
315            f,
316            "{}",
317            match self {
318                Angle::Deg(x) => {
319                    format!("{x}deg")
320                }
321                Angle::Grad(x) => {
322                    format!("{x}grad")
323                }
324                Angle::Rad(x) => {
325                    format!("{x}rad")
326                }
327                Angle::Turn(x) => {
328                    format!("{x}turn")
329                }
330                Angle::Calc(expr) => expr.to_string(),
331            }
332        )
333    }
334}
335
336impl fmt::Display for Overflow {
337    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
338        write!(
339            f,
340            "{}",
341            match self {
342                Overflow::Visible => "visible",
343                Overflow::Hidden => "hidden",
344                Overflow::Auto => "auto",
345                Overflow::Scroll => "scroll",
346            }
347        )
348    }
349}
350impl fmt::Display for OverflowWrap {
351    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
352        write!(
353            f,
354            "{}",
355            match self {
356                OverflowWrap::Normal => "normal",
357                OverflowWrap::BreakWord => "break-word",
358            }
359        )
360    }
361}
362impl fmt::Display for PointerEvents {
363    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
364        write!(
365            f,
366            "{}",
367            match self {
368                PointerEvents::Auto => "auto",
369                PointerEvents::None => "none",
370                PointerEvents::WxRoot => "root",
371            }
372        )
373    }
374}
375impl fmt::Display for WxEngineTouchEvent {
376    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
377        write!(
378            f,
379            "{}",
380            match self {
381                WxEngineTouchEvent::Gesture => "gesture",
382                WxEngineTouchEvent::Click => "click",
383                WxEngineTouchEvent::None => "none",
384            }
385        )
386    }
387}
388impl fmt::Display for Visibility {
389    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
390        write!(
391            f,
392            "{}",
393            match self {
394                Visibility::Visible => "visible",
395                Visibility::Hidden => "hidden",
396                Visibility::Collapse => "collapse",
397            }
398        )
399    }
400}
401impl fmt::Display for FlexWrap {
402    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
403        write!(
404            f,
405            "{}",
406            match self {
407                FlexWrap::NoWrap => "nowrap",
408                FlexWrap::Wrap => "wrap",
409                FlexWrap::WrapReverse => "wrap-reverse",
410            }
411        )
412    }
413}
414impl fmt::Display for FlexDirection {
415    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
416        write!(
417            f,
418            "{}",
419            match self {
420                FlexDirection::Row => "row",
421                FlexDirection::RowReverse => "row-reverse",
422                FlexDirection::Column => "column",
423                FlexDirection::ColumnReverse => "column-reverse",
424            }
425        )
426    }
427}
428impl fmt::Display for Direction {
429    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
430        write!(
431            f,
432            "{}",
433            match self {
434                Direction::Auto => "auto",
435                Direction::LTR => "ltr",
436                Direction::RTL => "rtl",
437            }
438        )
439    }
440}
441impl fmt::Display for WritingMode {
442    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
443        write!(
444            f,
445            "{}",
446            match self {
447                WritingMode::HorizontalTb => "horizontal-tb",
448                WritingMode::VerticalLr => "vertical-lr",
449                WritingMode::VerticalRl => "vertical-rl",
450            }
451        )
452    }
453}
454impl fmt::Display for AlignItems {
455    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
456        write!(
457            f,
458            "{}",
459            match self {
460                AlignItems::Stretch => "stretch",
461                AlignItems::Normal => "normal",
462                AlignItems::Center => "center",
463                AlignItems::Start => "start",
464                AlignItems::End => "end",
465                AlignItems::FlexStart => "flex-start",
466                AlignItems::FlexEnd => "flex-end",
467                AlignItems::SelfStart => "self-start",
468                AlignItems::SelfEnd => "self-end",
469                AlignItems::Baseline => "baseline",
470            }
471        )
472    }
473}
474impl fmt::Display for AlignSelf {
475    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
476        write!(
477            f,
478            "{}",
479            match self {
480                AlignSelf::Auto => "auto",
481                AlignSelf::Normal => "normal",
482                AlignSelf::Stretch => "stretch",
483                AlignSelf::Center => "center",
484                AlignSelf::Start => "start",
485                AlignSelf::End => "end",
486                AlignSelf::SelfStart => "self-start",
487                AlignSelf::SelfEnd => "self-end",
488                AlignSelf::FlexStart => "flex-start",
489                AlignSelf::FlexEnd => "flex-end",
490                AlignSelf::Baseline => "baseline",
491            }
492        )
493    }
494}
495impl fmt::Display for AlignContent {
496    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
497        write!(
498            f,
499            "{}",
500            match self {
501                AlignContent::Normal => "normal",
502                AlignContent::Start => "start",
503                AlignContent::End => "end",
504                AlignContent::Stretch => "stretch",
505                AlignContent::Center => "center",
506                AlignContent::FlexStart => "flex-start",
507                AlignContent::FlexEnd => "flex-end",
508                AlignContent::SpaceBetween => "space-between",
509                AlignContent::SpaceAround => "space-around",
510                AlignContent::SpaceEvenly => "space-evenly",
511                AlignContent::Baseline => "baseline",
512            }
513        )
514    }
515}
516impl fmt::Display for JustifyContent {
517    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
518        write!(
519            f,
520            "{}",
521            match self {
522                JustifyContent::Center => "center",
523                JustifyContent::FlexStart => "flex-start",
524                JustifyContent::FlexEnd => "flex-end",
525                JustifyContent::SpaceBetween => "space-between",
526                JustifyContent::SpaceAround => "space-around",
527                JustifyContent::SpaceEvenly => "space-evenly",
528                JustifyContent::Start => "start",
529                JustifyContent::End => "end",
530                JustifyContent::Left => "left",
531                JustifyContent::Right => "right",
532                JustifyContent::Stretch => "stretch",
533                JustifyContent::Baseline => "baseline",
534                JustifyContent::Normal => "normal",
535            }
536        )
537    }
538}
539impl fmt::Display for JustifyItems {
540    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
541        write!(
542            f,
543            "{}",
544            match self {
545                JustifyItems::Stretch => "stretch",
546                JustifyItems::Center => "center",
547                JustifyItems::Start => "start",
548                JustifyItems::End => "end",
549                JustifyItems::FlexStart => "flex-start",
550                JustifyItems::FlexEnd => "flex-end",
551                JustifyItems::SelfStart => "self-start",
552                JustifyItems::SelfEnd => "self-end",
553                JustifyItems::Left => "left",
554                JustifyItems::Right => "right",
555                JustifyItems::Normal => "normal",
556            }
557        )
558    }
559}
560impl fmt::Display for JustifySelf {
561    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
562        write!(
563            f,
564            "{}",
565            match self {
566                JustifySelf::Auto => "auto",
567                JustifySelf::Normal => "normal",
568                JustifySelf::Stretch => "stretch",
569                JustifySelf::Center => "center",
570                JustifySelf::Start => "start",
571                JustifySelf::End => "end",
572                JustifySelf::FlexStart => "flex-start",
573                JustifySelf::FlexEnd => "flex-end",
574                JustifySelf::SelfStart => "self-start",
575                JustifySelf::SelfEnd => "self-end",
576                JustifySelf::Left => "left",
577                JustifySelf::Right => "right",
578            }
579        )
580    }
581}
582impl fmt::Display for TextAlign {
583    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
584        write!(
585            f,
586            "{}",
587            match self {
588                TextAlign::Left => "left",
589                TextAlign::Center => "center",
590                TextAlign::Right => "right",
591                TextAlign::Justify => "justify",
592                TextAlign::JustifyAll => "justify-all",
593                TextAlign::Start => "start",
594                TextAlign::End => "end",
595                TextAlign::MatchParent => "match-parent",
596            }
597        )
598    }
599}
600impl fmt::Display for FontWeight {
601    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
602        let x;
603        write!(
604            f,
605            "{}",
606            match self {
607                FontWeight::Normal => "normal",
608                FontWeight::Bold => "bold",
609                FontWeight::Bolder => "bolder",
610                FontWeight::Lighter => "lighter",
611                FontWeight::Num(a) => {
612                    x = a.to_string();
613                    &x
614                }
615            }
616        )
617    }
618}
619impl fmt::Display for WordBreak {
620    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
621        write!(
622            f,
623            "{}",
624            match self {
625                WordBreak::BreakWord => "break-word",
626                WordBreak::BreakAll => "break-all",
627                WordBreak::KeepAll => "keep-all",
628            }
629        )
630    }
631}
632
633impl fmt::Display for WhiteSpace {
634    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
635        write!(
636            f,
637            "{}",
638            match self {
639                WhiteSpace::Normal => "normal",
640                WhiteSpace::NoWrap => "nowrap",
641                WhiteSpace::Pre => "pre",
642                WhiteSpace::PreWrap => "pre-wrap",
643                WhiteSpace::PreLine => "pre-line",
644                WhiteSpace::WxPreEdit => "-wx-pre-edit",
645            }
646        )
647    }
648}
649
650impl fmt::Display for TextOverflow {
651    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
652        write!(
653            f,
654            "{}",
655            match self {
656                TextOverflow::Clip => "clip",
657                TextOverflow::Ellipsis => "ellipsis",
658            }
659        )
660    }
661}
662impl fmt::Display for VerticalAlign {
663    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
664        write!(
665            f,
666            "{}",
667            match self {
668                VerticalAlign::Baseline => "baseline",
669                VerticalAlign::Top => "top",
670                VerticalAlign::Middle => "middle",
671                VerticalAlign::Bottom => "bottom",
672                VerticalAlign::TextTop => "text-top",
673                VerticalAlign::TextBottom => "text-bottom",
674            }
675        )
676    }
677}
678impl fmt::Display for LineHeight {
679    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
680        let x;
681        write!(
682            f,
683            "{}",
684            match self {
685                LineHeight::Normal => "normal",
686                LineHeight::Length(a) => {
687                    x = a.to_string();
688                    &x
689                }
690                LineHeight::Num(a) => {
691                    x = a.to_string();
692                    &x
693                }
694            }
695        )
696    }
697}
698impl fmt::Display for FontFamily {
699    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
700        let mut str: String = String::new();
701        write!(
702            f,
703            "{}",
704            match self {
705                FontFamily::Names(array) => {
706                    for index in 0..array.len() {
707                        str.push_str(&array[index].to_string());
708                        if index + 1 < array.len() {
709                            str.push_str(", ");
710                        }
711                    }
712                    &str
713                }
714            }
715        )
716    }
717}
718impl fmt::Display for FontFamilyName {
719    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
720        let str: String;
721        write!(
722            f,
723            "{}",
724            match self {
725                FontFamilyName::Serif => "serif",
726                FontFamilyName::SansSerif => "sans-serif",
727                FontFamilyName::Monospace => "monospace",
728                FontFamilyName::Cursive => "cursive",
729                FontFamilyName::Fantasy => "fantasy",
730                FontFamilyName::Title(a) => {
731                    str = format!("\"{}\"", a.to_string());
732                    &str
733                }
734                FontFamilyName::SystemUi => "system-ui",
735            }
736        )
737    }
738}
739impl fmt::Display for BoxSizing {
740    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
741        write!(
742            f,
743            "{}",
744            match self {
745                BoxSizing::ContentBox => "content-box",
746                BoxSizing::PaddingBox => "padding-box",
747                BoxSizing::BorderBox => "border-box",
748            }
749        )
750    }
751}
752impl fmt::Display for BorderStyle {
753    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
754        write!(
755            f,
756            "{}",
757            match self {
758                BorderStyle::None => "none",
759                BorderStyle::Solid => "solid",
760                BorderStyle::Dotted => "dotted",
761                BorderStyle::Dashed => "dashed",
762                BorderStyle::Hidden => "hidden",
763                BorderStyle::Double => "double",
764                BorderStyle::Groove => "groove",
765                BorderStyle::Ridge => "ridge",
766                BorderStyle::Inset => "inset",
767                BorderStyle::Outset => "outset",
768            }
769        )
770    }
771}
772impl fmt::Display for Transform {
773    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
774        let mut str = String::new();
775        write!(
776            f,
777            "{}",
778            match self {
779                Transform::Series(array) => {
780                    for index in 0..array.len() {
781                        str.push_str(&array[index].to_string());
782                        if index + 1 < array.len() {
783                            str.push(' ');
784                        }
785                    }
786                    &str
787                }
788            }
789        )
790    }
791}
792impl fmt::Display for TransformItem {
793    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
794        let mut str = String::new();
795        write!(
796            f,
797            "{}",
798            match self {
799                TransformItem::None => "none",
800                TransformItem::Matrix(array) => {
801                    for index in 0..array.len() {
802                        str.push_str(&array[index].to_string());
803                        if index + 1 < array.len() {
804                            str.push_str(", ");
805                        }
806                    }
807                    str = format!("matrix({})", &str);
808                    &str
809                }
810                TransformItem::Matrix3D(array) => {
811                    for index in 0..array.len() {
812                        str.push_str(&array[index].to_string());
813                        if index + 1 < array.len() {
814                            str.push_str(", ");
815                        }
816                    }
817                    str = format!("matrix3d({})", &str);
818                    &str
819                }
820                TransformItem::Translate2D(x, y) => {
821                    str = format!("translate({x}, {y})");
822                    &str
823                }
824                TransformItem::Translate3D(x, y, z) => {
825                    str = format!("translate3d({x}, {y}, {z})");
826                    &str
827                }
828                TransformItem::Scale2D(x, y) => {
829                    str = format!("scale({x}, {y})");
830                    &str
831                }
832                TransformItem::Scale3D(x, y, z) => {
833                    str = format!("scale3d({x}, {y}, {z})");
834                    &str
835                }
836                TransformItem::Rotate2D(x) => {
837                    str = format!("rotate({x})");
838                    &str
839                }
840                TransformItem::Rotate3D(x, y, z, deg) => {
841                    str = format!("rotate3d({x}, {y}, {z}, {deg})");
842                    &str
843                }
844                TransformItem::Skew(x, y) => {
845                    str = format!("skew({x}, {y})");
846                    &str
847                }
848                TransformItem::Perspective(x) => {
849                    str = format!("perspective({x})");
850                    &str
851                }
852            }
853        )
854    }
855}
856
857impl fmt::Display for TransitionProperty {
858    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
859        let mut str = String::new();
860        write!(
861            f,
862            "{}",
863            match self {
864                TransitionProperty::List(array) => {
865                    for index in 0..array.len() {
866                        str.push_str(&array[index].to_string());
867                        if index + 1 < array.len() {
868                            str.push_str(", ");
869                        }
870                    }
871                    &str
872                }
873            }
874        )
875    }
876}
877impl fmt::Display for TransitionPropertyItem {
878    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
879        write!(
880            f,
881            "{}",
882            match self {
883                TransitionPropertyItem::None => "none",
884                TransitionPropertyItem::Transform => "transform",
885                TransitionPropertyItem::TransformOrigin => "transform-origin",
886                TransitionPropertyItem::LineHeight => "line-height",
887                TransitionPropertyItem::Opacity => "opacity",
888                TransitionPropertyItem::All => "all",
889                TransitionPropertyItem::Height => "height",
890                TransitionPropertyItem::Width => "width",
891                TransitionPropertyItem::MinHeight => "min-height",
892                TransitionPropertyItem::MaxHeight => "max-height",
893                TransitionPropertyItem::MinWidth => "min-width",
894                TransitionPropertyItem::MaxWidth => "max-width",
895                TransitionPropertyItem::MarginTop => "margin-top",
896                TransitionPropertyItem::MarginRight => "margin-right",
897                TransitionPropertyItem::MarginLeft => "margin-left",
898                TransitionPropertyItem::MarginBottom => "margin-bottom",
899                TransitionPropertyItem::Margin => "margin",
900                TransitionPropertyItem::PaddingTop => "padding-top",
901                TransitionPropertyItem::PaddingRight => "padding-right",
902                TransitionPropertyItem::PaddingBottom => "padding-bottom",
903                TransitionPropertyItem::PaddingLeft => "padding-left",
904                TransitionPropertyItem::Padding => "padding",
905                TransitionPropertyItem::Top => "top",
906                TransitionPropertyItem::Right => "right",
907                TransitionPropertyItem::Bottom => "bottom",
908                TransitionPropertyItem::Left => "left",
909                TransitionPropertyItem::FlexGrow => "flex-grow",
910                TransitionPropertyItem::FlexShrink => "flex-shrink",
911                TransitionPropertyItem::FlexBasis => "flex-basis",
912                TransitionPropertyItem::Flex => "flex",
913                TransitionPropertyItem::BorderTopWidth => "border-top-width",
914                TransitionPropertyItem::BorderRightWidth => "border-right-width",
915                TransitionPropertyItem::BorderBottomWidth => "border-bottom-width",
916                TransitionPropertyItem::BorderLeftWidth => "border-left-width",
917                TransitionPropertyItem::BorderTopColor => "border-top-color",
918                TransitionPropertyItem::BorderRightColor => "border-right-color",
919                TransitionPropertyItem::BorderBottomColor => "border-bottom-color",
920                TransitionPropertyItem::BorderLeftColor => "border-left-color",
921                TransitionPropertyItem::BorderTopLeftRadius => "border-top-left-radius",
922                TransitionPropertyItem::BorderTopRightRadius => "border-top-right-radius",
923                TransitionPropertyItem::BorderBottomLeftRadius => "border-bottom-left-radius",
924                TransitionPropertyItem::BorderBottomRightRadius => "border-bottom-right-radius",
925                TransitionPropertyItem::Border => "border",
926                TransitionPropertyItem::BorderWidth => "border-width",
927                TransitionPropertyItem::BorderColor => "border-color",
928                TransitionPropertyItem::BorderRadius => "border-radius",
929                TransitionPropertyItem::BorderLeft => "border-left",
930                TransitionPropertyItem::BorderTop => "border-top",
931                TransitionPropertyItem::BorderRight => "border-right",
932                TransitionPropertyItem::BorderBottom => "border-bottom",
933                TransitionPropertyItem::Font => "font",
934                TransitionPropertyItem::ZIndex => "z-index",
935                TransitionPropertyItem::BoxShadow => "box-shadow",
936                TransitionPropertyItem::BackdropFilter => "backdrop-filter",
937                TransitionPropertyItem::Filter => "filter",
938                TransitionPropertyItem::Color => "color",
939                TransitionPropertyItem::TextDecorationColor => "text-decoration-color",
940                TransitionPropertyItem::TextDecorationThickness => "text-decoration-thickness",
941                TransitionPropertyItem::FontSize => "font-size",
942                TransitionPropertyItem::FontWeight => "font-weight",
943                TransitionPropertyItem::LetterSpacing => "letter-spacing",
944                TransitionPropertyItem::WordSpacing => "word-spacing",
945                TransitionPropertyItem::BackgroundColor => "background-color",
946                TransitionPropertyItem::BackgroundPosition => "background-position",
947                TransitionPropertyItem::BackgroundSize => "background-size",
948                TransitionPropertyItem::Background => "background",
949                TransitionPropertyItem::BackgroundPositionX => "background-position-x",
950                TransitionPropertyItem::BackgroundPositionY => "background-position-y",
951                TransitionPropertyItem::MaskPosition => "mask-position",
952                TransitionPropertyItem::MaskPositionX => "mask-position-x",
953                TransitionPropertyItem::MaskPositionY => "mask-position-y",
954                TransitionPropertyItem::MaskSize => "mask-size",
955                TransitionPropertyItem::Mask => "mask",
956            }
957        )
958    }
959}
960
961impl fmt::Display for StepPosition {
962    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
963        write!(
964            f,
965            "{}",
966            match self {
967                StepPosition::End => "end",
968                StepPosition::JumpStart => "jump-start",
969                StepPosition::JumpEnd => "jump-end",
970                StepPosition::JumpNone => "jump-none",
971                StepPosition::JumpBoth => "jump-both",
972                StepPosition::Start => "start",
973            }
974        )
975    }
976}
977
978impl fmt::Display for TransitionTime {
979    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
980        let mut str = String::new();
981        write!(
982            f,
983            "{}",
984            match self {
985                TransitionTime::List(array) => {
986                    for index in 0..array.len() {
987                        if array[index] >= 1000 {
988                            let s: u32 = array[index] / 1000;
989                            str.push_str(&s.to_string());
990                            str.push('s');
991                        } else {
992                            str.push_str(&array[index].to_string());
993                            str.push_str("ms");
994                        }
995
996                        if index + 1 < array.len() {
997                            str.push_str(", ");
998                        }
999                    }
1000                    &str
1001                }
1002                TransitionTime::ListI32(array) => {
1003                    for index in 0..array.len() {
1004                        if array[index] >= 1000 {
1005                            let s: i32 = array[index] / 1000;
1006                            str.push_str(&s.to_string());
1007                            str.push('s');
1008                        } else {
1009                            str.push_str(&array[index].to_string());
1010                            str.push_str("ms");
1011                        }
1012
1013                        if index + 1 < array.len() {
1014                            str.push_str(", ");
1015                        }
1016                    }
1017                    &str
1018                }
1019            }
1020        )
1021    }
1022}
1023
1024impl fmt::Display for TransitionTimingFn {
1025    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1026        let mut str = String::new();
1027        write!(
1028            f,
1029            "{}",
1030            match self {
1031                TransitionTimingFn::List(array) => {
1032                    for index in 0..array.len() {
1033                        str.push_str(&array[index].to_string());
1034                        if index + 1 < array.len() {
1035                            str.push_str(", ");
1036                        }
1037                    }
1038                    &str
1039                }
1040            }
1041        )
1042    }
1043}
1044impl fmt::Display for TransitionTimingFnItem {
1045    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1046        let str;
1047        write!(
1048            f,
1049            "{}",
1050            match self {
1051                TransitionTimingFnItem::Linear => "linear",
1052                TransitionTimingFnItem::Ease => "ease",
1053                TransitionTimingFnItem::EaseIn => "ease-in",
1054                TransitionTimingFnItem::EaseOut => "ease-out",
1055                TransitionTimingFnItem::EaseInOut => "ease-in-out",
1056                TransitionTimingFnItem::StepStart => "step-start",
1057                TransitionTimingFnItem::StepEnd => "step-end",
1058                TransitionTimingFnItem::Steps(x, y) => {
1059                    str = format!("steps({x}, {y})");
1060                    &str
1061                }
1062                TransitionTimingFnItem::CubicBezier(x, y, z, a) => {
1063                    str = format!("cubic-bezier({x}, {y}, {z}, {a})");
1064                    &str
1065                }
1066            }
1067        )
1068    }
1069}
1070
1071impl fmt::Display for Scrollbar {
1072    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1073        write!(
1074            f,
1075            "{}",
1076            match self {
1077                Scrollbar::Auto => "auto",
1078                Scrollbar::Hidden => "hidden",
1079                Scrollbar::AutoHide => "auto-hide",
1080                Scrollbar::AlwaysShow => "always-show",
1081            }
1082        )
1083    }
1084}
1085
1086impl fmt::Display for BackgroundRepeat {
1087    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1088        let mut str = String::new();
1089        write!(
1090            f,
1091            "{}",
1092            match self {
1093                BackgroundRepeat::List(array) => {
1094                    for index in 0..array.len() {
1095                        str.push_str(&array[index].to_string());
1096                        if index + 1 < array.len() {
1097                            str.push_str(", ");
1098                        }
1099                    }
1100                    &str
1101                }
1102            }
1103        )
1104    }
1105}
1106impl fmt::Display for BackgroundRepeatItem {
1107    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1108        let str;
1109        write!(
1110            f,
1111            "{}",
1112            match self {
1113                BackgroundRepeatItem::Pos(x, y) => {
1114                    str = format!("{x} {y}");
1115                    &str
1116                }
1117            }
1118        )
1119    }
1120}
1121impl fmt::Display for BackgroundRepeatValue {
1122    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1123        write!(
1124            f,
1125            "{}",
1126            match self {
1127                BackgroundRepeatValue::Repeat => "repeat",
1128                BackgroundRepeatValue::NoRepeat => "no-repeat",
1129                BackgroundRepeatValue::Space => "space",
1130                BackgroundRepeatValue::Round => "round",
1131            }
1132        )
1133    }
1134}
1135
1136impl fmt::Display for BackgroundSize {
1137    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1138        let mut str = String::new();
1139        write!(
1140            f,
1141            "{}",
1142            match self {
1143                BackgroundSize::List(array) => {
1144                    for index in 0..array.len() {
1145                        str.push_str(&array[index].to_string());
1146                        if index + 1 < array.len() {
1147                            str.push_str(", ");
1148                        }
1149                    }
1150                    &str
1151                }
1152            }
1153        )
1154    }
1155}
1156impl fmt::Display for BackgroundSizeItem {
1157    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1158        let str;
1159        write!(
1160            f,
1161            "{}",
1162            match self {
1163                BackgroundSizeItem::Auto => "auto",
1164                BackgroundSizeItem::Length(x, y) => {
1165                    str = format!("{x} {y}");
1166                    &str
1167                }
1168                BackgroundSizeItem::Cover => "cover",
1169                BackgroundSizeItem::Contain => "contain",
1170            }
1171        )
1172    }
1173}
1174impl fmt::Display for BackgroundImage {
1175    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1176        let mut str = String::new();
1177        write!(
1178            f,
1179            "{}",
1180            match self {
1181                BackgroundImage::List(array) => {
1182                    for index in 0..array.len() {
1183                        str.push_str(&array[index].to_string());
1184                        if index + 1 < array.len() {
1185                            str.push_str(", ");
1186                        }
1187                    }
1188                    &str
1189                }
1190            }
1191        )
1192    }
1193}
1194impl fmt::Display for ImageTags {
1195    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1196        write!(
1197            f,
1198            "{}",
1199            match self {
1200                ImageTags::LTR => "ltr",
1201                ImageTags::RTL => "rtl",
1202            }
1203        )
1204    }
1205}
1206impl fmt::Display for ImageSource {
1207    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1208        let str;
1209        write!(
1210            f,
1211            "{}",
1212            match self {
1213                ImageSource::None => "none",
1214                ImageSource::Url(x) => {
1215                    str = format!("url({})", x.to_string());
1216                    &str
1217                }
1218            }
1219        )
1220    }
1221}
1222impl fmt::Display for BackgroundImageItem {
1223    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1224        let mut tmp;
1225        write!(
1226            f,
1227            "{}",
1228            match self {
1229                BackgroundImageItem::None => "none",
1230                BackgroundImageItem::Url(x) => {
1231                    tmp = format!("url(\"{}\")", x.to_string());
1232                    &tmp
1233                }
1234                BackgroundImageItem::Gradient(x) => {
1235                    tmp = x.to_string();
1236                    &tmp
1237                }
1238                BackgroundImageItem::Image(x, y, z) => {
1239                    tmp = String::from("image(");
1240                    // ignore default LTR
1241                    if *x != ImageTags::LTR {
1242                        tmp.push_str(&x.to_string());
1243                        tmp.push(' ');
1244                    }
1245
1246                    if *y != ImageSource::None {
1247                        tmp.push_str(&y.to_string());
1248                    }
1249                    if *z != Color::Undefined {
1250                        tmp.push_str(", ");
1251                        tmp.push_str(&z.to_string());
1252                    }
1253                    tmp.push(')');
1254                    &tmp
1255                }
1256                BackgroundImageItem::Element(x) => {
1257                    tmp = format!("element(#{})", x.to_string());
1258                    &tmp
1259                }
1260            }
1261        )
1262    }
1263}
1264impl fmt::Display for BackgroundImageGradientItem {
1265    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1266        let mut str = String::new();
1267        write!(
1268            f,
1269            "{}",
1270            match self {
1271                BackgroundImageGradientItem::LinearGradient(x, array) => {
1272                    str.push_str("linear-gradient(");
1273                    // ignore default 180
1274                    if *x != Angle::Deg(180.0) {
1275                        str.push_str(&x.to_string());
1276                        str.push_str(", ");
1277                    }
1278                    str.push_str(&generate_array_str(array));
1279                    str.push(')');
1280                    &str
1281                }
1282                BackgroundImageGradientItem::RadialGradient(x, y, z, array) => {
1283                    str = generate_array_str(array);
1284                    str = format!("radial-gradient({x} {y} at {z}, {str})");
1285                    &str
1286                }
1287                BackgroundImageGradientItem::ConicGradient(gradient) => {
1288                    str = format!(
1289                        "conic-gradient(from {} at {}, {})",
1290                        gradient.angle,
1291                        gradient.position,
1292                        generate_array_str(&gradient.items)
1293                    );
1294                    &str
1295                }
1296            }
1297        )
1298    }
1299}
1300
1301impl fmt::Display for GradientSize {
1302    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1303        let tmp;
1304        write!(
1305            f,
1306            "{}",
1307            match self {
1308                GradientSize::ClosestSide => "closest-side",
1309                GradientSize::ClosestCorner => "closest-corner",
1310                GradientSize::FarthestSide => "farthest-side",
1311                GradientSize::FarthestCorner => "farthest-corner",
1312                GradientSize::Len(x, y) => {
1313                    tmp = format!("{x} {y}");
1314                    &tmp
1315                }
1316            }
1317        )
1318    }
1319}
1320impl fmt::Display for GradientPosition {
1321    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1322        let tmp;
1323        // left bottom  => 0% 100%
1324
1325        write!(
1326            f,
1327            "{}",
1328            match self {
1329                GradientPosition::Pos(x, y) => {
1330                    let horizontal_str = match x {
1331                        y if *y == Length::Ratio(0.5) => "center".to_string(),
1332                        y if *y == Length::Ratio(0.0) => "left".to_string(),
1333                        y if *y == Length::Ratio(1.0) => "right".to_string(),
1334                        x => x.to_string(),
1335                    };
1336                    let vertical_str = match y {
1337                        n if *n == Length::Ratio(0.5) => "center".to_string(),
1338                        n if *n == Length::Ratio(0.0) => "top".to_string(),
1339                        n if *n == Length::Ratio(1.0) => "bottom".to_string(),
1340                        y => y.to_string(),
1341                    };
1342
1343                    if horizontal_str == vertical_str {
1344                        "center"
1345                    } else {
1346                        tmp = format!("{horizontal_str} {vertical_str}");
1347                        &tmp
1348                    }
1349                }
1350                GradientPosition::SpecifiedPos(x, y) => {
1351                    let horizontal_str = match x {
1352                        GradientSpecifiedPos::Left(v) => format!("left {}", v),
1353                        GradientSpecifiedPos::Right(v) => format!("right {}", v),
1354                        GradientSpecifiedPos::Top(v) => format!("top {}", v),
1355                        GradientSpecifiedPos::Bottom(v) => format!("bottom {}", v),
1356                    };
1357
1358                    let vertical_str = match y {
1359                        GradientSpecifiedPos::Left(v) => format!("left {}", v),
1360                        GradientSpecifiedPos::Right(v) => format!("right {}", v),
1361                        GradientSpecifiedPos::Top(v) => format!("top {}", v),
1362                        GradientSpecifiedPos::Bottom(v) => format!("bottom {}", v),
1363                    };
1364                    tmp = format!("{horizontal_str} {vertical_str}");
1365                    &tmp
1366                }
1367            }
1368        )
1369    }
1370}
1371impl fmt::Display for GradientShape {
1372    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1373        write!(
1374            f,
1375            "{}",
1376            match self {
1377                GradientShape::Ellipse => "ellipse",
1378                GradientShape::Circle => "circle",
1379            }
1380        )
1381    }
1382}
1383impl fmt::Display for GradientColorItem {
1384    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1385        let mut tmp = String::new();
1386        write!(
1387            f,
1388            "{}",
1389            match self {
1390                GradientColorItem::ColorHint(color, len) => {
1391                    tmp.push_str(&color.to_string());
1392                    // ignore auto
1393                    if *len != Length::Auto {
1394                        tmp.push(' ');
1395                        tmp.push_str(&len.to_string());
1396                    }
1397                    &tmp
1398                }
1399                GradientColorItem::SimpleColorHint(color) => {
1400                    tmp.push_str(&color.to_string());
1401                    &tmp
1402                }
1403                GradientColorItem::AngleOrPercentageColorHint(color, angle_or_percentage) => {
1404                    tmp.push_str(&color.to_string());
1405                    tmp.push(' ');
1406                    match angle_or_percentage {
1407                        AngleOrPercentage::Angle(angle) => {
1408                            tmp.push_str(&angle.to_string());
1409                        }
1410                        AngleOrPercentage::Percentage(percentage) => {
1411                            tmp.push_str(&percentage.to_string());
1412                        }
1413                    }
1414                    &tmp
1415                }
1416            }
1417        )
1418    }
1419}
1420impl fmt::Display for BackgroundPosition {
1421    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1422        let mut x = String::new();
1423        write!(
1424            f,
1425            "{}",
1426            match self {
1427                BackgroundPosition::List(items) => {
1428                    for index in 0..items.len() {
1429                        x.push_str(&items[index].to_string());
1430                        if index < items.len() - 1 {
1431                            x.push_str(", ");
1432                        }
1433                    }
1434                    &x
1435                }
1436            }
1437        )
1438    }
1439}
1440impl fmt::Display for BackgroundPositionItem {
1441    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1442        let mut str = String::new();
1443        write!(
1444            f,
1445            "{}",
1446            match self {
1447                BackgroundPositionItem::Pos(x, y) => {
1448                    let horizontal_str = &x.to_string();
1449                    let vertical_str = &y.to_string();
1450                    if *horizontal_str == "center" && *vertical_str == "center" {
1451                        str.push_str("center");
1452                    } else if vertical_str == "center" {
1453                        str.push_str(horizontal_str);
1454                    } else {
1455                        str = format!("{horizontal_str} {vertical_str}");
1456                    }
1457                    &str
1458                }
1459                BackgroundPositionItem::Value(v) => {
1460                    str = v.to_string();
1461                    &str
1462                }
1463            }
1464        )
1465    }
1466}
1467impl fmt::Display for BackgroundPositionValue {
1468    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1469        let mut x = String::new();
1470        write!(
1471            f,
1472            "{}",
1473            match self {
1474                BackgroundPositionValue::Top(top) => {
1475                    match top {
1476                        n if *n == Length::Ratio(0.) => {
1477                            x.push_str("top");
1478                        }
1479                        n if *n == Length::Ratio(1.) => {
1480                            x.push_str("bottom");
1481                        }
1482                        n if *n == Length::Ratio(0.5) => {
1483                            x.push_str("center");
1484                        }
1485                        // top ratio not need keyword
1486                        Length::Ratio(ratio) => x.push_str(&Length::Ratio(*ratio).to_string()),
1487                        other => {
1488                            x = format!("{} {}", "top", &other.to_string());
1489                        }
1490                    }
1491                    &x
1492                }
1493                BackgroundPositionValue::Bottom(bottom) => {
1494                    match bottom {
1495                        n if *n == Length::Ratio(0.) => {
1496                            x.push_str("bottom");
1497                        }
1498                        n if *n == Length::Ratio(1.) => {
1499                            x.push_str("top");
1500                        }
1501                        n if *n == Length::Ratio(0.5) => {
1502                            x.push_str("center");
1503                        }
1504                        other => {
1505                            x = format!("{} {}", "bottom", &other.to_string());
1506                        }
1507                    }
1508                    &x
1509                }
1510                BackgroundPositionValue::Left(left) => {
1511                    match left {
1512                        n if *n == Length::Ratio(0.) => {
1513                            x.push_str("left");
1514                        }
1515                        n if *n == Length::Ratio(1.) => {
1516                            x.push_str("right");
1517                        }
1518                        n if *n == Length::Ratio(0.5) => {
1519                            x.push_str("center");
1520                        }
1521                        // left ratio not need keyword
1522                        Length::Ratio(ratio) => x.push_str(&Length::Ratio(*ratio).to_string()),
1523                        other => {
1524                            x = format!("{} {}", "left", &other.to_string());
1525                        }
1526                    }
1527                    &x
1528                }
1529                BackgroundPositionValue::Right(right) => {
1530                    match right {
1531                        n if *n == Length::Ratio(0.) => {
1532                            x.push_str("right");
1533                        }
1534                        n if *n == Length::Ratio(1.) => {
1535                            x.push_str("left");
1536                        }
1537                        n if *n == Length::Ratio(0.5) => {
1538                            x.push_str("center");
1539                        }
1540                        other => {
1541                            x = format!("{} {}", "right", &other.to_string());
1542                        }
1543                    }
1544                    &x
1545                }
1546            }
1547        )
1548    }
1549}
1550impl fmt::Display for FontStyle {
1551    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1552        let mut x = String::new();
1553        write!(
1554            f,
1555            "{}",
1556            match self {
1557                FontStyle::Normal => "normal",
1558                FontStyle::Italic => "italic",
1559                FontStyle::Oblique(a) => {
1560                    x.push_str("oblique");
1561                    if *a != Angle::Deg(14.) {
1562                        x.push(' ');
1563                        x.push_str(&a.to_string());
1564                    }
1565                    &x
1566                }
1567            }
1568        )
1569    }
1570}
1571impl fmt::Display for BackgroundClip {
1572    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1573        let mut str = String::new();
1574        write!(
1575            f,
1576            "{}",
1577            match self {
1578                BackgroundClip::List(items) => {
1579                    for index in 0..items.len() {
1580                        str.push_str(&items[index].to_string());
1581                        if index < items.len() - 1 {
1582                            str.push_str(", ")
1583                        }
1584                    }
1585                    &str
1586                }
1587            }
1588        )
1589    }
1590}
1591
1592impl fmt::Display for BackgroundClipItem {
1593    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1594        write!(
1595            f,
1596            "{}",
1597            match self {
1598                BackgroundClipItem::BorderBox => "border-box",
1599                BackgroundClipItem::PaddingBox => "padding-box",
1600                BackgroundClipItem::ContentBox => "content-box",
1601                BackgroundClipItem::Text => "text",
1602            }
1603        )
1604    }
1605}
1606
1607impl fmt::Display for BackgroundOrigin {
1608    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1609        let mut str = String::new();
1610        write!(
1611            f,
1612            "{}",
1613            match self {
1614                BackgroundOrigin::List(items) => {
1615                    for index in 0..items.len() {
1616                        str.push_str(&items[index].to_string());
1617                        if index < items.len() - 1 {
1618                            str.push_str(", ")
1619                        }
1620                    }
1621                    &str
1622                }
1623            }
1624        )
1625    }
1626}
1627impl fmt::Display for BackgroundOriginItem {
1628    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1629        write!(
1630            f,
1631            "{}",
1632            match self {
1633                BackgroundOriginItem::BorderBox => "border-box",
1634                BackgroundOriginItem::PaddingBox => "padding-box",
1635                BackgroundOriginItem::ContentBox => "content-box",
1636            }
1637        )
1638    }
1639}
1640impl fmt::Display for BackgroundAttachmentItem {
1641    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1642        write!(
1643            f,
1644            "{}",
1645            match self {
1646                BackgroundAttachmentItem::Scroll => "scroll",
1647                BackgroundAttachmentItem::Fixed => "fixed",
1648                BackgroundAttachmentItem::Local => "local",
1649            }
1650        )
1651    }
1652}
1653impl fmt::Display for BackgroundAttachment {
1654    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1655        let mut str = String::new();
1656        write!(
1657            f,
1658            "{}",
1659            match self {
1660                BackgroundAttachment::List(items) => {
1661                    for index in 0..items.len() {
1662                        str.push_str(&items[index].to_string());
1663                        if index < items.len() - 1 {
1664                            str.push_str(", ")
1665                        }
1666                    }
1667                    &str
1668                }
1669            }
1670        )
1671    }
1672}
1673impl fmt::Display for Float {
1674    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1675        write!(
1676            f,
1677            "{}",
1678            match self {
1679                Float::None => "none",
1680                Float::Left => "left",
1681                Float::Right => "right",
1682                Float::InlineStart => "inline-start",
1683                Float::InlineEnd => "inline-end",
1684            }
1685        )
1686    }
1687}
1688impl fmt::Display for ListStyleType {
1689    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1690        let x;
1691        write!(
1692            f,
1693            "{}",
1694            match self {
1695                ListStyleType::Disc => "disc",
1696                ListStyleType::None => "none",
1697                ListStyleType::Circle => "circle",
1698                ListStyleType::Square => "square",
1699                ListStyleType::Decimal => "decimal",
1700                ListStyleType::CjkDecimal => "cjk-decimal",
1701                ListStyleType::DecimalLeadingZero => "decimal-leading-zero",
1702                ListStyleType::LowerRoman => "lower-roman",
1703                ListStyleType::UpperRoman => "upper-roman",
1704                ListStyleType::LowerGreek => "lower-greek",
1705                ListStyleType::LowerAlpha => "lower-alpha",
1706                ListStyleType::LowerLatin => "lower-latin",
1707                ListStyleType::UpperAlpha => "upper-alpha",
1708                ListStyleType::UpperLatin => "upper-latin",
1709                ListStyleType::Armenian => "armenian",
1710                ListStyleType::Georgian => "georgian",
1711                ListStyleType::CustomIdent(str) => {
1712                    x = str.to_string();
1713                    &x
1714                }
1715            }
1716        )
1717    }
1718}
1719impl fmt::Display for ListStyleImage {
1720    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1721        let str;
1722        write!(
1723            f,
1724            "{}",
1725            match self {
1726                ListStyleImage::None => "none",
1727                ListStyleImage::Url(x) => {
1728                    str = format!("url({})", x.to_string());
1729                    &str
1730                }
1731            }
1732        )
1733    }
1734}
1735impl fmt::Display for ListStylePosition {
1736    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1737        write!(
1738            f,
1739            "{}",
1740            match self {
1741                ListStylePosition::Outside => "outside",
1742                ListStylePosition::Inside => "inside",
1743            }
1744        )
1745    }
1746}
1747impl fmt::Display for Resize {
1748    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1749        write!(
1750            f,
1751            "{}",
1752            match self {
1753                Resize::None => "none",
1754                Resize::Both => "both",
1755                Resize::Horizontal => "horizontal",
1756                Resize::Vertical => "vertical",
1757                Resize::Block => "block",
1758                Resize::Inline => "inline",
1759            }
1760        )
1761    }
1762}
1763impl fmt::Display for ZIndex {
1764    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1765        let x;
1766        write!(
1767            f,
1768            "{}",
1769            match self {
1770                ZIndex::Auto => "auto",
1771                ZIndex::Num(a) => {
1772                    x = format!("{a}");
1773                    &x
1774                }
1775            }
1776        )
1777    }
1778}
1779impl fmt::Display for TextShadow {
1780    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1781        let mut str = String::new();
1782        write!(
1783            f,
1784            "{}",
1785            match self {
1786                TextShadow::None => "none",
1787                TextShadow::List(items) => {
1788                    for index in 0..items.len() {
1789                        str.push_str(&items[index].to_string());
1790                        if index < items.len() - 1 {
1791                            str.push_str(", ")
1792                        }
1793                    }
1794                    &str
1795                }
1796            }
1797        )
1798    }
1799}
1800impl fmt::Display for TextShadowItem {
1801    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1802        let mut tmp = String::new();
1803        write!(
1804            f,
1805            "{}",
1806            match self {
1807                TextShadowItem::TextShadowValue(offsety, offsetx, blurradius, color) => {
1808                    if *offsety != Length::Px(0.) {
1809                        tmp.push_str(&offsety.to_string());
1810                    }
1811                    if *offsetx != Length::Px(0.) {
1812                        tmp.push(' ');
1813                        tmp.push_str(&offsetx.to_string());
1814                    }
1815                    if *blurradius != Length::Px(0.) && *blurradius != Length::Undefined {
1816                        tmp.push(' ');
1817                        tmp.push_str(&blurradius.to_string());
1818                    }
1819                    if *color != Color::Undefined {
1820                        tmp.push(' ');
1821                        tmp.push_str(&color.to_string());
1822                    }
1823                    &tmp
1824                }
1825            }
1826        )
1827    }
1828}
1829impl fmt::Display for TextDecorationLine {
1830    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1831        let mut str = String::new();
1832        write!(
1833            f,
1834            "{}",
1835            match self {
1836                TextDecorationLine::None => "none",
1837                TextDecorationLine::SpellingError => "spelling-error",
1838                TextDecorationLine::GrammarError => "grammar-error",
1839                TextDecorationLine::List(array) => {
1840                    for index in 0..array.len() {
1841                        str.push_str(&array[index].to_string());
1842                        if index + 1 < array.len() {
1843                            str.push(' ');
1844                        }
1845                    }
1846                    &str
1847                }
1848            }
1849        )
1850    }
1851}
1852
1853impl fmt::Display for TextDecorationLineItem {
1854    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1855        write!(
1856            f,
1857            "{}",
1858            match self {
1859                TextDecorationLineItem::Overline => "overline",
1860                TextDecorationLineItem::LineThrough => "line-through",
1861                TextDecorationLineItem::Underline => "underline",
1862                TextDecorationLineItem::Blink => "blink",
1863            }
1864        )
1865    }
1866}
1867impl fmt::Display for TextDecorationStyle {
1868    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1869        write!(
1870            f,
1871            "{}",
1872            match self {
1873                TextDecorationStyle::Solid => "solid",
1874                TextDecorationStyle::Double => "double",
1875                TextDecorationStyle::Dotted => "dotted",
1876                TextDecorationStyle::Dashed => "dashed",
1877                TextDecorationStyle::Wavy => "wavy",
1878            }
1879        )
1880    }
1881}
1882impl fmt::Display for TextDecorationThickness {
1883    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1884        let x;
1885        write!(
1886            f,
1887            "{}",
1888            match self {
1889                TextDecorationThickness::Auto => "auto",
1890                TextDecorationThickness::FromFont => "from-font",
1891                TextDecorationThickness::Length(len) => {
1892                    x = len.to_string();
1893                    &x
1894                }
1895            }
1896        )
1897    }
1898}
1899impl fmt::Display for LetterSpacing {
1900    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1901        let x;
1902        write!(
1903            f,
1904            "{}",
1905            match self {
1906                LetterSpacing::Normal => "normal",
1907                LetterSpacing::Length(len) => {
1908                    x = len.to_string();
1909                    &x
1910                }
1911            }
1912        )
1913    }
1914}
1915impl fmt::Display for WordSpacing {
1916    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1917        let x;
1918        write!(
1919            f,
1920            "{}",
1921            match self {
1922                WordSpacing::Normal => "normal",
1923                WordSpacing::Length(len) => {
1924                    x = len.to_string();
1925                    &x
1926                }
1927            }
1928        )
1929    }
1930}
1931impl fmt::Display for BorderRadius {
1932    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1933        let tmp;
1934        write!(
1935            f,
1936            "{}",
1937            match self {
1938                BorderRadius::Pos(x, y) => {
1939                    tmp = format!("{x} {y}");
1940                    &tmp
1941                }
1942            }
1943        )
1944    }
1945}
1946impl fmt::Display for BoxShadow {
1947    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1948        let mut str = String::new();
1949        write!(
1950            f,
1951            "{}",
1952            match self {
1953                BoxShadow::None => "none",
1954                BoxShadow::List(items) => {
1955                    for index in 0..items.len() {
1956                        str.push_str(&items[index].to_string());
1957                        if index < items.len() - 1 {
1958                            str.push_str(", ")
1959                        }
1960                    }
1961                    &str
1962                }
1963            }
1964        )
1965    }
1966}
1967impl fmt::Display for BoxShadowItem {
1968    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1969        let mut str = String::new();
1970        write!(
1971            f,
1972            "{}",
1973            match self {
1974                BoxShadowItem::List(items) => {
1975                    for index in 0..items.len() {
1976                        str.push_str(&items[index].to_string());
1977                        if index < items.len() - 1 {
1978                            str.push(' ')
1979                        }
1980                    }
1981                    &str
1982                }
1983            }
1984        )
1985    }
1986}
1987impl fmt::Display for ShadowItemType {
1988    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1989        let x;
1990        write!(
1991            f,
1992            "{}",
1993            match self {
1994                ShadowItemType::Inset => "inset",
1995                ShadowItemType::OffsetX(len) => {
1996                    x = len.to_string();
1997                    &x
1998                }
1999                ShadowItemType::OffsetY(len) => {
2000                    x = len.to_string();
2001                    &x
2002                }
2003                ShadowItemType::BlurRadius(len) => {
2004                    x = len.to_string();
2005                    &x
2006                }
2007                ShadowItemType::SpreadRadius(len) => {
2008                    x = len.to_string();
2009                    &x
2010                }
2011                ShadowItemType::Color(len) => {
2012                    x = len.to_string();
2013                    &x
2014                }
2015            }
2016        )
2017    }
2018}
2019impl fmt::Display for BackdropFilter {
2020    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2021        let mut str = String::new();
2022        write!(
2023            f,
2024            "{}",
2025            match self {
2026                BackdropFilter::None => "none",
2027                BackdropFilter::List(items) => {
2028                    for index in 0..items.len() {
2029                        str.push_str(&items[index].to_string());
2030                        if index < items.len() - 1 {
2031                            str.push(' ')
2032                        }
2033                    }
2034                    &str
2035                }
2036            }
2037        )
2038    }
2039}
2040impl fmt::Display for Filter {
2041    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2042        let mut str = String::new();
2043        write!(
2044            f,
2045            "{}",
2046            match self {
2047                Filter::None => "none",
2048                Filter::List(items) => {
2049                    for index in 0..items.len() {
2050                        str.push_str(&items[index].to_string());
2051                        if index < items.len() - 1 {
2052                            str.push(' ')
2053                        }
2054                    }
2055                    &str
2056                }
2057            }
2058        )
2059    }
2060}
2061impl fmt::Display for FilterFunc {
2062    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2063        let x;
2064        write!(
2065            f,
2066            "{}",
2067            match self {
2068                FilterFunc::Url(len) => {
2069                    x = format!("url({})", len.to_string());
2070                    &x
2071                }
2072                FilterFunc::Blur(len) => {
2073                    x = format!("blur({len})");
2074                    &x
2075                }
2076                FilterFunc::Brightness(len) => {
2077                    x = format!("brightness({len})");
2078                    &x
2079                }
2080                FilterFunc::Contrast(len) => {
2081                    x = format!("contranst({len})");
2082                    &x
2083                }
2084                FilterFunc::DropShadow(len) => {
2085                    x = format!("drop-shadow({len})");
2086                    &x
2087                }
2088                FilterFunc::Grayscale(len) => {
2089                    x = format!("grayscale({len})");
2090                    &x
2091                }
2092                FilterFunc::HueRotate(len) => {
2093                    x = format!("hue-rotate({len})");
2094                    &x
2095                }
2096                FilterFunc::Invert(len) => {
2097                    x = format!("invert({len})");
2098                    &x
2099                }
2100                FilterFunc::Opacity(len) => {
2101                    x = format!("opacity({len})");
2102                    &x
2103                }
2104                FilterFunc::Saturate(len) => {
2105                    x = format!("saturate({len})");
2106                    &x
2107                }
2108                FilterFunc::Sepia(len) => {
2109                    x = format!("sepia({len})");
2110                    &x
2111                }
2112            }
2113        )
2114    }
2115}
2116impl fmt::Display for DropShadow {
2117    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2118        let mut str = String::new();
2119        write!(
2120            f,
2121            "{}",
2122            match self {
2123                DropShadow::List(items) => {
2124                    for index in 0..items.len() {
2125                        str.push_str(&items[index].to_string());
2126                        if index < items.len() - 1 {
2127                            str.push(' ')
2128                        }
2129                    }
2130                    &str
2131                }
2132            }
2133        )
2134    }
2135}
2136impl fmt::Display for TransformOrigin {
2137    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2138        let mut tmp = String::new();
2139        write!(
2140            f,
2141            "{}",
2142            match self {
2143                TransformOrigin::LengthTuple(x, y, z) => {
2144                    let horizontal_str = match x {
2145                        n if *n == Length::Ratio(0.5) => "center".to_string(),
2146                        n if *n == Length::Ratio(0.0) => "left".to_string(),
2147                        n if *n == Length::Ratio(1.0) => "right".to_string(),
2148                        x => x.to_string(),
2149                    };
2150                    let vertical_str = match y {
2151                        n if *n == Length::Ratio(0.5) => "center".to_string(),
2152                        n if *n == Length::Ratio(0.0) => "top".to_string(),
2153                        n if *n == Length::Ratio(1.0) => "bottom".to_string(),
2154                        y => y.to_string(),
2155                    };
2156
2157                    if horizontal_str == vertical_str {
2158                        tmp.push_str("center");
2159                    } else {
2160                        tmp = format!("{horizontal_str} {vertical_str}");
2161                    }
2162
2163                    match z {
2164                        n if *n == Length::Px(0.) => {}
2165                        y => {
2166                            tmp.push(' ');
2167                            tmp.push_str(&y.to_string())
2168                        }
2169                    }
2170
2171                    &tmp
2172                }
2173                TransformOrigin::Left => "left",
2174                TransformOrigin::Right => "right",
2175                TransformOrigin::Center => "center",
2176                TransformOrigin::Bottom => "bottom",
2177                TransformOrigin::Top => "top",
2178                TransformOrigin::Length(len) => {
2179                    tmp = len.to_string();
2180                    &tmp
2181                }
2182            }
2183        )
2184    }
2185}
2186
2187impl fmt::Display for MaskMode {
2188    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2189        let mut str = String::new();
2190        write!(
2191            f,
2192            "{}",
2193            match self {
2194                MaskMode::List(items) => {
2195                    for index in 0..items.len() {
2196                        str.push_str(&items[index].to_string());
2197                        if index < items.len() - 1 {
2198                            str.push_str(", ")
2199                        }
2200                    }
2201                    &str
2202                }
2203            }
2204        )
2205    }
2206}
2207impl fmt::Display for MaskModeItem {
2208    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2209        write!(
2210            f,
2211            "{}",
2212            match self {
2213                MaskModeItem::MatchSource => "match-source",
2214                MaskModeItem::Alpha => "alpha",
2215                MaskModeItem::Luminance => "luminance",
2216            }
2217        )
2218    }
2219}
2220
2221impl fmt::Display for AspectRatio {
2222    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2223        match self {
2224            AspectRatio::Auto => write!(f, "auto"),
2225            AspectRatio::Ratio(x, y) => write!(f, "{x} / {y}"),
2226        }
2227    }
2228}
2229
2230impl fmt::Display for Contain {
2231    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2232        match self {
2233            Contain::None => write!(f, "none"),
2234            Contain::Content => write!(f, "content"),
2235            Contain::Strict => write!(f, "strict"),
2236            Contain::Multiple(v) => {
2237                let mut ret = vec![];
2238                v.iter().for_each(|key| match key {
2239                    ContainKeyword::Layout => ret.push("layout"),
2240                    ContainKeyword::Paint => ret.push("paint"),
2241                    ContainKeyword::Size => ret.push("size"),
2242                    ContainKeyword::Style => ret.push("style"),
2243                });
2244                write!(f, "{}", ret.join(" "))
2245            }
2246        }
2247    }
2248}
2249
2250impl fmt::Display for Content {
2251    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2252        match self {
2253            Content::None => write!(f, "none"),
2254            Content::Normal => write!(f, "normal"),
2255            Content::Str(x) => write!(f, "'{}'", x.to_string()),
2256            Content::Url(x) => write!(f, "'{}'", x.to_string()),
2257        }
2258    }
2259}
2260
2261impl fmt::Display for CustomProperty {
2262    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2263        match self {
2264            CustomProperty::None => write!(f, "none"),
2265            CustomProperty::Expr(key, value) => {
2266                write!(f, "{}:{}", key.to_string(), value.to_string())
2267            }
2268        }
2269    }
2270}
2271
2272impl fmt::Display for AnimationName {
2273    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2274        let mut ret = vec![];
2275        match self {
2276            AnimationName::List(list) => list.iter().for_each(|x| match x {
2277                AnimationNameItem::None => ret.push("none".to_string()),
2278                AnimationNameItem::CustomIdent(ident) => ret.push(ident.to_string()),
2279            }),
2280        }
2281        write!(f, "{}", ret.join(","))
2282    }
2283}
2284
2285impl fmt::Display for AnimationDirection {
2286    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2287        let mut ret: Vec<&str> = vec![];
2288        match self {
2289            AnimationDirection::List(list) => list.iter().for_each(|x| match x {
2290                AnimationDirectionItem::Normal => ret.push("normal"),
2291                AnimationDirectionItem::Alternate => ret.push("alternate"),
2292                AnimationDirectionItem::AlternateReverse => ret.push("alternate-reverse"),
2293                AnimationDirectionItem::Reverse => ret.push("reverse"),
2294            }),
2295        }
2296        write!(f, "{}", ret.join(","))
2297    }
2298}
2299
2300impl fmt::Display for AnimationFillMode {
2301    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2302        let mut ret = vec![];
2303        match self {
2304            AnimationFillMode::List(list) => list.iter().for_each(|x| match x {
2305                AnimationFillModeItem::None => ret.push("none"),
2306                AnimationFillModeItem::Forwards => ret.push("forwards"),
2307                AnimationFillModeItem::Backwards => ret.push("backwords"),
2308                AnimationFillModeItem::Both => ret.push("both"),
2309            }),
2310        }
2311        write!(f, "{}", ret.join(","))
2312    }
2313}
2314
2315impl fmt::Display for AnimationIterationCount {
2316    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2317        let mut ret = vec![];
2318        match self {
2319            AnimationIterationCount::List(list) => list.iter().for_each(|x| match x {
2320                AnimationIterationCountItem::Infinite => ret.push("infinite".to_string()),
2321                AnimationIterationCountItem::Number(num) => ret.push(num.to_string()),
2322            }),
2323        }
2324        write!(f, "{}", ret.join(","))
2325    }
2326}
2327
2328impl fmt::Display for AnimationPlayState {
2329    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2330        let mut ret = vec![];
2331        match self {
2332            AnimationPlayState::List(list) => list.iter().for_each(|x| match x {
2333                AnimationPlayStateItem::Running => ret.push("running"),
2334                AnimationPlayStateItem::Paused => ret.push("paused"),
2335            }),
2336        }
2337        write!(f, "{}", ret.join(","))
2338    }
2339}
2340
2341impl fmt::Display for WillChange {
2342    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2343        let mut ret = vec![];
2344        match self {
2345            WillChange::Auto => ret.push("auto".to_string()),
2346            WillChange::List(list) => list.iter().for_each(|feature| match feature {
2347                AnimateableFeature::Contents => ret.push("contents".to_string()),
2348                AnimateableFeature::ScrollPosition => ret.push("scroll-position".to_string()),
2349                AnimateableFeature::CustomIdent(x) => ret.push(x.to_string()),
2350            }),
2351        };
2352        write!(f, "{}", ret.join(","))
2353    }
2354}
2355
2356impl fmt::Display for FontFeatureSettings {
2357    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2358        let mut ret = vec![];
2359        match self {
2360            FontFeatureSettings::Normal => ret.push("normal".to_string()),
2361            FontFeatureSettings::FeatureTags(tags) => tags.iter().for_each(|feature_tag_value| {
2362                ret.push(format!(
2363                    "{} {}",
2364                    feature_tag_value.opentype_tag.to_string(),
2365                    feature_tag_value.value
2366                ));
2367            }),
2368        };
2369        write!(f, "{}", ret.join(","))
2370    }
2371}
2372
2373impl fmt::Display for Gap {
2374    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2375        match self {
2376            Gap::Normal => write!(f, "normal"),
2377            Gap::Length(length) => write!(f, "{length}"),
2378        }
2379    }
2380}
2381
2382impl fmt::Display for TrackSize {
2383    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2384        match self {
2385            TrackSize::Length(length) => write!(f, "{length}"),
2386            TrackSize::MinContent => write!(f, "min-content"),
2387            TrackSize::MaxContent => write!(f, "max-content"),
2388            TrackSize::Fr(x) => write!(f, "{x}fr"),
2389        }
2390    }
2391}
2392
2393impl fmt::Display for GridTemplate {
2394    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2395        match self {
2396            GridTemplate::None => write!(f, "none"),
2397            GridTemplate::TrackList(list) => {
2398                let mut ret = vec![];
2399                list.iter().for_each(|x| match x {
2400                    TrackListItem::LineNames(line_names) => ret.push(
2401                        line_names
2402                            .iter()
2403                            .map(|x| x.to_string())
2404                            .collect::<Vec<_>>()
2405                            .join(" "),
2406                    ),
2407                    TrackListItem::TrackSize(track_size) => ret.push(track_size.to_string()),
2408                });
2409                write!(f, "{}", ret.join(" "))
2410            }
2411        }
2412    }
2413}
2414
2415impl fmt::Display for GridAutoFlow {
2416    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2417        match self {
2418            GridAutoFlow::Row => write!(f, "row"),
2419            GridAutoFlow::Column => write!(f, "column"),
2420            GridAutoFlow::RowDense => write!(f, "row dense"),
2421            GridAutoFlow::ColumnDense => write!(f, "column dense"),
2422        }
2423    }
2424}
2425
2426impl fmt::Display for GridAuto {
2427    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2428        match self {
2429            GridAuto::List(list) => {
2430                let mut ret = vec![];
2431                list.iter().for_each(|x| ret.push(x.to_string()));
2432                write!(f, "{}", ret.join(" "))
2433            }
2434        }
2435    }
2436}