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, 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(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(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(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(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(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)" => "lightslategrey",
171 "rgb(176, 196, 222)" => "lightsteelblue",
172 "rgb(255, 255, 224)" => "lightyellow",
173 "rgb(50, 205, 50)" => "limegreen",
174 "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)" => "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::TextUnderlineOffset => "text-underline-offset",
942 TransitionPropertyItem::FontSize => "font-size",
943 TransitionPropertyItem::FontWeight => "font-weight",
944 TransitionPropertyItem::LetterSpacing => "letter-spacing",
945 TransitionPropertyItem::WordSpacing => "word-spacing",
946 TransitionPropertyItem::BackgroundColor => "background-color",
947 TransitionPropertyItem::BackgroundPosition => "background-position",
948 TransitionPropertyItem::BackgroundSize => "background-size",
949 TransitionPropertyItem::Background => "background",
950 TransitionPropertyItem::BackgroundPositionX => "background-position-x",
951 TransitionPropertyItem::BackgroundPositionY => "background-position-y",
952 TransitionPropertyItem::MaskPosition => "mask-position",
953 TransitionPropertyItem::MaskPositionX => "mask-position-x",
954 TransitionPropertyItem::MaskPositionY => "mask-position-y",
955 TransitionPropertyItem::MaskSize => "mask-size",
956 TransitionPropertyItem::Mask => "mask",
957 }
958 )
959 }
960}
961
962impl fmt::Display for StepPosition {
963 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
964 write!(
965 f,
966 "{}",
967 match self {
968 StepPosition::End => "end",
969 StepPosition::JumpStart => "jump-start",
970 StepPosition::JumpEnd => "jump-end",
971 StepPosition::JumpNone => "jump-none",
972 StepPosition::JumpBoth => "jump-both",
973 StepPosition::Start => "start",
974 }
975 )
976 }
977}
978
979impl fmt::Display for TransitionTime {
980 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
981 let mut str = String::new();
982 write!(
983 f,
984 "{}",
985 match self {
986 TransitionTime::List(array) => {
987 for index in 0..array.len() {
988 if array[index] >= 1000 {
989 let s: u32 = array[index] / 1000;
990 str.push_str(&s.to_string());
991 str.push('s');
992 } else {
993 str.push_str(&array[index].to_string());
994 str.push_str("ms");
995 }
996
997 if index + 1 < array.len() {
998 str.push_str(", ");
999 }
1000 }
1001 &str
1002 }
1003 TransitionTime::ListI32(array) => {
1004 for index in 0..array.len() {
1005 if array[index] >= 1000 {
1006 let s: i32 = array[index] / 1000;
1007 str.push_str(&s.to_string());
1008 str.push('s');
1009 } else {
1010 str.push_str(&array[index].to_string());
1011 str.push_str("ms");
1012 }
1013
1014 if index + 1 < array.len() {
1015 str.push_str(", ");
1016 }
1017 }
1018 &str
1019 }
1020 }
1021 )
1022 }
1023}
1024
1025impl fmt::Display for TransitionTimingFn {
1026 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1027 let mut str = String::new();
1028 write!(
1029 f,
1030 "{}",
1031 match self {
1032 TransitionTimingFn::List(array) => {
1033 for index in 0..array.len() {
1034 str.push_str(&array[index].to_string());
1035 if index + 1 < array.len() {
1036 str.push_str(", ");
1037 }
1038 }
1039 &str
1040 }
1041 }
1042 )
1043 }
1044}
1045impl fmt::Display for TransitionTimingFnItem {
1046 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1047 let str;
1048 write!(
1049 f,
1050 "{}",
1051 match self {
1052 TransitionTimingFnItem::Linear => "linear",
1053 TransitionTimingFnItem::Ease => "ease",
1054 TransitionTimingFnItem::EaseIn => "ease-in",
1055 TransitionTimingFnItem::EaseOut => "ease-out",
1056 TransitionTimingFnItem::EaseInOut => "ease-in-out",
1057 TransitionTimingFnItem::StepStart => "step-start",
1058 TransitionTimingFnItem::StepEnd => "step-end",
1059 TransitionTimingFnItem::Steps(x, y) => {
1060 str = format!("steps({x}, {y})");
1061 &str
1062 }
1063 TransitionTimingFnItem::CubicBezier(x, y, z, a) => {
1064 str = format!("cubic-bezier({x}, {y}, {z}, {a})");
1065 &str
1066 }
1067 }
1068 )
1069 }
1070}
1071
1072impl fmt::Display for Scrollbar {
1073 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1074 write!(
1075 f,
1076 "{}",
1077 match self {
1078 Scrollbar::Auto => "auto",
1079 Scrollbar::Hidden => "hidden",
1080 Scrollbar::AutoHide => "auto-hide",
1081 Scrollbar::AlwaysShow => "always-show",
1082 }
1083 )
1084 }
1085}
1086
1087impl fmt::Display for BackgroundRepeat {
1088 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1089 let mut str = String::new();
1090 write!(
1091 f,
1092 "{}",
1093 match self {
1094 BackgroundRepeat::List(array) => {
1095 for index in 0..array.len() {
1096 str.push_str(&array[index].to_string());
1097 if index + 1 < array.len() {
1098 str.push_str(", ");
1099 }
1100 }
1101 &str
1102 }
1103 }
1104 )
1105 }
1106}
1107impl fmt::Display for BackgroundRepeatItem {
1108 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1109 let str;
1110 write!(
1111 f,
1112 "{}",
1113 match self {
1114 BackgroundRepeatItem::Pos(x, y) => {
1115 str = format!("{x} {y}");
1116 &str
1117 }
1118 }
1119 )
1120 }
1121}
1122impl fmt::Display for BackgroundRepeatValue {
1123 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1124 write!(
1125 f,
1126 "{}",
1127 match self {
1128 BackgroundRepeatValue::Repeat => "repeat",
1129 BackgroundRepeatValue::NoRepeat => "no-repeat",
1130 BackgroundRepeatValue::Space => "space",
1131 BackgroundRepeatValue::Round => "round",
1132 }
1133 )
1134 }
1135}
1136
1137impl fmt::Display for BackgroundSize {
1138 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1139 let mut str = String::new();
1140 write!(
1141 f,
1142 "{}",
1143 match self {
1144 BackgroundSize::List(array) => {
1145 for index in 0..array.len() {
1146 str.push_str(&array[index].to_string());
1147 if index + 1 < array.len() {
1148 str.push_str(", ");
1149 }
1150 }
1151 &str
1152 }
1153 }
1154 )
1155 }
1156}
1157impl fmt::Display for BackgroundSizeItem {
1158 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1159 let str;
1160 write!(
1161 f,
1162 "{}",
1163 match self {
1164 BackgroundSizeItem::Auto => "auto",
1165 BackgroundSizeItem::Length(x, y) => {
1166 str = format!("{x} {y}");
1167 &str
1168 }
1169 BackgroundSizeItem::Cover => "cover",
1170 BackgroundSizeItem::Contain => "contain",
1171 }
1172 )
1173 }
1174}
1175impl fmt::Display for BackgroundImage {
1176 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1177 let mut str = String::new();
1178 write!(
1179 f,
1180 "{}",
1181 match self {
1182 BackgroundImage::List(array) => {
1183 for index in 0..array.len() {
1184 str.push_str(&array[index].to_string());
1185 if index + 1 < array.len() {
1186 str.push_str(", ");
1187 }
1188 }
1189 &str
1190 }
1191 }
1192 )
1193 }
1194}
1195impl fmt::Display for ImageTags {
1196 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1197 write!(
1198 f,
1199 "{}",
1200 match self {
1201 ImageTags::LTR => "ltr",
1202 ImageTags::RTL => "rtl",
1203 }
1204 )
1205 }
1206}
1207impl fmt::Display for ImageSource {
1208 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1209 let str;
1210 write!(
1211 f,
1212 "{}",
1213 match self {
1214 ImageSource::None => "none",
1215 ImageSource::Url(x) => {
1216 str = format!("url({})", x.to_string());
1217 &str
1218 }
1219 }
1220 )
1221 }
1222}
1223impl fmt::Display for BackgroundImageItem {
1224 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1225 let mut tmp;
1226 write!(
1227 f,
1228 "{}",
1229 match self {
1230 BackgroundImageItem::None => "none",
1231 BackgroundImageItem::Url(x) => {
1232 tmp = format!("url(\"{}\")", x.to_string());
1233 &tmp
1234 }
1235 BackgroundImageItem::Gradient(x) => {
1236 tmp = x.to_string();
1237 &tmp
1238 }
1239 BackgroundImageItem::Image(x, y, z) => {
1240 tmp = String::from("image(");
1241 if *x != ImageTags::LTR {
1243 tmp.push_str(&x.to_string());
1244 tmp.push(' ');
1245 }
1246
1247 if *y != ImageSource::None {
1248 tmp.push_str(&y.to_string());
1249 }
1250 if *z != Color::Undefined {
1251 tmp.push_str(", ");
1252 tmp.push_str(&z.to_string());
1253 }
1254 tmp.push(')');
1255 &tmp
1256 }
1257 BackgroundImageItem::Element(x) => {
1258 tmp = format!("element(#{})", x.to_string());
1259 &tmp
1260 }
1261 }
1262 )
1263 }
1264}
1265impl fmt::Display for BackgroundImageGradientItem {
1266 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1267 let mut str = String::new();
1268 write!(
1269 f,
1270 "{}",
1271 match self {
1272 BackgroundImageGradientItem::LinearGradient(x, array) => {
1273 str.push_str("linear-gradient(");
1274 if *x != Angle::Deg(180.0) {
1276 str.push_str(&x.to_string());
1277 str.push_str(", ");
1278 }
1279 str.push_str(&generate_array_str(array));
1280 str.push(')');
1281 &str
1282 }
1283 BackgroundImageGradientItem::RadialGradient(x, y, z, array) => {
1284 str = generate_array_str(array);
1285 str = format!("radial-gradient({x} {y} at {z}, {str})");
1286 &str
1287 }
1288 BackgroundImageGradientItem::ConicGradient(gradient) => {
1289 str = format!(
1290 "conic-gradient(from {} at {}, {})",
1291 gradient.angle,
1292 gradient.position,
1293 generate_array_str(&gradient.items)
1294 );
1295 &str
1296 }
1297 }
1298 )
1299 }
1300}
1301
1302impl fmt::Display for GradientSize {
1303 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1304 let tmp;
1305 write!(
1306 f,
1307 "{}",
1308 match self {
1309 GradientSize::ClosestSide => "closest-side",
1310 GradientSize::ClosestCorner => "closest-corner",
1311 GradientSize::FarthestSide => "farthest-side",
1312 GradientSize::FarthestCorner => "farthest-corner",
1313 GradientSize::Len(x, y) => {
1314 tmp = format!("{x} {y}");
1315 &tmp
1316 }
1317 }
1318 )
1319 }
1320}
1321impl fmt::Display for GradientPosition {
1322 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1323 let tmp;
1324 write!(
1327 f,
1328 "{}",
1329 match self {
1330 GradientPosition::Pos(x, y) => {
1331 let horizontal_str = match x {
1332 y if *y == Length::Ratio(0.5) => "center".to_string(),
1333 y if *y == Length::Ratio(0.0) => "left".to_string(),
1334 y if *y == Length::Ratio(1.0) => "right".to_string(),
1335 x => x.to_string(),
1336 };
1337 let vertical_str = match y {
1338 n if *n == Length::Ratio(0.5) => "center".to_string(),
1339 n if *n == Length::Ratio(0.0) => "top".to_string(),
1340 n if *n == Length::Ratio(1.0) => "bottom".to_string(),
1341 y => y.to_string(),
1342 };
1343
1344 if horizontal_str == vertical_str {
1345 "center"
1346 } else {
1347 tmp = format!("{horizontal_str} {vertical_str}");
1348 &tmp
1349 }
1350 }
1351 GradientPosition::SpecifiedPos(x, y) => {
1352 let horizontal_str = match x {
1353 GradientSpecifiedPos::Left(v) => format!("left {}", v),
1354 GradientSpecifiedPos::Right(v) => format!("right {}", v),
1355 GradientSpecifiedPos::Top(v) => format!("top {}", v),
1356 GradientSpecifiedPos::Bottom(v) => format!("bottom {}", v),
1357 };
1358
1359 let vertical_str = match y {
1360 GradientSpecifiedPos::Left(v) => format!("left {}", v),
1361 GradientSpecifiedPos::Right(v) => format!("right {}", v),
1362 GradientSpecifiedPos::Top(v) => format!("top {}", v),
1363 GradientSpecifiedPos::Bottom(v) => format!("bottom {}", v),
1364 };
1365 tmp = format!("{horizontal_str} {vertical_str}");
1366 &tmp
1367 }
1368 }
1369 )
1370 }
1371}
1372impl fmt::Display for GradientShape {
1373 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1374 write!(
1375 f,
1376 "{}",
1377 match self {
1378 GradientShape::Ellipse => "ellipse",
1379 GradientShape::Circle => "circle",
1380 }
1381 )
1382 }
1383}
1384impl fmt::Display for GradientColorItem {
1385 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1386 let mut tmp = String::new();
1387 write!(
1388 f,
1389 "{}",
1390 match self {
1391 GradientColorItem::ColorHint(color, len) => {
1392 tmp.push_str(&color.to_string());
1393 if *len != Length::Auto {
1395 tmp.push(' ');
1396 tmp.push_str(&len.to_string());
1397 }
1398 &tmp
1399 }
1400 GradientColorItem::SimpleColorHint(color) => {
1401 tmp.push_str(&color.to_string());
1402 &tmp
1403 }
1404 GradientColorItem::AngleOrPercentageColorHint(color, angle_or_percentage) => {
1405 tmp.push_str(&color.to_string());
1406 tmp.push(' ');
1407 match angle_or_percentage {
1408 AngleOrPercentage::Angle(angle) => {
1409 tmp.push_str(&angle.to_string());
1410 }
1411 AngleOrPercentage::Percentage(percentage) => {
1412 tmp.push_str(&percentage.to_string());
1413 }
1414 }
1415 &tmp
1416 }
1417 }
1418 )
1419 }
1420}
1421impl fmt::Display for BackgroundPosition {
1422 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1423 let mut x = String::new();
1424 write!(
1425 f,
1426 "{}",
1427 match self {
1428 BackgroundPosition::List(items) => {
1429 for index in 0..items.len() {
1430 x.push_str(&items[index].to_string());
1431 if index < items.len() - 1 {
1432 x.push_str(", ");
1433 }
1434 }
1435 &x
1436 }
1437 }
1438 )
1439 }
1440}
1441impl fmt::Display for BackgroundPositionItem {
1442 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1443 let mut str = String::new();
1444 write!(
1445 f,
1446 "{}",
1447 match self {
1448 BackgroundPositionItem::Pos(x, y) => {
1449 let horizontal_str = &x.to_string();
1450 let vertical_str = &y.to_string();
1451 if *horizontal_str == "center" && *vertical_str == "center" {
1452 str.push_str("center");
1453 } else if vertical_str == "center" {
1454 str.push_str(horizontal_str);
1455 } else {
1456 str = format!("{horizontal_str} {vertical_str}");
1457 }
1458 &str
1459 }
1460 BackgroundPositionItem::Value(v) => {
1461 str = v.to_string();
1462 &str
1463 }
1464 }
1465 )
1466 }
1467}
1468impl fmt::Display for BackgroundPositionValue {
1469 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1470 let mut x = String::new();
1471 write!(
1472 f,
1473 "{}",
1474 match self {
1475 BackgroundPositionValue::Top(top) => {
1476 match top {
1477 n if *n == Length::Ratio(0.) => {
1478 x.push_str("top");
1479 }
1480 n if *n == Length::Ratio(1.) => {
1481 x.push_str("bottom");
1482 }
1483 n if *n == Length::Ratio(0.5) => {
1484 x.push_str("center");
1485 }
1486 Length::Ratio(ratio) => x.push_str(&Length::Ratio(*ratio).to_string()),
1488 other => {
1489 x = format!("{} {}", "top", &other.to_string());
1490 }
1491 }
1492 &x
1493 }
1494 BackgroundPositionValue::Bottom(bottom) => {
1495 match bottom {
1496 n if *n == Length::Ratio(0.) => {
1497 x.push_str("bottom");
1498 }
1499 n if *n == Length::Ratio(1.) => {
1500 x.push_str("top");
1501 }
1502 n if *n == Length::Ratio(0.5) => {
1503 x.push_str("center");
1504 }
1505 other => {
1506 x = format!("{} {}", "bottom", &other.to_string());
1507 }
1508 }
1509 &x
1510 }
1511 BackgroundPositionValue::Left(left) => {
1512 match left {
1513 n if *n == Length::Ratio(0.) => {
1514 x.push_str("left");
1515 }
1516 n if *n == Length::Ratio(1.) => {
1517 x.push_str("right");
1518 }
1519 n if *n == Length::Ratio(0.5) => {
1520 x.push_str("center");
1521 }
1522 Length::Ratio(ratio) => x.push_str(&Length::Ratio(*ratio).to_string()),
1524 other => {
1525 x = format!("{} {}", "left", &other.to_string());
1526 }
1527 }
1528 &x
1529 }
1530 BackgroundPositionValue::Right(right) => {
1531 match right {
1532 n if *n == Length::Ratio(0.) => {
1533 x.push_str("right");
1534 }
1535 n if *n == Length::Ratio(1.) => {
1536 x.push_str("left");
1537 }
1538 n if *n == Length::Ratio(0.5) => {
1539 x.push_str("center");
1540 }
1541 other => {
1542 x = format!("{} {}", "right", &other.to_string());
1543 }
1544 }
1545 &x
1546 }
1547 }
1548 )
1549 }
1550}
1551impl fmt::Display for FontStyle {
1552 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1553 let mut x = String::new();
1554 write!(
1555 f,
1556 "{}",
1557 match self {
1558 FontStyle::Normal => "normal",
1559 FontStyle::Italic => "italic",
1560 FontStyle::Oblique(a) => {
1561 x.push_str("oblique");
1562 if *a != Angle::Deg(14.) {
1563 x.push(' ');
1564 x.push_str(&a.to_string());
1565 }
1566 &x
1567 }
1568 }
1569 )
1570 }
1571}
1572impl fmt::Display for BackgroundClip {
1573 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1574 let mut str = String::new();
1575 write!(
1576 f,
1577 "{}",
1578 match self {
1579 BackgroundClip::List(items) => {
1580 for index in 0..items.len() {
1581 str.push_str(&items[index].to_string());
1582 if index < items.len() - 1 {
1583 str.push_str(", ")
1584 }
1585 }
1586 &str
1587 }
1588 }
1589 )
1590 }
1591}
1592
1593impl fmt::Display for BackgroundClipItem {
1594 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1595 write!(
1596 f,
1597 "{}",
1598 match self {
1599 BackgroundClipItem::BorderBox => "border-box",
1600 BackgroundClipItem::PaddingBox => "padding-box",
1601 BackgroundClipItem::ContentBox => "content-box",
1602 BackgroundClipItem::Text => "text",
1603 }
1604 )
1605 }
1606}
1607
1608impl fmt::Display for BackgroundOrigin {
1609 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1610 let mut str = String::new();
1611 write!(
1612 f,
1613 "{}",
1614 match self {
1615 BackgroundOrigin::List(items) => {
1616 for index in 0..items.len() {
1617 str.push_str(&items[index].to_string());
1618 if index < items.len() - 1 {
1619 str.push_str(", ")
1620 }
1621 }
1622 &str
1623 }
1624 }
1625 )
1626 }
1627}
1628impl fmt::Display for BackgroundOriginItem {
1629 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1630 write!(
1631 f,
1632 "{}",
1633 match self {
1634 BackgroundOriginItem::BorderBox => "border-box",
1635 BackgroundOriginItem::PaddingBox => "padding-box",
1636 BackgroundOriginItem::ContentBox => "content-box",
1637 }
1638 )
1639 }
1640}
1641impl fmt::Display for BackgroundAttachmentItem {
1642 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1643 write!(
1644 f,
1645 "{}",
1646 match self {
1647 BackgroundAttachmentItem::Scroll => "scroll",
1648 BackgroundAttachmentItem::Fixed => "fixed",
1649 BackgroundAttachmentItem::Local => "local",
1650 }
1651 )
1652 }
1653}
1654impl fmt::Display for BackgroundAttachment {
1655 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1656 let mut str = String::new();
1657 write!(
1658 f,
1659 "{}",
1660 match self {
1661 BackgroundAttachment::List(items) => {
1662 for index in 0..items.len() {
1663 str.push_str(&items[index].to_string());
1664 if index < items.len() - 1 {
1665 str.push_str(", ")
1666 }
1667 }
1668 &str
1669 }
1670 }
1671 )
1672 }
1673}
1674impl fmt::Display for Float {
1675 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1676 write!(
1677 f,
1678 "{}",
1679 match self {
1680 Float::None => "none",
1681 Float::Left => "left",
1682 Float::Right => "right",
1683 Float::InlineStart => "inline-start",
1684 Float::InlineEnd => "inline-end",
1685 }
1686 )
1687 }
1688}
1689impl fmt::Display for ListStyleType {
1690 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1691 let x;
1692 write!(
1693 f,
1694 "{}",
1695 match self {
1696 ListStyleType::Disc => "disc",
1697 ListStyleType::None => "none",
1698 ListStyleType::Circle => "circle",
1699 ListStyleType::Square => "square",
1700 ListStyleType::Decimal => "decimal",
1701 ListStyleType::CjkDecimal => "cjk-decimal",
1702 ListStyleType::DecimalLeadingZero => "decimal-leading-zero",
1703 ListStyleType::LowerRoman => "lower-roman",
1704 ListStyleType::UpperRoman => "upper-roman",
1705 ListStyleType::LowerGreek => "lower-greek",
1706 ListStyleType::LowerAlpha => "lower-alpha",
1707 ListStyleType::LowerLatin => "lower-latin",
1708 ListStyleType::UpperAlpha => "upper-alpha",
1709 ListStyleType::UpperLatin => "upper-latin",
1710 ListStyleType::Armenian => "armenian",
1711 ListStyleType::Georgian => "georgian",
1712 ListStyleType::CustomIdent(str) => {
1713 x = str.to_string();
1714 &x
1715 }
1716 }
1717 )
1718 }
1719}
1720impl fmt::Display for ListStyleImage {
1721 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1722 let str;
1723 write!(
1724 f,
1725 "{}",
1726 match self {
1727 ListStyleImage::None => "none",
1728 ListStyleImage::Url(x) => {
1729 str = format!("url({})", x.to_string());
1730 &str
1731 }
1732 }
1733 )
1734 }
1735}
1736impl fmt::Display for ListStylePosition {
1737 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1738 write!(
1739 f,
1740 "{}",
1741 match self {
1742 ListStylePosition::Outside => "outside",
1743 ListStylePosition::Inside => "inside",
1744 }
1745 )
1746 }
1747}
1748impl fmt::Display for Resize {
1749 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1750 write!(
1751 f,
1752 "{}",
1753 match self {
1754 Resize::None => "none",
1755 Resize::Both => "both",
1756 Resize::Horizontal => "horizontal",
1757 Resize::Vertical => "vertical",
1758 Resize::Block => "block",
1759 Resize::Inline => "inline",
1760 }
1761 )
1762 }
1763}
1764impl fmt::Display for ZIndex {
1765 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1766 let x;
1767 write!(
1768 f,
1769 "{}",
1770 match self {
1771 ZIndex::Auto => "auto",
1772 ZIndex::Num(a) => {
1773 x = format!("{a}");
1774 &x
1775 }
1776 }
1777 )
1778 }
1779}
1780impl fmt::Display for TextShadow {
1781 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1782 let mut str = String::new();
1783 write!(
1784 f,
1785 "{}",
1786 match self {
1787 TextShadow::None => "none",
1788 TextShadow::List(items) => {
1789 for index in 0..items.len() {
1790 str.push_str(&items[index].to_string());
1791 if index < items.len() - 1 {
1792 str.push_str(", ")
1793 }
1794 }
1795 &str
1796 }
1797 }
1798 )
1799 }
1800}
1801impl fmt::Display for TextShadowItem {
1802 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1803 let mut tmp = String::new();
1804 write!(
1805 f,
1806 "{}",
1807 match self {
1808 TextShadowItem::TextShadowValue(offsety, offsetx, blurradius, color) => {
1809 if *offsety != Length::Px(0.) {
1810 tmp.push_str(&offsety.to_string());
1811 }
1812 if *offsetx != Length::Px(0.) {
1813 tmp.push(' ');
1814 tmp.push_str(&offsetx.to_string());
1815 }
1816 if *blurradius != Length::Px(0.) && *blurradius != Length::Undefined {
1817 tmp.push(' ');
1818 tmp.push_str(&blurradius.to_string());
1819 }
1820 if *color != Color::Undefined {
1821 tmp.push(' ');
1822 tmp.push_str(&color.to_string());
1823 }
1824 &tmp
1825 }
1826 }
1827 )
1828 }
1829}
1830impl fmt::Display for TextDecorationLine {
1831 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1832 let mut str = String::new();
1833 write!(
1834 f,
1835 "{}",
1836 match self {
1837 TextDecorationLine::None => "none",
1838 TextDecorationLine::SpellingError => "spelling-error",
1839 TextDecorationLine::GrammarError => "grammar-error",
1840 TextDecorationLine::List(array) => {
1841 for index in 0..array.len() {
1842 str.push_str(&array[index].to_string());
1843 if index + 1 < array.len() {
1844 str.push(' ');
1845 }
1846 }
1847 &str
1848 }
1849 }
1850 )
1851 }
1852}
1853
1854impl fmt::Display for TextDecorationLineItem {
1855 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1856 write!(
1857 f,
1858 "{}",
1859 match self {
1860 TextDecorationLineItem::Overline => "overline",
1861 TextDecorationLineItem::LineThrough => "line-through",
1862 TextDecorationLineItem::Underline => "underline",
1863 TextDecorationLineItem::Blink => "blink",
1864 }
1865 )
1866 }
1867}
1868impl fmt::Display for TextDecorationStyle {
1869 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1870 write!(
1871 f,
1872 "{}",
1873 match self {
1874 TextDecorationStyle::Solid => "solid",
1875 TextDecorationStyle::Double => "double",
1876 TextDecorationStyle::Dotted => "dotted",
1877 TextDecorationStyle::Dashed => "dashed",
1878 TextDecorationStyle::Wavy => "wavy",
1879 }
1880 )
1881 }
1882}
1883impl fmt::Display for TextDecorationThickness {
1884 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1885 let x;
1886 write!(
1887 f,
1888 "{}",
1889 match self {
1890 TextDecorationThickness::Auto => "auto",
1891 TextDecorationThickness::FromFont => "from-font",
1892 TextDecorationThickness::Length(len) => {
1893 x = len.to_string();
1894 &x
1895 }
1896 }
1897 )
1898 }
1899}
1900impl fmt::Display for TextUnderlineOffset {
1901 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1902 let x;
1903 write!(
1904 f,
1905 "{}",
1906 match self {
1907 TextUnderlineOffset::Auto => "auto",
1908 TextUnderlineOffset::Length(len) => {
1909 x = len.to_string();
1910 &x
1911 }
1912 }
1913 )
1914 }
1915}
1916impl fmt::Display for LetterSpacing {
1917 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1918 let x;
1919 write!(
1920 f,
1921 "{}",
1922 match self {
1923 LetterSpacing::Normal => "normal",
1924 LetterSpacing::Length(len) => {
1925 x = len.to_string();
1926 &x
1927 }
1928 }
1929 )
1930 }
1931}
1932impl fmt::Display for WordSpacing {
1933 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1934 let x;
1935 write!(
1936 f,
1937 "{}",
1938 match self {
1939 WordSpacing::Normal => "normal",
1940 WordSpacing::Length(len) => {
1941 x = len.to_string();
1942 &x
1943 }
1944 }
1945 )
1946 }
1947}
1948impl fmt::Display for BorderRadius {
1949 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1950 let tmp;
1951 write!(
1952 f,
1953 "{}",
1954 match self {
1955 BorderRadius::Pos(x, y) => {
1956 tmp = format!("{x} {y}");
1957 &tmp
1958 }
1959 }
1960 )
1961 }
1962}
1963impl fmt::Display for BoxShadow {
1964 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1965 let mut str = String::new();
1966 write!(
1967 f,
1968 "{}",
1969 match self {
1970 BoxShadow::None => "none",
1971 BoxShadow::List(items) => {
1972 for index in 0..items.len() {
1973 str.push_str(&items[index].to_string());
1974 if index < items.len() - 1 {
1975 str.push_str(", ")
1976 }
1977 }
1978 &str
1979 }
1980 }
1981 )
1982 }
1983}
1984impl fmt::Display for BoxShadowItem {
1985 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1986 let mut str = String::new();
1987 write!(
1988 f,
1989 "{}",
1990 match self {
1991 BoxShadowItem::List(items) => {
1992 for index in 0..items.len() {
1993 str.push_str(&items[index].to_string());
1994 if index < items.len() - 1 {
1995 str.push(' ')
1996 }
1997 }
1998 &str
1999 }
2000 }
2001 )
2002 }
2003}
2004impl fmt::Display for ShadowItemType {
2005 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2006 let x;
2007 write!(
2008 f,
2009 "{}",
2010 match self {
2011 ShadowItemType::Inset => "inset",
2012 ShadowItemType::OffsetX(len) => {
2013 x = len.to_string();
2014 &x
2015 }
2016 ShadowItemType::OffsetY(len) => {
2017 x = len.to_string();
2018 &x
2019 }
2020 ShadowItemType::BlurRadius(len) => {
2021 x = len.to_string();
2022 &x
2023 }
2024 ShadowItemType::SpreadRadius(len) => {
2025 x = len.to_string();
2026 &x
2027 }
2028 ShadowItemType::Color(len) => {
2029 x = len.to_string();
2030 &x
2031 }
2032 }
2033 )
2034 }
2035}
2036impl fmt::Display for BackdropFilter {
2037 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2038 let mut str = String::new();
2039 write!(
2040 f,
2041 "{}",
2042 match self {
2043 BackdropFilter::None => "none",
2044 BackdropFilter::List(items) => {
2045 for index in 0..items.len() {
2046 str.push_str(&items[index].to_string());
2047 if index < items.len() - 1 {
2048 str.push(' ')
2049 }
2050 }
2051 &str
2052 }
2053 }
2054 )
2055 }
2056}
2057impl fmt::Display for Filter {
2058 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2059 let mut str = String::new();
2060 write!(
2061 f,
2062 "{}",
2063 match self {
2064 Filter::None => "none",
2065 Filter::List(items) => {
2066 for index in 0..items.len() {
2067 str.push_str(&items[index].to_string());
2068 if index < items.len() - 1 {
2069 str.push(' ')
2070 }
2071 }
2072 &str
2073 }
2074 }
2075 )
2076 }
2077}
2078impl fmt::Display for FilterFunc {
2079 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2080 let x;
2081 write!(
2082 f,
2083 "{}",
2084 match self {
2085 FilterFunc::Url(len) => {
2086 x = format!("url({})", len.to_string());
2087 &x
2088 }
2089 FilterFunc::Blur(len) => {
2090 x = format!("blur({len})");
2091 &x
2092 }
2093 FilterFunc::Brightness(len) => {
2094 x = format!("brightness({len})");
2095 &x
2096 }
2097 FilterFunc::Contrast(len) => {
2098 x = format!("contranst({len})");
2099 &x
2100 }
2101 FilterFunc::DropShadow(len) => {
2102 x = format!("drop-shadow({len})");
2103 &x
2104 }
2105 FilterFunc::Grayscale(len) => {
2106 x = format!("grayscale({len})");
2107 &x
2108 }
2109 FilterFunc::HueRotate(len) => {
2110 x = format!("hue-rotate({len})");
2111 &x
2112 }
2113 FilterFunc::Invert(len) => {
2114 x = format!("invert({len})");
2115 &x
2116 }
2117 FilterFunc::Opacity(len) => {
2118 x = format!("opacity({len})");
2119 &x
2120 }
2121 FilterFunc::Saturate(len) => {
2122 x = format!("saturate({len})");
2123 &x
2124 }
2125 FilterFunc::Sepia(len) => {
2126 x = format!("sepia({len})");
2127 &x
2128 }
2129 }
2130 )
2131 }
2132}
2133impl fmt::Display for DropShadow {
2134 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2135 let mut str = String::new();
2136 write!(
2137 f,
2138 "{}",
2139 match self {
2140 DropShadow::List(items) => {
2141 for index in 0..items.len() {
2142 str.push_str(&items[index].to_string());
2143 if index < items.len() - 1 {
2144 str.push(' ')
2145 }
2146 }
2147 &str
2148 }
2149 }
2150 )
2151 }
2152}
2153impl fmt::Display for TransformOrigin {
2154 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2155 let mut tmp = String::new();
2156 write!(
2157 f,
2158 "{}",
2159 match self {
2160 TransformOrigin::LengthTuple(x, y, z) => {
2161 let horizontal_str = match x {
2162 n if *n == Length::Ratio(0.5) => "center".to_string(),
2163 n if *n == Length::Ratio(0.0) => "left".to_string(),
2164 n if *n == Length::Ratio(1.0) => "right".to_string(),
2165 x => x.to_string(),
2166 };
2167 let vertical_str = match y {
2168 n if *n == Length::Ratio(0.5) => "center".to_string(),
2169 n if *n == Length::Ratio(0.0) => "top".to_string(),
2170 n if *n == Length::Ratio(1.0) => "bottom".to_string(),
2171 y => y.to_string(),
2172 };
2173
2174 if horizontal_str == vertical_str {
2175 tmp.push_str("center");
2176 } else {
2177 tmp = format!("{horizontal_str} {vertical_str}");
2178 }
2179
2180 match z {
2181 n if *n == Length::Px(0.) => {}
2182 y => {
2183 tmp.push(' ');
2184 tmp.push_str(&y.to_string())
2185 }
2186 }
2187
2188 &tmp
2189 }
2190 TransformOrigin::Left => "left",
2191 TransformOrigin::Right => "right",
2192 TransformOrigin::Center => "center",
2193 TransformOrigin::Bottom => "bottom",
2194 TransformOrigin::Top => "top",
2195 TransformOrigin::Length(len) => {
2196 tmp = len.to_string();
2197 &tmp
2198 }
2199 }
2200 )
2201 }
2202}
2203
2204impl fmt::Display for MaskMode {
2205 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2206 let mut str = String::new();
2207 write!(
2208 f,
2209 "{}",
2210 match self {
2211 MaskMode::List(items) => {
2212 for index in 0..items.len() {
2213 str.push_str(&items[index].to_string());
2214 if index < items.len() - 1 {
2215 str.push_str(", ")
2216 }
2217 }
2218 &str
2219 }
2220 }
2221 )
2222 }
2223}
2224impl fmt::Display for MaskModeItem {
2225 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2226 write!(
2227 f,
2228 "{}",
2229 match self {
2230 MaskModeItem::MatchSource => "match-source",
2231 MaskModeItem::Alpha => "alpha",
2232 MaskModeItem::Luminance => "luminance",
2233 }
2234 )
2235 }
2236}
2237
2238impl fmt::Display for AspectRatio {
2239 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2240 match self {
2241 AspectRatio::Auto => write!(f, "auto"),
2242 AspectRatio::Ratio(x, y) => write!(f, "{x} / {y}"),
2243 }
2244 }
2245}
2246
2247impl fmt::Display for Contain {
2248 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2249 match self {
2250 Contain::None => write!(f, "none"),
2251 Contain::Content => write!(f, "content"),
2252 Contain::Strict => write!(f, "strict"),
2253 Contain::Multiple(v) => {
2254 let mut ret = vec![];
2255 v.iter().for_each(|key| match key {
2256 ContainKeyword::Layout => ret.push("layout"),
2257 ContainKeyword::Paint => ret.push("paint"),
2258 ContainKeyword::Size => ret.push("size"),
2259 ContainKeyword::Style => ret.push("style"),
2260 });
2261 write!(f, "{}", ret.join(" "))
2262 }
2263 }
2264 }
2265}
2266
2267impl fmt::Display for Content {
2268 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2269 match self {
2270 Content::None => write!(f, "none"),
2271 Content::Normal => write!(f, "normal"),
2272 Content::Str(x) => write!(f, "'{}'", x.to_string()),
2273 Content::Url(x) => write!(f, "'{}'", x.to_string()),
2274 }
2275 }
2276}
2277
2278impl fmt::Display for CustomProperty {
2279 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2280 match self {
2281 CustomProperty::None => write!(f, "none"),
2282 CustomProperty::Expr(key, value) => {
2283 write!(f, "{}:{}", key.to_string(), value.to_string())
2284 }
2285 }
2286 }
2287}
2288
2289impl fmt::Display for AnimationName {
2290 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2291 let mut ret = vec![];
2292 match self {
2293 AnimationName::List(list) => list.iter().for_each(|x| match x {
2294 AnimationNameItem::None => ret.push("none".to_string()),
2295 AnimationNameItem::CustomIdent(ident) => ret.push(ident.to_string()),
2296 }),
2297 }
2298 write!(f, "{}", ret.join(","))
2299 }
2300}
2301
2302impl fmt::Display for AnimationDirection {
2303 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2304 let mut ret: Vec<&str> = vec![];
2305 match self {
2306 AnimationDirection::List(list) => list.iter().for_each(|x| match x {
2307 AnimationDirectionItem::Normal => ret.push("normal"),
2308 AnimationDirectionItem::Alternate => ret.push("alternate"),
2309 AnimationDirectionItem::AlternateReverse => ret.push("alternate-reverse"),
2310 AnimationDirectionItem::Reverse => ret.push("reverse"),
2311 }),
2312 }
2313 write!(f, "{}", ret.join(","))
2314 }
2315}
2316
2317impl fmt::Display for AnimationFillMode {
2318 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2319 let mut ret = vec![];
2320 match self {
2321 AnimationFillMode::List(list) => list.iter().for_each(|x| match x {
2322 AnimationFillModeItem::None => ret.push("none"),
2323 AnimationFillModeItem::Forwards => ret.push("forwards"),
2324 AnimationFillModeItem::Backwards => ret.push("backwords"),
2325 AnimationFillModeItem::Both => ret.push("both"),
2326 }),
2327 }
2328 write!(f, "{}", ret.join(","))
2329 }
2330}
2331
2332impl fmt::Display for AnimationIterationCount {
2333 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2334 let mut ret = vec![];
2335 match self {
2336 AnimationIterationCount::List(list) => list.iter().for_each(|x| match x {
2337 AnimationIterationCountItem::Infinite => ret.push("infinite".to_string()),
2338 AnimationIterationCountItem::Number(num) => ret.push(num.to_string()),
2339 }),
2340 }
2341 write!(f, "{}", ret.join(","))
2342 }
2343}
2344
2345impl fmt::Display for AnimationPlayState {
2346 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2347 let mut ret = vec![];
2348 match self {
2349 AnimationPlayState::List(list) => list.iter().for_each(|x| match x {
2350 AnimationPlayStateItem::Running => ret.push("running"),
2351 AnimationPlayStateItem::Paused => ret.push("paused"),
2352 }),
2353 }
2354 write!(f, "{}", ret.join(","))
2355 }
2356}
2357
2358impl fmt::Display for WillChange {
2359 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2360 let mut ret = vec![];
2361 match self {
2362 WillChange::Auto => ret.push("auto".to_string()),
2363 WillChange::List(list) => list.iter().for_each(|feature| match feature {
2364 AnimateableFeature::Contents => ret.push("contents".to_string()),
2365 AnimateableFeature::ScrollPosition => ret.push("scroll-position".to_string()),
2366 AnimateableFeature::CustomIdent(x) => ret.push(x.to_string()),
2367 }),
2368 };
2369 write!(f, "{}", ret.join(","))
2370 }
2371}
2372
2373impl fmt::Display for FontFeatureSettings {
2374 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2375 let mut ret = vec![];
2376 match self {
2377 FontFeatureSettings::Normal => ret.push("normal".to_string()),
2378 FontFeatureSettings::FeatureTags(tags) => tags.iter().for_each(|feature_tag_value| {
2379 ret.push(format!(
2380 "{} {}",
2381 feature_tag_value.opentype_tag.to_string(),
2382 feature_tag_value.value
2383 ));
2384 }),
2385 };
2386 write!(f, "{}", ret.join(","))
2387 }
2388}
2389
2390impl fmt::Display for Gap {
2391 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2392 match self {
2393 Gap::Normal => write!(f, "normal"),
2394 Gap::Length(length) => write!(f, "{length}"),
2395 }
2396 }
2397}
2398
2399impl fmt::Display for TrackSize {
2400 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2401 match self {
2402 TrackSize::Length(length) => write!(f, "{length}"),
2403 TrackSize::MinContent => write!(f, "min-content"),
2404 TrackSize::MaxContent => write!(f, "max-content"),
2405 TrackSize::Fr(x) => write!(f, "{x}fr"),
2406 }
2407 }
2408}
2409
2410impl fmt::Display for GridTemplate {
2411 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2412 match self {
2413 GridTemplate::None => write!(f, "none"),
2414 GridTemplate::TrackList(list) => {
2415 let mut ret = vec![];
2416 list.iter().for_each(|x| match x {
2417 TrackListItem::LineNames(line_names) => ret.push(
2418 line_names
2419 .iter()
2420 .map(|x| x.to_string())
2421 .collect::<Vec<_>>()
2422 .join(" "),
2423 ),
2424 TrackListItem::TrackSize(track_size) => ret.push(track_size.to_string()),
2425 });
2426 write!(f, "{}", ret.join(" "))
2427 }
2428 }
2429 }
2430}
2431
2432impl fmt::Display for GridAutoFlow {
2433 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2434 match self {
2435 GridAutoFlow::Row => write!(f, "row"),
2436 GridAutoFlow::Column => write!(f, "column"),
2437 GridAutoFlow::RowDense => write!(f, "row dense"),
2438 GridAutoFlow::ColumnDense => write!(f, "column dense"),
2439 }
2440 }
2441}
2442
2443impl fmt::Display for GridAuto {
2444 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2445 match self {
2446 GridAuto::List(list) => {
2447 let mut ret = vec![];
2448 list.iter().for_each(|x| ret.push(x.to_string()));
2449 write!(f, "{}", ret.join(" "))
2450 }
2451 }
2452 }
2453}
2454
2455impl fmt::Display for TouchAction {
2456 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2457 match self {
2458 TouchAction::Auto => write!(f, "auto"),
2459 TouchAction::None => write!(f, "none"),
2460 TouchAction::Manipulation => write!(f, "manipulation"),
2461 TouchAction::Gestures(ges) => write!(f, "{}", ges),
2462 }
2463 }
2464}
2465
2466impl fmt::Display for TouchActionGestures {
2467 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2468 let Self {
2469 pan_left,
2470 pan_right,
2471 pan_up,
2472 pan_down,
2473 } = self;
2474 let pan_x = if *pan_left && *pan_right {
2475 "pan-x"
2476 } else if *pan_left {
2477 "pan-left"
2478 } else if *pan_right {
2479 "pan-right"
2480 } else {
2481 ""
2482 };
2483 let pan_y = if *pan_up && *pan_down {
2484 "pan-y"
2485 } else if *pan_up {
2486 "pan-up"
2487 } else if *pan_down {
2488 "pan-down"
2489 } else {
2490 ""
2491 };
2492 let s: Vec<_> = [pan_x, pan_y]
2493 .into_iter()
2494 .filter(|x| !x.is_empty())
2495 .collect();
2496 write!(f, "{}", s.join(" "))
2497 }
2498}