Skip to main content

float_pigment_css/
typing.rs

1//! CSS value types for each CSS property.
2//!
3//! The possible CSS values are different for each CSS property. This module lists all of them.
4//!
5//! For example, enum `BoxSizing` list out all possible values of the `box-sizing` property.
6
7use alloc::{
8    boxed::Box,
9    string::{String, ToString},
10};
11
12use float_pigment_css_macro::{property_value_type, ResolveFontSize};
13
14#[cfg(debug_assertions)]
15use float_pigment_css_macro::{CompatibilityEnumCheck, CompatibilityStructCheck};
16
17use serde::{Deserialize, Serialize};
18
19use crate::length_num::LengthNum;
20use crate::property::PropertyValueWithGlobal;
21use crate::query::MediaQueryStatus;
22use crate::resolve_font_size::ResolveFontSize;
23use crate::sheet::{borrow::Array, str_store::StrRef};
24
25/// A bitset for representing `!important`.
26///
27/// It is used in the binary format for better size.
28/// Not suitable for common cases.
29#[allow(missing_docs)]
30#[repr(C)]
31#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
32#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
33pub enum ImportantBitSet {
34    None,
35    Array(Array<u8>),
36}
37
38/// An expression inside `calc(...)`.
39#[repr(C)]
40#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
41#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
42pub enum CalcExpr {
43    /// A length, e.g. `2px`.
44    Length(Length),
45    /// A number, e.g. `0.1`.
46    Number(Box<Number>),
47    /// An angle, e.g. `45deg`.
48    Angle(Box<Angle>),
49    /// `+` expression.
50    Plus(Box<CalcExpr>, Box<CalcExpr>),
51    /// `-` expression.
52    Sub(Box<CalcExpr>, Box<CalcExpr>),
53    /// `*` expression.
54    Mul(Box<CalcExpr>, Box<CalcExpr>),
55    /// `/` expression.
56    Div(Box<CalcExpr>, Box<CalcExpr>),
57}
58
59impl Default for CalcExpr {
60    fn default() -> Self {
61        Self::Length(Length::Undefined)
62    }
63}
64
65/// A number or an expression that evaluates to a number.
66#[allow(missing_docs)]
67#[repr(C)]
68#[property_value_type(PropertyValueWithGlobal for NumberType)]
69#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
70#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
71pub enum Number {
72    F32(f32),
73    I32(i32),
74    Calc(Box<CalcExpr>),
75}
76
77impl Default for Number {
78    fn default() -> Self {
79        Self::I32(0)
80    }
81}
82
83impl From<f32> for NumberType {
84    fn from(x: f32) -> Self {
85        NumberType::F32(x)
86    }
87}
88
89impl From<i32> for NumberType {
90    fn from(x: i32) -> Self {
91        NumberType::I32(x)
92    }
93}
94
95impl Number {
96    /// Convert the number to `f32`.
97    ///
98    /// Panics if it is an expression.
99    pub fn to_f32(&self) -> f32 {
100        match self {
101            Number::F32(x) => *x,
102            Number::I32(x) => *x as f32,
103            _ => panic!("cannot convert an expression to a number"),
104        }
105    }
106
107    /// Convert the number to `i32`.
108    ///
109    /// Panics if it is an expression.
110    pub fn to_i32(&self) -> i32 {
111        match self {
112            Number::I32(x) => *x,
113            Number::F32(x) => *x as i32,
114            _ => panic!("cannot convert an expression to a number"),
115        }
116    }
117}
118
119impl ResolveFontSize for Number {
120    fn resolve_font_size(&mut self, _: f32) {
121        // empty
122    }
123}
124
125/// A color value or `current-color`.
126#[allow(missing_docs)]
127#[repr(C)]
128#[property_value_type(PropertyValueWithGlobal for ColorType)]
129#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
130#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
131pub enum Color {
132    Undefined,
133    CurrentColor,
134    Specified(u8, u8, u8, u8),
135}
136
137/// A length value or an expression that evaluates to a length value.
138#[allow(missing_docs)]
139#[repr(C)]
140#[property_value_type(PropertyValueWithGlobal for LengthType)]
141#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
142#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
143pub enum Length {
144    Undefined,
145    Auto,
146    Px(f32),
147    Vw(f32),
148    Vh(f32),
149    Rem(f32),
150    Rpx(f32),
151    Em(f32),
152    Ratio(f32),
153    Expr(Box<LengthExpr>),
154    Vmin(f32),
155    Vmax(f32),
156}
157
158#[allow(clippy::derivable_impls)]
159impl Default for Length {
160    fn default() -> Self {
161        Length::Undefined
162    }
163}
164
165impl Length {
166    pub(crate) fn ratio_to_f32(&self) -> Option<f32> {
167        match self {
168            Length::Ratio(x) => Some(*x),
169            _ => None,
170        }
171    }
172
173    pub(crate) fn resolve_set(&mut self, font_size: f32) {
174        *self = Self::Px(font_size);
175    }
176
177    pub(crate) fn resolve_em(&mut self, font_size: f32) {
178        if let Self::Em(x) = *self {
179            *self = Self::Px(x * font_size);
180        }
181    }
182
183    pub(crate) fn resolve_em_and_ratio(&mut self, font_size: f32) {
184        if let Self::Em(x) = *self {
185            *self = Self::Px(x * font_size);
186        } else if let Self::Ratio(x) = *self {
187            *self = Self::Px(x * font_size);
188        }
189    }
190
191    /// Create a new `Length` from a `CalcExpr`.
192    pub fn new_calc_expr(calc_expr: Box<CalcExpr>) -> Self {
193        Self::Expr(Box::new(LengthExpr::Calc(calc_expr)))
194    }
195
196    /// Convert to `Box<CalcExpr>`.
197    ///
198    /// If the length is already a `CalcExpr`, it will be returned directly.
199    /// Otherwise, it will be wrapped into a new `CalcExpr`.
200    pub fn into_calc_expr(self) -> Box<CalcExpr> {
201        match self {
202            Length::Expr(x) => match *x {
203                LengthExpr::Calc(x) => x,
204                x => Box::new(CalcExpr::Length(Length::Expr(Box::new(x)))),
205            },
206            x => Box::new(CalcExpr::Length(x)),
207        }
208    }
209
210    /// Resolve the length value to `f32`.
211    ///
212    /// The `relative_length` is used to calculate `...%` length.
213    /// If `length_as_parent_font_size` is set, the `relative_length` is used for `em` length;
214    /// otherwise the base font size in `media_query_status` is used.
215    pub fn resolve_to_f32<L: LengthNum>(
216        &self,
217        media_query_status: &MediaQueryStatus<L>,
218        relative_length: f32,
219        length_as_parent_font_size: bool,
220    ) -> Option<f32> {
221        let r = match self {
222            Length::Undefined | Length::Auto => None?,
223            Length::Px(x) => *x,
224            Length::Vw(x) => media_query_status.width.to_f32() / 100. * *x,
225            Length::Vh(x) => media_query_status.height.to_f32() / 100. * *x,
226            Length::Rem(x) => media_query_status.base_font_size.to_f32() * *x,
227            Length::Rpx(x) => media_query_status.width.to_f32() / 750. * *x,
228            Length::Em(x) => {
229                if length_as_parent_font_size {
230                    relative_length * *x
231                } else {
232                    media_query_status.base_font_size.to_f32() * *x
233                }
234            }
235            Length::Ratio(x) => relative_length * *x,
236            Length::Expr(x) => match &**x {
237                LengthExpr::Invalid => None?,
238                LengthExpr::Env(name, default_value) => match name.as_str() {
239                    "safe-area-inset-left" => media_query_status.env.safe_area_inset_left.to_f32(),
240                    "safe-area-inset-top" => media_query_status.env.safe_area_inset_top.to_f32(),
241                    "safe-area-inset-right" => {
242                        media_query_status.env.safe_area_inset_right.to_f32()
243                    }
244                    "safe-area-inset-bottom" => {
245                        media_query_status.env.safe_area_inset_bottom.to_f32()
246                    }
247                    _ => default_value.resolve_to_f32(
248                        media_query_status,
249                        relative_length,
250                        length_as_parent_font_size,
251                    )?,
252                },
253                LengthExpr::Calc(x) => x.resolve_to_f32(
254                    media_query_status,
255                    relative_length,
256                    length_as_parent_font_size,
257                )?,
258            },
259            Length::Vmin(x) => {
260                media_query_status
261                    .width
262                    .upper_bound(media_query_status.height)
263                    .to_f32()
264                    / 100.
265                    * *x
266            }
267            Length::Vmax(x) => {
268                media_query_status
269                    .width
270                    .lower_bound(media_query_status.height)
271                    .to_f32()
272                    / 100.
273                    * *x
274            }
275        };
276        Some(r)
277    }
278
279    /// Resolve the length value to `L`.
280    ///
281    /// The `relative_length` is used to calculate `...%` length.
282    /// The base font size in `media_query_status` is used for `em` length.
283    pub fn resolve_length<L: LengthNum>(
284        &self,
285        media_query_status: &MediaQueryStatus<L>,
286        relative_length: L,
287    ) -> Option<L> {
288        let r = match self {
289            Length::Undefined | Length::Auto => None?,
290            Length::Expr(x) => match &**x {
291                LengthExpr::Invalid => None?,
292                LengthExpr::Env(name, default_value) => match name.as_str() {
293                    "safe-area-inset-left" => media_query_status.env.safe_area_inset_left,
294                    "safe-area-inset-top" => media_query_status.env.safe_area_inset_top,
295                    "safe-area-inset-right" => media_query_status.env.safe_area_inset_right,
296                    "safe-area-inset-bottom" => media_query_status.env.safe_area_inset_bottom,
297                    _ => default_value.resolve_length(media_query_status, relative_length)?,
298                },
299                LengthExpr::Calc(x) => L::from_f32(x.resolve_to_f32(
300                    media_query_status,
301                    relative_length.to_f32(),
302                    false,
303                )?),
304            },
305            _ => L::from_f32(self.resolve_to_f32(
306                media_query_status,
307                relative_length.to_f32(),
308                false,
309            )?),
310        };
311        Some(r)
312    }
313}
314
315/// An expression for a length value.
316#[allow(missing_docs)]
317#[repr(C)]
318#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
319#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
320#[derive(Default)]
321pub enum LengthExpr {
322    #[default]
323    Invalid,
324    Env(StrRef, Box<Length>),
325    Calc(Box<CalcExpr>),
326}
327
328impl CalcExpr {
329    fn resolve_to_f32<L: LengthNum>(
330        &self,
331        media_query_status: &MediaQueryStatus<L>,
332        relative_length: f32,
333        length_as_parent_font_size: bool,
334    ) -> Option<f32> {
335        let ret = match self {
336            CalcExpr::Length(x) => x.resolve_to_f32(
337                media_query_status,
338                relative_length,
339                length_as_parent_font_size,
340            )?,
341            CalcExpr::Number(_) => None?,
342            CalcExpr::Angle(_) => None?,
343            CalcExpr::Plus(x, y) => {
344                let x = x.resolve_to_f32(
345                    media_query_status,
346                    relative_length,
347                    length_as_parent_font_size,
348                )?;
349                let y = y.resolve_to_f32(
350                    media_query_status,
351                    relative_length,
352                    length_as_parent_font_size,
353                )?;
354                x + y
355            }
356            CalcExpr::Sub(x, y) => {
357                let x = x.resolve_to_f32(
358                    media_query_status,
359                    relative_length,
360                    length_as_parent_font_size,
361                )?;
362                let y = y.resolve_to_f32(
363                    media_query_status,
364                    relative_length,
365                    length_as_parent_font_size,
366                )?;
367                x - y
368            }
369            CalcExpr::Mul(x, y) => {
370                let x = x.resolve_to_f32(
371                    media_query_status,
372                    relative_length,
373                    length_as_parent_font_size,
374                )?;
375                let y = y.resolve_to_f32(
376                    media_query_status,
377                    relative_length,
378                    length_as_parent_font_size,
379                )?;
380                x * y
381            }
382            CalcExpr::Div(x, y) => {
383                let x = x.resolve_to_f32(
384                    media_query_status,
385                    relative_length,
386                    length_as_parent_font_size,
387                )?;
388                let y = y.resolve_to_f32(
389                    media_query_status,
390                    relative_length,
391                    length_as_parent_font_size,
392                )?;
393                x / y
394            }
395        };
396        Some(ret)
397    }
398
399    /// Resolve the length value to `L`.
400    ///
401    /// The `relative_length` is used to calculate `...%` length.
402    /// The base font size in `media_query_status` is used for `em` length.
403    pub fn resolve_length<L: LengthNum>(
404        &self,
405        media_query_status: &MediaQueryStatus<L>,
406        relative_length: L,
407    ) -> Option<L> {
408        self.resolve_to_f32(media_query_status, relative_length.to_f32(), false)
409            .map(|x| L::from_f32(x))
410    }
411}
412
413/// An angle value or an expression that evaluates to an angle.
414#[allow(missing_docs)]
415#[repr(C)]
416#[property_value_type(PropertyValueWithGlobal for AngleType)]
417#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
418#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
419pub enum Angle {
420    Deg(f32),
421    Grad(f32),
422    Rad(f32),
423    Turn(f32),
424    Calc(Box<CalcExpr>),
425}
426
427impl Default for Angle {
428    fn default() -> Self {
429        Self::Deg(0.)
430    }
431}
432
433impl ResolveFontSize for Angle {
434    fn resolve_font_size(&mut self, _: f32) {
435        // empty
436    }
437}
438
439/// An angle value or a percentage value.
440#[allow(missing_docs)]
441#[repr(C)]
442#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
443#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
444pub enum AngleOrPercentage {
445    Angle(Angle),
446    Percentage(f32),
447}
448
449#[allow(missing_docs)]
450#[repr(C)]
451#[property_value_type(PropertyValueWithGlobal for DisplayType)]
452#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
453#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
454pub enum Display {
455    None,
456    Block,
457    Flex,
458    Inline,
459    InlineBlock,
460    Grid,
461    FlowRoot,
462    InlineFlex,
463    InlineGrid,
464}
465
466#[allow(missing_docs)]
467#[repr(C)]
468#[property_value_type(PropertyValueWithGlobal for PositionType)]
469#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
470#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
471pub enum Position {
472    Static,
473    Relative,
474    Absolute,
475    Fixed,
476    Sticky,
477}
478
479#[allow(missing_docs)]
480#[repr(C)]
481#[property_value_type(PropertyValueWithGlobal for OverflowType)]
482#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
483#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
484pub enum Overflow {
485    Visible,
486    Hidden,
487    Auto,
488    Scroll,
489}
490
491#[allow(missing_docs)]
492#[repr(C)]
493#[property_value_type(PropertyValueWithGlobal for OverflowWrapType)]
494#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
495#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
496pub enum OverflowWrap {
497    Normal,
498    BreakWord,
499}
500
501#[allow(missing_docs)]
502#[repr(C)]
503#[property_value_type(PropertyValueWithGlobal for PointerEventsType)]
504#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
505#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
506pub enum PointerEvents {
507    Auto,
508    None,
509    /// A `wx` specific pointer-events type.
510    WxRoot,
511}
512
513/// `wx` specific touch handling strategy.
514#[allow(missing_docs)]
515#[repr(C)]
516#[property_value_type(PropertyValueWithGlobal for WxEngineTouchEventType)]
517#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
518#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
519pub enum WxEngineTouchEvent {
520    Gesture,
521    Click,
522    None,
523}
524
525#[allow(missing_docs)]
526#[repr(C)]
527#[property_value_type(PropertyValueWithGlobal for VisibilityType)]
528#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
529#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
530pub enum Visibility {
531    Visible,
532    Hidden,
533    Collapse,
534}
535
536#[allow(missing_docs)]
537#[repr(C)]
538#[property_value_type(PropertyValueWithGlobal for FlexWrapType)]
539#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
540#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
541pub enum FlexWrap {
542    NoWrap,
543    Wrap,
544    WrapReverse,
545}
546
547#[allow(missing_docs)]
548#[repr(C)]
549#[property_value_type(PropertyValueWithGlobal for FlexDirectionType)]
550#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
551#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
552pub enum FlexDirection {
553    Row,
554    RowReverse,
555    Column,
556    ColumnReverse,
557}
558
559#[allow(missing_docs)]
560#[repr(C)]
561#[property_value_type(PropertyValueWithGlobal for DirectionType)]
562#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
563#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
564pub enum Direction {
565    Auto,
566    LTR,
567    RTL,
568}
569
570#[allow(missing_docs)]
571#[repr(C)]
572#[property_value_type(PropertyValueWithGlobal for WritingModeType)]
573#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
574#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
575pub enum WritingMode {
576    HorizontalTb,
577    VerticalLr,
578    VerticalRl,
579}
580
581#[allow(missing_docs)]
582#[repr(C)]
583#[property_value_type(PropertyValueWithGlobal for AlignItemsType)]
584#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
585#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
586pub enum AlignItems {
587    Stretch,
588    Normal,
589    Center,
590    Start,
591    End,
592    FlexStart,
593    FlexEnd,
594    SelfStart,
595    SelfEnd,
596    Baseline,
597}
598
599#[allow(missing_docs)]
600#[repr(C)]
601#[property_value_type(PropertyValueWithGlobal for AlignSelfType)]
602#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
603#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
604pub enum AlignSelf {
605    Auto,
606    Normal,
607    Stretch,
608    Center,
609    Start,
610    End,
611    SelfStart,
612    SelfEnd,
613    FlexStart,
614    FlexEnd,
615    Baseline,
616}
617
618#[allow(missing_docs)]
619#[repr(C)]
620#[property_value_type(PropertyValueWithGlobal for AlignContentType)]
621#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
622#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
623pub enum AlignContent {
624    Normal,
625    Start,
626    End,
627    Stretch,
628    Center,
629    FlexStart,
630    FlexEnd,
631    SpaceBetween,
632    SpaceAround,
633    SpaceEvenly,
634    Baseline,
635}
636
637#[allow(missing_docs)]
638#[repr(C)]
639#[property_value_type(PropertyValueWithGlobal for JustifyContentType)]
640#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
641#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
642pub enum JustifyContent {
643    Center,
644    FlexStart,
645    FlexEnd,
646    SpaceBetween,
647    SpaceAround,
648    SpaceEvenly,
649    Start,
650    End,
651    Left,
652    Right,
653    Stretch,
654    Baseline,
655    Normal,
656}
657
658#[allow(missing_docs)]
659#[repr(C)]
660#[property_value_type(PropertyValueWithGlobal for JustifyItemsType)]
661#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
662#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
663pub enum JustifyItems {
664    Stretch,
665    Center,
666    Start,
667    End,
668    FlexStart,
669    FlexEnd,
670    SelfStart,
671    SelfEnd,
672    Left,
673    Right,
674    Normal,
675}
676
677#[allow(missing_docs)]
678#[repr(C)]
679#[property_value_type(PropertyValueWithGlobal for JustifySelfType)]
680#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
681#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
682pub enum JustifySelf {
683    Auto,
684    Normal,
685    Stretch,
686    Center,
687    Start,
688    End,
689    FlexStart,
690    FlexEnd,
691    SelfStart,
692    SelfEnd,
693    Left,
694    Right,
695}
696
697#[allow(missing_docs)]
698#[repr(C)]
699#[property_value_type(PropertyValueWithGlobal for TextAlignType)]
700#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
701#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
702pub enum TextAlign {
703    Left,
704    Center,
705    Right,
706    Justify,
707    JustifyAll,
708    Start,
709    End,
710    MatchParent,
711}
712
713#[allow(missing_docs)]
714#[repr(C)]
715#[property_value_type(PropertyValueWithGlobal for FontWeightType)]
716#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
717#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
718pub enum FontWeight {
719    Normal,
720    Bold,
721    Bolder,
722    Lighter,
723    Num(Number),
724}
725
726#[allow(missing_docs)]
727#[repr(C)]
728#[property_value_type(PropertyValueWithGlobal for WordBreakType)]
729#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
730#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
731pub enum WordBreak {
732    BreakWord,
733    BreakAll,
734    KeepAll,
735}
736
737#[allow(missing_docs)]
738#[repr(C)]
739#[property_value_type(PropertyValueWithGlobal for WhiteSpaceType)]
740#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
741#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
742pub enum WhiteSpace {
743    Normal,
744    NoWrap,
745    Pre,
746    PreWrap,
747    PreLine,
748    WxPreEdit,
749}
750
751#[allow(missing_docs)]
752#[repr(C)]
753#[property_value_type(PropertyValueWithGlobal for TextOverflowType)]
754#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
755#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
756pub enum TextOverflow {
757    Clip,
758    Ellipsis,
759}
760
761#[allow(missing_docs)]
762#[repr(C)]
763#[property_value_type(PropertyValueWithGlobal for VerticalAlignType)]
764#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
765#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
766pub enum VerticalAlign {
767    Baseline,
768    Top,
769    Middle,
770    Bottom,
771    TextTop,
772    TextBottom,
773}
774
775#[allow(missing_docs)]
776#[repr(C)]
777#[property_value_type(PropertyValueWithGlobal for LineHeightType)]
778#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
779#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
780pub enum LineHeight {
781    Normal,
782    #[resolve_font_size(Length::resolve_em_and_ratio)]
783    Length(Length),
784    Num(Number),
785}
786
787#[allow(missing_docs)]
788#[repr(C)]
789#[property_value_type(PropertyValueWithGlobal for FontFamilyType)]
790#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
791#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
792pub enum FontFamily {
793    Names(Array<FontFamilyName>),
794}
795
796#[allow(missing_docs)]
797#[repr(C)]
798#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
799#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
800pub enum FontFamilyName {
801    Serif,
802    SansSerif,
803    Monospace,
804    Cursive,
805    Fantasy,
806    Title(StrRef),
807    SystemUi,
808}
809
810#[allow(missing_docs)]
811#[repr(C)]
812#[property_value_type(PropertyValueWithGlobal for BoxSizingType)]
813#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
814#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
815pub enum BoxSizing {
816    ContentBox,
817    PaddingBox,
818    BorderBox,
819}
820
821#[allow(missing_docs)]
822#[repr(C)]
823#[property_value_type(PropertyValueWithGlobal for BorderStyleType)]
824#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
825#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
826pub enum BorderStyle {
827    None,
828    Solid,
829    Dotted,
830    Dashed,
831    Hidden,
832    Double,
833    Groove,
834    Ridge,
835    Inset,
836    Outset,
837}
838
839/// The CSS `transform` item series.
840#[allow(missing_docs)]
841#[repr(C)]
842#[property_value_type(PropertyValueWithGlobal for TransformType)]
843#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
844#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
845pub enum Transform {
846    Series(Array<TransformItem>),
847}
848
849/// A `transform` item.
850#[allow(missing_docs)]
851#[repr(C)]
852#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
853#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
854pub enum TransformItem {
855    None,
856    Matrix([f32; 6]),
857    Matrix3D([f32; 16]),
858    #[resolve_font_size(Length::resolve_em)]
859    Translate2D(Length, Length),
860    #[resolve_font_size(Length::resolve_em)]
861    Translate3D(Length, Length, Length),
862    Scale2D(f32, f32),
863    Scale3D(f32, f32, f32),
864    Rotate2D(Angle),
865    Rotate3D(f32, f32, f32, Angle),
866    Skew(Angle, Angle),
867    #[resolve_font_size(Length::resolve_em)]
868    Perspective(Length),
869}
870
871#[allow(missing_docs)]
872#[repr(C)]
873#[property_value_type(PropertyValueWithGlobal for TransitionPropertyType)]
874#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
875#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
876pub enum TransitionProperty {
877    List(Array<TransitionPropertyItem>),
878}
879
880/// The property name allowed in CSS `transition-property`.
881#[allow(missing_docs)]
882#[repr(C)]
883#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
884#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
885pub enum TransitionPropertyItem {
886    None,
887    Transform,
888    TransformOrigin,
889    LineHeight,
890    Opacity,
891    All,
892    Height,
893    Width,
894    MinHeight,
895    MaxHeight,
896    MinWidth,
897    MaxWidth,
898    MarginTop,
899    MarginRight,
900    MarginLeft,
901    MarginBottom,
902    Margin,
903    PaddingTop,
904    PaddingRight,
905    PaddingBottom,
906    PaddingLeft,
907    Padding,
908    Top,
909    Right,
910    Bottom,
911    Left,
912    FlexGrow,
913    FlexShrink,
914    FlexBasis,
915    Flex,
916    BorderTopWidth,
917    BorderRightWidth,
918    BorderBottomWidth,
919    BorderLeftWidth,
920    BorderTopColor,
921    BorderRightColor,
922    BorderBottomColor,
923    BorderLeftColor,
924    BorderTopLeftRadius,
925    BorderTopRightRadius,
926    BorderBottomLeftRadius,
927    BorderBottomRightRadius,
928    Border,
929    BorderWidth,
930    BorderColor,
931    BorderRadius,
932    BorderLeft,
933    BorderTop,
934    BorderRight,
935    BorderBottom,
936    Font,
937    ZIndex,
938    BoxShadow,
939    BackdropFilter,
940    Filter,
941    Color,
942    TextDecorationColor,
943    TextDecorationThickness,
944    FontSize,
945    FontWeight,
946    LetterSpacing,
947    WordSpacing,
948    BackgroundColor,
949    BackgroundPosition,
950    BackgroundSize,
951    Background,
952    BackgroundPositionX,
953    BackgroundPositionY,
954    Mask,
955    MaskSize,
956    MaskPositionX,
957    MaskPositionY,
958    MaskPosition,
959    TextUnderlineOffset,
960}
961
962/// A helper type for `transition-timing-function`.
963#[allow(missing_docs)]
964#[repr(C)]
965#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
966#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
967pub enum StepPosition {
968    End,
969    JumpStart,
970    JumpEnd,
971    JumpNone,
972    JumpBoth,
973    Start,
974}
975
976#[allow(missing_docs)]
977#[repr(C)]
978#[property_value_type(PropertyValueWithGlobal for TransitionTimeType)]
979#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
980#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
981pub enum TransitionTime {
982    List(Array<u32>),
983    ListI32(Array<i32>),
984}
985
986/// The CSS `transition-timing-funcction`.
987#[allow(missing_docs)]
988#[repr(C)]
989#[property_value_type(PropertyValueWithGlobal for TransitionTimingFnType)]
990#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
991#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
992pub enum TransitionTimingFn {
993    List(Array<TransitionTimingFnItem>),
994}
995
996#[allow(missing_docs)]
997#[repr(C)]
998#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
999#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1000pub enum TransitionTimingFnItem {
1001    Linear,
1002    Ease,
1003    EaseIn,
1004    EaseOut,
1005    EaseInOut,
1006    StepStart,
1007    StepEnd,
1008    Steps(i32, StepPosition),
1009    CubicBezier(f32, f32, f32, f32),
1010}
1011
1012/// The scroll bar options.
1013#[allow(missing_docs)]
1014#[repr(C)]
1015#[property_value_type(PropertyValueWithGlobal for ScrollbarType)]
1016#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1017#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1018pub enum Scrollbar {
1019    /// Show the scroll bar when needed.
1020    Auto,
1021    /// Always hide the scroll bar.
1022    Hidden,
1023    /// Hide the scroll bar when not scrolling.
1024    AutoHide,
1025    /// Always show the scroll bar.
1026    AlwaysShow,
1027}
1028
1029#[allow(missing_docs)]
1030#[repr(C)]
1031#[property_value_type(PropertyValueWithGlobal for BackgroundRepeatType)]
1032#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1033#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1034pub enum BackgroundRepeat {
1035    List(Array<BackgroundRepeatItem>),
1036}
1037
1038/// An item in `background-repeat`.
1039#[repr(C)]
1040#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1041#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1042pub enum BackgroundRepeatItem {
1043    /// The two-value form of `background-repeat`.
1044    Pos(BackgroundRepeatValue, BackgroundRepeatValue),
1045}
1046
1047/// A `background-repeat` value.
1048#[allow(missing_docs)]
1049#[repr(C)]
1050#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1051#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1052pub enum BackgroundRepeatValue {
1053    Repeat,
1054    NoRepeat,
1055    Space,
1056    Round,
1057}
1058
1059#[allow(missing_docs)]
1060#[repr(C)]
1061#[property_value_type(PropertyValueWithGlobal for BackgroundSizeType)]
1062#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1063#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1064pub enum BackgroundSize {
1065    List(Array<BackgroundSizeItem>),
1066}
1067
1068/// An item in `background-size`.
1069#[allow(missing_docs)]
1070#[repr(C)]
1071#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1072#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1073pub enum BackgroundSizeItem {
1074    Auto,
1075    #[resolve_font_size(Length::resolve_em)]
1076    Length(Length, Length),
1077    Cover,
1078    Contain,
1079}
1080
1081#[allow(missing_docs)]
1082#[repr(C)]
1083#[property_value_type(PropertyValueWithGlobal for BackgroundImageType)]
1084#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1085#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1086pub enum BackgroundImage {
1087    List(Array<BackgroundImageItem>),
1088}
1089
1090/// An image tag in image description.
1091#[allow(missing_docs)]
1092#[repr(C)]
1093#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1094#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1095pub enum ImageTags {
1096    LTR,
1097    RTL,
1098}
1099
1100/// An image source in image description.
1101#[allow(missing_docs)]
1102#[repr(C)]
1103#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1104#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1105pub enum ImageSource {
1106    None,
1107    Url(StrRef),
1108}
1109
1110/// An item in `background-image`.
1111#[allow(missing_docs)]
1112#[repr(C)]
1113#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1114#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1115pub enum BackgroundImageItem {
1116    None,
1117    Url(StrRef),
1118    Gradient(BackgroundImageGradientItem),
1119    Image(ImageTags, ImageSource, Color),
1120    Element(StrRef),
1121}
1122
1123/// Gradient types in image description.
1124#[allow(missing_docs)]
1125#[repr(C)]
1126#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1127#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1128pub enum BackgroundImageGradientItem {
1129    LinearGradient(Angle, Array<GradientColorItem>),
1130    RadialGradient(
1131        GradientShape,
1132        GradientSize,
1133        GradientPosition,
1134        Array<GradientColorItem>,
1135    ),
1136    ConicGradient(ConicGradientItem),
1137}
1138
1139/// Gradient size types in image description.
1140#[allow(missing_docs)]
1141#[repr(C)]
1142#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1143#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1144pub enum GradientSize {
1145    FarthestCorner,
1146    ClosestSide,
1147    ClosestCorner,
1148    FarthestSide,
1149    #[resolve_font_size(Length::resolve_em)]
1150    Len(Length, Length),
1151}
1152
1153/// Gradient position types in image description.
1154#[allow(missing_docs)]
1155#[repr(C)]
1156#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1157#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1158pub enum GradientPosition {
1159    #[resolve_font_size(Length::resolve_em)]
1160    Pos(Length, Length),
1161    SpecifiedPos(GradientSpecifiedPos, GradientSpecifiedPos),
1162}
1163
1164#[allow(missing_docs)]
1165#[repr(C)]
1166#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1167#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1168pub enum GradientSpecifiedPos {
1169    #[resolve_font_size(Length::resolve_em)]
1170    Left(Length),
1171    #[resolve_font_size(Length::resolve_em)]
1172    Right(Length),
1173    #[resolve_font_size(Length::resolve_em)]
1174    Top(Length),
1175    #[resolve_font_size(Length::resolve_em)]
1176    Bottom(Length),
1177    // TODO: Support x/y-start/end, block-start/end, inline-start/end, start, end
1178}
1179
1180/// Gradient shape types in image description.
1181#[allow(missing_docs)]
1182#[repr(C)]
1183#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1184#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1185pub enum GradientShape {
1186    Ellipse,
1187    Circle,
1188}
1189
1190/// Gradient color types in image description.
1191#[allow(missing_docs)]
1192#[repr(C)]
1193#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1194#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1195pub enum GradientColorItem {
1196    ColorHint(Color, #[resolve_font_size(Length::resolve_em)] Length),
1197    SimpleColorHint(Color),
1198    AngleOrPercentageColorHint(Color, AngleOrPercentage),
1199}
1200
1201/// A conic-gradient item.
1202#[allow(missing_docs)]
1203#[repr(C)]
1204#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1205#[cfg_attr(debug_assertions, derive(CompatibilityStructCheck))]
1206pub struct ConicGradientItem {
1207    pub angle: Angle,
1208    pub position: GradientPosition,
1209    pub items: Array<GradientColorItem>,
1210}
1211
1212impl<T: ResolveFontSize> ResolveFontSize for Option<T> {
1213    fn resolve_font_size(&mut self, font_size: f32) {
1214        if let Some(value) = self {
1215            value.resolve_font_size(font_size)
1216        }
1217    }
1218}
1219
1220#[allow(missing_docs)]
1221#[repr(C)]
1222#[property_value_type(PropertyValueWithGlobal for BackgroundPositionType)]
1223#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1224#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1225pub enum BackgroundPosition {
1226    List(Array<BackgroundPositionItem>),
1227}
1228
1229/// An item in `background-position`.
1230#[allow(missing_docs)]
1231#[repr(C)]
1232#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1233#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1234pub enum BackgroundPositionItem {
1235    Pos(BackgroundPositionValue, BackgroundPositionValue),
1236    Value(BackgroundPositionValue),
1237}
1238
1239/// A `background-position` value.
1240#[allow(missing_docs)]
1241#[repr(C)]
1242#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1243#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1244pub enum BackgroundPositionValue {
1245    #[resolve_font_size(Length::resolve_em)]
1246    Top(Length),
1247    #[resolve_font_size(Length::resolve_em)]
1248    Bottom(Length),
1249    #[resolve_font_size(Length::resolve_em)]
1250    Left(Length),
1251    #[resolve_font_size(Length::resolve_em)]
1252    Right(Length),
1253}
1254
1255#[allow(missing_docs)]
1256#[repr(C)]
1257#[property_value_type(PropertyValueWithGlobal for FontStyleType)]
1258#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1259#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1260pub enum FontStyle {
1261    Normal,
1262    Italic,
1263    Oblique(Angle),
1264}
1265
1266#[allow(missing_docs)]
1267#[repr(C)]
1268#[property_value_type(PropertyValueWithGlobal for BackgroundClipType)]
1269#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1270#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1271pub enum BackgroundClip {
1272    List(Array<BackgroundClipItem>),
1273}
1274
1275/// An item in `background-clip`.
1276#[allow(missing_docs)]
1277#[repr(C)]
1278#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1279#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1280pub enum BackgroundClipItem {
1281    BorderBox,
1282    PaddingBox,
1283    ContentBox,
1284    Text,
1285}
1286
1287#[allow(missing_docs)]
1288#[repr(C)]
1289#[property_value_type(PropertyValueWithGlobal for BackgroundOriginType)]
1290#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1291#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1292pub enum BackgroundOrigin {
1293    List(Array<BackgroundOriginItem>),
1294}
1295
1296/// An item in `background-origin`.
1297#[allow(missing_docs)]
1298#[repr(C)]
1299#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1300#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1301pub enum BackgroundOriginItem {
1302    BorderBox,
1303    PaddingBox,
1304    ContentBox,
1305}
1306
1307/// An item in `background-attachment`.
1308#[allow(missing_docs)]
1309#[repr(C)]
1310#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1311#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1312pub enum BackgroundAttachmentItem {
1313    Scroll,
1314    Fixed,
1315    Local,
1316}
1317
1318#[allow(missing_docs)]
1319#[repr(C)]
1320#[property_value_type(PropertyValueWithGlobal for BackgroundAttachmentType)]
1321#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1322#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1323pub enum BackgroundAttachment {
1324    List(Array<BackgroundAttachmentItem>),
1325}
1326
1327#[allow(missing_docs)]
1328#[repr(C)]
1329#[property_value_type(PropertyValueWithGlobal for FloatType)]
1330#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1331#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1332pub enum Float {
1333    None,
1334    Left,
1335    Right,
1336    InlineStart,
1337    InlineEnd,
1338}
1339
1340#[allow(missing_docs)]
1341#[repr(C)]
1342#[property_value_type(PropertyValueWithGlobal for ListStyleTypeType)]
1343#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1344#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1345pub enum ListStyleType {
1346    Disc,
1347    None,
1348    Circle,
1349    Square,
1350    Decimal,
1351    CjkDecimal,
1352    DecimalLeadingZero,
1353    LowerRoman,
1354    UpperRoman,
1355    LowerGreek,
1356    LowerAlpha,
1357    LowerLatin,
1358    UpperAlpha,
1359    UpperLatin,
1360    Armenian,
1361    Georgian,
1362    CustomIdent(StrRef),
1363}
1364
1365#[allow(missing_docs)]
1366#[repr(C)]
1367#[property_value_type(PropertyValueWithGlobal for ListStyleImageType)]
1368#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1369#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1370pub enum ListStyleImage {
1371    None,
1372    Url(StrRef),
1373}
1374
1375#[allow(missing_docs)]
1376#[repr(C)]
1377#[property_value_type(PropertyValueWithGlobal for ListStylePositionType)]
1378#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1379#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1380pub enum ListStylePosition {
1381    Outside,
1382    Inside,
1383}
1384
1385#[allow(missing_docs)]
1386#[repr(C)]
1387#[property_value_type(PropertyValueWithGlobal for ResizeType)]
1388#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1389#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1390pub enum Resize {
1391    None,
1392    Both,
1393    Horizontal,
1394    Vertical,
1395    Block,
1396    Inline,
1397}
1398
1399#[allow(missing_docs)]
1400#[repr(C)]
1401#[property_value_type(PropertyValueWithGlobal for ZIndexType)]
1402#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1403#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1404pub enum ZIndex {
1405    Auto,
1406    Num(Number),
1407}
1408
1409#[allow(missing_docs)]
1410#[repr(C)]
1411#[property_value_type(PropertyValueWithGlobal for TextShadowType)]
1412#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1413#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1414pub enum TextShadow {
1415    None,
1416    List(Array<TextShadowItem>),
1417}
1418
1419/// An item in `text-shadow`.
1420#[repr(C)]
1421#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1422#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1423pub enum TextShadowItem {
1424    /// A value of offset-y, offset-x, blur-radius, and color.
1425    TextShadowValue(
1426        #[resolve_font_size(Length::resolve_em_and_ratio)] Length,
1427        #[resolve_font_size(Length::resolve_em_and_ratio)] Length,
1428        #[resolve_font_size(Length::resolve_em_and_ratio)] Length,
1429        Color,
1430    ),
1431}
1432
1433#[allow(missing_docs)]
1434#[repr(C)]
1435#[property_value_type(PropertyValueWithGlobal for TextDecorationLineType)]
1436#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1437#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1438pub enum TextDecorationLine {
1439    None,
1440    SpellingError,
1441    GrammarError,
1442    List(Array<TextDecorationLineItem>),
1443}
1444
1445/// An item in `text-decoration-line`.
1446#[allow(missing_docs)]
1447#[repr(C)]
1448#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1449#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1450pub enum TextDecorationLineItem {
1451    Overline,
1452    LineThrough,
1453    Underline,
1454    Blink,
1455}
1456
1457#[allow(missing_docs)]
1458#[repr(C)]
1459#[property_value_type(PropertyValueWithGlobal for TextDecorationStyleType)]
1460#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1461#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1462pub enum TextDecorationStyle {
1463    Solid,
1464    Double,
1465    Dotted,
1466    Dashed,
1467    Wavy,
1468}
1469
1470#[allow(missing_docs)]
1471#[repr(C)]
1472#[property_value_type(PropertyValueWithGlobal for TextDecorationThicknessType)]
1473#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1474#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1475pub enum TextDecorationThickness {
1476    Auto,
1477    FromFont,
1478    #[resolve_font_size(Length::resolve_em_and_ratio)]
1479    Length(Length),
1480}
1481
1482#[allow(missing_docs)]
1483#[repr(C)]
1484#[property_value_type(PropertyValueWithGlobal for TextUnderlineOffsetType)]
1485#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1486#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1487pub enum TextUnderlineOffset {
1488    Auto,
1489    #[resolve_font_size(Length::resolve_em_and_ratio)]
1490    Length(Length),
1491}
1492
1493#[allow(missing_docs)]
1494#[repr(C)]
1495#[property_value_type(PropertyValueWithGlobal for LetterSpacingType)]
1496#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1497#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1498pub enum LetterSpacing {
1499    Normal,
1500    #[resolve_font_size(Length::resolve_em_and_ratio)]
1501    Length(Length),
1502}
1503
1504#[allow(missing_docs)]
1505#[repr(C)]
1506#[property_value_type(PropertyValueWithGlobal for WordSpacingType)]
1507#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1508#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1509pub enum WordSpacing {
1510    Normal,
1511    #[resolve_font_size(Length::resolve_em_and_ratio)]
1512    Length(Length),
1513}
1514
1515#[allow(missing_docs)]
1516#[repr(C)]
1517#[property_value_type(PropertyValueWithGlobal for BorderRadiusType)]
1518#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1519#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1520pub enum BorderRadius {
1521    #[resolve_font_size(Length::resolve_em)]
1522    Pos(Length, Length),
1523}
1524
1525#[allow(missing_docs)]
1526#[repr(C)]
1527#[property_value_type(PropertyValueWithGlobal for BoxShadowType)]
1528#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1529#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1530pub enum BoxShadow {
1531    None,
1532    List(Array<BoxShadowItem>),
1533}
1534
1535/// An item in `box-shadow`.
1536#[allow(missing_docs)]
1537#[repr(C)]
1538#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1539#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1540pub enum BoxShadowItem {
1541    List(Array<ShadowItemType>),
1542}
1543
1544/// A shadow type in `box-shadow`.
1545#[allow(missing_docs)]
1546#[repr(C)]
1547#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1548#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1549pub enum ShadowItemType {
1550    Inset,
1551    #[resolve_font_size(Length::resolve_em)]
1552    OffsetX(Length),
1553    #[resolve_font_size(Length::resolve_em)]
1554    OffsetY(Length),
1555    #[resolve_font_size(Length::resolve_em)]
1556    BlurRadius(Length),
1557    #[resolve_font_size(Length::resolve_em)]
1558    SpreadRadius(Length),
1559    Color(Color),
1560}
1561
1562#[allow(missing_docs)]
1563#[repr(C)]
1564#[property_value_type(PropertyValueWithGlobal for BackdropFilterType)]
1565#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1566#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1567pub enum BackdropFilter {
1568    None,
1569    List(Array<FilterFunc>),
1570}
1571
1572#[allow(missing_docs)]
1573#[repr(C)]
1574#[property_value_type(PropertyValueWithGlobal for FilterType)]
1575#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1576#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1577pub enum Filter {
1578    None,
1579    List(Array<FilterFunc>),
1580}
1581
1582/// A filter function for `filter` and `backdrop-filter`.
1583#[allow(missing_docs)]
1584#[repr(C)]
1585#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1586#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1587pub enum FilterFunc {
1588    Url(StrRef),
1589    #[resolve_font_size(Length::resolve_em)]
1590    Blur(Length),
1591    #[resolve_font_size(Length::resolve_em)]
1592    Brightness(Length),
1593    #[resolve_font_size(Length::resolve_em)]
1594    Contrast(Length),
1595    DropShadow(DropShadow),
1596    #[resolve_font_size(Length::resolve_em)]
1597    Grayscale(Length),
1598    HueRotate(Angle),
1599    #[resolve_font_size(Length::resolve_em)]
1600    Invert(Length),
1601    #[resolve_font_size(Length::resolve_em)]
1602    Opacity(Length),
1603    #[resolve_font_size(Length::resolve_em)]
1604    Saturate(Length),
1605    #[resolve_font_size(Length::resolve_em)]
1606    Sepia(Length),
1607}
1608
1609/// A drop shadow in filter function for `filter` and `backdrop-filter`.
1610#[allow(missing_docs)]
1611#[repr(C)]
1612#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1613#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1614pub enum DropShadow {
1615    List(Array<ShadowItemType>),
1616}
1617
1618#[allow(missing_docs)]
1619#[repr(C)]
1620#[property_value_type(PropertyValueWithGlobal for TransformOriginType)]
1621#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1622#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1623pub enum TransformOrigin {
1624    #[resolve_font_size(Length::resolve_em)]
1625    LengthTuple(Length, Length, Length),
1626    Left,
1627    Right,
1628    Center,
1629    Bottom,
1630    Top,
1631    #[resolve_font_size(Length::resolve_em)]
1632    Length(Length),
1633}
1634
1635#[allow(missing_docs)]
1636#[repr(C)]
1637#[property_value_type(PropertyValueWithGlobal for MaskModeType)]
1638#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1639#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1640pub enum MaskMode {
1641    List(Array<MaskModeItem>),
1642}
1643
1644/// An item in mask-mode.
1645#[allow(missing_docs)]
1646#[repr(C)]
1647#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1648#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1649pub enum MaskModeItem {
1650    MatchSource,
1651    Alpha,
1652    Luminance,
1653}
1654
1655#[allow(missing_docs)]
1656#[repr(C)]
1657#[property_value_type(PropertyValueWithGlobal for AspectRatioType)]
1658#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1659#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1660pub enum AspectRatio {
1661    Auto,
1662    Ratio(Number, Number),
1663}
1664
1665#[allow(missing_docs)]
1666#[repr(C)]
1667#[property_value_type(PropertyValueWithGlobal for ContainType)]
1668#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1669#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1670pub enum Contain {
1671    None,
1672    Strict,
1673    Content,
1674    Multiple(Array<ContainKeyword>),
1675}
1676
1677/// An item in multi-value form of `contain`.
1678#[allow(missing_docs)]
1679#[repr(C)]
1680#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1681#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1682pub enum ContainKeyword {
1683    Size,
1684    Layout,
1685    Style,
1686    Paint,
1687}
1688
1689#[allow(missing_docs)]
1690#[repr(C)]
1691#[property_value_type(PropertyValueWithGlobal for ContentType)]
1692#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1693#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1694pub enum Content {
1695    None,
1696    Normal,
1697    Str(StrRef),
1698    Url(StrRef),
1699}
1700
1701/// A unknown property.
1702#[allow(missing_docs)]
1703#[repr(C)]
1704#[property_value_type(PropertyValueWithGlobal for CustomPropertyType)]
1705#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1706#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1707pub enum CustomProperty {
1708    None,
1709    Expr(StrRef, StrRef),
1710}
1711
1712#[allow(missing_docs)]
1713#[repr(C)]
1714#[property_value_type(PropertyValueWithGlobal for AnimationIterationCountType)]
1715#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1716#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1717pub enum AnimationIterationCount {
1718    List(Array<AnimationIterationCountItem>),
1719}
1720
1721/// An item in `animation-iteration-count`.
1722#[allow(missing_docs)]
1723#[repr(C)]
1724#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1725#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1726pub enum AnimationIterationCountItem {
1727    Number(f32),
1728    Infinite,
1729}
1730
1731#[allow(missing_docs)]
1732#[repr(C)]
1733#[property_value_type(PropertyValueWithGlobal for AnimationDirectionType)]
1734#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1735#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1736pub enum AnimationDirection {
1737    List(Array<AnimationDirectionItem>),
1738}
1739
1740/// An item in `animation-direction`.
1741#[allow(missing_docs)]
1742#[repr(C)]
1743#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1744#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1745pub enum AnimationDirectionItem {
1746    Normal,
1747    Reverse,
1748    Alternate,
1749    AlternateReverse,
1750}
1751
1752#[allow(missing_docs)]
1753#[repr(C)]
1754#[property_value_type(PropertyValueWithGlobal for AnimationFillModeType)]
1755#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1756#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1757pub enum AnimationFillMode {
1758    List(Array<AnimationFillModeItem>),
1759}
1760
1761/// An item in `animation-fill-mode`.
1762#[allow(missing_docs)]
1763#[repr(C)]
1764#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1765#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1766pub enum AnimationFillModeItem {
1767    None,
1768    Forwards,
1769    Backwards,
1770    Both,
1771}
1772
1773#[allow(missing_docs)]
1774#[repr(C)]
1775#[property_value_type(PropertyValueWithGlobal for AnimationPlayStateType)]
1776#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1777#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1778pub enum AnimationPlayState {
1779    List(Array<AnimationPlayStateItem>),
1780}
1781
1782/// An item in `animation-play-state`.
1783#[allow(missing_docs)]
1784#[repr(C)]
1785#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1786#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1787pub enum AnimationPlayStateItem {
1788    Running,
1789    Paused,
1790}
1791
1792#[allow(missing_docs)]
1793#[repr(C)]
1794#[property_value_type(PropertyValueWithGlobal for AnimationNameType)]
1795#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1796#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1797pub enum AnimationName {
1798    List(Array<AnimationNameItem>),
1799}
1800
1801/// An item in `animation-name`.
1802#[allow(missing_docs)]
1803#[repr(C)]
1804#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1805#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1806pub enum AnimationNameItem {
1807    None,
1808    CustomIdent(StrRef),
1809}
1810
1811#[allow(missing_docs)]
1812#[repr(C)]
1813#[property_value_type(PropertyValueWithGlobal for WillChangeType)]
1814#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1815#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1816pub enum WillChange {
1817    Auto,
1818    List(Array<AnimateableFeature>),
1819}
1820
1821/// An animation kind for `will-change`.
1822#[allow(missing_docs)]
1823#[repr(C)]
1824#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1825#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1826pub enum AnimateableFeature {
1827    /// The content of the element is likely to be animated.
1828    Contents,
1829    /// The content of the element is scrollable.
1830    ScrollPosition,
1831    /// An unknown kind.
1832    CustomIdent(StrRef),
1833}
1834
1835#[allow(missing_docs)]
1836#[repr(C)]
1837#[property_value_type(PropertyValueWithGlobal for FontFeatureSettingsType)]
1838#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1839#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1840pub enum FontFeatureSettings {
1841    Normal,
1842    FeatureTags(Array<FeatureTag>),
1843}
1844
1845/// A font feature tag for `font-feature-settings`.
1846#[repr(C)]
1847#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1848#[cfg_attr(debug_assertions, derive(CompatibilityStructCheck))]
1849pub struct FeatureTag {
1850    /// The four-letter OpenType tag, e.g. `liga`.
1851    pub opentype_tag: StrRef,
1852    /// The optional number value in `font-feature-settings`.
1853    pub value: Number,
1854}
1855
1856#[allow(missing_docs)]
1857#[repr(C)]
1858#[property_value_type(PropertyValueWithGlobal for GapType)]
1859#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1860#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1861pub enum Gap {
1862    Normal,
1863    #[resolve_font_size(Length::resolve_em)]
1864    Length(Length),
1865}
1866
1867/// The `grid-template-rows` property defines the line names and track sizing functions of the grid rows.
1868#[allow(missing_docs)]
1869#[repr(C)]
1870#[property_value_type(PropertyValueWithGlobal for GridTemplateType)]
1871#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1872#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1873pub enum GridTemplate {
1874    /// A keyword meaning that there is no explicit grid
1875    None,
1876    TrackList(Array<TrackListItem>),
1877}
1878
1879#[allow(missing_docs)]
1880#[repr(C)]
1881#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1882#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1883pub enum TrackListItem {
1884    LineNames(Array<StrRef>),
1885    TrackSize(TrackSize),
1886}
1887
1888#[allow(missing_docs)]
1889#[repr(C)]
1890#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1891#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1892pub enum TrackSize {
1893    MinContent,
1894    MaxContent,
1895    Fr(f32),
1896    #[resolve_font_size(Length::resolve_em)]
1897    Length(Length),
1898}
1899
1900#[allow(missing_docs)]
1901#[repr(C)]
1902#[property_value_type(PropertyValueWithGlobal for GridAutoFlowType)]
1903#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1904#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1905pub enum GridAutoFlow {
1906    Row,
1907    Column,
1908    RowDense,
1909    ColumnDense,
1910}
1911
1912#[allow(missing_docs)]
1913#[repr(C)]
1914#[property_value_type(PropertyValueWithGlobal for GridAutoType)]
1915#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1916#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1917pub enum GridAuto {
1918    List(Array<TrackSize>),
1919}
1920
1921#[allow(missing_docs)]
1922#[repr(C)]
1923#[property_value_type(PropertyValueWithGlobal for TouchActionType)]
1924#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1925#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1926pub enum TouchAction {
1927    Auto,
1928    None,
1929    Manipulation,
1930    Gestures(TouchActionGestures),
1931}
1932
1933#[allow(missing_docs)]
1934#[repr(C)]
1935#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
1936#[cfg_attr(debug_assertions, derive(CompatibilityStructCheck))]
1937pub struct TouchActionGestures {
1938    pub pan_left: bool,
1939    pub pan_right: bool,
1940    pub pan_up: bool,
1941    pub pan_down: bool,
1942}
1943
1944impl ResolveFontSize for TouchActionGestures {
1945    fn resolve_font_size(&mut self, _: f32) {
1946        // empty
1947    }
1948}