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}
960
961/// A helper type for `transition-timing-function`.
962#[allow(missing_docs)]
963#[repr(C)]
964#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
965#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
966pub enum StepPosition {
967    End,
968    JumpStart,
969    JumpEnd,
970    JumpNone,
971    JumpBoth,
972    Start,
973}
974
975#[allow(missing_docs)]
976#[repr(C)]
977#[property_value_type(PropertyValueWithGlobal for TransitionTimeType)]
978#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
979#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
980pub enum TransitionTime {
981    List(Array<u32>),
982    ListI32(Array<i32>),
983}
984
985/// The CSS `transition-timing-funcction`.
986#[allow(missing_docs)]
987#[repr(C)]
988#[property_value_type(PropertyValueWithGlobal for TransitionTimingFnType)]
989#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
990#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
991pub enum TransitionTimingFn {
992    List(Array<TransitionTimingFnItem>),
993}
994
995#[allow(missing_docs)]
996#[repr(C)]
997#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
998#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
999pub enum TransitionTimingFnItem {
1000    Linear,
1001    Ease,
1002    EaseIn,
1003    EaseOut,
1004    EaseInOut,
1005    StepStart,
1006    StepEnd,
1007    Steps(i32, StepPosition),
1008    CubicBezier(f32, f32, f32, f32),
1009}
1010
1011/// The scroll bar options.
1012#[allow(missing_docs)]
1013#[repr(C)]
1014#[property_value_type(PropertyValueWithGlobal for ScrollbarType)]
1015#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1016#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1017pub enum Scrollbar {
1018    /// Show the scroll bar when needed.
1019    Auto,
1020    /// Always hide the scroll bar.
1021    Hidden,
1022    /// Hide the scroll bar when not scrolling.
1023    AutoHide,
1024    /// Always show the scroll bar.
1025    AlwaysShow,
1026}
1027
1028#[allow(missing_docs)]
1029#[repr(C)]
1030#[property_value_type(PropertyValueWithGlobal for BackgroundRepeatType)]
1031#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1032#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1033pub enum BackgroundRepeat {
1034    List(Array<BackgroundRepeatItem>),
1035}
1036
1037/// An item in `background-repeat`.
1038#[repr(C)]
1039#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1040#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1041pub enum BackgroundRepeatItem {
1042    /// The two-value form of `background-repeat`.
1043    Pos(BackgroundRepeatValue, BackgroundRepeatValue),
1044}
1045
1046/// A `background-repeat` value.
1047#[allow(missing_docs)]
1048#[repr(C)]
1049#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1050#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1051pub enum BackgroundRepeatValue {
1052    Repeat,
1053    NoRepeat,
1054    Space,
1055    Round,
1056}
1057
1058#[allow(missing_docs)]
1059#[repr(C)]
1060#[property_value_type(PropertyValueWithGlobal for BackgroundSizeType)]
1061#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1062#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1063pub enum BackgroundSize {
1064    List(Array<BackgroundSizeItem>),
1065}
1066
1067/// An item in `background-size`.
1068#[allow(missing_docs)]
1069#[repr(C)]
1070#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1071#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1072pub enum BackgroundSizeItem {
1073    Auto,
1074    #[resolve_font_size(Length::resolve_em)]
1075    Length(Length, Length),
1076    Cover,
1077    Contain,
1078}
1079
1080#[allow(missing_docs)]
1081#[repr(C)]
1082#[property_value_type(PropertyValueWithGlobal for BackgroundImageType)]
1083#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1084#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1085pub enum BackgroundImage {
1086    List(Array<BackgroundImageItem>),
1087}
1088
1089/// An image tag in image description.
1090#[allow(missing_docs)]
1091#[repr(C)]
1092#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1093#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1094pub enum ImageTags {
1095    LTR,
1096    RTL,
1097}
1098
1099/// An image source in image description.
1100#[allow(missing_docs)]
1101#[repr(C)]
1102#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1103#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1104pub enum ImageSource {
1105    None,
1106    Url(StrRef),
1107}
1108
1109/// An item in `background-image`.
1110#[allow(missing_docs)]
1111#[repr(C)]
1112#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1113#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1114pub enum BackgroundImageItem {
1115    None,
1116    Url(StrRef),
1117    Gradient(BackgroundImageGradientItem),
1118    Image(ImageTags, ImageSource, Color),
1119    Element(StrRef),
1120}
1121
1122/// Gradient types in image description.
1123#[allow(missing_docs)]
1124#[repr(C)]
1125#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1126#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1127pub enum BackgroundImageGradientItem {
1128    LinearGradient(Angle, Array<GradientColorItem>),
1129    RadialGradient(
1130        GradientShape,
1131        GradientSize,
1132        GradientPosition,
1133        Array<GradientColorItem>,
1134    ),
1135    ConicGradient(ConicGradientItem),
1136}
1137
1138/// Gradient size types in image description.
1139#[allow(missing_docs)]
1140#[repr(C)]
1141#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1142#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1143pub enum GradientSize {
1144    FarthestCorner,
1145    ClosestSide,
1146    ClosestCorner,
1147    FarthestSide,
1148    #[resolve_font_size(Length::resolve_em)]
1149    Len(Length, Length),
1150}
1151
1152/// Gradient position types in image description.
1153#[allow(missing_docs)]
1154#[repr(C)]
1155#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1156#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1157pub enum GradientPosition {
1158    #[resolve_font_size(Length::resolve_em)]
1159    Pos(Length, Length),
1160    SpecifiedPos(GradientSpecifiedPos, GradientSpecifiedPos),
1161}
1162
1163#[allow(missing_docs)]
1164#[repr(C)]
1165#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1166#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1167pub enum GradientSpecifiedPos {
1168    #[resolve_font_size(Length::resolve_em)]
1169    Left(Length),
1170    #[resolve_font_size(Length::resolve_em)]
1171    Right(Length),
1172    #[resolve_font_size(Length::resolve_em)]
1173    Top(Length),
1174    #[resolve_font_size(Length::resolve_em)]
1175    Bottom(Length),
1176    // TODO: Support x/y-start/end, block-start/end, inline-start/end, start, end
1177}
1178
1179/// Gradient shape types in image description.
1180#[allow(missing_docs)]
1181#[repr(C)]
1182#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1183#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1184pub enum GradientShape {
1185    Ellipse,
1186    Circle,
1187}
1188
1189/// Gradient color types in image description.
1190#[allow(missing_docs)]
1191#[repr(C)]
1192#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1193#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1194pub enum GradientColorItem {
1195    ColorHint(Color, #[resolve_font_size(Length::resolve_em)] Length),
1196    SimpleColorHint(Color),
1197    AngleOrPercentageColorHint(Color, AngleOrPercentage),
1198}
1199
1200/// A conic-gradient item.
1201#[allow(missing_docs)]
1202#[repr(C)]
1203#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1204#[cfg_attr(debug_assertions, derive(CompatibilityStructCheck))]
1205pub struct ConicGradientItem {
1206    pub angle: Angle,
1207    pub position: GradientPosition,
1208    pub items: Array<GradientColorItem>,
1209}
1210
1211impl<T: ResolveFontSize> ResolveFontSize for Option<T> {
1212    fn resolve_font_size(&mut self, font_size: f32) {
1213        if let Some(value) = self {
1214            value.resolve_font_size(font_size)
1215        }
1216    }
1217}
1218
1219#[allow(missing_docs)]
1220#[repr(C)]
1221#[property_value_type(PropertyValueWithGlobal for BackgroundPositionType)]
1222#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1223#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1224pub enum BackgroundPosition {
1225    List(Array<BackgroundPositionItem>),
1226}
1227
1228/// An item in `background-position`.
1229#[allow(missing_docs)]
1230#[repr(C)]
1231#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1232#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1233pub enum BackgroundPositionItem {
1234    Pos(BackgroundPositionValue, BackgroundPositionValue),
1235    Value(BackgroundPositionValue),
1236}
1237
1238/// A `background-position` value.
1239#[allow(missing_docs)]
1240#[repr(C)]
1241#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1242#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1243pub enum BackgroundPositionValue {
1244    #[resolve_font_size(Length::resolve_em)]
1245    Top(Length),
1246    #[resolve_font_size(Length::resolve_em)]
1247    Bottom(Length),
1248    #[resolve_font_size(Length::resolve_em)]
1249    Left(Length),
1250    #[resolve_font_size(Length::resolve_em)]
1251    Right(Length),
1252}
1253
1254#[allow(missing_docs)]
1255#[repr(C)]
1256#[property_value_type(PropertyValueWithGlobal for FontStyleType)]
1257#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1258#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1259pub enum FontStyle {
1260    Normal,
1261    Italic,
1262    Oblique(Angle),
1263}
1264
1265#[allow(missing_docs)]
1266#[repr(C)]
1267#[property_value_type(PropertyValueWithGlobal for BackgroundClipType)]
1268#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1269#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1270pub enum BackgroundClip {
1271    List(Array<BackgroundClipItem>),
1272}
1273
1274/// An item in `background-clip`.
1275#[allow(missing_docs)]
1276#[repr(C)]
1277#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1278#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1279pub enum BackgroundClipItem {
1280    BorderBox,
1281    PaddingBox,
1282    ContentBox,
1283    Text,
1284}
1285
1286#[allow(missing_docs)]
1287#[repr(C)]
1288#[property_value_type(PropertyValueWithGlobal for BackgroundOriginType)]
1289#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1290#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1291pub enum BackgroundOrigin {
1292    List(Array<BackgroundOriginItem>),
1293}
1294
1295/// An item in `background-origin`.
1296#[allow(missing_docs)]
1297#[repr(C)]
1298#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1299#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1300pub enum BackgroundOriginItem {
1301    BorderBox,
1302    PaddingBox,
1303    ContentBox,
1304}
1305
1306/// An item in `background-attachment`.
1307#[allow(missing_docs)]
1308#[repr(C)]
1309#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1310#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1311pub enum BackgroundAttachmentItem {
1312    Scroll,
1313    Fixed,
1314    Local,
1315}
1316
1317#[allow(missing_docs)]
1318#[repr(C)]
1319#[property_value_type(PropertyValueWithGlobal for BackgroundAttachmentType)]
1320#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1321#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1322pub enum BackgroundAttachment {
1323    List(Array<BackgroundAttachmentItem>),
1324}
1325
1326#[allow(missing_docs)]
1327#[repr(C)]
1328#[property_value_type(PropertyValueWithGlobal for FloatType)]
1329#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1330#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1331pub enum Float {
1332    None,
1333    Left,
1334    Right,
1335    InlineStart,
1336    InlineEnd,
1337}
1338
1339#[allow(missing_docs)]
1340#[repr(C)]
1341#[property_value_type(PropertyValueWithGlobal for ListStyleTypeType)]
1342#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1343#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1344pub enum ListStyleType {
1345    Disc,
1346    None,
1347    Circle,
1348    Square,
1349    Decimal,
1350    CjkDecimal,
1351    DecimalLeadingZero,
1352    LowerRoman,
1353    UpperRoman,
1354    LowerGreek,
1355    LowerAlpha,
1356    LowerLatin,
1357    UpperAlpha,
1358    UpperLatin,
1359    Armenian,
1360    Georgian,
1361    CustomIdent(StrRef),
1362}
1363
1364#[allow(missing_docs)]
1365#[repr(C)]
1366#[property_value_type(PropertyValueWithGlobal for ListStyleImageType)]
1367#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1368#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1369pub enum ListStyleImage {
1370    None,
1371    Url(StrRef),
1372}
1373
1374#[allow(missing_docs)]
1375#[repr(C)]
1376#[property_value_type(PropertyValueWithGlobal for ListStylePositionType)]
1377#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1378#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1379pub enum ListStylePosition {
1380    Outside,
1381    Inside,
1382}
1383
1384#[allow(missing_docs)]
1385#[repr(C)]
1386#[property_value_type(PropertyValueWithGlobal for ResizeType)]
1387#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1388#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1389pub enum Resize {
1390    None,
1391    Both,
1392    Horizontal,
1393    Vertical,
1394    Block,
1395    Inline,
1396}
1397
1398#[allow(missing_docs)]
1399#[repr(C)]
1400#[property_value_type(PropertyValueWithGlobal for ZIndexType)]
1401#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1402#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1403pub enum ZIndex {
1404    Auto,
1405    Num(Number),
1406}
1407
1408#[allow(missing_docs)]
1409#[repr(C)]
1410#[property_value_type(PropertyValueWithGlobal for TextShadowType)]
1411#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1412#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1413pub enum TextShadow {
1414    None,
1415    List(Array<TextShadowItem>),
1416}
1417
1418/// An item in `text-shadow`.
1419#[repr(C)]
1420#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1421#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1422pub enum TextShadowItem {
1423    /// A value of offset-y, offset-x, blur-radius, and color.
1424    TextShadowValue(
1425        #[resolve_font_size(Length::resolve_em_and_ratio)] Length,
1426        #[resolve_font_size(Length::resolve_em_and_ratio)] Length,
1427        #[resolve_font_size(Length::resolve_em_and_ratio)] Length,
1428        Color,
1429    ),
1430}
1431
1432#[allow(missing_docs)]
1433#[repr(C)]
1434#[property_value_type(PropertyValueWithGlobal for TextDecorationLineType)]
1435#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1436#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1437pub enum TextDecorationLine {
1438    None,
1439    SpellingError,
1440    GrammarError,
1441    List(Array<TextDecorationLineItem>),
1442}
1443
1444/// An item in `text-decoration-line`.
1445#[allow(missing_docs)]
1446#[repr(C)]
1447#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1448#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1449pub enum TextDecorationLineItem {
1450    Overline,
1451    LineThrough,
1452    Underline,
1453    Blink,
1454}
1455
1456#[allow(missing_docs)]
1457#[repr(C)]
1458#[property_value_type(PropertyValueWithGlobal for TextDecorationStyleType)]
1459#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1460#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1461pub enum TextDecorationStyle {
1462    Solid,
1463    Double,
1464    Dotted,
1465    Dashed,
1466    Wavy,
1467}
1468
1469#[allow(missing_docs)]
1470#[repr(C)]
1471#[property_value_type(PropertyValueWithGlobal for TextDecorationThicknessType)]
1472#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1473#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1474pub enum TextDecorationThickness {
1475    Auto,
1476    FromFont,
1477    #[resolve_font_size(Length::resolve_em_and_ratio)]
1478    Length(Length),
1479}
1480
1481#[allow(missing_docs)]
1482#[repr(C)]
1483#[property_value_type(PropertyValueWithGlobal for LetterSpacingType)]
1484#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1485#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1486pub enum LetterSpacing {
1487    Normal,
1488    #[resolve_font_size(Length::resolve_em_and_ratio)]
1489    Length(Length),
1490}
1491
1492#[allow(missing_docs)]
1493#[repr(C)]
1494#[property_value_type(PropertyValueWithGlobal for WordSpacingType)]
1495#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1496#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1497pub enum WordSpacing {
1498    Normal,
1499    #[resolve_font_size(Length::resolve_em_and_ratio)]
1500    Length(Length),
1501}
1502
1503#[allow(missing_docs)]
1504#[repr(C)]
1505#[property_value_type(PropertyValueWithGlobal for BorderRadiusType)]
1506#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1507#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1508pub enum BorderRadius {
1509    #[resolve_font_size(Length::resolve_em)]
1510    Pos(Length, Length),
1511}
1512
1513#[allow(missing_docs)]
1514#[repr(C)]
1515#[property_value_type(PropertyValueWithGlobal for BoxShadowType)]
1516#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1517#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1518pub enum BoxShadow {
1519    None,
1520    List(Array<BoxShadowItem>),
1521}
1522
1523/// An item in `box-shadow`.
1524#[allow(missing_docs)]
1525#[repr(C)]
1526#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1527#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1528pub enum BoxShadowItem {
1529    List(Array<ShadowItemType>),
1530}
1531
1532/// A shadow type in `box-shadow`.
1533#[allow(missing_docs)]
1534#[repr(C)]
1535#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1536#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1537pub enum ShadowItemType {
1538    Inset,
1539    #[resolve_font_size(Length::resolve_em)]
1540    OffsetX(Length),
1541    #[resolve_font_size(Length::resolve_em)]
1542    OffsetY(Length),
1543    #[resolve_font_size(Length::resolve_em)]
1544    BlurRadius(Length),
1545    #[resolve_font_size(Length::resolve_em)]
1546    SpreadRadius(Length),
1547    Color(Color),
1548}
1549
1550#[allow(missing_docs)]
1551#[repr(C)]
1552#[property_value_type(PropertyValueWithGlobal for BackdropFilterType)]
1553#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1554#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1555pub enum BackdropFilter {
1556    None,
1557    List(Array<FilterFunc>),
1558}
1559
1560#[allow(missing_docs)]
1561#[repr(C)]
1562#[property_value_type(PropertyValueWithGlobal for FilterType)]
1563#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1564#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1565pub enum Filter {
1566    None,
1567    List(Array<FilterFunc>),
1568}
1569
1570/// A filter function for `filter` and `backdrop-filter`.
1571#[allow(missing_docs)]
1572#[repr(C)]
1573#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1574#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1575pub enum FilterFunc {
1576    Url(StrRef),
1577    #[resolve_font_size(Length::resolve_em)]
1578    Blur(Length),
1579    #[resolve_font_size(Length::resolve_em)]
1580    Brightness(Length),
1581    #[resolve_font_size(Length::resolve_em)]
1582    Contrast(Length),
1583    DropShadow(DropShadow),
1584    #[resolve_font_size(Length::resolve_em)]
1585    Grayscale(Length),
1586    HueRotate(Angle),
1587    #[resolve_font_size(Length::resolve_em)]
1588    Invert(Length),
1589    #[resolve_font_size(Length::resolve_em)]
1590    Opacity(Length),
1591    #[resolve_font_size(Length::resolve_em)]
1592    Saturate(Length),
1593    #[resolve_font_size(Length::resolve_em)]
1594    Sepia(Length),
1595}
1596
1597/// A drop shadow in filter function for `filter` and `backdrop-filter`.
1598#[allow(missing_docs)]
1599#[repr(C)]
1600#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1601#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1602pub enum DropShadow {
1603    List(Array<ShadowItemType>),
1604}
1605
1606#[allow(missing_docs)]
1607#[repr(C)]
1608#[property_value_type(PropertyValueWithGlobal for TransformOriginType)]
1609#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1610#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1611pub enum TransformOrigin {
1612    #[resolve_font_size(Length::resolve_em)]
1613    LengthTuple(Length, Length, Length),
1614    Left,
1615    Right,
1616    Center,
1617    Bottom,
1618    Top,
1619    #[resolve_font_size(Length::resolve_em)]
1620    Length(Length),
1621}
1622
1623#[allow(missing_docs)]
1624#[repr(C)]
1625#[property_value_type(PropertyValueWithGlobal for MaskModeType)]
1626#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1627#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1628pub enum MaskMode {
1629    List(Array<MaskModeItem>),
1630}
1631
1632/// An item in mask-mode.
1633#[allow(missing_docs)]
1634#[repr(C)]
1635#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1636#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1637pub enum MaskModeItem {
1638    MatchSource,
1639    Alpha,
1640    Luminance,
1641}
1642
1643#[allow(missing_docs)]
1644#[repr(C)]
1645#[property_value_type(PropertyValueWithGlobal for AspectRatioType)]
1646#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1647#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1648pub enum AspectRatio {
1649    Auto,
1650    Ratio(Number, Number),
1651}
1652
1653#[allow(missing_docs)]
1654#[repr(C)]
1655#[property_value_type(PropertyValueWithGlobal for ContainType)]
1656#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1657#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1658pub enum Contain {
1659    None,
1660    Strict,
1661    Content,
1662    Multiple(Array<ContainKeyword>),
1663}
1664
1665/// An item in multi-value form of `contain`.
1666#[allow(missing_docs)]
1667#[repr(C)]
1668#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1669#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1670pub enum ContainKeyword {
1671    Size,
1672    Layout,
1673    Style,
1674    Paint,
1675}
1676
1677#[allow(missing_docs)]
1678#[repr(C)]
1679#[property_value_type(PropertyValueWithGlobal for ContentType)]
1680#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1681#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1682pub enum Content {
1683    None,
1684    Normal,
1685    Str(StrRef),
1686    Url(StrRef),
1687}
1688
1689/// A unknown property.
1690#[allow(missing_docs)]
1691#[repr(C)]
1692#[property_value_type(PropertyValueWithGlobal for CustomPropertyType)]
1693#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1694#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1695pub enum CustomProperty {
1696    None,
1697    Expr(StrRef, StrRef),
1698}
1699
1700#[allow(missing_docs)]
1701#[repr(C)]
1702#[property_value_type(PropertyValueWithGlobal for AnimationIterationCountType)]
1703#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1704#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1705pub enum AnimationIterationCount {
1706    List(Array<AnimationIterationCountItem>),
1707}
1708
1709/// An item in `animation-iteration-count`.
1710#[allow(missing_docs)]
1711#[repr(C)]
1712#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1713#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1714pub enum AnimationIterationCountItem {
1715    Number(f32),
1716    Infinite,
1717}
1718
1719#[allow(missing_docs)]
1720#[repr(C)]
1721#[property_value_type(PropertyValueWithGlobal for AnimationDirectionType)]
1722#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1723#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1724pub enum AnimationDirection {
1725    List(Array<AnimationDirectionItem>),
1726}
1727
1728/// An item in `animation-direction`.
1729#[allow(missing_docs)]
1730#[repr(C)]
1731#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1732#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1733pub enum AnimationDirectionItem {
1734    Normal,
1735    Reverse,
1736    Alternate,
1737    AlternateReverse,
1738}
1739
1740#[allow(missing_docs)]
1741#[repr(C)]
1742#[property_value_type(PropertyValueWithGlobal for AnimationFillModeType)]
1743#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1744#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1745pub enum AnimationFillMode {
1746    List(Array<AnimationFillModeItem>),
1747}
1748
1749/// An item in `animation-fill-mode`.
1750#[allow(missing_docs)]
1751#[repr(C)]
1752#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1753#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1754pub enum AnimationFillModeItem {
1755    None,
1756    Forwards,
1757    Backwards,
1758    Both,
1759}
1760
1761#[allow(missing_docs)]
1762#[repr(C)]
1763#[property_value_type(PropertyValueWithGlobal for AnimationPlayStateType)]
1764#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1765#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1766pub enum AnimationPlayState {
1767    List(Array<AnimationPlayStateItem>),
1768}
1769
1770/// An item in `animation-play-state`.
1771#[allow(missing_docs)]
1772#[repr(C)]
1773#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1774#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1775pub enum AnimationPlayStateItem {
1776    Running,
1777    Paused,
1778}
1779
1780#[allow(missing_docs)]
1781#[repr(C)]
1782#[property_value_type(PropertyValueWithGlobal for AnimationNameType)]
1783#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1784#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1785pub enum AnimationName {
1786    List(Array<AnimationNameItem>),
1787}
1788
1789/// An item in `animation-name`.
1790#[allow(missing_docs)]
1791#[repr(C)]
1792#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1793#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1794pub enum AnimationNameItem {
1795    None,
1796    CustomIdent(StrRef),
1797}
1798
1799#[allow(missing_docs)]
1800#[repr(C)]
1801#[property_value_type(PropertyValueWithGlobal for WillChangeType)]
1802#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1803#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1804pub enum WillChange {
1805    Auto,
1806    List(Array<AnimateableFeature>),
1807}
1808
1809/// An animation kind for `will-change`.
1810#[allow(missing_docs)]
1811#[repr(C)]
1812#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1813#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1814pub enum AnimateableFeature {
1815    /// The content of the element is likely to be animated.
1816    Contents,
1817    /// The content of the element is scrollable.
1818    ScrollPosition,
1819    /// An unknown kind.
1820    CustomIdent(StrRef),
1821}
1822
1823#[allow(missing_docs)]
1824#[repr(C)]
1825#[property_value_type(PropertyValueWithGlobal for FontFeatureSettingsType)]
1826#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1827#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1828pub enum FontFeatureSettings {
1829    Normal,
1830    FeatureTags(Array<FeatureTag>),
1831}
1832
1833/// A font feature tag for `font-feature-settings`.
1834#[repr(C)]
1835#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1836#[cfg_attr(debug_assertions, derive(CompatibilityStructCheck))]
1837pub struct FeatureTag {
1838    /// The four-letter OpenType tag, e.g. `liga`.
1839    pub opentype_tag: StrRef,
1840    /// The optional number value in `font-feature-settings`.
1841    pub value: Number,
1842}
1843
1844#[allow(missing_docs)]
1845#[repr(C)]
1846#[property_value_type(PropertyValueWithGlobal for GapType)]
1847#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1848#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1849pub enum Gap {
1850    Normal,
1851    #[resolve_font_size(Length::resolve_em)]
1852    Length(Length),
1853}
1854
1855/// The `grid-template-rows` property defines the line names and track sizing functions of the grid rows.
1856#[allow(missing_docs)]
1857#[repr(C)]
1858#[property_value_type(PropertyValueWithGlobal for GridTemplateType)]
1859#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1860#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1861pub enum GridTemplate {
1862    /// A keyword meaning that there is no explicit grid
1863    None,
1864    TrackList(Array<TrackListItem>),
1865}
1866
1867#[allow(missing_docs)]
1868#[repr(C)]
1869#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1870#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1871pub enum TrackListItem {
1872    LineNames(Array<StrRef>),
1873    TrackSize(TrackSize),
1874}
1875
1876#[allow(missing_docs)]
1877#[repr(C)]
1878#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1879#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1880pub enum TrackSize {
1881    MinContent,
1882    MaxContent,
1883    Fr(f32),
1884    #[resolve_font_size(Length::resolve_em)]
1885    Length(Length),
1886}
1887
1888#[allow(missing_docs)]
1889#[repr(C)]
1890#[property_value_type(PropertyValueWithGlobal for GridAutoFlowType)]
1891#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1892#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1893pub enum GridAutoFlow {
1894    Row,
1895    Column,
1896    RowDense,
1897    ColumnDense,
1898}
1899
1900#[allow(missing_docs)]
1901#[repr(C)]
1902#[property_value_type(PropertyValueWithGlobal for GridAutoType)]
1903#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ResolveFontSize)]
1904#[cfg_attr(debug_assertions, derive(CompatibilityEnumCheck))]
1905pub enum GridAuto {
1906    List(Array<TrackSize>),
1907}