Skip to main content

azul_css/props/
property.rs

1//! Defines the core `CssProperty` enum, which represents any single parsed CSS property,
2//! as well as top-level functions for parsing CSS keys and values.
3
4use alloc::{
5    boxed::Box,
6    collections::btree_map::BTreeMap,
7    string::{String, ToString},
8    vec::Vec,
9};
10use core::fmt;
11
12use crate::{
13    corety::AzString,
14    css::CssPropertyValue,
15    props::basic::{error::InvalidValueErr, pixel::PixelValueWithAuto},
16};
17// Import all property types from their new locations
18use crate::{
19    format_rust_code::FormatAsRustCode,
20    props::{
21        basic::{
22            color::{parse_css_color, ColorU, CssColorParseError, CssColorParseErrorOwned},
23            font::{
24                parse_style_font_family, CssStyleFontFamilyParseError,
25                CssStyleFontFamilyParseErrorOwned, StyleFontFamilyVec, *,
26            },
27            length::{parse_float_value, parse_percentage_value, FloatValue, PercentageValue},
28            pixel::{
29                parse_pixel_value, CssPixelValueParseError, CssPixelValueParseErrorOwned,
30                PixelValue,
31            },
32            DurationParseError, DurationParseErrorOwned, InterpolateResolver, InvalidValueErrOwned,
33            PercentageParseError,
34        },
35        formatter::PrintAsCssValue,
36        layout::{
37            column::*, dimensions::*, display::*, flex::*, flow::*, fragmentation::*, grid::*,
38            overflow::*, position::*, shape::*, spacing::*, table::*, text::*, wrapping::*,
39        },
40        style::{
41            azul_exclusion::*, background::*, border::*, border_radius::*, box_shadow::*,
42            content::*, effects::*, filter::*, lists::*, scrollbar::*, text::*, transform::*,
43            SelectionBackgroundColor, SelectionColor, SelectionRadius,
44        },
45    },
46};
47
48const COMBINED_CSS_PROPERTIES_KEY_MAP: [(CombinedCssPropertyType, &'static str); 24] = [
49    (CombinedCssPropertyType::BorderRadius, "border-radius"),
50    (CombinedCssPropertyType::Overflow, "overflow"),
51    (CombinedCssPropertyType::Padding, "padding"),
52    (CombinedCssPropertyType::Margin, "margin"),
53    (CombinedCssPropertyType::Border, "border"),
54    (CombinedCssPropertyType::BorderLeft, "border-left"),
55    (CombinedCssPropertyType::BorderRight, "border-right"),
56    (CombinedCssPropertyType::BorderTop, "border-top"),
57    (CombinedCssPropertyType::BorderBottom, "border-bottom"),
58    (CombinedCssPropertyType::BorderColor, "border-color"),
59    (CombinedCssPropertyType::BorderStyle, "border-style"),
60    (CombinedCssPropertyType::BorderWidth, "border-width"),
61    (CombinedCssPropertyType::BoxShadow, "box-shadow"),
62    (CombinedCssPropertyType::BackgroundColor, "background-color"),
63    (CombinedCssPropertyType::BackgroundImage, "background-image"),
64    (CombinedCssPropertyType::Background, "background"),
65    (CombinedCssPropertyType::Flex, "flex"),
66    (CombinedCssPropertyType::Grid, "grid"),
67    (CombinedCssPropertyType::Gap, "gap"),
68    (CombinedCssPropertyType::GridGap, "grid-gap"),
69    (CombinedCssPropertyType::Font, "font"),
70    (CombinedCssPropertyType::Columns, "columns"),
71    (CombinedCssPropertyType::GridArea, "grid-area"),
72    (CombinedCssPropertyType::ColumnRule, "column-rule"),
73];
74
75const CSS_PROPERTY_KEY_MAP: [(CssPropertyType, &'static str); 150] = [
76    (CssPropertyType::Display, "display"),
77    (CssPropertyType::Float, "float"),
78    (CssPropertyType::BoxSizing, "box-sizing"),
79    (CssPropertyType::TextColor, "color"),
80    (CssPropertyType::FontSize, "font-size"),
81    (CssPropertyType::FontFamily, "font-family"),
82    (CssPropertyType::FontWeight, "font-weight"),
83    (CssPropertyType::FontStyle, "font-style"),
84    (CssPropertyType::TextAlign, "text-align"),
85    (CssPropertyType::TextJustify, "text-justify"),
86    (CssPropertyType::VerticalAlign, "vertical-align"),
87    (CssPropertyType::LetterSpacing, "letter-spacing"),
88    (CssPropertyType::LineHeight, "line-height"),
89    (CssPropertyType::WordSpacing, "word-spacing"),
90    (CssPropertyType::TabSize, "tab-size"),
91    (CssPropertyType::WhiteSpace, "white-space"),
92    (CssPropertyType::Hyphens, "hyphens"),
93    (CssPropertyType::Direction, "direction"),
94    (CssPropertyType::UserSelect, "user-select"),
95    (CssPropertyType::TextDecoration, "text-decoration"),
96    (CssPropertyType::TextIndent, "text-indent"),
97    (CssPropertyType::InitialLetter, "initial-letter"),
98    (CssPropertyType::LineClamp, "line-clamp"),
99    (CssPropertyType::HangingPunctuation, "hanging-punctuation"),
100    (CssPropertyType::TextCombineUpright, "text-combine-upright"),
101    (CssPropertyType::ExclusionMargin, "-azul-exclusion-margin"),
102    (
103        CssPropertyType::HyphenationLanguage,
104        "-azul-hyphenation-language",
105    ),
106    (CssPropertyType::Cursor, "cursor"),
107    (CssPropertyType::Width, "width"),
108    (CssPropertyType::Height, "height"),
109    (CssPropertyType::MinWidth, "min-width"),
110    (CssPropertyType::MinHeight, "min-height"),
111    (CssPropertyType::MaxWidth, "max-width"),
112    (CssPropertyType::MaxHeight, "max-height"),
113    (CssPropertyType::Position, "position"),
114    (CssPropertyType::Top, "top"),
115    (CssPropertyType::Right, "right"),
116    (CssPropertyType::Left, "left"),
117    (CssPropertyType::Bottom, "bottom"),
118    (CssPropertyType::ZIndex, "z-index"),
119    (CssPropertyType::FlexWrap, "flex-wrap"),
120    (CssPropertyType::FlexDirection, "flex-direction"),
121    (CssPropertyType::FlexGrow, "flex-grow"),
122    (CssPropertyType::FlexShrink, "flex-shrink"),
123    (CssPropertyType::FlexBasis, "flex-basis"),
124    (CssPropertyType::JustifyContent, "justify-content"),
125    (CssPropertyType::AlignItems, "align-items"),
126    (CssPropertyType::AlignContent, "align-content"),
127    (CssPropertyType::ColumnGap, "column-gap"),
128    (CssPropertyType::RowGap, "row-gap"),
129    (
130        CssPropertyType::GridTemplateColumns,
131        "grid-template-columns",
132    ),
133    (CssPropertyType::GridTemplateRows, "grid-template-rows"),
134    (CssPropertyType::GridAutoColumns, "grid-auto-columns"),
135    (CssPropertyType::GridAutoRows, "grid-auto-rows"),
136    (CssPropertyType::GridColumn, "grid-column"),
137    (CssPropertyType::GridRow, "grid-row"),
138    (CssPropertyType::GridTemplateAreas, "grid-template-areas"),
139    (CssPropertyType::WritingMode, "writing-mode"),
140    (CssPropertyType::Clear, "clear"),
141    (CssPropertyType::OverflowX, "overflow-x"),
142    (CssPropertyType::OverflowY, "overflow-y"),
143    (CssPropertyType::PaddingTop, "padding-top"),
144    (CssPropertyType::PaddingLeft, "padding-left"),
145    (CssPropertyType::PaddingRight, "padding-right"),
146    (CssPropertyType::PaddingBottom, "padding-bottom"),
147    (CssPropertyType::PaddingInlineStart, "padding-inline-start"),
148    (CssPropertyType::PaddingInlineEnd, "padding-inline-end"),
149    (CssPropertyType::MarginTop, "margin-top"),
150    (CssPropertyType::MarginLeft, "margin-left"),
151    (CssPropertyType::MarginRight, "margin-right"),
152    (CssPropertyType::MarginBottom, "margin-bottom"),
153    (CssPropertyType::BackgroundContent, "background"),
154    (CssPropertyType::BackgroundPosition, "background-position"),
155    (CssPropertyType::BackgroundSize, "background-size"),
156    (CssPropertyType::BackgroundRepeat, "background-repeat"),
157    (
158        CssPropertyType::BorderTopLeftRadius,
159        "border-top-left-radius",
160    ),
161    (
162        CssPropertyType::BorderTopRightRadius,
163        "border-top-right-radius",
164    ),
165    (
166        CssPropertyType::BorderBottomLeftRadius,
167        "border-bottom-left-radius",
168    ),
169    (
170        CssPropertyType::BorderBottomRightRadius,
171        "border-bottom-right-radius",
172    ),
173    (CssPropertyType::BorderTopColor, "border-top-color"),
174    (CssPropertyType::BorderRightColor, "border-right-color"),
175    (CssPropertyType::BorderLeftColor, "border-left-color"),
176    (CssPropertyType::BorderBottomColor, "border-bottom-color"),
177    (CssPropertyType::BorderTopStyle, "border-top-style"),
178    (CssPropertyType::BorderRightStyle, "border-right-style"),
179    (CssPropertyType::BorderLeftStyle, "border-left-style"),
180    (CssPropertyType::BorderBottomStyle, "border-bottom-style"),
181    (CssPropertyType::BorderTopWidth, "border-top-width"),
182    (CssPropertyType::BorderRightWidth, "border-right-width"),
183    (CssPropertyType::BorderLeftWidth, "border-left-width"),
184    (CssPropertyType::BorderBottomWidth, "border-bottom-width"),
185    (CssPropertyType::BoxShadowTop, "-azul-box-shadow-top"),
186    (CssPropertyType::BoxShadowRight, "-azul-box-shadow-right"),
187    (CssPropertyType::BoxShadowLeft, "-azul-box-shadow-left"),
188    (CssPropertyType::BoxShadowBottom, "-azul-box-shadow-bottom"),
189    (CssPropertyType::Scrollbar, "-azul-scrollbar-style"),
190    (CssPropertyType::CaretColor, "caret-color"),
191    (
192        CssPropertyType::CaretAnimationDuration,
193        "caret-animation-duration",
194    ),
195    (CssPropertyType::CaretWidth, "-azul-caret-width"),
196    (
197        CssPropertyType::SelectionBackgroundColor,
198        "-azul-selection-background-color",
199    ),
200    (CssPropertyType::SelectionColor, "-azul-selection-color"),
201    (CssPropertyType::SelectionRadius, "-azul-selection-radius"),
202    (CssPropertyType::ScrollbarWidth, "scrollbar-width"),
203    (CssPropertyType::ScrollbarColor, "scrollbar-color"),
204    (CssPropertyType::Opacity, "opacity"),
205    (CssPropertyType::Visibility, "visibility"),
206    (CssPropertyType::Transform, "transform"),
207    (CssPropertyType::PerspectiveOrigin, "perspective-origin"),
208    (CssPropertyType::TransformOrigin, "transform-origin"),
209    (CssPropertyType::BackfaceVisibility, "backface-visibility"),
210    (CssPropertyType::MixBlendMode, "mix-blend-mode"),
211    (CssPropertyType::Filter, "filter"),
212    (CssPropertyType::BackdropFilter, "backdrop-filter"),
213    (CssPropertyType::TextShadow, "text-shadow"),
214    (CssPropertyType::GridAutoFlow, "grid-auto-flow"),
215    (CssPropertyType::JustifySelf, "justify-self"),
216    (CssPropertyType::JustifyItems, "justify-items"),
217    (CssPropertyType::Gap, "gap"),
218    (CssPropertyType::GridGap, "grid-gap"),
219    (CssPropertyType::AlignSelf, "align-self"),
220    (CssPropertyType::Font, "font"),
221    (CssPropertyType::BreakBefore, "break-before"),
222    (CssPropertyType::BreakAfter, "break-after"),
223    (CssPropertyType::BreakInside, "break-inside"),
224    // CSS 2.1 legacy aliases for page breaking
225    (CssPropertyType::BreakBefore, "page-break-before"),
226    (CssPropertyType::BreakAfter, "page-break-after"),
227    (CssPropertyType::BreakInside, "page-break-inside"),
228    (CssPropertyType::Orphans, "orphans"),
229    (CssPropertyType::Widows, "widows"),
230    (CssPropertyType::BoxDecorationBreak, "box-decoration-break"),
231    (CssPropertyType::ColumnCount, "column-count"),
232    (CssPropertyType::ColumnWidth, "column-width"),
233    (CssPropertyType::ColumnSpan, "column-span"),
234    (CssPropertyType::ColumnFill, "column-fill"),
235    (CssPropertyType::ColumnRuleWidth, "column-rule-width"),
236    (CssPropertyType::ColumnRuleStyle, "column-rule-style"),
237    (CssPropertyType::ColumnRuleColor, "column-rule-color"),
238    (CssPropertyType::FlowInto, "flow-into"),
239    (CssPropertyType::FlowFrom, "flow-from"),
240    (CssPropertyType::ShapeOutside, "shape-outside"),
241    (CssPropertyType::ShapeInside, "shape-inside"),
242    (CssPropertyType::ClipPath, "clip-path"),
243    (CssPropertyType::ShapeMargin, "shape-margin"),
244    (
245        CssPropertyType::ShapeImageThreshold,
246        "shape-image-threshold",
247    ),
248    (CssPropertyType::Content, "content"),
249    (CssPropertyType::CounterReset, "counter-reset"),
250    (CssPropertyType::CounterIncrement, "counter-increment"),
251    (CssPropertyType::ListStyleType, "list-style-type"),
252    (CssPropertyType::ListStylePosition, "list-style-position"),
253    (CssPropertyType::StringSet, "string-set"),
254];
255
256// Type aliases for `CssPropertyValue<T>`
257pub type CaretColorValue = CssPropertyValue<CaretColor>;
258pub type CaretAnimationDurationValue = CssPropertyValue<CaretAnimationDuration>;
259pub type CaretWidthValue = CssPropertyValue<CaretWidth>;
260pub type SelectionBackgroundColorValue = CssPropertyValue<SelectionBackgroundColor>;
261pub type SelectionColorValue = CssPropertyValue<SelectionColor>;
262pub type SelectionRadiusValue = CssPropertyValue<SelectionRadius>;
263pub type StyleBackgroundContentVecValue = CssPropertyValue<StyleBackgroundContentVec>;
264pub type StyleBackgroundPositionVecValue = CssPropertyValue<StyleBackgroundPositionVec>;
265pub type StyleBackgroundSizeVecValue = CssPropertyValue<StyleBackgroundSizeVec>;
266pub type StyleBackgroundRepeatVecValue = CssPropertyValue<StyleBackgroundRepeatVec>;
267pub type StyleFontSizeValue = CssPropertyValue<StyleFontSize>;
268pub type StyleFontFamilyVecValue = CssPropertyValue<StyleFontFamilyVec>;
269pub type StyleFontWeightValue = CssPropertyValue<StyleFontWeight>;
270pub type StyleFontStyleValue = CssPropertyValue<StyleFontStyle>;
271pub type StyleTextColorValue = CssPropertyValue<StyleTextColor>;
272pub type StyleTextAlignValue = CssPropertyValue<StyleTextAlign>;
273pub type StyleVerticalAlignValue = CssPropertyValue<StyleVerticalAlign>;
274pub type StyleLineHeightValue = CssPropertyValue<StyleLineHeight>;
275pub type StyleLetterSpacingValue = CssPropertyValue<StyleLetterSpacing>;
276pub type StyleTextIndentValue = CssPropertyValue<StyleTextIndent>;
277pub type StyleInitialLetterValue = CssPropertyValue<StyleInitialLetter>;
278pub type StyleLineClampValue = CssPropertyValue<StyleLineClamp>;
279pub type StyleHangingPunctuationValue = CssPropertyValue<StyleHangingPunctuation>;
280pub type StyleTextCombineUprightValue = CssPropertyValue<StyleTextCombineUpright>;
281pub type StyleExclusionMarginValue = CssPropertyValue<StyleExclusionMargin>;
282pub type StyleHyphenationLanguageValue = CssPropertyValue<StyleHyphenationLanguage>;
283pub type StyleWordSpacingValue = CssPropertyValue<StyleWordSpacing>;
284pub type StyleTabSizeValue = CssPropertyValue<StyleTabSize>;
285pub type StyleCursorValue = CssPropertyValue<StyleCursor>;
286pub type StyleBoxShadowValue = CssPropertyValue<StyleBoxShadow>;
287pub type StyleBorderTopColorValue = CssPropertyValue<StyleBorderTopColor>;
288pub type StyleBorderLeftColorValue = CssPropertyValue<StyleBorderLeftColor>;
289pub type StyleBorderRightColorValue = CssPropertyValue<StyleBorderRightColor>;
290pub type StyleBorderBottomColorValue = CssPropertyValue<StyleBorderBottomColor>;
291pub type StyleBorderTopStyleValue = CssPropertyValue<StyleBorderTopStyle>;
292pub type StyleBorderLeftStyleValue = CssPropertyValue<StyleBorderLeftStyle>;
293pub type StyleBorderRightStyleValue = CssPropertyValue<StyleBorderRightStyle>;
294pub type StyleBorderBottomStyleValue = CssPropertyValue<StyleBorderBottomStyle>;
295pub type StyleBorderTopLeftRadiusValue = CssPropertyValue<StyleBorderTopLeftRadius>;
296pub type StyleBorderTopRightRadiusValue = CssPropertyValue<StyleBorderTopRightRadius>;
297pub type StyleBorderBottomLeftRadiusValue = CssPropertyValue<StyleBorderBottomLeftRadius>;
298pub type StyleBorderBottomRightRadiusValue = CssPropertyValue<StyleBorderBottomRightRadius>;
299pub type StyleOpacityValue = CssPropertyValue<StyleOpacity>;
300pub type StyleVisibilityValue = CssPropertyValue<StyleVisibility>;
301pub type StyleTransformVecValue = CssPropertyValue<StyleTransformVec>;
302pub type StyleTransformOriginValue = CssPropertyValue<StyleTransformOrigin>;
303pub type StylePerspectiveOriginValue = CssPropertyValue<StylePerspectiveOrigin>;
304pub type StyleBackfaceVisibilityValue = CssPropertyValue<StyleBackfaceVisibility>;
305pub type StyleMixBlendModeValue = CssPropertyValue<StyleMixBlendMode>;
306pub type StyleFilterVecValue = CssPropertyValue<StyleFilterVec>;
307pub type ScrollbarStyleValue = CssPropertyValue<ScrollbarStyle>;
308pub type LayoutScrollbarWidthValue = CssPropertyValue<LayoutScrollbarWidth>;
309pub type StyleScrollbarColorValue = CssPropertyValue<StyleScrollbarColor>;
310pub type LayoutDisplayValue = CssPropertyValue<LayoutDisplay>;
311pub type StyleHyphensValue = CssPropertyValue<StyleHyphens>;
312pub type StyleDirectionValue = CssPropertyValue<StyleDirection>;
313pub type StyleUserSelectValue = CssPropertyValue<StyleUserSelect>;
314pub type StyleTextDecorationValue = CssPropertyValue<StyleTextDecoration>;
315pub type StyleWhiteSpaceValue = CssPropertyValue<StyleWhiteSpace>;
316pub type LayoutFloatValue = CssPropertyValue<LayoutFloat>;
317pub type LayoutBoxSizingValue = CssPropertyValue<LayoutBoxSizing>;
318pub type LayoutWidthValue = CssPropertyValue<LayoutWidth>;
319pub type LayoutHeightValue = CssPropertyValue<LayoutHeight>;
320pub type LayoutMinWidthValue = CssPropertyValue<LayoutMinWidth>;
321pub type LayoutMinHeightValue = CssPropertyValue<LayoutMinHeight>;
322pub type LayoutMaxWidthValue = CssPropertyValue<LayoutMaxWidth>;
323pub type LayoutMaxHeightValue = CssPropertyValue<LayoutMaxHeight>;
324pub type LayoutPositionValue = CssPropertyValue<LayoutPosition>;
325pub type LayoutTopValue = CssPropertyValue<LayoutTop>;
326pub type LayoutInsetBottomValue = CssPropertyValue<LayoutInsetBottom>;
327pub type LayoutRightValue = CssPropertyValue<LayoutRight>;
328pub type LayoutLeftValue = CssPropertyValue<LayoutLeft>;
329pub type LayoutZIndexValue = CssPropertyValue<LayoutZIndex>;
330pub type LayoutPaddingTopValue = CssPropertyValue<LayoutPaddingTop>;
331pub type LayoutPaddingBottomValue = CssPropertyValue<LayoutPaddingBottom>;
332pub type LayoutPaddingLeftValue = CssPropertyValue<LayoutPaddingLeft>;
333pub type LayoutPaddingRightValue = CssPropertyValue<LayoutPaddingRight>;
334pub type LayoutPaddingInlineStartValue = CssPropertyValue<LayoutPaddingInlineStart>;
335pub type LayoutPaddingInlineEndValue = CssPropertyValue<LayoutPaddingInlineEnd>;
336pub type LayoutMarginTopValue = CssPropertyValue<LayoutMarginTop>;
337pub type LayoutMarginBottomValue = CssPropertyValue<LayoutMarginBottom>;
338pub type LayoutTextJustifyValue = CssPropertyValue<LayoutTextJustify>;
339pub type LayoutMarginLeftValue = CssPropertyValue<LayoutMarginLeft>;
340pub type LayoutMarginRightValue = CssPropertyValue<LayoutMarginRight>;
341pub type LayoutBorderTopWidthValue = CssPropertyValue<LayoutBorderTopWidth>;
342pub type LayoutBorderLeftWidthValue = CssPropertyValue<LayoutBorderLeftWidth>;
343pub type LayoutBorderRightWidthValue = CssPropertyValue<LayoutBorderRightWidth>;
344pub type LayoutBorderBottomWidthValue = CssPropertyValue<LayoutBorderBottomWidth>;
345pub type LayoutOverflowValue = CssPropertyValue<LayoutOverflow>;
346pub type LayoutFlexDirectionValue = CssPropertyValue<LayoutFlexDirection>;
347pub type LayoutFlexWrapValue = CssPropertyValue<LayoutFlexWrap>;
348pub type LayoutFlexGrowValue = CssPropertyValue<LayoutFlexGrow>;
349pub type LayoutFlexShrinkValue = CssPropertyValue<LayoutFlexShrink>;
350pub type LayoutFlexBasisValue = CssPropertyValue<LayoutFlexBasis>;
351pub type LayoutJustifyContentValue = CssPropertyValue<LayoutJustifyContent>;
352pub type LayoutAlignItemsValue = CssPropertyValue<LayoutAlignItems>;
353pub type LayoutAlignContentValue = CssPropertyValue<LayoutAlignContent>;
354pub type LayoutColumnGapValue = CssPropertyValue<LayoutColumnGap>;
355pub type LayoutRowGapValue = CssPropertyValue<LayoutRowGap>;
356pub type LayoutGridTemplateColumnsValue = CssPropertyValue<GridTemplate>;
357pub type LayoutGridTemplateRowsValue = CssPropertyValue<GridTemplate>;
358pub type LayoutGridAutoColumnsValue = CssPropertyValue<GridAutoTracks>;
359pub type LayoutGridAutoRowsValue = CssPropertyValue<GridAutoTracks>;
360pub type LayoutGridColumnValue = CssPropertyValue<GridPlacement>;
361pub type LayoutGridRowValue = CssPropertyValue<GridPlacement>;
362pub type LayoutGridTemplateAreasValue = CssPropertyValue<crate::props::layout::grid::GridTemplateAreas>;
363pub type LayoutWritingModeValue = CssPropertyValue<LayoutWritingMode>;
364pub type LayoutClearValue = CssPropertyValue<LayoutClear>;
365pub type LayoutGridAutoFlowValue = CssPropertyValue<LayoutGridAutoFlow>;
366pub type LayoutJustifySelfValue = CssPropertyValue<LayoutJustifySelf>;
367pub type LayoutJustifyItemsValue = CssPropertyValue<LayoutJustifyItems>;
368pub type LayoutGapValue = CssPropertyValue<LayoutGap>;
369pub type LayoutAlignSelfValue = CssPropertyValue<LayoutAlignSelf>;
370pub type StyleFontValue = CssPropertyValue<StyleFontFamilyVec>;
371pub type PageBreakValue = CssPropertyValue<PageBreak>;
372pub type BreakInsideValue = CssPropertyValue<BreakInside>;
373pub type WidowsValue = CssPropertyValue<Widows>;
374pub type OrphansValue = CssPropertyValue<Orphans>;
375pub type BoxDecorationBreakValue = CssPropertyValue<BoxDecorationBreak>;
376pub type ColumnCountValue = CssPropertyValue<ColumnCount>;
377pub type ColumnWidthValue = CssPropertyValue<ColumnWidth>;
378pub type ColumnSpanValue = CssPropertyValue<ColumnSpan>;
379pub type ColumnFillValue = CssPropertyValue<ColumnFill>;
380pub type ColumnRuleWidthValue = CssPropertyValue<ColumnRuleWidth>;
381pub type ColumnRuleStyleValue = CssPropertyValue<ColumnRuleStyle>;
382pub type ColumnRuleColorValue = CssPropertyValue<ColumnRuleColor>;
383pub type FlowIntoValue = CssPropertyValue<FlowInto>;
384pub type FlowFromValue = CssPropertyValue<FlowFrom>;
385pub type ShapeOutsideValue = CssPropertyValue<ShapeOutside>;
386pub type ShapeInsideValue = CssPropertyValue<ShapeInside>;
387pub type ClipPathValue = CssPropertyValue<ClipPath>;
388pub type ShapeMarginValue = CssPropertyValue<ShapeMargin>;
389pub type ShapeImageThresholdValue = CssPropertyValue<ShapeImageThreshold>;
390pub type LayoutTableLayoutValue = CssPropertyValue<LayoutTableLayout>;
391pub type StyleBorderCollapseValue = CssPropertyValue<StyleBorderCollapse>;
392pub type LayoutBorderSpacingValue = CssPropertyValue<LayoutBorderSpacing>;
393pub type StyleCaptionSideValue = CssPropertyValue<StyleCaptionSide>;
394pub type StyleEmptyCellsValue = CssPropertyValue<StyleEmptyCells>;
395pub type ContentValue = CssPropertyValue<Content>;
396pub type CounterResetValue = CssPropertyValue<CounterReset>;
397pub type CounterIncrementValue = CssPropertyValue<CounterIncrement>;
398pub type StyleListStyleTypeValue = CssPropertyValue<StyleListStyleType>;
399pub type StyleListStylePositionValue = CssPropertyValue<StyleListStylePosition>;
400pub type StringSetValue = CssPropertyValue<StringSet>;
401
402#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
403pub struct CssKeyMap {
404    // Contains all keys that have no shorthand
405    pub non_shorthands: BTreeMap<&'static str, CssPropertyType>,
406    // Contains all keys that act as a shorthand for other types
407    pub shorthands: BTreeMap<&'static str, CombinedCssPropertyType>,
408}
409
410impl CssKeyMap {
411    pub fn get() -> Self {
412        get_css_key_map()
413    }
414}
415
416/// Returns a map useful for parsing the keys of CSS stylesheets
417pub fn get_css_key_map() -> CssKeyMap {
418    CssKeyMap {
419        non_shorthands: CSS_PROPERTY_KEY_MAP.iter().map(|(v, k)| (*k, *v)).collect(),
420        shorthands: COMBINED_CSS_PROPERTIES_KEY_MAP
421            .iter()
422            .map(|(v, k)| (*k, *v))
423            .collect(),
424    }
425}
426
427#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
428pub enum CombinedCssPropertyType {
429    BorderRadius,
430    Overflow,
431    Margin,
432    Border,
433    BorderLeft,
434    BorderRight,
435    BorderTop,
436    BorderBottom,
437    BorderColor,
438    BorderStyle,
439    BorderWidth,
440    Padding,
441    BoxShadow,
442    BackgroundColor, // BackgroundContent::Color
443    BackgroundImage, // BackgroundContent::Image
444    Background,
445    Flex,
446    Grid,
447    Gap,
448    GridGap,
449    Font,
450    Columns,
451    ColumnRule,
452    GridArea,
453}
454
455impl fmt::Display for CombinedCssPropertyType {
456    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
457        let key = COMBINED_CSS_PROPERTIES_KEY_MAP
458            .iter()
459            .find(|(v, _)| *v == *self)
460            .and_then(|(k, _)| Some(k))
461            .unwrap();
462        write!(f, "{}", key)
463    }
464}
465
466impl CombinedCssPropertyType {
467    /// Parses a CSS key, such as `width` from a string:
468    ///
469    /// # Example
470    ///
471    /// ```rust
472    /// # use azul_css::props::property::{CombinedCssPropertyType, get_css_key_map};
473    /// let map = get_css_key_map();
474    /// assert_eq!(
475    ///     Some(CombinedCssPropertyType::Border),
476    ///     CombinedCssPropertyType::from_str("border", &map)
477    /// );
478    /// ```
479    pub fn from_str(input: &str, map: &CssKeyMap) -> Option<Self> {
480        let input = input.trim();
481        map.shorthands.get(input).map(|x| *x)
482    }
483
484    /// Returns the original string that was used to construct this `CssPropertyType`.
485    pub fn to_str(&self, map: &CssKeyMap) -> &'static str {
486        map.shorthands
487            .iter()
488            .find(|(_, v)| *v == self)
489            .map(|(k, _)| k)
490            .unwrap()
491    }
492}
493
494/// Represents one parsed CSS key-value pair, such as `"width: 20px"` =>
495/// `CssProperty::Width(LayoutWidth::px(20.0))`
496#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
497#[repr(C, u8)]
498pub enum CssProperty {
499    CaretColor(CaretColorValue),
500    CaretAnimationDuration(CaretAnimationDurationValue),
501    CaretWidth(CaretWidthValue),
502    SelectionBackgroundColor(SelectionBackgroundColorValue),
503    SelectionColor(SelectionColorValue),
504    SelectionRadius(SelectionRadiusValue),
505    TextColor(StyleTextColorValue),
506    FontSize(StyleFontSizeValue),
507    FontFamily(StyleFontFamilyVecValue),
508    FontWeight(StyleFontWeightValue),
509    FontStyle(StyleFontStyleValue),
510    TextAlign(StyleTextAlignValue),
511    TextJustify(LayoutTextJustifyValue),
512    VerticalAlign(StyleVerticalAlignValue),
513    LetterSpacing(StyleLetterSpacingValue),
514    TextIndent(StyleTextIndentValue),
515    InitialLetter(StyleInitialLetterValue),
516    LineClamp(StyleLineClampValue),
517    HangingPunctuation(StyleHangingPunctuationValue),
518    TextCombineUpright(StyleTextCombineUprightValue),
519    ExclusionMargin(StyleExclusionMarginValue),
520    HyphenationLanguage(StyleHyphenationLanguageValue),
521    LineHeight(StyleLineHeightValue),
522    WordSpacing(StyleWordSpacingValue),
523    TabSize(StyleTabSizeValue),
524    WhiteSpace(StyleWhiteSpaceValue),
525    Hyphens(StyleHyphensValue),
526    Direction(StyleDirectionValue),
527    UserSelect(StyleUserSelectValue),
528    TextDecoration(StyleTextDecorationValue),
529    Cursor(StyleCursorValue),
530    Display(LayoutDisplayValue),
531    Float(LayoutFloatValue),
532    BoxSizing(LayoutBoxSizingValue),
533    Width(LayoutWidthValue),
534    Height(LayoutHeightValue),
535    MinWidth(LayoutMinWidthValue),
536    MinHeight(LayoutMinHeightValue),
537    MaxWidth(LayoutMaxWidthValue),
538    MaxHeight(LayoutMaxHeightValue),
539    Position(LayoutPositionValue),
540    Top(LayoutTopValue),
541    Right(LayoutRightValue),
542    Left(LayoutLeftValue),
543    Bottom(LayoutInsetBottomValue),
544    ZIndex(LayoutZIndexValue),
545    FlexWrap(LayoutFlexWrapValue),
546    FlexDirection(LayoutFlexDirectionValue),
547    FlexGrow(LayoutFlexGrowValue),
548    FlexShrink(LayoutFlexShrinkValue),
549    FlexBasis(LayoutFlexBasisValue),
550    JustifyContent(LayoutJustifyContentValue),
551    AlignItems(LayoutAlignItemsValue),
552    AlignContent(LayoutAlignContentValue),
553    ColumnGap(LayoutColumnGapValue),
554    RowGap(LayoutRowGapValue),
555    GridTemplateColumns(LayoutGridTemplateColumnsValue),
556    GridTemplateRows(LayoutGridTemplateRowsValue),
557    GridAutoColumns(LayoutGridAutoColumnsValue),
558    GridAutoRows(LayoutGridAutoRowsValue),
559    GridColumn(LayoutGridColumnValue),
560    GridRow(LayoutGridRowValue),
561    GridTemplateAreas(LayoutGridTemplateAreasValue),
562    WritingMode(LayoutWritingModeValue),
563    Clear(LayoutClearValue),
564    BackgroundContent(StyleBackgroundContentVecValue),
565    BackgroundPosition(StyleBackgroundPositionVecValue),
566    BackgroundSize(StyleBackgroundSizeVecValue),
567    BackgroundRepeat(StyleBackgroundRepeatVecValue),
568    OverflowX(LayoutOverflowValue),
569    OverflowY(LayoutOverflowValue),
570    GridAutoFlow(LayoutGridAutoFlowValue),
571    JustifySelf(LayoutJustifySelfValue),
572    JustifyItems(LayoutJustifyItemsValue),
573    Gap(LayoutGapValue),
574    GridGap(LayoutGapValue),
575    AlignSelf(LayoutAlignSelfValue),
576    Font(StyleFontValue),
577    PaddingTop(LayoutPaddingTopValue),
578    PaddingLeft(LayoutPaddingLeftValue),
579    PaddingRight(LayoutPaddingRightValue),
580    PaddingBottom(LayoutPaddingBottomValue),
581    PaddingInlineStart(LayoutPaddingInlineStartValue),
582    PaddingInlineEnd(LayoutPaddingInlineEndValue),
583    MarginTop(LayoutMarginTopValue),
584    MarginLeft(LayoutMarginLeftValue),
585    MarginRight(LayoutMarginRightValue),
586    MarginBottom(LayoutMarginBottomValue),
587    BorderTopLeftRadius(StyleBorderTopLeftRadiusValue),
588    LayoutTextJustify(LayoutTextJustifyValue),
589    BorderTopRightRadius(StyleBorderTopRightRadiusValue),
590    BorderBottomLeftRadius(StyleBorderBottomLeftRadiusValue),
591    BorderBottomRightRadius(StyleBorderBottomRightRadiusValue),
592    BorderTopColor(StyleBorderTopColorValue),
593    BorderRightColor(StyleBorderRightColorValue),
594    BorderLeftColor(StyleBorderLeftColorValue),
595    BorderBottomColor(StyleBorderBottomColorValue),
596    BorderTopStyle(StyleBorderTopStyleValue),
597    BorderRightStyle(StyleBorderRightStyleValue),
598    BorderLeftStyle(StyleBorderLeftStyleValue),
599    BorderBottomStyle(StyleBorderBottomStyleValue),
600    BorderTopWidth(LayoutBorderTopWidthValue),
601    BorderRightWidth(LayoutBorderRightWidthValue),
602    BorderLeftWidth(LayoutBorderLeftWidthValue),
603    BorderBottomWidth(LayoutBorderBottomWidthValue),
604    BoxShadowLeft(StyleBoxShadowValue),
605    BoxShadowRight(StyleBoxShadowValue),
606    BoxShadowTop(StyleBoxShadowValue),
607    BoxShadowBottom(StyleBoxShadowValue),
608    Scrollbar(ScrollbarStyleValue),
609    ScrollbarWidth(LayoutScrollbarWidthValue),
610    ScrollbarColor(StyleScrollbarColorValue),
611    Opacity(StyleOpacityValue),
612    Visibility(StyleVisibilityValue),
613    Transform(StyleTransformVecValue),
614    TransformOrigin(StyleTransformOriginValue),
615    PerspectiveOrigin(StylePerspectiveOriginValue),
616    BackfaceVisibility(StyleBackfaceVisibilityValue),
617    MixBlendMode(StyleMixBlendModeValue),
618    Filter(StyleFilterVecValue),
619    BackdropFilter(StyleFilterVecValue),
620    TextShadow(StyleBoxShadowValue),
621    BreakBefore(PageBreakValue),
622    BreakAfter(PageBreakValue),
623    BreakInside(BreakInsideValue),
624    Orphans(OrphansValue),
625    Widows(WidowsValue),
626    BoxDecorationBreak(BoxDecorationBreakValue),
627    ColumnCount(ColumnCountValue),
628    ColumnWidth(ColumnWidthValue),
629    ColumnSpan(ColumnSpanValue),
630    ColumnFill(ColumnFillValue),
631    ColumnRuleWidth(ColumnRuleWidthValue),
632    ColumnRuleStyle(ColumnRuleStyleValue),
633    ColumnRuleColor(ColumnRuleColorValue),
634    FlowInto(FlowIntoValue),
635    FlowFrom(FlowFromValue),
636    ShapeOutside(ShapeOutsideValue),
637    ShapeInside(ShapeInsideValue),
638    ClipPath(ClipPathValue),
639    ShapeMargin(ShapeMarginValue),
640    ShapeImageThreshold(ShapeImageThresholdValue),
641    TableLayout(LayoutTableLayoutValue),
642    BorderCollapse(StyleBorderCollapseValue),
643    BorderSpacing(LayoutBorderSpacingValue),
644    CaptionSide(StyleCaptionSideValue),
645    EmptyCells(StyleEmptyCellsValue),
646    Content(ContentValue),
647    CounterReset(CounterResetValue),
648    CounterIncrement(CounterIncrementValue),
649    ListStyleType(StyleListStyleTypeValue),
650    ListStylePosition(StyleListStylePositionValue),
651    StringSet(StringSetValue),
652}
653
654impl_option!(
655    CssProperty,
656    OptionCssProperty,
657    copy = false,
658    [Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord]
659);
660
661crate::impl_vec!(CssProperty, CssPropertyVec, CssPropertyVecDestructor, CssPropertyVecDestructorType, CssPropertyVecSlice, OptionCssProperty);
662crate::impl_vec_clone!(CssProperty, CssPropertyVec, CssPropertyVecDestructor);
663crate::impl_vec_debug!(CssProperty, CssPropertyVec);
664crate::impl_vec_partialeq!(CssProperty, CssPropertyVec);
665crate::impl_vec_eq!(CssProperty, CssPropertyVec);
666crate::impl_vec_partialord!(CssProperty, CssPropertyVec);
667crate::impl_vec_ord!(CssProperty, CssPropertyVec);
668crate::impl_vec_hash!(CssProperty, CssPropertyVec);
669
670/// Categorizes a CSS property by its effect on the layout pipeline.
671#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
672pub enum CssPropertyCategory {
673    GpuOnly,
674    /// Affects geometry (width, height, margin, padding, font-size, etc.)
675    Layout,
676    /// Affects only appearance (color, background-color, etc.)
677    Paint,
678    /// A layout-affecting property that also requires children to be re-evaluated.
679    InheritedLayout,
680    /// A paint-affecting property that also requires children to be re-evaluated.
681    InheritedPaint,
682}
683
684/// Fine-grained dirty classification for CSS property changes.
685///
686/// Inspired by Taffy's binary dirty flag but extended to 4 levels for CSS-specific
687/// optimizations. Instead of "clean vs dirty", we classify property changes by their
688/// actual layout impact, enabling the engine to skip unnecessary work.
689///
690/// Reference: Taffy (https://github.com/DioxusLabs/taffy) uses a binary dirty flag
691/// (clean/dirty). Our improvement: 4-level classification enables IFC-only reflow,
692/// sizing-only recomputation, and paint-only updates without full subtree relayout.
693#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
694#[repr(C)]
695pub enum RelayoutScope {
696    /// No relayout needed — repaint only (e.g., color, background, opacity, transform).
697    /// The node's size and position are unchanged.
698    None,
699    /// Only the IFC (Inline Formatting Context) containing this node needs re-shaping.
700    /// Block-level siblings are unaffected unless the IFC height changes,
701    /// in which case this auto-upgrades to SizingOnly.
702    IfcOnly,
703    /// This node's sizing needs recomputation. Parent may need repositioning
704    /// of subsequent siblings but doesn't need full recursive relayout.
705    SizingOnly,
706    /// Full subtree relayout required (e.g., display, position, float change).
707    Full,
708}
709
710impl Default for RelayoutScope {
711    fn default() -> Self {
712        RelayoutScope::None
713    }
714}
715
716/// Represents a CSS key (for example `"border-radius"` => `BorderRadius`).
717/// You can also derive this key from a `CssProperty` by calling `CssProperty::get_type()`.
718#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, strum_macros::EnumIter)]
719#[repr(C)]
720pub enum CssPropertyType {
721    CaretColor,
722    CaretAnimationDuration,
723    CaretWidth,
724    SelectionBackgroundColor,
725    SelectionColor,
726    SelectionRadius,
727    TextColor,
728    FontSize,
729    FontFamily,
730    FontWeight,
731    FontStyle,
732    TextAlign,
733    TextJustify,
734    VerticalAlign,
735    LetterSpacing,
736    TextIndent,
737    InitialLetter,
738    LineClamp,
739    HangingPunctuation,
740    TextCombineUpright,
741    ExclusionMargin,
742    HyphenationLanguage,
743    LineHeight,
744    WordSpacing,
745    TabSize,
746    WhiteSpace,
747    Hyphens,
748    Direction,
749    UserSelect,
750    TextDecoration,
751    Cursor,
752    Display,
753    Float,
754    BoxSizing,
755    Width,
756    Height,
757    MinWidth,
758    MinHeight,
759    MaxWidth,
760    MaxHeight,
761    Position,
762    Top,
763    Right,
764    Left,
765    Bottom,
766    ZIndex,
767    FlexWrap,
768    FlexDirection,
769    FlexGrow,
770    FlexShrink,
771    FlexBasis,
772    JustifyContent,
773    AlignItems,
774    AlignContent,
775    ColumnGap,
776    RowGap,
777    GridTemplateColumns,
778    GridTemplateRows,
779    GridAutoColumns,
780    GridAutoRows,
781    GridColumn,
782    GridRow,
783    GridTemplateAreas,
784    GridAutoFlow,
785    JustifySelf,
786    JustifyItems,
787    Gap,
788    GridGap,
789    AlignSelf,
790    Font,
791    WritingMode,
792    Clear,
793    BackgroundContent,
794    BackgroundPosition,
795    BackgroundSize,
796    BackgroundRepeat,
797    OverflowX,
798    OverflowY,
799    PaddingTop,
800    PaddingLeft,
801    PaddingRight,
802    PaddingBottom,
803    PaddingInlineStart,
804    PaddingInlineEnd,
805    MarginTop,
806    MarginLeft,
807    MarginRight,
808    MarginBottom,
809    BorderTopLeftRadius,
810    BorderTopRightRadius,
811    BorderBottomLeftRadius,
812    BorderBottomRightRadius,
813    BorderTopColor,
814    BorderRightColor,
815    BorderLeftColor,
816    BorderBottomColor,
817    BorderTopStyle,
818    BorderRightStyle,
819    BorderLeftStyle,
820    BorderBottomStyle,
821    BorderTopWidth,
822    BorderRightWidth,
823    BorderLeftWidth,
824    BorderBottomWidth,
825    BoxShadowLeft,
826    BoxShadowRight,
827    BoxShadowTop,
828    BoxShadowBottom,
829    Scrollbar,
830    ScrollbarWidth,
831    ScrollbarColor,
832    Opacity,
833    Visibility,
834    Transform,
835    TransformOrigin,
836    PerspectiveOrigin,
837    BackfaceVisibility,
838    MixBlendMode,
839    Filter,
840    BackdropFilter,
841    TextShadow,
842    BreakBefore,
843    BreakAfter,
844    BreakInside,
845    Orphans,
846    Widows,
847    BoxDecorationBreak,
848    ColumnCount,
849    ColumnWidth,
850    ColumnSpan,
851    ColumnFill,
852    ColumnRuleWidth,
853    ColumnRuleStyle,
854    ColumnRuleColor,
855    FlowInto,
856    FlowFrom,
857    ShapeOutside,
858    ShapeInside,
859    ClipPath,
860    ShapeMargin,
861    ShapeImageThreshold,
862    TableLayout,
863    BorderCollapse,
864    BorderSpacing,
865    CaptionSide,
866    EmptyCells,
867    Content,
868    CounterReset,
869    CounterIncrement,
870    ListStyleType,
871    ListStylePosition,
872    StringSet,
873}
874
875impl fmt::Debug for CssPropertyType {
876    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
877        write!(f, "{}", self.to_str())
878    }
879}
880
881impl fmt::Display for CssPropertyType {
882    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
883        write!(f, "{}", self.to_str())
884    }
885}
886
887impl CssPropertyType {
888    /// Parses a CSS key, such as `width` from a string:
889    ///
890    /// # Example
891    ///
892    /// ```rust
893    /// # use azul_css::props::property::{CssPropertyType, get_css_key_map};
894    /// let map = get_css_key_map();
895    /// assert_eq!(
896    ///     Some(CssPropertyType::Width),
897    ///     CssPropertyType::from_str("width", &map)
898    /// );
899    /// assert_eq!(
900    ///     Some(CssPropertyType::JustifyContent),
901    ///     CssPropertyType::from_str("justify-content", &map)
902    /// );
903    /// assert_eq!(None, CssPropertyType::from_str("asdfasdfasdf", &map));
904    /// ```
905    pub fn from_str(input: &str, map: &CssKeyMap) -> Option<Self> {
906        let input = input.trim();
907        map.non_shorthands.get(input).and_then(|x| Some(*x))
908    }
909
910    /// Returns the original string that was used to construct this `CssPropertyType`.
911    pub fn to_str(&self) -> &'static str {
912        match self {
913            CssPropertyType::CaretColor => "caret-color",
914            CssPropertyType::CaretAnimationDuration => "caret-animation-duration",
915            CssPropertyType::CaretWidth => "-azul-caret-width",
916            CssPropertyType::SelectionBackgroundColor => "-azul-selection-background-color",
917            CssPropertyType::SelectionColor => "-azul-selection-color",
918            CssPropertyType::SelectionRadius => "-azul-selection-radius",
919            CssPropertyType::TextColor => "color",
920            CssPropertyType::FontSize => "font-size",
921            CssPropertyType::FontFamily => "font-family",
922            CssPropertyType::FontWeight => "font-weight",
923            CssPropertyType::FontStyle => "font-style",
924            CssPropertyType::TextAlign => "text-align",
925            CssPropertyType::TextJustify => "text-justify",
926            CssPropertyType::VerticalAlign => "vertical-align",
927            CssPropertyType::LetterSpacing => "letter-spacing",
928            CssPropertyType::TextIndent => "text-indent",
929            CssPropertyType::InitialLetter => "initial-letter",
930            CssPropertyType::LineClamp => "line-clamp",
931            CssPropertyType::HangingPunctuation => "hanging-punctuation",
932            CssPropertyType::TextCombineUpright => "text-combine-upright",
933            CssPropertyType::ExclusionMargin => "-azul-exclusion-margin",
934            CssPropertyType::HyphenationLanguage => "-azul-hyphenation-language",
935            CssPropertyType::LineHeight => "line-height",
936            CssPropertyType::WordSpacing => "word-spacing",
937            CssPropertyType::TabSize => "tab-size",
938            CssPropertyType::Cursor => "cursor",
939            CssPropertyType::Display => "display",
940            CssPropertyType::Float => "float",
941            CssPropertyType::BoxSizing => "box-sizing",
942            CssPropertyType::Width => "width",
943            CssPropertyType::Height => "height",
944            CssPropertyType::MinWidth => "min-width",
945            CssPropertyType::MinHeight => "min-height",
946            CssPropertyType::MaxWidth => "max-width",
947            CssPropertyType::MaxHeight => "max-height",
948            CssPropertyType::Position => "position",
949            CssPropertyType::Top => "top",
950            CssPropertyType::Right => "right",
951            CssPropertyType::Left => "left",
952            CssPropertyType::Bottom => "bottom",
953            CssPropertyType::ZIndex => "z-index",
954            CssPropertyType::FlexWrap => "flex-wrap",
955            CssPropertyType::FlexDirection => "flex-direction",
956            CssPropertyType::FlexGrow => "flex-grow",
957            CssPropertyType::FlexShrink => "flex-shrink",
958            CssPropertyType::FlexBasis => "flex-basis",
959            CssPropertyType::JustifyContent => "justify-content",
960            CssPropertyType::AlignItems => "align-items",
961            CssPropertyType::AlignContent => "align-content",
962            CssPropertyType::ColumnGap => "column-gap",
963            CssPropertyType::RowGap => "row-gap",
964            CssPropertyType::GridTemplateColumns => "grid-template-columns",
965            CssPropertyType::GridTemplateRows => "grid-template-rows",
966            CssPropertyType::GridAutoFlow => "grid-auto-flow",
967            CssPropertyType::JustifySelf => "justify-self",
968            CssPropertyType::JustifyItems => "justify-items",
969            CssPropertyType::Gap => "gap",
970            CssPropertyType::GridGap => "grid-gap",
971            CssPropertyType::AlignSelf => "align-self",
972            CssPropertyType::Font => "font",
973            CssPropertyType::GridAutoColumns => "grid-auto-columns",
974            CssPropertyType::GridAutoRows => "grid-auto-rows",
975            CssPropertyType::GridColumn => "grid-column",
976            CssPropertyType::GridRow => "grid-row",
977            CssPropertyType::GridTemplateAreas => "grid-template-areas",
978            CssPropertyType::WritingMode => "writing-mode",
979            CssPropertyType::Clear => "clear",
980            CssPropertyType::BackgroundContent => "background",
981            CssPropertyType::BackgroundPosition => "background-position",
982            CssPropertyType::BackgroundSize => "background-size",
983            CssPropertyType::BackgroundRepeat => "background-repeat",
984            CssPropertyType::OverflowX => "overflow-x",
985            CssPropertyType::OverflowY => "overflow-y",
986            CssPropertyType::PaddingTop => "padding-top",
987            CssPropertyType::PaddingLeft => "padding-left",
988            CssPropertyType::PaddingRight => "padding-right",
989            CssPropertyType::PaddingBottom => "padding-bottom",
990            CssPropertyType::PaddingInlineStart => "padding-inline-start",
991            CssPropertyType::PaddingInlineEnd => "padding-inline-end",
992            CssPropertyType::MarginTop => "margin-top",
993            CssPropertyType::MarginLeft => "margin-left",
994            CssPropertyType::MarginRight => "margin-right",
995            CssPropertyType::MarginBottom => "margin-bottom",
996            CssPropertyType::BorderTopLeftRadius => "border-top-left-radius",
997            CssPropertyType::BorderTopRightRadius => "border-top-right-radius",
998            CssPropertyType::BorderBottomLeftRadius => "border-bottom-left-radius",
999            CssPropertyType::BorderBottomRightRadius => "border-bottom-right-radius",
1000            CssPropertyType::BorderTopColor => "border-top-color",
1001            CssPropertyType::BorderRightColor => "border-right-color",
1002            CssPropertyType::BorderLeftColor => "border-left-color",
1003            CssPropertyType::BorderBottomColor => "border-bottom-color",
1004            CssPropertyType::BorderTopStyle => "border-top-style",
1005            CssPropertyType::BorderRightStyle => "border-right-style",
1006            CssPropertyType::BorderLeftStyle => "border-left-style",
1007            CssPropertyType::BorderBottomStyle => "border-bottom-style",
1008            CssPropertyType::BorderTopWidth => "border-top-width",
1009            CssPropertyType::BorderRightWidth => "border-right-width",
1010            CssPropertyType::BorderLeftWidth => "border-left-width",
1011            CssPropertyType::BorderBottomWidth => "border-bottom-width",
1012            CssPropertyType::BoxShadowLeft => "-azul-box-shadow-left",
1013            CssPropertyType::BoxShadowRight => "-azul-box-shadow-right",
1014            CssPropertyType::BoxShadowTop => "-azul-box-shadow-top",
1015            CssPropertyType::BoxShadowBottom => "-azul-box-shadow-bottom",
1016            CssPropertyType::Scrollbar => "-azul-scrollbar-style",
1017            CssPropertyType::ScrollbarWidth => "scrollbar-width",
1018            CssPropertyType::ScrollbarColor => "scrollbar-color",
1019            CssPropertyType::Opacity => "opacity",
1020            CssPropertyType::Visibility => "visibility",
1021            CssPropertyType::Transform => "transform",
1022            CssPropertyType::TransformOrigin => "transform-origin",
1023            CssPropertyType::PerspectiveOrigin => "perspective-origin",
1024            CssPropertyType::BackfaceVisibility => "backface-visibility",
1025            CssPropertyType::MixBlendMode => "mix-blend-mode",
1026            CssPropertyType::Filter => "filter",
1027            CssPropertyType::BackdropFilter => "backdrop-filter",
1028            CssPropertyType::TextShadow => "text-shadow",
1029            CssPropertyType::WhiteSpace => "white-space",
1030            CssPropertyType::Hyphens => "hyphens",
1031            CssPropertyType::Direction => "direction",
1032            CssPropertyType::UserSelect => "user-select",
1033            CssPropertyType::TextDecoration => "text-decoration",
1034            CssPropertyType::BreakBefore => "break-before",
1035            CssPropertyType::BreakAfter => "break-after",
1036            CssPropertyType::BreakInside => "break-inside",
1037            CssPropertyType::Orphans => "orphans",
1038            CssPropertyType::Widows => "widows",
1039            CssPropertyType::BoxDecorationBreak => "box-decoration-break",
1040            CssPropertyType::ColumnCount => "column-count",
1041            CssPropertyType::ColumnWidth => "column-width",
1042            CssPropertyType::ColumnSpan => "column-span",
1043            CssPropertyType::ColumnFill => "column-fill",
1044            CssPropertyType::ColumnRuleWidth => "column-rule-width",
1045            CssPropertyType::ColumnRuleStyle => "column-rule-style",
1046            CssPropertyType::ColumnRuleColor => "column-rule-color",
1047            CssPropertyType::FlowInto => "flow-into",
1048            CssPropertyType::FlowFrom => "flow-from",
1049            CssPropertyType::ShapeOutside => "shape-outside",
1050            CssPropertyType::ShapeInside => "shape-inside",
1051            CssPropertyType::ClipPath => "clip-path",
1052            CssPropertyType::ShapeMargin => "shape-margin",
1053            CssPropertyType::ShapeImageThreshold => "shape-image-threshold",
1054            CssPropertyType::TableLayout => "table-layout",
1055            CssPropertyType::BorderCollapse => "border-collapse",
1056            CssPropertyType::BorderSpacing => "border-spacing",
1057            CssPropertyType::CaptionSide => "caption-side",
1058            CssPropertyType::EmptyCells => "empty-cells",
1059            CssPropertyType::Content => "content",
1060            CssPropertyType::CounterReset => "counter-reset",
1061            CssPropertyType::CounterIncrement => "counter-increment",
1062            CssPropertyType::ListStyleType => "list-style-type",
1063            CssPropertyType::ListStylePosition => "list-style-position",
1064            CssPropertyType::StringSet => "string-set",
1065        }
1066    }
1067
1068    /// Returns whether this property will be inherited during cascading
1069    /// Returns whether this CSS property is inherited by default according to CSS specifications.
1070    ///
1071    /// Reference: https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Cascade/Inheritance
1072    pub fn is_inheritable(&self) -> bool {
1073        use self::CssPropertyType::*;
1074        match self {
1075            // Font properties
1076            FontFamily | FontSize | FontWeight | FontStyle | LineHeight | LetterSpacing | WordSpacing | TextIndent |
1077
1078            // Text properties
1079            TextColor | TextAlign | TextJustify | TextDecoration | WhiteSpace | Direction | Hyphens | TabSize |
1080            HangingPunctuation | TextCombineUpright | HyphenationLanguage |
1081
1082            // List properties
1083            ListStyleType | ListStylePosition |
1084
1085            // Table properties
1086            BorderCollapse | BorderSpacing | CaptionSide | EmptyCells |
1087
1088            // Other inherited properties
1089            // NOTE: Cursor is inheritable per CSS spec (https://developer.mozilla.org/en-US/docs/Web/CSS/cursor)
1090            // This means a Button with cursor:pointer will pass that to child Text nodes.
1091            // This is correct behavior - if you want text inside a button to show I-beam,
1092            // the Text node needs an explicit cursor:text style that overrides the inherited value.
1093            Visibility | Cursor | Widows | Orphans |
1094
1095            // Writing mode
1096            WritingMode |
1097
1098            // User interaction
1099            UserSelect
1100            => true,
1101
1102            _ => false,
1103        }
1104    }
1105
1106    pub fn get_category(&self) -> CssPropertyCategory {
1107        if self.is_gpu_only_property() {
1108            CssPropertyCategory::GpuOnly
1109        } else {
1110            let is_inheritable = self.is_inheritable();
1111            let can_trigger_layout = self.can_trigger_relayout();
1112            match (is_inheritable, can_trigger_layout) {
1113                (true, true) => CssPropertyCategory::InheritedLayout,
1114                (true, false) => CssPropertyCategory::InheritedPaint,
1115                (false, true) => CssPropertyCategory::Layout,
1116                (false, false) => CssPropertyCategory::Paint,
1117            }
1118        }
1119    }
1120
1121    /// Returns whether this property can trigger a re-layout (important for incremental layout and
1122    /// caching layouted DOMs).
1123    pub fn can_trigger_relayout(&self) -> bool {
1124        use self::CssPropertyType::*;
1125
1126        // Since the border can be larger than the content,
1127        // in which case the content needs to be re-layouted, assume true for Border
1128
1129        // FontFamily, FontSize, LetterSpacing and LineHeight can affect
1130        // the text layout and therefore the screen layout
1131
1132        match self {
1133            TextColor
1134            | Cursor
1135            | BackgroundContent
1136            | BackgroundPosition
1137            | BackgroundSize
1138            | BackgroundRepeat
1139            | BorderTopLeftRadius
1140            | BorderTopRightRadius
1141            | BorderBottomLeftRadius
1142            | BorderBottomRightRadius
1143            | BorderTopColor
1144            | BorderRightColor
1145            | BorderLeftColor
1146            | BorderBottomColor
1147            | BorderTopStyle
1148            | BorderRightStyle
1149            | BorderLeftStyle
1150            | BorderBottomStyle
1151            | ColumnRuleColor
1152            | ColumnRuleStyle
1153            | BoxShadowLeft
1154            | BoxShadowRight
1155            | BoxShadowTop
1156            | BoxShadowBottom
1157            | BoxDecorationBreak
1158            | Scrollbar
1159            | Opacity
1160            | Transform
1161            | TransformOrigin
1162            | PerspectiveOrigin
1163            | BackfaceVisibility
1164            | MixBlendMode
1165            | Filter
1166            | BackdropFilter
1167            | TextShadow => false,
1168            _ => true,
1169        }
1170    }
1171
1172    /// Returns whether the property is a GPU property (currently only opacity and transforms)
1173    pub fn is_gpu_only_property(&self) -> bool {
1174        match self {
1175            CssPropertyType::Opacity |
1176            CssPropertyType::Transform /* | CssPropertyType::Color */ => true,
1177            _ => false
1178        }
1179    }
1180
1181    /// Context-dependent relayout scope for a CSS property change.
1182    ///
1183    /// This is a more granular replacement for `can_trigger_relayout()`.
1184    /// Instead of returning a flat bool, it classifies the property change
1185    /// into one of four impact levels (see `RelayoutScope`).
1186    ///
1187    /// Inspired by Taffy's binary dirty flag, extended with CSS-specific
1188    /// knowledge: font/text changes only affect IFC, sizing changes don't
1189    /// require full subtree relayout, and paint-only changes skip layout entirely.
1190    ///
1191    /// `node_is_ifc_member`: whether this node participates in an IFC
1192    /// (has inline formatting context membership). When true, font/text
1193    /// property changes trigger IFC-only relayout instead of being ignored.
1194    pub fn relayout_scope(&self, node_is_ifc_member: bool) -> RelayoutScope {
1195        use CssPropertyType::*;
1196        match self {
1197            // Pure paint — never triggers relayout
1198            TextColor | Cursor | BackgroundContent | BackgroundPosition
1199            | BackgroundSize | BackgroundRepeat | BorderTopColor | BorderRightColor
1200            | BorderLeftColor | BorderBottomColor | BorderTopStyle | BorderRightStyle
1201            | BorderLeftStyle | BorderBottomStyle | BorderTopLeftRadius
1202            | BorderTopRightRadius | BorderBottomLeftRadius | BorderBottomRightRadius
1203            | ColumnRuleColor | ColumnRuleStyle | BoxShadowLeft | BoxShadowRight
1204            | BoxShadowTop | BoxShadowBottom | BoxDecorationBreak | Scrollbar
1205            | Opacity | Transform | TransformOrigin | PerspectiveOrigin
1206            | BackfaceVisibility | MixBlendMode | Filter | BackdropFilter
1207            | TextShadow | SelectionBackgroundColor | SelectionColor
1208            | SelectionRadius | CaretColor | CaretAnimationDuration
1209            | CaretWidth => RelayoutScope::None,
1210
1211            // Font/text properties — IFC-only if inside inline context,
1212            // otherwise no layout impact (block with only block children
1213            // inherits but doesn't directly reflow).
1214            FontFamily | FontSize | FontWeight | FontStyle
1215            | LetterSpacing | WordSpacing | LineHeight | TextAlign | TextJustify
1216            | TextIndent | WhiteSpace | TabSize | Hyphens
1217            | HyphenationLanguage | TextCombineUpright | TextDecoration
1218            | HangingPunctuation | InitialLetter | LineClamp
1219            | Direction | VerticalAlign => {
1220                if node_is_ifc_member {
1221                    RelayoutScope::IfcOnly
1222                } else {
1223                    // Block container with only block children: font properties
1224                    // are inherited but don't affect this node's own sizing.
1225                    // Children pick up the change via inheritance and get their
1226                    // own dirty flags.
1227                    RelayoutScope::None
1228                }
1229            }
1230
1231            // Sizing properties — only this node's size changes.
1232            // Parent may reposition subsequent siblings but doesn't need
1233            // full recursive relayout of unaffected subtrees.
1234            Width | Height | MinWidth | MinHeight | MaxWidth | MaxHeight
1235            | PaddingTop | PaddingRight | PaddingBottom | PaddingLeft
1236            | PaddingInlineStart | PaddingInlineEnd
1237            | BorderTopWidth | BorderRightWidth | BorderBottomWidth
1238            | BorderLeftWidth | BoxSizing
1239            | ScrollbarWidth => RelayoutScope::SizingOnly,
1240
1241            // Everything else: display, position, float, margin, flex-*,
1242            // grid-*, overflow, writing-mode, etc. — full relayout.
1243            _ => RelayoutScope::Full,
1244        }
1245    }
1246}
1247
1248// -- PARSING --
1249
1250/// Master error type that aggregates all possible CSS parsing errors.
1251#[derive(Clone, PartialEq)]
1252pub enum CssParsingError<'a> {
1253    // Shorthand properties
1254    Border(CssBorderParseError<'a>),
1255    BorderRadius(CssStyleBorderRadiusParseError<'a>),
1256    Padding(LayoutPaddingParseError<'a>),
1257    Margin(LayoutMarginParseError<'a>),
1258    Overflow(InvalidValueErr<'a>),
1259    BoxShadow(CssShadowParseError<'a>),
1260
1261    // Individual properties
1262    Color(CssColorParseError<'a>),
1263    PixelValue(CssPixelValueParseError<'a>),
1264    Percentage(PercentageParseError),
1265    FontFamily(CssStyleFontFamilyParseError<'a>),
1266    InvalidValue(InvalidValueErr<'a>),
1267    FlexGrow(FlexGrowParseError<'a>),
1268    FlexShrink(FlexShrinkParseError<'a>),
1269    Background(CssBackgroundParseError<'a>),
1270    BackgroundPosition(CssBackgroundPositionParseError<'a>),
1271    Opacity(OpacityParseError<'a>),
1272    Visibility(StyleVisibilityParseError<'a>),
1273    Scrollbar(CssScrollbarStyleParseError<'a>),
1274    LayoutScrollbarWidth(LayoutScrollbarWidthParseError<'a>),
1275    StyleScrollbarColor(StyleScrollbarColorParseError<'a>),
1276    Transform(CssStyleTransformParseError<'a>),
1277    TransformOrigin(CssStyleTransformOriginParseError<'a>),
1278    PerspectiveOrigin(CssStylePerspectiveOriginParseError<'a>),
1279    Filter(CssStyleFilterParseError<'a>),
1280
1281    // Text/Style properties
1282    TextColor(StyleTextColorParseError<'a>),
1283    FontSize(CssStyleFontSizeParseError<'a>),
1284    FontWeight(CssFontWeightParseError<'a>),
1285    FontStyle(CssFontStyleParseError<'a>),
1286    TextAlign(StyleTextAlignParseError<'a>),
1287    TextJustify(TextJustifyParseError<'a>),
1288    VerticalAlign(StyleVerticalAlignParseError<'a>),
1289    LetterSpacing(StyleLetterSpacingParseError<'a>),
1290    TextIndent(StyleTextIndentParseError<'a>),
1291    InitialLetter(StyleInitialLetterParseError<'a>),
1292    LineClamp(StyleLineClampParseError<'a>),
1293    HangingPunctuation(StyleHangingPunctuationParseError<'a>),
1294    TextCombineUpright(StyleTextCombineUprightParseError<'a>),
1295    ExclusionMargin(StyleExclusionMarginParseError),
1296    HyphenationLanguage(StyleHyphenationLanguageParseError),
1297    LineHeight(StyleLineHeightParseError),
1298    WordSpacing(StyleWordSpacingParseError<'a>),
1299    TabSize(StyleTabSizeParseError<'a>),
1300    WhiteSpace(StyleWhiteSpaceParseError<'a>),
1301    Hyphens(StyleHyphensParseError<'a>),
1302    Direction(StyleDirectionParseError<'a>),
1303    UserSelect(StyleUserSelectParseError<'a>),
1304    TextDecoration(StyleTextDecorationParseError<'a>),
1305    Cursor(CursorParseError<'a>),
1306    CaretColor(CssColorParseError<'a>),
1307    CaretAnimationDuration(DurationParseError<'a>),
1308    CaretWidth(CssPixelValueParseError<'a>),
1309    SelectionBackgroundColor(CssColorParseError<'a>),
1310    SelectionColor(CssColorParseError<'a>),
1311    SelectionRadius(CssPixelValueParseError<'a>),
1312
1313    // Layout basic properties
1314    LayoutDisplay(LayoutDisplayParseError<'a>),
1315    LayoutFloat(LayoutFloatParseError<'a>),
1316    LayoutBoxSizing(LayoutBoxSizingParseError<'a>),
1317
1318    // Layout dimensions
1319    LayoutWidth(LayoutWidthParseError<'a>),
1320    LayoutHeight(LayoutHeightParseError<'a>),
1321    LayoutMinWidth(LayoutMinWidthParseError<'a>),
1322    LayoutMinHeight(LayoutMinHeightParseError<'a>),
1323    LayoutMaxWidth(LayoutMaxWidthParseError<'a>),
1324    LayoutMaxHeight(LayoutMaxHeightParseError<'a>),
1325
1326    // Layout position
1327    LayoutPosition(LayoutPositionParseError<'a>),
1328    LayoutTop(LayoutTopParseError<'a>),
1329    LayoutRight(LayoutRightParseError<'a>),
1330    LayoutLeft(LayoutLeftParseError<'a>),
1331    LayoutInsetBottom(LayoutInsetBottomParseError<'a>),
1332    LayoutZIndex(LayoutZIndexParseError<'a>),
1333
1334    // Layout flex
1335    FlexWrap(FlexWrapParseError<'a>),
1336    FlexDirection(FlexDirectionParseError<'a>),
1337    FlexBasis(FlexBasisParseError<'a>),
1338    JustifyContent(JustifyContentParseError<'a>),
1339    AlignItems(AlignItemsParseError<'a>),
1340    AlignContent(AlignContentParseError<'a>),
1341
1342    // Layout grid
1343    Grid(GridParseError<'a>),
1344    GridAutoFlow(GridAutoFlowParseError<'a>),
1345    JustifySelf(JustifySelfParseError<'a>),
1346    JustifyItems(JustifyItemsParseError<'a>),
1347    AlignSelf(AlignSelfParseError<'a>),
1348
1349    // Layout wrapping
1350    LayoutWrap(LayoutWrapParseError<'a>),
1351    LayoutWritingMode(LayoutWritingModeParseError<'a>),
1352    LayoutClear(LayoutClearParseError<'a>),
1353
1354    // Layout overflow
1355    LayoutOverflow(LayoutOverflowParseError<'a>),
1356
1357    // Border radius individual corners
1358    BorderTopLeftRadius(StyleBorderTopLeftRadiusParseError<'a>),
1359    BorderTopRightRadius(StyleBorderTopRightRadiusParseError<'a>),
1360    BorderBottomLeftRadius(StyleBorderBottomLeftRadiusParseError<'a>),
1361    BorderBottomRightRadius(StyleBorderBottomRightRadiusParseError<'a>),
1362
1363    // Border style
1364    BorderStyle(CssBorderStyleParseError<'a>),
1365
1366    // Effects
1367    BackfaceVisibility(CssBackfaceVisibilityParseError<'a>),
1368    MixBlendMode(MixBlendModeParseError<'a>),
1369
1370    // Fragmentation
1371    PageBreak(PageBreakParseError<'a>),
1372    BreakInside(BreakInsideParseError<'a>),
1373    Widows(WidowsParseError<'a>),
1374    Orphans(OrphansParseError<'a>),
1375    BoxDecorationBreak(BoxDecorationBreakParseError<'a>),
1376
1377    // Columns
1378    ColumnCount(ColumnCountParseError<'a>),
1379    ColumnWidth(ColumnWidthParseError<'a>),
1380    ColumnSpan(ColumnSpanParseError<'a>),
1381    ColumnFill(ColumnFillParseError<'a>),
1382    ColumnRuleWidth(ColumnRuleWidthParseError<'a>),
1383    ColumnRuleStyle(ColumnRuleStyleParseError<'a>),
1384    ColumnRuleColor(ColumnRuleColorParseError<'a>),
1385
1386    // Flow & Shape
1387    FlowInto(FlowIntoParseError<'a>),
1388    FlowFrom(FlowFromParseError<'a>),
1389    GenericParseError,
1390
1391    // Content
1392    Content, // Simplified errors for now
1393    Counter,
1394    ListStyleType(StyleListStyleTypeParseError<'a>),
1395    ListStylePosition(StyleListStylePositionParseError<'a>),
1396    StringSet,
1397}
1398
1399/// Owned version of `CssParsingError`.
1400#[derive(Debug, Clone, PartialEq)]
1401pub enum CssParsingErrorOwned {
1402    // Shorthand properties
1403    Border(CssBorderParseErrorOwned),
1404    BorderRadius(CssStyleBorderRadiusParseErrorOwned),
1405    Padding(LayoutPaddingParseErrorOwned),
1406    Margin(LayoutMarginParseErrorOwned),
1407    Overflow(InvalidValueErrOwned),
1408    BoxShadow(CssShadowParseErrorOwned),
1409
1410    // Individual properties
1411    Color(CssColorParseErrorOwned),
1412    PixelValue(CssPixelValueParseErrorOwned),
1413    Percentage(PercentageParseError),
1414    FontFamily(CssStyleFontFamilyParseErrorOwned),
1415    InvalidValue(InvalidValueErrOwned),
1416    FlexGrow(FlexGrowParseErrorOwned),
1417    FlexShrink(FlexShrinkParseErrorOwned),
1418    Background(CssBackgroundParseErrorOwned),
1419    BackgroundPosition(CssBackgroundPositionParseErrorOwned),
1420    Opacity(OpacityParseErrorOwned),
1421    Visibility(StyleVisibilityParseErrorOwned),
1422    Scrollbar(CssScrollbarStyleParseErrorOwned),
1423    LayoutScrollbarWidth(LayoutScrollbarWidthParseErrorOwned),
1424    StyleScrollbarColor(StyleScrollbarColorParseErrorOwned),
1425    Transform(CssStyleTransformParseErrorOwned),
1426    TransformOrigin(CssStyleTransformOriginParseErrorOwned),
1427    PerspectiveOrigin(CssStylePerspectiveOriginParseErrorOwned),
1428    Filter(CssStyleFilterParseErrorOwned),
1429
1430    // Text/Style properties
1431    TextColor(StyleTextColorParseErrorOwned),
1432    FontSize(CssStyleFontSizeParseErrorOwned),
1433    FontWeight(CssFontWeightParseErrorOwned),
1434    FontStyle(CssFontStyleParseErrorOwned),
1435    TextAlign(StyleTextAlignParseErrorOwned),
1436    TextJustify(TextJustifyParseErrorOwned),
1437    VerticalAlign(StyleVerticalAlignParseErrorOwned),
1438    LetterSpacing(StyleLetterSpacingParseErrorOwned),
1439    TextIndent(StyleTextIndentParseErrorOwned),
1440    InitialLetter(StyleInitialLetterParseErrorOwned),
1441    LineClamp(StyleLineClampParseErrorOwned),
1442    HangingPunctuation(StyleHangingPunctuationParseErrorOwned),
1443    TextCombineUpright(StyleTextCombineUprightParseErrorOwned),
1444    ExclusionMargin(StyleExclusionMarginParseErrorOwned),
1445    HyphenationLanguage(StyleHyphenationLanguageParseErrorOwned),
1446    LineHeight(StyleLineHeightParseError),
1447    WordSpacing(StyleWordSpacingParseErrorOwned),
1448    TabSize(StyleTabSizeParseErrorOwned),
1449    WhiteSpace(StyleWhiteSpaceParseErrorOwned),
1450    Hyphens(StyleHyphensParseErrorOwned),
1451    Direction(StyleDirectionParseErrorOwned),
1452    UserSelect(StyleUserSelectParseErrorOwned),
1453    TextDecoration(StyleTextDecorationParseErrorOwned),
1454    Cursor(CursorParseErrorOwned),
1455    CaretColor(CssColorParseErrorOwned),
1456    CaretAnimationDuration(DurationParseErrorOwned),
1457    CaretWidth(CssPixelValueParseErrorOwned),
1458    SelectionBackgroundColor(CssColorParseErrorOwned),
1459    SelectionColor(CssColorParseErrorOwned),
1460    SelectionRadius(CssPixelValueParseErrorOwned),
1461
1462    // Layout basic properties
1463    LayoutDisplay(LayoutDisplayParseErrorOwned),
1464    LayoutFloat(LayoutFloatParseErrorOwned),
1465    LayoutBoxSizing(LayoutBoxSizingParseErrorOwned),
1466
1467    // Layout dimensions
1468    LayoutWidth(LayoutWidthParseErrorOwned),
1469    LayoutHeight(LayoutHeightParseErrorOwned),
1470    LayoutMinWidth(LayoutMinWidthParseErrorOwned),
1471    LayoutMinHeight(LayoutMinHeightParseErrorOwned),
1472    LayoutMaxWidth(LayoutMaxWidthParseErrorOwned),
1473    LayoutMaxHeight(LayoutMaxHeightParseErrorOwned),
1474
1475    // Layout position
1476    LayoutPosition(LayoutPositionParseErrorOwned),
1477    LayoutTop(LayoutTopParseErrorOwned),
1478    LayoutRight(LayoutRightParseErrorOwned),
1479    LayoutLeft(LayoutLeftParseErrorOwned),
1480    LayoutInsetBottom(LayoutInsetBottomParseErrorOwned),
1481    LayoutZIndex(LayoutZIndexParseErrorOwned),
1482
1483    // Layout flex
1484    FlexWrap(FlexWrapParseErrorOwned),
1485    FlexDirection(FlexDirectionParseErrorOwned),
1486    FlexBasis(FlexBasisParseErrorOwned),
1487    JustifyContent(JustifyContentParseErrorOwned),
1488    AlignItems(AlignItemsParseErrorOwned),
1489    AlignContent(AlignContentParseErrorOwned),
1490
1491    // Layout grid
1492    Grid(GridParseErrorOwned),
1493    GridAutoFlow(GridAutoFlowParseErrorOwned),
1494    JustifySelf(JustifySelfParseErrorOwned),
1495    JustifyItems(JustifyItemsParseErrorOwned),
1496    AlignSelf(AlignSelfParseErrorOwned),
1497
1498    // Layout wrapping
1499    LayoutWrap(LayoutWrapParseErrorOwned),
1500    LayoutWritingMode(LayoutWritingModeParseErrorOwned),
1501    LayoutClear(LayoutClearParseErrorOwned),
1502
1503    // Layout overflow
1504    LayoutOverflow(LayoutOverflowParseErrorOwned),
1505
1506    // Border radius individual corners
1507    BorderTopLeftRadius(StyleBorderTopLeftRadiusParseErrorOwned),
1508    BorderTopRightRadius(StyleBorderTopRightRadiusParseErrorOwned),
1509    BorderBottomLeftRadius(StyleBorderBottomLeftRadiusParseErrorOwned),
1510    BorderBottomRightRadius(StyleBorderBottomRightRadiusParseErrorOwned),
1511
1512    // Border style
1513    BorderStyle(CssBorderStyleParseErrorOwned),
1514
1515    // Effects
1516    BackfaceVisibility(CssBackfaceVisibilityParseErrorOwned),
1517    MixBlendMode(MixBlendModeParseErrorOwned),
1518
1519    // Fragmentation
1520    PageBreak(PageBreakParseErrorOwned),
1521    BreakInside(BreakInsideParseErrorOwned),
1522    Widows(WidowsParseErrorOwned),
1523    Orphans(OrphansParseErrorOwned),
1524    BoxDecorationBreak(BoxDecorationBreakParseErrorOwned),
1525
1526    // Columns
1527    ColumnCount(ColumnCountParseErrorOwned),
1528    ColumnWidth(ColumnWidthParseErrorOwned),
1529    ColumnSpan(ColumnSpanParseErrorOwned),
1530    ColumnFill(ColumnFillParseErrorOwned),
1531    ColumnRuleWidth(ColumnRuleWidthParseErrorOwned),
1532    ColumnRuleStyle(ColumnRuleStyleParseErrorOwned),
1533    ColumnRuleColor(ColumnRuleColorParseErrorOwned),
1534
1535    // Flow & Shape
1536    FlowInto(FlowIntoParseErrorOwned),
1537    FlowFrom(FlowFromParseErrorOwned),
1538    GenericParseError,
1539
1540    // Content
1541    Content,
1542    Counter,
1543    ListStyleType(StyleListStyleTypeParseErrorOwned),
1544    ListStylePosition(StyleListStylePositionParseErrorOwned),
1545    StringSet,
1546}
1547
1548// -- PARSING ERROR IMPLEMENTATIONS --
1549
1550impl_debug_as_display!(CssParsingError<'a>);
1551impl_display! { CssParsingError<'a>, {
1552    CaretColor(e) => format!("Invalid caret-color: {}", e),
1553    CaretAnimationDuration(e) => format!("Invalid caret-animation-duration: {}", e),
1554    CaretWidth(e) => format!("Invalid -azul-caret-width: {}", e),
1555    SelectionBackgroundColor(e) => format!("Invalid -azul-selection-background-color: {}", e),
1556    SelectionColor(e) => format!("Invalid -azul-selection-color: {}", e),
1557    SelectionRadius(e) => format!("Invalid -azul-selection-radius: {}", e),
1558    Border(e) => format!("Invalid border property: {}", e),
1559    BorderRadius(e) => format!("Invalid border-radius: {}", e),
1560    Padding(e) => format!("Invalid padding property: {}", e),
1561    Margin(e) => format!("Invalid margin property: {}", e),
1562    Overflow(e) => format!("Invalid overflow property: \"{}\"", e.0),
1563    BoxShadow(e) => format!("Invalid shadow property: {}", e),
1564    Color(e) => format!("Invalid color value: {}", e),
1565    PixelValue(e) => format!("Invalid pixel value: {}", e),
1566    Percentage(e) => format!("Invalid percentage value: {}", e),
1567    FontFamily(e) => format!("Invalid font-family value: {}", e),
1568    InvalidValue(e) => format!("Invalid value: \"{}\"", e.0),
1569    FlexGrow(e) => format!("Invalid flex-grow value: {}", e),
1570    FlexShrink(e) => format!("Invalid flex-shrink value: {}", e),
1571    Background(e) => format!("Invalid background property: {}", e),
1572    BackgroundPosition(e) => format!("Invalid background-position: {}", e),
1573    Opacity(e) => format!("Invalid opacity value: {}", e),
1574    Visibility(e) => format!("Invalid visibility value: {}", e),
1575    Scrollbar(e) => format!("Invalid scrollbar style: {}", e),
1576    LayoutScrollbarWidth(e) => format!("Invalid scrollbar-width: {}", e),
1577    StyleScrollbarColor(e) => format!("Invalid scrollbar-color: {}", e),
1578    Transform(e) => format!("Invalid transform property: {}", e),
1579    TransformOrigin(e) => format!("Invalid transform-origin: {}", e),
1580    PerspectiveOrigin(e) => format!("Invalid perspective-origin: {}", e),
1581    Filter(e) => format!("Invalid filter property: {}", e),
1582    LayoutWidth(e) => format!("Invalid width value: {}", e),
1583    LayoutHeight(e) => format!("Invalid height value: {}", e),
1584    LayoutMinWidth(e) => format!("Invalid min-width value: {}", e),
1585    LayoutMinHeight(e) => format!("Invalid min-height value: {}", e),
1586    LayoutMaxWidth(e) => format!("Invalid max-width value: {}", e),
1587    LayoutMaxHeight(e) => format!("Invalid max-height value: {}", e),
1588    LayoutPosition(e) => format!("Invalid position value: {}", e),
1589    LayoutTop(e) => format!("Invalid top value: {}", e),
1590    LayoutRight(e) => format!("Invalid right value: {}", e),
1591    LayoutLeft(e) => format!("Invalid left value: {}", e),
1592    LayoutInsetBottom(e) => format!("Invalid bottom value: {}", e),
1593    LayoutZIndex(e) => format!("Invalid z-index value: {}", e),
1594    FlexWrap(e) => format!("Invalid flex-wrap value: {}", e),
1595    FlexDirection(e) => format!("Invalid flex-direction value: {}", e),
1596    FlexBasis(e) => format!("Invalid flex-basis value: {}", e),
1597    JustifyContent(e) => format!("Invalid justify-content value: {}", e),
1598    AlignItems(e) => format!("Invalid align-items value: {}", e),
1599    AlignContent(e) => format!("Invalid align-content value: {}", e),
1600    GridAutoFlow(e) => format!("Invalid grid-auto-flow value: {}", e),
1601    JustifySelf(e) => format!("Invalid justify-self value: {}", e),
1602    JustifyItems(e) => format!("Invalid justify-items value: {}", e),
1603    AlignSelf(e) => format!("Invalid align-self value: {}", e),
1604    Grid(e) => format!("Invalid grid value: {}", e),
1605    LayoutWrap(e) => format!("Invalid wrap value: {}", e),
1606    LayoutWritingMode(e) => format!("Invalid writing-mode value: {}", e),
1607    LayoutClear(e) => format!("Invalid clear value: {}", e),
1608    LayoutOverflow(e) => format!("Invalid overflow value: {}", e),
1609    BorderTopLeftRadius(e) => format!("Invalid border-top-left-radius: {}", e),
1610    BorderTopRightRadius(e) => format!("Invalid border-top-right-radius: {}", e),
1611    BorderBottomLeftRadius(e) => format!("Invalid border-bottom-left-radius: {}", e),
1612    BorderBottomRightRadius(e) => format!("Invalid border-bottom-right-radius: {}", e),
1613    BorderStyle(e) => format!("Invalid border style: {}", e),
1614    BackfaceVisibility(e) => format!("Invalid backface-visibility: {}", e),
1615    MixBlendMode(e) => format!("Invalid mix-blend-mode: {}", e),
1616    TextColor(e) => format!("Invalid text color: {}", e),
1617    FontSize(e) => format!("Invalid font-size: {}", e),
1618    FontWeight(e) => format!("Invalid font-weight: {}", e),
1619    FontStyle(e) => format!("Invalid font-style: {}", e),
1620    TextAlign(e) => format!("Invalid text-align: {}", e),
1621    TextJustify(e) => format!("Invalid text-justify: {}", e),
1622    VerticalAlign(e) => format!("Invalid vertical-align: {}", e),
1623    LetterSpacing(e) => format!("Invalid letter-spacing: {}", e),
1624    TextIndent(e) => format!("Invalid text-indent: {}", e),
1625    InitialLetter(e) => format!("Invalid initial-letter: {}", e),
1626    LineClamp(e) => format!("Invalid line-clamp: {}", e),
1627    HangingPunctuation(e) => format!("Invalid hanging-punctuation: {}", e),
1628    TextCombineUpright(e) => format!("Invalid text-combine-upright: {}", e),
1629    ExclusionMargin(e) => format!("Invalid -azul-exclusion-margin: {}", e),
1630    HyphenationLanguage(e) => format!("Invalid -azul-hyphenation-language: {}", e),
1631    LineHeight(e) => format!("Invalid line-height: {}", e),
1632    WordSpacing(e) => format!("Invalid word-spacing: {}", e),
1633    TabSize(e) => format!("Invalid tab-size: {}", e),
1634    WhiteSpace(e) => format!("Invalid white-space: {}", e),
1635    Hyphens(e) => format!("Invalid hyphens: {}", e),
1636    Direction(e) => format!("Invalid direction: {}", e),
1637    UserSelect(e) => format!("Invalid user-select: {}", e),
1638    TextDecoration(e) => format!("Invalid text-decoration: {}", e),
1639    Cursor(e) => format!("Invalid cursor: {}", e),
1640    LayoutDisplay(e) => format!("Invalid display: {}", e),
1641    LayoutFloat(e) => format!("Invalid float: {}", e),
1642    LayoutBoxSizing(e) => format!("Invalid box-sizing: {}", e),
1643    PageBreak(e) => format!("Invalid break property: {}", e),
1644    BreakInside(e) => format!("Invalid break-inside property: {}", e),
1645    Widows(e) => format!("Invalid widows property: {}", e),
1646    Orphans(e) => format!("Invalid orphans property: {}", e),
1647    BoxDecorationBreak(e) => format!("Invalid box-decoration-break property: {}", e),
1648    ColumnCount(e) => format!("Invalid column-count: {}", e),
1649    ColumnWidth(e) => format!("Invalid column-width: {}", e),
1650    ColumnSpan(e) => format!("Invalid column-span: {}", e),
1651    ColumnFill(e) => format!("Invalid column-fill: {}", e),
1652    ColumnRuleWidth(e) => format!("Invalid column-rule-width: {}", e),
1653    ColumnRuleStyle(e) => format!("Invalid column-rule-style: {}", e),
1654    ColumnRuleColor(e) => format!("Invalid column-rule-color: {}", e),
1655    FlowInto(e) => format!("Invalid flow-into: {}", e),
1656    FlowFrom(e) => format!("Invalid flow-from: {}", e),
1657    GenericParseError => "Failed to parse value",
1658    Content => "Failed to parse content property",
1659    Counter => "Failed to parse counter property",
1660    ListStyleType(e) => format!("Invalid list-style-type: {}", e),
1661    ListStylePosition(e) => format!("Invalid list-style-position: {}", e),
1662    StringSet => "Failed to parse string-set property",
1663}}
1664
1665// From impls for CssParsingError
1666impl_from!(
1667    DurationParseError<'a>,
1668    CssParsingError::CaretAnimationDuration
1669);
1670impl_from!(CssBorderParseError<'a>, CssParsingError::Border);
1671impl_from!(
1672    CssStyleBorderRadiusParseError<'a>,
1673    CssParsingError::BorderRadius
1674);
1675impl_from!(LayoutPaddingParseError<'a>, CssParsingError::Padding);
1676impl_from!(LayoutMarginParseError<'a>, CssParsingError::Margin);
1677impl_from!(CssShadowParseError<'a>, CssParsingError::BoxShadow);
1678impl_from!(CssColorParseError<'a>, CssParsingError::Color);
1679impl_from!(CssPixelValueParseError<'a>, CssParsingError::PixelValue);
1680impl_from!(
1681    CssStyleFontFamilyParseError<'a>,
1682    CssParsingError::FontFamily
1683);
1684impl_from!(CssFontWeightParseError<'a>, CssParsingError::FontWeight);
1685impl_from!(CssFontStyleParseError<'a>, CssParsingError::FontStyle);
1686impl_from!(
1687    StyleInitialLetterParseError<'a>,
1688    CssParsingError::InitialLetter
1689);
1690impl_from!(StyleLineClampParseError<'a>, CssParsingError::LineClamp);
1691impl_from!(
1692    StyleHangingPunctuationParseError<'a>,
1693    CssParsingError::HangingPunctuation
1694);
1695impl_from!(
1696    StyleTextCombineUprightParseError<'a>,
1697    CssParsingError::TextCombineUpright
1698);
1699
1700// Manual From implementation for StyleExclusionMarginParseError (no lifetime)
1701#[cfg(feature = "parser")]
1702impl<'a> From<StyleExclusionMarginParseError> for CssParsingError<'a> {
1703    fn from(e: StyleExclusionMarginParseError) -> Self {
1704        CssParsingError::ExclusionMargin(e)
1705    }
1706}
1707
1708// Manual From implementation for StyleHyphenationLanguageParseError (no lifetime)
1709#[cfg(feature = "parser")]
1710impl<'a> From<StyleHyphenationLanguageParseError> for CssParsingError<'a> {
1711    fn from(e: StyleHyphenationLanguageParseError) -> Self {
1712        CssParsingError::HyphenationLanguage(e)
1713    }
1714}
1715impl_from!(FlexGrowParseError<'a>, CssParsingError::FlexGrow);
1716impl_from!(FlexShrinkParseError<'a>, CssParsingError::FlexShrink);
1717impl_from!(CssBackgroundParseError<'a>, CssParsingError::Background);
1718impl_from!(
1719    CssBackgroundPositionParseError<'a>,
1720    CssParsingError::BackgroundPosition
1721);
1722impl_from!(OpacityParseError<'a>, CssParsingError::Opacity);
1723impl_from!(StyleVisibilityParseError<'a>, CssParsingError::Visibility);
1724impl_from!(CssScrollbarStyleParseError<'a>, CssParsingError::Scrollbar);
1725impl_from!(
1726    LayoutScrollbarWidthParseError<'a>,
1727    CssParsingError::LayoutScrollbarWidth
1728);
1729impl_from!(
1730    StyleScrollbarColorParseError<'a>,
1731    CssParsingError::StyleScrollbarColor
1732);
1733impl_from!(CssStyleTransformParseError<'a>, CssParsingError::Transform);
1734impl_from!(
1735    CssStyleTransformOriginParseError<'a>,
1736    CssParsingError::TransformOrigin
1737);
1738impl_from!(
1739    CssStylePerspectiveOriginParseError<'a>,
1740    CssParsingError::PerspectiveOrigin
1741);
1742impl_from!(CssStyleFilterParseError<'a>, CssParsingError::Filter);
1743
1744// Layout dimensions
1745impl_from!(LayoutWidthParseError<'a>, CssParsingError::LayoutWidth);
1746impl_from!(LayoutHeightParseError<'a>, CssParsingError::LayoutHeight);
1747impl_from!(
1748    LayoutMinWidthParseError<'a>,
1749    CssParsingError::LayoutMinWidth
1750);
1751impl_from!(
1752    LayoutMinHeightParseError<'a>,
1753    CssParsingError::LayoutMinHeight
1754);
1755impl_from!(
1756    LayoutMaxWidthParseError<'a>,
1757    CssParsingError::LayoutMaxWidth
1758);
1759impl_from!(
1760    LayoutMaxHeightParseError<'a>,
1761    CssParsingError::LayoutMaxHeight
1762);
1763
1764// Layout position
1765impl_from!(
1766    LayoutPositionParseError<'a>,
1767    CssParsingError::LayoutPosition
1768);
1769impl_from!(LayoutTopParseError<'a>, CssParsingError::LayoutTop);
1770impl_from!(LayoutRightParseError<'a>, CssParsingError::LayoutRight);
1771impl_from!(LayoutLeftParseError<'a>, CssParsingError::LayoutLeft);
1772impl_from!(
1773    LayoutInsetBottomParseError<'a>,
1774    CssParsingError::LayoutInsetBottom
1775);
1776impl_from!(LayoutZIndexParseError<'a>, CssParsingError::LayoutZIndex);
1777
1778// Layout flex
1779impl_from!(FlexWrapParseError<'a>, CssParsingError::FlexWrap);
1780impl_from!(FlexDirectionParseError<'a>, CssParsingError::FlexDirection);
1781impl_from!(FlexBasisParseError<'a>, CssParsingError::FlexBasis);
1782impl_from!(
1783    JustifyContentParseError<'a>,
1784    CssParsingError::JustifyContent
1785);
1786impl_from!(AlignItemsParseError<'a>, CssParsingError::AlignItems);
1787impl_from!(AlignContentParseError<'a>, CssParsingError::AlignContent);
1788
1789// Layout grid
1790impl_from!(GridParseError<'a>, CssParsingError::Grid);
1791impl_from!(GridAutoFlowParseError<'a>, CssParsingError::GridAutoFlow);
1792impl_from!(JustifySelfParseError<'a>, CssParsingError::JustifySelf);
1793impl_from!(JustifyItemsParseError<'a>, CssParsingError::JustifyItems);
1794// pixel value impl_from already exists earlier; avoid duplicate impl
1795// impl_from!(CssPixelValueParseError<'a>, CssParsingError::PixelValue);
1796impl_from!(AlignSelfParseError<'a>, CssParsingError::AlignSelf);
1797
1798// Layout wrapping
1799impl_from!(LayoutWrapParseError<'a>, CssParsingError::LayoutWrap);
1800impl_from!(
1801    LayoutWritingModeParseError<'a>,
1802    CssParsingError::LayoutWritingMode
1803);
1804impl_from!(LayoutClearParseError<'a>, CssParsingError::LayoutClear);
1805
1806// Layout overflow
1807impl_from!(
1808    LayoutOverflowParseError<'a>,
1809    CssParsingError::LayoutOverflow
1810);
1811
1812// Border radius individual corners
1813impl_from!(
1814    StyleBorderTopLeftRadiusParseError<'a>,
1815    CssParsingError::BorderTopLeftRadius
1816);
1817impl_from!(
1818    StyleBorderTopRightRadiusParseError<'a>,
1819    CssParsingError::BorderTopRightRadius
1820);
1821impl_from!(
1822    StyleBorderBottomLeftRadiusParseError<'a>,
1823    CssParsingError::BorderBottomLeftRadius
1824);
1825impl_from!(
1826    StyleBorderBottomRightRadiusParseError<'a>,
1827    CssParsingError::BorderBottomRightRadius
1828);
1829
1830// Border style
1831impl_from!(CssBorderStyleParseError<'a>, CssParsingError::BorderStyle);
1832
1833// Effects
1834impl_from!(
1835    CssBackfaceVisibilityParseError<'a>,
1836    CssParsingError::BackfaceVisibility
1837);
1838impl_from!(MixBlendModeParseError<'a>, CssParsingError::MixBlendMode);
1839
1840// Text/Style properties
1841impl_from!(StyleTextColorParseError<'a>, CssParsingError::TextColor);
1842impl_from!(CssStyleFontSizeParseError<'a>, CssParsingError::FontSize);
1843impl_from!(StyleTextAlignParseError<'a>, CssParsingError::TextAlign);
1844impl_from!(TextJustifyParseError<'a>, CssParsingError::TextJustify);
1845impl_from!(
1846    StyleLetterSpacingParseError<'a>,
1847    CssParsingError::LetterSpacing
1848);
1849impl_from!(StyleWordSpacingParseError<'a>, CssParsingError::WordSpacing);
1850impl_from!(StyleTabSizeParseError<'a>, CssParsingError::TabSize);
1851impl_from!(StyleWhiteSpaceParseError<'a>, CssParsingError::WhiteSpace);
1852impl_from!(StyleHyphensParseError<'a>, CssParsingError::Hyphens);
1853impl_from!(StyleDirectionParseError<'a>, CssParsingError::Direction);
1854impl_from!(StyleUserSelectParseError<'a>, CssParsingError::UserSelect);
1855impl_from!(
1856    StyleTextDecorationParseError<'a>,
1857    CssParsingError::TextDecoration
1858);
1859impl_from!(CursorParseError<'a>, CssParsingError::Cursor);
1860
1861// Layout basic properties
1862impl_from!(LayoutDisplayParseError<'a>, CssParsingError::LayoutDisplay);
1863impl_from!(LayoutFloatParseError<'a>, CssParsingError::LayoutFloat);
1864impl_from!(
1865    LayoutBoxSizingParseError<'a>,
1866    CssParsingError::LayoutBoxSizing
1867);
1868
1869// DTP properties
1870impl_from!(PageBreakParseError<'a>, CssParsingError::PageBreak);
1871impl_from!(BreakInsideParseError<'a>, CssParsingError::BreakInside);
1872impl_from!(WidowsParseError<'a>, CssParsingError::Widows);
1873impl_from!(OrphansParseError<'a>, CssParsingError::Orphans);
1874impl_from!(
1875    BoxDecorationBreakParseError<'a>,
1876    CssParsingError::BoxDecorationBreak
1877);
1878impl_from!(ColumnCountParseError<'a>, CssParsingError::ColumnCount);
1879impl_from!(ColumnWidthParseError<'a>, CssParsingError::ColumnWidth);
1880impl_from!(ColumnSpanParseError<'a>, CssParsingError::ColumnSpan);
1881impl_from!(ColumnFillParseError<'a>, CssParsingError::ColumnFill);
1882impl_from!(
1883    ColumnRuleWidthParseError<'a>,
1884    CssParsingError::ColumnRuleWidth
1885);
1886impl_from!(
1887    ColumnRuleStyleParseError<'a>,
1888    CssParsingError::ColumnRuleStyle
1889);
1890impl_from!(
1891    ColumnRuleColorParseError<'a>,
1892    CssParsingError::ColumnRuleColor
1893);
1894impl_from!(FlowIntoParseError<'a>, CssParsingError::FlowInto);
1895impl_from!(FlowFromParseError<'a>, CssParsingError::FlowFrom);
1896
1897impl<'a> From<InvalidValueErr<'a>> for CssParsingError<'a> {
1898    fn from(e: InvalidValueErr<'a>) -> Self {
1899        CssParsingError::InvalidValue(e)
1900    }
1901}
1902
1903impl<'a> From<PercentageParseError> for CssParsingError<'a> {
1904    fn from(e: PercentageParseError) -> Self {
1905        CssParsingError::Percentage(e)
1906    }
1907}
1908
1909impl<'a> From<StyleLineHeightParseError> for CssParsingError<'a> {
1910    fn from(e: StyleLineHeightParseError) -> Self {
1911        CssParsingError::LineHeight(e)
1912    }
1913}
1914
1915impl<'a> From<StyleTextIndentParseError<'a>> for CssParsingError<'a> {
1916    fn from(e: StyleTextIndentParseError<'a>) -> Self {
1917        CssParsingError::TextIndent(e)
1918    }
1919}
1920
1921impl<'a> From<StyleVerticalAlignParseError<'a>> for CssParsingError<'a> {
1922    fn from(e: StyleVerticalAlignParseError<'a>) -> Self {
1923        CssParsingError::VerticalAlign(e)
1924    }
1925}
1926
1927impl<'a> CssParsingError<'a> {
1928    pub fn to_contained(&self) -> CssParsingErrorOwned {
1929        match self {
1930            CssParsingError::CaretColor(e) => CssParsingErrorOwned::CaretColor(e.to_contained()),
1931            CssParsingError::CaretWidth(e) => CssParsingErrorOwned::CaretWidth(e.to_contained()),
1932            CssParsingError::CaretAnimationDuration(e) => {
1933                CssParsingErrorOwned::CaretAnimationDuration(e.to_contained())
1934            }
1935            CssParsingError::SelectionBackgroundColor(e) => {
1936                CssParsingErrorOwned::SelectionBackgroundColor(e.to_contained())
1937            }
1938            CssParsingError::SelectionColor(e) => {
1939                CssParsingErrorOwned::SelectionColor(e.to_contained())
1940            }
1941            CssParsingError::SelectionRadius(e) => {
1942                CssParsingErrorOwned::SelectionRadius(e.to_contained())
1943            }
1944            CssParsingError::Border(e) => CssParsingErrorOwned::Border(e.to_contained()),
1945            CssParsingError::BorderRadius(e) => {
1946                CssParsingErrorOwned::BorderRadius(e.to_contained())
1947            }
1948            CssParsingError::Padding(e) => CssParsingErrorOwned::Padding(e.to_contained()),
1949            CssParsingError::Margin(e) => CssParsingErrorOwned::Margin(e.to_contained()),
1950            CssParsingError::Overflow(e) => CssParsingErrorOwned::Overflow(e.to_contained()),
1951            CssParsingError::BoxShadow(e) => CssParsingErrorOwned::BoxShadow(e.to_contained()),
1952            CssParsingError::Color(e) => CssParsingErrorOwned::Color(e.to_contained()),
1953            CssParsingError::PixelValue(e) => CssParsingErrorOwned::PixelValue(e.to_contained()),
1954            CssParsingError::Percentage(e) => CssParsingErrorOwned::Percentage(e.clone()),
1955            CssParsingError::FontFamily(e) => CssParsingErrorOwned::FontFamily(e.to_contained()),
1956            CssParsingError::InvalidValue(e) => {
1957                CssParsingErrorOwned::InvalidValue(e.to_contained())
1958            }
1959            CssParsingError::FlexGrow(e) => CssParsingErrorOwned::FlexGrow(e.to_contained()),
1960            CssParsingError::FlexShrink(e) => CssParsingErrorOwned::FlexShrink(e.to_contained()),
1961            CssParsingError::Background(e) => CssParsingErrorOwned::Background(e.to_contained()),
1962            CssParsingError::BackgroundPosition(e) => {
1963                CssParsingErrorOwned::BackgroundPosition(e.to_contained())
1964            }
1965            CssParsingError::GridAutoFlow(e) => {
1966                CssParsingErrorOwned::GridAutoFlow(e.to_contained())
1967            }
1968            CssParsingError::JustifySelf(e) => CssParsingErrorOwned::JustifySelf(e.to_contained()),
1969            CssParsingError::JustifyItems(e) => {
1970                CssParsingErrorOwned::JustifyItems(e.to_contained())
1971            }
1972            CssParsingError::AlignSelf(e) => CssParsingErrorOwned::AlignSelf(e.to_contained()),
1973            CssParsingError::Opacity(e) => CssParsingErrorOwned::Opacity(e.to_contained()),
1974            CssParsingError::Visibility(e) => CssParsingErrorOwned::Visibility(e.to_contained()),
1975            CssParsingError::Scrollbar(e) => CssParsingErrorOwned::Scrollbar(e.to_contained()),
1976            CssParsingError::LayoutScrollbarWidth(e) => {
1977                CssParsingErrorOwned::LayoutScrollbarWidth(e.to_contained())
1978            }
1979            CssParsingError::StyleScrollbarColor(e) => {
1980                CssParsingErrorOwned::StyleScrollbarColor(e.to_contained())
1981            }
1982            CssParsingError::Transform(e) => CssParsingErrorOwned::Transform(e.to_contained()),
1983            CssParsingError::TransformOrigin(e) => {
1984                CssParsingErrorOwned::TransformOrigin(e.to_contained())
1985            }
1986            CssParsingError::PerspectiveOrigin(e) => {
1987                CssParsingErrorOwned::PerspectiveOrigin(e.to_contained())
1988            }
1989            CssParsingError::Filter(e) => CssParsingErrorOwned::Filter(e.to_contained()),
1990            CssParsingError::LayoutWidth(e) => CssParsingErrorOwned::LayoutWidth(e.to_contained()),
1991            CssParsingError::LayoutHeight(e) => {
1992                CssParsingErrorOwned::LayoutHeight(e.to_contained())
1993            }
1994            CssParsingError::LayoutMinWidth(e) => {
1995                CssParsingErrorOwned::LayoutMinWidth(e.to_contained())
1996            }
1997            CssParsingError::LayoutMinHeight(e) => {
1998                CssParsingErrorOwned::LayoutMinHeight(e.to_contained())
1999            }
2000            CssParsingError::LayoutMaxWidth(e) => {
2001                CssParsingErrorOwned::LayoutMaxWidth(e.to_contained())
2002            }
2003            CssParsingError::LayoutMaxHeight(e) => {
2004                CssParsingErrorOwned::LayoutMaxHeight(e.to_contained())
2005            }
2006            CssParsingError::LayoutPosition(e) => {
2007                CssParsingErrorOwned::LayoutPosition(e.to_contained())
2008            }
2009            CssParsingError::LayoutTop(e) => CssParsingErrorOwned::LayoutTop(e.to_contained()),
2010            CssParsingError::LayoutRight(e) => CssParsingErrorOwned::LayoutRight(e.to_contained()),
2011            CssParsingError::LayoutLeft(e) => CssParsingErrorOwned::LayoutLeft(e.to_contained()),
2012            CssParsingError::LayoutInsetBottom(e) => {
2013                CssParsingErrorOwned::LayoutInsetBottom(e.to_contained())
2014            }
2015            CssParsingError::LayoutZIndex(e) => {
2016                CssParsingErrorOwned::LayoutZIndex(e.to_contained())
2017            }
2018            CssParsingError::FlexWrap(e) => CssParsingErrorOwned::FlexWrap(e.to_contained()),
2019            CssParsingError::FlexDirection(e) => {
2020                CssParsingErrorOwned::FlexDirection(e.to_contained())
2021            }
2022            CssParsingError::FlexBasis(e) => CssParsingErrorOwned::FlexBasis(e.to_contained()),
2023            CssParsingError::JustifyContent(e) => {
2024                CssParsingErrorOwned::JustifyContent(e.to_contained())
2025            }
2026            CssParsingError::AlignItems(e) => CssParsingErrorOwned::AlignItems(e.to_contained()),
2027            CssParsingError::AlignContent(e) => {
2028                CssParsingErrorOwned::AlignContent(e.to_contained())
2029            }
2030            CssParsingError::Grid(e) => CssParsingErrorOwned::Grid(e.to_contained()),
2031            CssParsingError::LayoutWrap(e) => CssParsingErrorOwned::LayoutWrap(e.to_contained()),
2032            CssParsingError::LayoutWritingMode(e) => {
2033                CssParsingErrorOwned::LayoutWritingMode(e.to_contained())
2034            }
2035            CssParsingError::LayoutClear(e) => CssParsingErrorOwned::LayoutClear(e.to_contained()),
2036            CssParsingError::LayoutOverflow(e) => {
2037                CssParsingErrorOwned::LayoutOverflow(e.to_contained())
2038            }
2039            CssParsingError::BorderTopLeftRadius(e) => {
2040                CssParsingErrorOwned::BorderTopLeftRadius(e.to_contained())
2041            }
2042            CssParsingError::BorderTopRightRadius(e) => {
2043                CssParsingErrorOwned::BorderTopRightRadius(e.to_contained())
2044            }
2045            CssParsingError::BorderBottomLeftRadius(e) => {
2046                CssParsingErrorOwned::BorderBottomLeftRadius(e.to_contained())
2047            }
2048            CssParsingError::BorderBottomRightRadius(e) => {
2049                CssParsingErrorOwned::BorderBottomRightRadius(e.to_contained())
2050            }
2051            CssParsingError::BorderStyle(e) => CssParsingErrorOwned::BorderStyle(e.to_contained()),
2052            CssParsingError::BackfaceVisibility(e) => {
2053                CssParsingErrorOwned::BackfaceVisibility(e.to_contained())
2054            }
2055            CssParsingError::MixBlendMode(e) => {
2056                CssParsingErrorOwned::MixBlendMode(e.to_contained())
2057            }
2058            CssParsingError::TextColor(e) => CssParsingErrorOwned::TextColor(e.to_contained()),
2059            CssParsingError::FontSize(e) => CssParsingErrorOwned::FontSize(e.to_contained()),
2060            CssParsingError::TextAlign(e) => CssParsingErrorOwned::TextAlign(e.to_contained()),
2061            CssParsingError::TextJustify(e) => CssParsingErrorOwned::TextJustify(e.to_owned()),
2062            CssParsingError::VerticalAlign(e) => {
2063                CssParsingErrorOwned::VerticalAlign(e.to_contained())
2064            }
2065            CssParsingError::LetterSpacing(e) => {
2066                CssParsingErrorOwned::LetterSpacing(e.to_contained())
2067            }
2068            CssParsingError::TextIndent(e) => CssParsingErrorOwned::TextIndent(e.to_contained()),
2069            CssParsingError::InitialLetter(e) => {
2070                CssParsingErrorOwned::InitialLetter(e.to_contained())
2071            }
2072            CssParsingError::LineClamp(e) => CssParsingErrorOwned::LineClamp(e.to_contained()),
2073            CssParsingError::HangingPunctuation(e) => {
2074                CssParsingErrorOwned::HangingPunctuation(e.to_contained())
2075            }
2076            CssParsingError::TextCombineUpright(e) => {
2077                CssParsingErrorOwned::TextCombineUpright(e.to_contained())
2078            }
2079            CssParsingError::ExclusionMargin(e) => {
2080                CssParsingErrorOwned::ExclusionMargin(e.to_contained())
2081            }
2082            CssParsingError::HyphenationLanguage(e) => {
2083                CssParsingErrorOwned::HyphenationLanguage(e.to_contained())
2084            }
2085            CssParsingError::LineHeight(e) => CssParsingErrorOwned::LineHeight(e.clone()),
2086            CssParsingError::WordSpacing(e) => CssParsingErrorOwned::WordSpacing(e.to_contained()),
2087            CssParsingError::TabSize(e) => CssParsingErrorOwned::TabSize(e.to_contained()),
2088            CssParsingError::WhiteSpace(e) => CssParsingErrorOwned::WhiteSpace(e.to_contained()),
2089            CssParsingError::Hyphens(e) => CssParsingErrorOwned::Hyphens(e.to_contained()),
2090            CssParsingError::Direction(e) => CssParsingErrorOwned::Direction(e.to_contained()),
2091            CssParsingError::UserSelect(e) => CssParsingErrorOwned::UserSelect(e.to_contained()),
2092            CssParsingError::TextDecoration(e) => {
2093                CssParsingErrorOwned::TextDecoration(e.to_contained())
2094            }
2095            CssParsingError::Cursor(e) => CssParsingErrorOwned::Cursor(e.to_contained()),
2096            CssParsingError::LayoutDisplay(e) => {
2097                CssParsingErrorOwned::LayoutDisplay(e.to_contained())
2098            }
2099            CssParsingError::LayoutFloat(e) => CssParsingErrorOwned::LayoutFloat(e.to_contained()),
2100            CssParsingError::LayoutBoxSizing(e) => {
2101                CssParsingErrorOwned::LayoutBoxSizing(e.to_contained())
2102            }
2103            // DTP properties...
2104            CssParsingError::PageBreak(e) => CssParsingErrorOwned::PageBreak(e.to_contained()),
2105            CssParsingError::BreakInside(e) => CssParsingErrorOwned::BreakInside(e.to_contained()),
2106            CssParsingError::Widows(e) => CssParsingErrorOwned::Widows(e.to_contained()),
2107            CssParsingError::Orphans(e) => CssParsingErrorOwned::Orphans(e.to_contained()),
2108            CssParsingError::BoxDecorationBreak(e) => {
2109                CssParsingErrorOwned::BoxDecorationBreak(e.to_contained())
2110            }
2111            CssParsingError::ColumnCount(e) => CssParsingErrorOwned::ColumnCount(e.to_contained()),
2112            CssParsingError::ColumnWidth(e) => CssParsingErrorOwned::ColumnWidth(e.to_contained()),
2113            CssParsingError::ColumnSpan(e) => CssParsingErrorOwned::ColumnSpan(e.to_contained()),
2114            CssParsingError::ColumnFill(e) => CssParsingErrorOwned::ColumnFill(e.to_contained()),
2115            CssParsingError::ColumnRuleWidth(e) => {
2116                CssParsingErrorOwned::ColumnRuleWidth(e.to_contained())
2117            }
2118            CssParsingError::ColumnRuleStyle(e) => {
2119                CssParsingErrorOwned::ColumnRuleStyle(e.to_contained())
2120            }
2121            CssParsingError::ColumnRuleColor(e) => {
2122                CssParsingErrorOwned::ColumnRuleColor(e.to_contained())
2123            }
2124            CssParsingError::FlowInto(e) => CssParsingErrorOwned::FlowInto(e.to_contained()),
2125            CssParsingError::FlowFrom(e) => CssParsingErrorOwned::FlowFrom(e.to_contained()),
2126            CssParsingError::GenericParseError => CssParsingErrorOwned::GenericParseError,
2127            CssParsingError::Content => CssParsingErrorOwned::Content,
2128            CssParsingError::Counter => CssParsingErrorOwned::Counter,
2129            CssParsingError::ListStyleType(e) => {
2130                CssParsingErrorOwned::ListStyleType(e.to_contained())
2131            }
2132            CssParsingError::ListStylePosition(e) => {
2133                CssParsingErrorOwned::ListStylePosition(e.to_contained())
2134            }
2135            CssParsingError::StringSet => CssParsingErrorOwned::StringSet,
2136            CssParsingError::FontWeight(e) => CssParsingErrorOwned::FontWeight(e.to_contained()),
2137            CssParsingError::FontStyle(e) => CssParsingErrorOwned::FontStyle(e.to_contained()),
2138        }
2139    }
2140}
2141
2142impl CssParsingErrorOwned {
2143    pub fn to_shared<'a>(&'a self) -> CssParsingError<'a> {
2144        match self {
2145            CssParsingErrorOwned::CaretColor(e) => CssParsingError::CaretColor(e.to_shared()),
2146            CssParsingErrorOwned::CaretWidth(e) => CssParsingError::CaretWidth(e.to_shared()),
2147            CssParsingErrorOwned::CaretAnimationDuration(e) => {
2148                CssParsingError::CaretAnimationDuration(e.to_shared())
2149            }
2150            CssParsingErrorOwned::SelectionBackgroundColor(e) => {
2151                CssParsingError::SelectionBackgroundColor(e.to_shared())
2152            }
2153            CssParsingErrorOwned::SelectionColor(e) => {
2154                CssParsingError::SelectionColor(e.to_shared())
2155            }
2156            CssParsingErrorOwned::SelectionRadius(e) => {
2157                CssParsingError::SelectionRadius(e.to_shared())
2158            }
2159            CssParsingErrorOwned::Border(e) => CssParsingError::Border(e.to_shared()),
2160            CssParsingErrorOwned::BorderRadius(e) => CssParsingError::BorderRadius(e.to_shared()),
2161            CssParsingErrorOwned::Padding(e) => CssParsingError::Padding(e.to_shared()),
2162            CssParsingErrorOwned::Margin(e) => CssParsingError::Margin(e.to_shared()),
2163            CssParsingErrorOwned::Overflow(e) => CssParsingError::Overflow(e.to_shared()),
2164            CssParsingErrorOwned::BoxShadow(e) => CssParsingError::BoxShadow(e.to_shared()),
2165            CssParsingErrorOwned::Color(e) => CssParsingError::Color(e.to_shared()),
2166            CssParsingErrorOwned::PixelValue(e) => CssParsingError::PixelValue(e.to_shared()),
2167            CssParsingErrorOwned::Percentage(e) => CssParsingError::Percentage(e.clone()),
2168            CssParsingErrorOwned::FontFamily(e) => CssParsingError::FontFamily(e.to_shared()),
2169            CssParsingErrorOwned::InvalidValue(e) => CssParsingError::InvalidValue(e.to_shared()),
2170            CssParsingErrorOwned::FlexGrow(e) => CssParsingError::FlexGrow(e.to_shared()),
2171            CssParsingErrorOwned::FlexShrink(e) => CssParsingError::FlexShrink(e.to_shared()),
2172            CssParsingErrorOwned::Background(e) => CssParsingError::Background(e.to_shared()),
2173            CssParsingErrorOwned::BackgroundPosition(e) => {
2174                CssParsingError::BackgroundPosition(e.to_shared())
2175            }
2176            CssParsingErrorOwned::Opacity(e) => CssParsingError::Opacity(e.to_shared()),
2177            CssParsingErrorOwned::Visibility(e) => CssParsingError::Visibility(e.to_shared()),
2178            CssParsingErrorOwned::Scrollbar(e) => CssParsingError::Scrollbar(e.to_shared()),
2179            CssParsingErrorOwned::LayoutScrollbarWidth(e) => {
2180                CssParsingError::LayoutScrollbarWidth(e.to_shared())
2181            }
2182            CssParsingErrorOwned::StyleScrollbarColor(e) => {
2183                CssParsingError::StyleScrollbarColor(e.to_shared())
2184            }
2185            CssParsingErrorOwned::Transform(e) => CssParsingError::Transform(e.to_shared()),
2186            CssParsingErrorOwned::TransformOrigin(e) => {
2187                CssParsingError::TransformOrigin(e.to_shared())
2188            }
2189            CssParsingErrorOwned::PerspectiveOrigin(e) => {
2190                CssParsingError::PerspectiveOrigin(e.to_shared())
2191            }
2192            CssParsingErrorOwned::Filter(e) => CssParsingError::Filter(e.to_shared()),
2193            CssParsingErrorOwned::LayoutWidth(e) => CssParsingError::LayoutWidth(e.to_shared()),
2194            CssParsingErrorOwned::LayoutHeight(e) => CssParsingError::LayoutHeight(e.to_shared()),
2195            CssParsingErrorOwned::LayoutMinWidth(e) => {
2196                CssParsingError::LayoutMinWidth(e.to_shared())
2197            }
2198            CssParsingErrorOwned::LayoutMinHeight(e) => {
2199                CssParsingError::LayoutMinHeight(e.to_shared())
2200            }
2201            CssParsingErrorOwned::LayoutMaxWidth(e) => {
2202                CssParsingError::LayoutMaxWidth(e.to_shared())
2203            }
2204            CssParsingErrorOwned::LayoutMaxHeight(e) => {
2205                CssParsingError::LayoutMaxHeight(e.to_shared())
2206            }
2207            CssParsingErrorOwned::LayoutPosition(e) => {
2208                CssParsingError::LayoutPosition(e.to_shared())
2209            }
2210            CssParsingErrorOwned::LayoutTop(e) => CssParsingError::LayoutTop(e.to_shared()),
2211            CssParsingErrorOwned::LayoutRight(e) => CssParsingError::LayoutRight(e.to_shared()),
2212            CssParsingErrorOwned::LayoutLeft(e) => CssParsingError::LayoutLeft(e.to_shared()),
2213            CssParsingErrorOwned::LayoutInsetBottom(e) => {
2214                CssParsingError::LayoutInsetBottom(e.to_shared())
2215            }
2216            CssParsingErrorOwned::LayoutZIndex(e) => CssParsingError::LayoutZIndex(e.to_shared()),
2217            CssParsingErrorOwned::FlexWrap(e) => CssParsingError::FlexWrap(e.to_shared()),
2218            CssParsingErrorOwned::FlexDirection(e) => CssParsingError::FlexDirection(e.to_shared()),
2219            CssParsingErrorOwned::FlexBasis(e) => CssParsingError::FlexBasis(e.to_shared()),
2220            CssParsingErrorOwned::JustifyContent(e) => {
2221                CssParsingError::JustifyContent(e.to_shared())
2222            }
2223            CssParsingErrorOwned::AlignItems(e) => CssParsingError::AlignItems(e.to_shared()),
2224            CssParsingErrorOwned::AlignContent(e) => CssParsingError::AlignContent(e.to_shared()),
2225            CssParsingErrorOwned::Grid(e) => CssParsingError::Grid(e.to_shared()),
2226            CssParsingErrorOwned::GridAutoFlow(e) => CssParsingError::GridAutoFlow(e.to_shared()),
2227            CssParsingErrorOwned::JustifySelf(e) => CssParsingError::JustifySelf(e.to_shared()),
2228            CssParsingErrorOwned::JustifyItems(e) => CssParsingError::JustifyItems(e.to_shared()),
2229            CssParsingErrorOwned::AlignSelf(e) => CssParsingError::AlignSelf(e.to_shared()),
2230            CssParsingErrorOwned::LayoutWrap(e) => CssParsingError::LayoutWrap(e.to_shared()),
2231            CssParsingErrorOwned::LayoutWritingMode(e) => {
2232                CssParsingError::LayoutWritingMode(e.to_shared())
2233            }
2234            CssParsingErrorOwned::LayoutClear(e) => CssParsingError::LayoutClear(e.to_shared()),
2235            CssParsingErrorOwned::LayoutOverflow(e) => {
2236                CssParsingError::LayoutOverflow(e.to_shared())
2237            }
2238            CssParsingErrorOwned::BorderTopLeftRadius(e) => {
2239                CssParsingError::BorderTopLeftRadius(e.to_shared())
2240            }
2241            CssParsingErrorOwned::BorderTopRightRadius(e) => {
2242                CssParsingError::BorderTopRightRadius(e.to_shared())
2243            }
2244            CssParsingErrorOwned::BorderBottomLeftRadius(e) => {
2245                CssParsingError::BorderBottomLeftRadius(e.to_shared())
2246            }
2247            CssParsingErrorOwned::BorderBottomRightRadius(e) => {
2248                CssParsingError::BorderBottomRightRadius(e.to_shared())
2249            }
2250            CssParsingErrorOwned::BorderStyle(e) => CssParsingError::BorderStyle(e.to_shared()),
2251            CssParsingErrorOwned::BackfaceVisibility(e) => {
2252                CssParsingError::BackfaceVisibility(e.to_shared())
2253            }
2254            CssParsingErrorOwned::MixBlendMode(e) => CssParsingError::MixBlendMode(e.to_shared()),
2255            CssParsingErrorOwned::TextColor(e) => CssParsingError::TextColor(e.to_shared()),
2256            CssParsingErrorOwned::FontSize(e) => CssParsingError::FontSize(e.to_shared()),
2257            CssParsingErrorOwned::TextAlign(e) => CssParsingError::TextAlign(e.to_shared()),
2258            CssParsingErrorOwned::TextJustify(e) => CssParsingError::TextJustify(e.to_borrowed()),
2259            CssParsingErrorOwned::LetterSpacing(e) => CssParsingError::LetterSpacing(e.to_shared()),
2260            CssParsingErrorOwned::TextIndent(e) => CssParsingError::TextIndent(e.to_shared()),
2261            CssParsingErrorOwned::InitialLetter(e) => CssParsingError::InitialLetter(e.to_shared()),
2262            CssParsingErrorOwned::LineClamp(e) => CssParsingError::LineClamp(e.to_shared()),
2263            CssParsingErrorOwned::HangingPunctuation(e) => {
2264                CssParsingError::HangingPunctuation(e.to_shared())
2265            }
2266            CssParsingErrorOwned::TextCombineUpright(e) => {
2267                CssParsingError::TextCombineUpright(e.to_shared())
2268            }
2269            CssParsingErrorOwned::ExclusionMargin(e) => {
2270                CssParsingError::ExclusionMargin(e.to_shared())
2271            }
2272            CssParsingErrorOwned::HyphenationLanguage(e) => {
2273                CssParsingError::HyphenationLanguage(e.to_shared())
2274            }
2275            CssParsingErrorOwned::LineHeight(e) => CssParsingError::LineHeight(e.clone()),
2276            CssParsingErrorOwned::WordSpacing(e) => CssParsingError::WordSpacing(e.to_shared()),
2277            CssParsingErrorOwned::TabSize(e) => CssParsingError::TabSize(e.to_shared()),
2278            CssParsingErrorOwned::WhiteSpace(e) => CssParsingError::WhiteSpace(e.to_shared()),
2279            CssParsingErrorOwned::Hyphens(e) => CssParsingError::Hyphens(e.to_shared()),
2280            CssParsingErrorOwned::Direction(e) => CssParsingError::Direction(e.to_shared()),
2281            CssParsingErrorOwned::UserSelect(e) => CssParsingError::UserSelect(e.to_shared()),
2282            CssParsingErrorOwned::TextDecoration(e) => {
2283                CssParsingError::TextDecoration(e.to_shared())
2284            }
2285            CssParsingErrorOwned::Cursor(e) => CssParsingError::Cursor(e.to_shared()),
2286            CssParsingErrorOwned::LayoutDisplay(e) => CssParsingError::LayoutDisplay(e.to_shared()),
2287            CssParsingErrorOwned::LayoutFloat(e) => CssParsingError::LayoutFloat(e.to_shared()),
2288            CssParsingErrorOwned::LayoutBoxSizing(e) => {
2289                CssParsingError::LayoutBoxSizing(e.to_shared())
2290            }
2291            // DTP properties...
2292            CssParsingErrorOwned::PageBreak(e) => CssParsingError::PageBreak(e.to_shared()),
2293            CssParsingErrorOwned::BreakInside(e) => CssParsingError::BreakInside(e.to_shared()),
2294            CssParsingErrorOwned::Widows(e) => CssParsingError::Widows(e.to_shared()),
2295            CssParsingErrorOwned::Orphans(e) => CssParsingError::Orphans(e.to_shared()),
2296            CssParsingErrorOwned::BoxDecorationBreak(e) => {
2297                CssParsingError::BoxDecorationBreak(e.to_shared())
2298            }
2299            CssParsingErrorOwned::ColumnCount(e) => CssParsingError::ColumnCount(e.to_shared()),
2300            CssParsingErrorOwned::ColumnWidth(e) => CssParsingError::ColumnWidth(e.to_shared()),
2301            CssParsingErrorOwned::ColumnSpan(e) => CssParsingError::ColumnSpan(e.to_shared()),
2302            CssParsingErrorOwned::ColumnFill(e) => CssParsingError::ColumnFill(e.to_shared()),
2303            CssParsingErrorOwned::ColumnRuleWidth(e) => {
2304                CssParsingError::ColumnRuleWidth(e.to_shared())
2305            }
2306            CssParsingErrorOwned::ColumnRuleStyle(e) => {
2307                CssParsingError::ColumnRuleStyle(e.to_shared())
2308            }
2309            CssParsingErrorOwned::ColumnRuleColor(e) => {
2310                CssParsingError::ColumnRuleColor(e.to_shared())
2311            }
2312            CssParsingErrorOwned::FlowInto(e) => CssParsingError::FlowInto(e.to_shared()),
2313            CssParsingErrorOwned::FlowFrom(e) => CssParsingError::FlowFrom(e.to_shared()),
2314            CssParsingErrorOwned::GenericParseError => CssParsingError::GenericParseError,
2315            CssParsingErrorOwned::Content => CssParsingError::Content,
2316            CssParsingErrorOwned::Counter => CssParsingError::Counter,
2317            CssParsingErrorOwned::ListStyleType(e) => CssParsingError::ListStyleType(e.to_shared()),
2318            CssParsingErrorOwned::ListStylePosition(e) => {
2319                CssParsingError::ListStylePosition(e.to_shared())
2320            }
2321            CssParsingErrorOwned::StringSet => CssParsingError::StringSet,
2322            CssParsingErrorOwned::FontWeight(e) => CssParsingError::FontWeight(e.to_shared()),
2323            CssParsingErrorOwned::FontStyle(e) => CssParsingError::FontStyle(e.to_shared()),
2324            CssParsingErrorOwned::VerticalAlign(e) => CssParsingError::VerticalAlign(e.to_shared()),
2325        }
2326    }
2327}
2328
2329#[cfg(feature = "parser")]
2330pub fn parse_css_property<'a>(
2331    key: CssPropertyType,
2332    value: &'a str,
2333) -> Result<CssProperty, CssParsingError<'a>> {
2334    use crate::props::style::{
2335        parse_selection_background_color, parse_selection_color, parse_selection_radius,
2336    };
2337
2338    let value = value.trim();
2339
2340    // For properties where "auto" or "none" is a valid typed value (not just the generic CSS
2341    // keyword), we must NOT intercept them here. Let the specific parser handle them.
2342    let has_typed_auto = matches!(
2343        key,
2344        CssPropertyType::Hyphens |      // hyphens: auto means StyleHyphens::Auto
2345        CssPropertyType::OverflowX |
2346        CssPropertyType::OverflowY |
2347        CssPropertyType::UserSelect // user-select: auto is a typed value
2348    );
2349
2350    let has_typed_none = matches!(
2351        key,
2352        CssPropertyType::Hyphens |      // hyphens: none means StyleHyphens::None
2353        CssPropertyType::Display |      // display: none means LayoutDisplay::None
2354        CssPropertyType::UserSelect |
2355        CssPropertyType::Float |        // float: none means LayoutFloat::None
2356        CssPropertyType::TextDecoration // text-decoration: none is a typed value
2357    );
2358
2359    Ok(match value {
2360        "auto" if !has_typed_auto => CssProperty::auto(key),
2361        "none" if !has_typed_none => CssProperty::none(key),
2362        "initial" => CssProperty::initial(key),
2363        "inherit" => CssProperty::inherit(key),
2364        value => match key {
2365            CssPropertyType::CaretColor => parse_caret_color(value)?.into(),
2366            CssPropertyType::CaretWidth => parse_caret_width(value)?.into(),
2367            CssPropertyType::CaretAnimationDuration => {
2368                parse_caret_animation_duration(value)?.into()
2369            }
2370            CssPropertyType::SelectionBackgroundColor => {
2371                parse_selection_background_color(value)?.into()
2372            }
2373            CssPropertyType::SelectionColor => parse_selection_color(value)?.into(),
2374            CssPropertyType::SelectionRadius => parse_selection_radius(value)?.into(),
2375
2376            CssPropertyType::TextColor => parse_style_text_color(value)?.into(),
2377            CssPropertyType::FontSize => {
2378                CssProperty::FontSize(parse_style_font_size(value)?.into())
2379            }
2380            CssPropertyType::FontFamily => parse_style_font_family(value)?.into(),
2381            CssPropertyType::FontWeight => {
2382                CssProperty::FontWeight(parse_font_weight(value)?.into())
2383            }
2384            CssPropertyType::FontStyle => CssProperty::FontStyle(parse_font_style(value)?.into()),
2385            CssPropertyType::TextAlign => parse_style_text_align(value)?.into(),
2386            CssPropertyType::TextJustify => parse_layout_text_justify(value)?.into(),
2387            CssPropertyType::VerticalAlign => parse_style_vertical_align(value)?.into(),
2388            CssPropertyType::LetterSpacing => parse_style_letter_spacing(value)?.into(),
2389            CssPropertyType::TextIndent => parse_style_text_indent(value)?.into(),
2390            CssPropertyType::InitialLetter => parse_style_initial_letter(value)?.into(),
2391            CssPropertyType::LineClamp => parse_style_line_clamp(value)?.into(),
2392            CssPropertyType::HangingPunctuation => parse_style_hanging_punctuation(value)?.into(),
2393            CssPropertyType::TextCombineUpright => parse_style_text_combine_upright(value)?.into(),
2394            CssPropertyType::ExclusionMargin => parse_style_exclusion_margin(value)?.into(),
2395            CssPropertyType::HyphenationLanguage => parse_style_hyphenation_language(value)?.into(),
2396            CssPropertyType::LineHeight => parse_style_line_height(value)?.into(),
2397            CssPropertyType::WordSpacing => parse_style_word_spacing(value)?.into(),
2398            CssPropertyType::TabSize => parse_style_tab_size(value)?.into(),
2399            CssPropertyType::WhiteSpace => parse_style_white_space(value)?.into(),
2400            CssPropertyType::Hyphens => parse_style_hyphens(value)?.into(),
2401            CssPropertyType::Direction => parse_style_direction(value)?.into(),
2402            CssPropertyType::UserSelect => parse_style_user_select(value)?.into(),
2403            CssPropertyType::TextDecoration => parse_style_text_decoration(value)?.into(),
2404            CssPropertyType::Cursor => parse_style_cursor(value)?.into(),
2405
2406            CssPropertyType::Display => parse_layout_display(value)?.into(),
2407            CssPropertyType::Float => parse_layout_float(value)?.into(),
2408            CssPropertyType::BoxSizing => parse_layout_box_sizing(value)?.into(),
2409            CssPropertyType::Width => parse_layout_width(value)?.into(),
2410            CssPropertyType::Height => parse_layout_height(value)?.into(),
2411            CssPropertyType::MinWidth => parse_layout_min_width(value)?.into(),
2412            CssPropertyType::MinHeight => parse_layout_min_height(value)?.into(),
2413            CssPropertyType::MaxWidth => parse_layout_max_width(value)?.into(),
2414            CssPropertyType::MaxHeight => parse_layout_max_height(value)?.into(),
2415            CssPropertyType::Position => parse_layout_position(value)?.into(),
2416            CssPropertyType::Top => parse_layout_top(value)?.into(),
2417            CssPropertyType::Right => parse_layout_right(value)?.into(),
2418            CssPropertyType::Left => parse_layout_left(value)?.into(),
2419            CssPropertyType::Bottom => parse_layout_bottom(value)?.into(),
2420            CssPropertyType::ZIndex => CssProperty::ZIndex(parse_layout_z_index(value)?.into()),
2421
2422            CssPropertyType::FlexWrap => parse_layout_flex_wrap(value)?.into(),
2423            CssPropertyType::FlexDirection => parse_layout_flex_direction(value)?.into(),
2424            CssPropertyType::FlexGrow => parse_layout_flex_grow(value)?.into(),
2425            CssPropertyType::FlexShrink => parse_layout_flex_shrink(value)?.into(),
2426            CssPropertyType::FlexBasis => parse_layout_flex_basis(value)?.into(),
2427            CssPropertyType::JustifyContent => parse_layout_justify_content(value)?.into(),
2428            CssPropertyType::AlignItems => parse_layout_align_items(value)?.into(),
2429            CssPropertyType::AlignContent => parse_layout_align_content(value)?.into(),
2430            CssPropertyType::ColumnGap => parse_layout_column_gap(value)?.into(),
2431            CssPropertyType::RowGap => parse_layout_row_gap(value)?.into(),
2432            CssPropertyType::GridTemplateColumns => {
2433                CssProperty::GridTemplateColumns(parse_grid_template(value)?.into())
2434            }
2435            CssPropertyType::GridTemplateRows => {
2436                CssProperty::GridTemplateRows(parse_grid_template(value)?.into())
2437            }
2438            CssPropertyType::GridAutoColumns => {
2439                let template = parse_grid_template(value)?;
2440                CssProperty::GridAutoColumns(CssPropertyValue::Exact(GridAutoTracks::from(
2441                    template,
2442                )))
2443            }
2444            CssPropertyType::GridAutoFlow => {
2445                CssProperty::GridAutoFlow(parse_layout_grid_auto_flow(value)?.into())
2446            }
2447            CssPropertyType::JustifySelf => {
2448                CssProperty::JustifySelf(parse_layout_justify_self(value)?.into())
2449            }
2450            CssPropertyType::JustifyItems => {
2451                CssProperty::JustifyItems(parse_layout_justify_items(value)?.into())
2452            }
2453            CssPropertyType::Gap => {
2454                // gap shorthand: single value -> both row & column
2455                CssProperty::Gap(parse_layout_gap(value)?.into())
2456            }
2457            CssPropertyType::GridGap => CssProperty::GridGap(parse_layout_gap(value)?.into()),
2458            CssPropertyType::AlignSelf => {
2459                CssProperty::AlignSelf(parse_layout_align_self(value)?.into())
2460            }
2461            CssPropertyType::Font => {
2462                // minimal font parser: map to font-family for now
2463                let fam = parse_style_font_family(value)?;
2464                CssProperty::Font(fam.into())
2465            }
2466            CssPropertyType::GridAutoRows => {
2467                let template = parse_grid_template(value)?;
2468                CssProperty::GridAutoRows(CssPropertyValue::Exact(GridAutoTracks::from(template)))
2469            }
2470            CssPropertyType::GridColumn => {
2471                CssProperty::GridColumn(parse_grid_placement(value)?.into())
2472            }
2473            CssPropertyType::GridRow => CssProperty::GridRow(parse_grid_placement(value)?.into()),
2474            CssPropertyType::GridTemplateAreas => {
2475                use crate::props::layout::grid::parse_grid_template_areas;
2476                let areas = parse_grid_template_areas(value)
2477                    .map_err(|_| CssParsingError::InvalidValue(InvalidValueErr(value)))?;
2478                CssProperty::GridTemplateAreas(CssPropertyValue::Exact(areas))
2479            }
2480            CssPropertyType::WritingMode => parse_layout_writing_mode(value)?.into(),
2481            CssPropertyType::Clear => parse_layout_clear(value)?.into(),
2482
2483            CssPropertyType::BackgroundContent => {
2484                parse_style_background_content_multiple(value)?.into()
2485            }
2486            CssPropertyType::BackgroundPosition => {
2487                parse_style_background_position_multiple(value)?.into()
2488            }
2489            CssPropertyType::BackgroundSize => parse_style_background_size_multiple(value)?.into(),
2490            CssPropertyType::BackgroundRepeat => {
2491                parse_style_background_repeat_multiple(value)?.into()
2492            }
2493
2494            CssPropertyType::OverflowX => {
2495                CssProperty::OverflowX(parse_layout_overflow(value)?.into())
2496            }
2497            CssPropertyType::OverflowY => {
2498                CssProperty::OverflowY(parse_layout_overflow(value)?.into())
2499            }
2500
2501            CssPropertyType::PaddingTop => parse_layout_padding_top(value)?.into(),
2502            CssPropertyType::PaddingLeft => parse_layout_padding_left(value)?.into(),
2503            CssPropertyType::PaddingRight => parse_layout_padding_right(value)?.into(),
2504            CssPropertyType::PaddingBottom => parse_layout_padding_bottom(value)?.into(),
2505            CssPropertyType::PaddingInlineStart => parse_layout_padding_inline_start(value)?.into(),
2506            CssPropertyType::PaddingInlineEnd => parse_layout_padding_inline_end(value)?.into(),
2507
2508            CssPropertyType::MarginTop => parse_layout_margin_top(value)?.into(),
2509            CssPropertyType::MarginLeft => parse_layout_margin_left(value)?.into(),
2510            CssPropertyType::MarginRight => parse_layout_margin_right(value)?.into(),
2511            CssPropertyType::MarginBottom => parse_layout_margin_bottom(value)?.into(),
2512
2513            CssPropertyType::BorderTopLeftRadius => {
2514                parse_style_border_top_left_radius(value)?.into()
2515            }
2516            CssPropertyType::BorderTopRightRadius => {
2517                parse_style_border_top_right_radius(value)?.into()
2518            }
2519            CssPropertyType::BorderBottomLeftRadius => {
2520                parse_style_border_bottom_left_radius(value)?.into()
2521            }
2522            CssPropertyType::BorderBottomRightRadius => {
2523                parse_style_border_bottom_right_radius(value)?.into()
2524            }
2525
2526            CssPropertyType::BorderTopColor => parse_border_top_color(value)?.into(),
2527            CssPropertyType::BorderRightColor => parse_border_right_color(value)?.into(),
2528            CssPropertyType::BorderLeftColor => parse_border_left_color(value)?.into(),
2529            CssPropertyType::BorderBottomColor => parse_border_bottom_color(value)?.into(),
2530
2531            CssPropertyType::BorderTopStyle => parse_border_top_style(value)?.into(),
2532            CssPropertyType::BorderRightStyle => parse_border_right_style(value)?.into(),
2533            CssPropertyType::BorderLeftStyle => parse_border_left_style(value)?.into(),
2534            CssPropertyType::BorderBottomStyle => parse_border_bottom_style(value)?.into(),
2535
2536            CssPropertyType::BorderTopWidth => parse_border_top_width(value)?.into(),
2537            CssPropertyType::BorderRightWidth => parse_border_right_width(value)?.into(),
2538            CssPropertyType::BorderLeftWidth => parse_border_left_width(value)?.into(),
2539            CssPropertyType::BorderBottomWidth => parse_border_bottom_width(value)?.into(),
2540
2541            CssPropertyType::BoxShadowLeft => {
2542                CssProperty::BoxShadowLeft(parse_style_box_shadow(value)?.into())
2543            }
2544            CssPropertyType::BoxShadowRight => {
2545                CssProperty::BoxShadowRight(parse_style_box_shadow(value)?.into())
2546            }
2547            CssPropertyType::BoxShadowTop => {
2548                CssProperty::BoxShadowTop(parse_style_box_shadow(value)?.into())
2549            }
2550            CssPropertyType::BoxShadowBottom => {
2551                CssProperty::BoxShadowBottom(parse_style_box_shadow(value)?.into())
2552            }
2553
2554            CssPropertyType::Scrollbar => parse_scrollbar_style(value)?.into(),
2555            CssPropertyType::ScrollbarWidth => parse_layout_scrollbar_width(value)?.into(),
2556            CssPropertyType::ScrollbarColor => parse_style_scrollbar_color(value)?.into(),
2557            CssPropertyType::Opacity => parse_style_opacity(value)?.into(),
2558            CssPropertyType::Visibility => parse_style_visibility(value)?.into(),
2559            CssPropertyType::Transform => parse_style_transform_vec(value)?.into(),
2560            CssPropertyType::TransformOrigin => parse_style_transform_origin(value)?.into(),
2561            CssPropertyType::PerspectiveOrigin => parse_style_perspective_origin(value)?.into(),
2562            CssPropertyType::BackfaceVisibility => parse_style_backface_visibility(value)?.into(),
2563
2564            CssPropertyType::MixBlendMode => parse_style_mix_blend_mode(value)?.into(),
2565            CssPropertyType::Filter => CssProperty::Filter(parse_style_filter_vec(value)?.into()),
2566            CssPropertyType::BackdropFilter => {
2567                CssProperty::BackdropFilter(parse_style_filter_vec(value)?.into())
2568            }
2569            CssPropertyType::TextShadow => {
2570                CssProperty::TextShadow(parse_style_box_shadow(value)?.into())
2571            }
2572
2573            // DTP properties
2574            CssPropertyType::BreakBefore => {
2575                CssProperty::BreakBefore(parse_page_break(value)?.into())
2576            }
2577            CssPropertyType::BreakAfter => CssProperty::BreakAfter(parse_page_break(value)?.into()),
2578            CssPropertyType::BreakInside => {
2579                CssProperty::BreakInside(parse_break_inside(value)?.into())
2580            }
2581            CssPropertyType::Orphans => CssProperty::Orphans(parse_orphans(value)?.into()),
2582            CssPropertyType::Widows => CssProperty::Widows(parse_widows(value)?.into()),
2583            CssPropertyType::BoxDecorationBreak => {
2584                CssProperty::BoxDecorationBreak(parse_box_decoration_break(value)?.into())
2585            }
2586            CssPropertyType::ColumnCount => {
2587                CssProperty::ColumnCount(parse_column_count(value)?.into())
2588            }
2589            CssPropertyType::ColumnWidth => {
2590                CssProperty::ColumnWidth(parse_column_width(value)?.into())
2591            }
2592            CssPropertyType::ColumnSpan => {
2593                CssProperty::ColumnSpan(parse_column_span(value)?.into())
2594            }
2595            CssPropertyType::ColumnFill => {
2596                CssProperty::ColumnFill(parse_column_fill(value)?.into())
2597            }
2598            CssPropertyType::ColumnRuleWidth => {
2599                CssProperty::ColumnRuleWidth(parse_column_rule_width(value)?.into())
2600            }
2601            CssPropertyType::ColumnRuleStyle => {
2602                CssProperty::ColumnRuleStyle(parse_column_rule_style(value)?.into())
2603            }
2604            CssPropertyType::ColumnRuleColor => {
2605                CssProperty::ColumnRuleColor(parse_column_rule_color(value)?.into())
2606            }
2607            CssPropertyType::FlowInto => CssProperty::FlowInto(parse_flow_into(value)?.into()),
2608            CssPropertyType::FlowFrom => CssProperty::FlowFrom(parse_flow_from(value)?.into()),
2609            CssPropertyType::ShapeOutside => CssProperty::ShapeOutside(
2610                parse_shape_outside(value)
2611                    .map_err(|_| CssParsingError::GenericParseError)?
2612                    .into(),
2613            ),
2614            CssPropertyType::ShapeInside => CssProperty::ShapeInside(
2615                parse_shape_inside(value)
2616                    .map_err(|_| CssParsingError::GenericParseError)?
2617                    .into(),
2618            ),
2619            CssPropertyType::ClipPath => CssProperty::ClipPath(
2620                parse_clip_path(value)
2621                    .map_err(|_| CssParsingError::GenericParseError)?
2622                    .into(),
2623            ),
2624            CssPropertyType::ShapeMargin => {
2625                CssProperty::ShapeMargin(parse_shape_margin(value)?.into())
2626            }
2627            CssPropertyType::ShapeImageThreshold => CssProperty::ShapeImageThreshold(
2628                parse_shape_image_threshold(value)
2629                    .map_err(|_| CssParsingError::GenericParseError)?
2630                    .into(),
2631            ),
2632            CssPropertyType::Content => CssProperty::Content(
2633                parse_content(value)
2634                    .map_err(|_| CssParsingError::Content)?
2635                    .into(),
2636            ),
2637            CssPropertyType::CounterReset => CssProperty::CounterReset(
2638                parse_counter_reset(value)
2639                    .map_err(|_| CssParsingError::Counter)?
2640                    .into(),
2641            ),
2642            CssPropertyType::CounterIncrement => CssProperty::CounterIncrement(
2643                parse_counter_increment(value)
2644                    .map_err(|_| CssParsingError::Counter)?
2645                    .into(),
2646            ),
2647            CssPropertyType::ListStyleType => CssProperty::ListStyleType(
2648                parse_style_list_style_type(value)
2649                    .map_err(|e| CssParsingError::ListStyleType(e))?
2650                    .into(),
2651            ),
2652            CssPropertyType::ListStylePosition => CssProperty::ListStylePosition(
2653                parse_style_list_style_position(value)
2654                    .map_err(|e| CssParsingError::ListStylePosition(e))?
2655                    .into(),
2656            ),
2657            CssPropertyType::StringSet => CssProperty::StringSet(
2658                parse_string_set(value)
2659                    .map_err(|_| CssParsingError::StringSet)?
2660                    .into(),
2661            ),
2662            CssPropertyType::TableLayout => CssProperty::TableLayout(
2663                parse_table_layout(value)
2664                    .map_err(|_| CssParsingError::GenericParseError)?
2665                    .into(),
2666            ),
2667            CssPropertyType::BorderCollapse => CssProperty::BorderCollapse(
2668                parse_border_collapse(value)
2669                    .map_err(|_| CssParsingError::GenericParseError)?
2670                    .into(),
2671            ),
2672            CssPropertyType::BorderSpacing => CssProperty::BorderSpacing(
2673                parse_border_spacing(value)
2674                    .map_err(|_| CssParsingError::GenericParseError)?
2675                    .into(),
2676            ),
2677            CssPropertyType::CaptionSide => CssProperty::CaptionSide(
2678                parse_caption_side(value)
2679                    .map_err(|_| CssParsingError::GenericParseError)?
2680                    .into(),
2681            ),
2682            CssPropertyType::EmptyCells => CssProperty::EmptyCells(
2683                parse_empty_cells(value)
2684                    .map_err(|_| CssParsingError::GenericParseError)?
2685                    .into(),
2686            ),
2687        },
2688    })
2689}
2690
2691#[cfg(feature = "parser")]
2692
2693/// Parses a combined CSS property or a CSS property shorthand, for example "margin"
2694/// (as a shorthand for setting all four properties of "margin-top", "margin-bottom",
2695/// "margin-left" and "margin-right")
2696///
2697/// ```rust
2698/// # extern crate azul_css;
2699/// # use azul_css::*;
2700/// # use azul_css::props::style::*;
2701/// # use azul_css::css::CssPropertyValue;
2702/// # use azul_css::props::property::*;
2703/// assert_eq!(
2704///     parse_combined_css_property(CombinedCssPropertyType::BorderRadius, "10px"),
2705///     Ok(vec![
2706///         CssProperty::BorderTopLeftRadius(CssPropertyValue::Exact(
2707///             StyleBorderTopLeftRadius::px(10.0)
2708///         )),
2709///         CssProperty::BorderTopRightRadius(CssPropertyValue::Exact(
2710///             StyleBorderTopRightRadius::px(10.0)
2711///         )),
2712///         CssProperty::BorderBottomLeftRadius(CssPropertyValue::Exact(
2713///             StyleBorderBottomLeftRadius::px(10.0)
2714///         )),
2715///         CssProperty::BorderBottomRightRadius(CssPropertyValue::Exact(
2716///             StyleBorderBottomRightRadius::px(10.0)
2717///         )),
2718///     ])
2719/// )
2720/// ```
2721#[cfg(feature = "parser")]
2722pub fn parse_combined_css_property<'a>(
2723    key: CombinedCssPropertyType,
2724    value: &'a str,
2725) -> Result<Vec<CssProperty>, CssParsingError<'a>> {
2726    use self::CombinedCssPropertyType::*;
2727
2728    macro_rules! convert_value {
2729        ($thing:expr, $prop_type:ident, $wrapper:ident) => {
2730            match $thing {
2731                PixelValueWithAuto::None => CssProperty::none(CssPropertyType::$prop_type),
2732                PixelValueWithAuto::Initial => CssProperty::initial(CssPropertyType::$prop_type),
2733                PixelValueWithAuto::Inherit => CssProperty::inherit(CssPropertyType::$prop_type),
2734                PixelValueWithAuto::Auto => CssProperty::auto(CssPropertyType::$prop_type),
2735                PixelValueWithAuto::Exact(x) => {
2736                    CssProperty::$prop_type($wrapper { inner: x }.into())
2737                }
2738            }
2739        };
2740    }
2741
2742    let keys = match key {
2743        BorderRadius => {
2744            vec![
2745                CssPropertyType::BorderTopLeftRadius,
2746                CssPropertyType::BorderTopRightRadius,
2747                CssPropertyType::BorderBottomLeftRadius,
2748                CssPropertyType::BorderBottomRightRadius,
2749            ]
2750        }
2751        Overflow => {
2752            vec![CssPropertyType::OverflowX, CssPropertyType::OverflowY]
2753        }
2754        Padding => {
2755            vec![
2756                CssPropertyType::PaddingTop,
2757                CssPropertyType::PaddingBottom,
2758                CssPropertyType::PaddingLeft,
2759                CssPropertyType::PaddingRight,
2760            ]
2761        }
2762        Margin => {
2763            vec![
2764                CssPropertyType::MarginTop,
2765                CssPropertyType::MarginBottom,
2766                CssPropertyType::MarginLeft,
2767                CssPropertyType::MarginRight,
2768            ]
2769        }
2770        Border => {
2771            vec![
2772                CssPropertyType::BorderTopColor,
2773                CssPropertyType::BorderRightColor,
2774                CssPropertyType::BorderLeftColor,
2775                CssPropertyType::BorderBottomColor,
2776                CssPropertyType::BorderTopStyle,
2777                CssPropertyType::BorderRightStyle,
2778                CssPropertyType::BorderLeftStyle,
2779                CssPropertyType::BorderBottomStyle,
2780                CssPropertyType::BorderTopWidth,
2781                CssPropertyType::BorderRightWidth,
2782                CssPropertyType::BorderLeftWidth,
2783                CssPropertyType::BorderBottomWidth,
2784            ]
2785        }
2786        BorderLeft => {
2787            vec![
2788                CssPropertyType::BorderLeftColor,
2789                CssPropertyType::BorderLeftStyle,
2790                CssPropertyType::BorderLeftWidth,
2791            ]
2792        }
2793        BorderRight => {
2794            vec![
2795                CssPropertyType::BorderRightColor,
2796                CssPropertyType::BorderRightStyle,
2797                CssPropertyType::BorderRightWidth,
2798            ]
2799        }
2800        BorderTop => {
2801            vec![
2802                CssPropertyType::BorderTopColor,
2803                CssPropertyType::BorderTopStyle,
2804                CssPropertyType::BorderTopWidth,
2805            ]
2806        }
2807        BorderBottom => {
2808            vec![
2809                CssPropertyType::BorderBottomColor,
2810                CssPropertyType::BorderBottomStyle,
2811                CssPropertyType::BorderBottomWidth,
2812            ]
2813        }
2814        BorderColor => {
2815            vec![
2816                CssPropertyType::BorderTopColor,
2817                CssPropertyType::BorderRightColor,
2818                CssPropertyType::BorderBottomColor,
2819                CssPropertyType::BorderLeftColor,
2820            ]
2821        }
2822        BorderStyle => {
2823            vec![
2824                CssPropertyType::BorderTopStyle,
2825                CssPropertyType::BorderRightStyle,
2826                CssPropertyType::BorderBottomStyle,
2827                CssPropertyType::BorderLeftStyle,
2828            ]
2829        }
2830        BorderWidth => {
2831            vec![
2832                CssPropertyType::BorderTopWidth,
2833                CssPropertyType::BorderRightWidth,
2834                CssPropertyType::BorderBottomWidth,
2835                CssPropertyType::BorderLeftWidth,
2836            ]
2837        }
2838        BoxShadow => {
2839            vec![
2840                CssPropertyType::BoxShadowLeft,
2841                CssPropertyType::BoxShadowRight,
2842                CssPropertyType::BoxShadowTop,
2843                CssPropertyType::BoxShadowBottom,
2844            ]
2845        }
2846        BackgroundColor => {
2847            vec![CssPropertyType::BackgroundContent]
2848        }
2849        BackgroundImage => {
2850            vec![CssPropertyType::BackgroundContent]
2851        }
2852        Background => {
2853            vec![CssPropertyType::BackgroundContent]
2854        }
2855        Flex => {
2856            vec![
2857                CssPropertyType::FlexGrow,
2858                CssPropertyType::FlexShrink,
2859                CssPropertyType::FlexBasis,
2860            ]
2861        }
2862        Grid => {
2863            vec![
2864                CssPropertyType::GridTemplateColumns,
2865                CssPropertyType::GridTemplateRows,
2866            ]
2867        }
2868        Gap => {
2869            vec![CssPropertyType::RowGap, CssPropertyType::ColumnGap]
2870        }
2871        GridGap => {
2872            vec![CssPropertyType::RowGap, CssPropertyType::ColumnGap]
2873        }
2874        Font => {
2875            vec![CssPropertyType::Font]
2876        }
2877        Columns => {
2878            vec![CssPropertyType::ColumnWidth, CssPropertyType::ColumnCount]
2879        }
2880        GridArea => {
2881            vec![CssPropertyType::GridRow, CssPropertyType::GridColumn]
2882        }
2883        ColumnRule => {
2884            vec![
2885                CssPropertyType::ColumnRuleWidth,
2886                CssPropertyType::ColumnRuleStyle,
2887                CssPropertyType::ColumnRuleColor,
2888            ]
2889        }
2890    };
2891
2892    // For Overflow, "auto" is a typed value (LayoutOverflow::Auto), not the generic CSS keyword,
2893    // so we must not intercept it here and let the specific parser handle it below.
2894    let has_typed_auto = matches!(key, Overflow);
2895    let has_typed_none = false; // Currently no combined properties have typed "none"
2896
2897    match value {
2898        "auto" if !has_typed_auto => {
2899            return Ok(keys.into_iter().map(|ty| CssProperty::auto(ty)).collect())
2900        }
2901        "none" if !has_typed_none => {
2902            return Ok(keys.into_iter().map(|ty| CssProperty::none(ty)).collect())
2903        }
2904        "initial" => {
2905            return Ok(keys
2906                .into_iter()
2907                .map(|ty| CssProperty::initial(ty))
2908                .collect());
2909        }
2910        "inherit" => {
2911            return Ok(keys
2912                .into_iter()
2913                .map(|ty| CssProperty::inherit(ty))
2914                .collect());
2915        }
2916        _ => {}
2917    };
2918
2919    match key {
2920        BorderRadius => {
2921            let border_radius = parse_style_border_radius(value)?;
2922            Ok(vec![
2923                CssProperty::BorderTopLeftRadius(
2924                    StyleBorderTopLeftRadius {
2925                        inner: border_radius.top_left,
2926                    }
2927                    .into(),
2928                ),
2929                CssProperty::BorderTopRightRadius(
2930                    StyleBorderTopRightRadius {
2931                        inner: border_radius.top_right,
2932                    }
2933                    .into(),
2934                ),
2935                CssProperty::BorderBottomLeftRadius(
2936                    StyleBorderBottomLeftRadius {
2937                        inner: border_radius.bottom_left,
2938                    }
2939                    .into(),
2940                ),
2941                CssProperty::BorderBottomRightRadius(
2942                    StyleBorderBottomRightRadius {
2943                        inner: border_radius.bottom_right,
2944                    }
2945                    .into(),
2946                ),
2947            ])
2948        }
2949        Overflow => {
2950            let overflow = parse_layout_overflow(value)?;
2951            Ok(vec![
2952                CssProperty::OverflowX(overflow.into()),
2953                CssProperty::OverflowY(overflow.into()),
2954            ])
2955        }
2956        Padding => {
2957            let padding = parse_layout_padding(value)?;
2958            Ok(vec![
2959                convert_value!(padding.top, PaddingTop, LayoutPaddingTop),
2960                convert_value!(padding.bottom, PaddingBottom, LayoutPaddingBottom),
2961                convert_value!(padding.left, PaddingLeft, LayoutPaddingLeft),
2962                convert_value!(padding.right, PaddingRight, LayoutPaddingRight),
2963            ])
2964        }
2965        Margin => {
2966            let margin = parse_layout_margin(value)?;
2967            Ok(vec![
2968                convert_value!(margin.top, MarginTop, LayoutMarginTop),
2969                convert_value!(margin.bottom, MarginBottom, LayoutMarginBottom),
2970                convert_value!(margin.left, MarginLeft, LayoutMarginLeft),
2971                convert_value!(margin.right, MarginRight, LayoutMarginRight),
2972            ])
2973        }
2974        Border => {
2975            let border = parse_style_border(value)?;
2976            Ok(vec![
2977                CssProperty::BorderTopColor(
2978                    StyleBorderTopColor {
2979                        inner: border.border_color,
2980                    }
2981                    .into(),
2982                ),
2983                CssProperty::BorderRightColor(
2984                    StyleBorderRightColor {
2985                        inner: border.border_color,
2986                    }
2987                    .into(),
2988                ),
2989                CssProperty::BorderLeftColor(
2990                    StyleBorderLeftColor {
2991                        inner: border.border_color,
2992                    }
2993                    .into(),
2994                ),
2995                CssProperty::BorderBottomColor(
2996                    StyleBorderBottomColor {
2997                        inner: border.border_color,
2998                    }
2999                    .into(),
3000                ),
3001                CssProperty::BorderTopStyle(
3002                    StyleBorderTopStyle {
3003                        inner: border.border_style,
3004                    }
3005                    .into(),
3006                ),
3007                CssProperty::BorderRightStyle(
3008                    StyleBorderRightStyle {
3009                        inner: border.border_style,
3010                    }
3011                    .into(),
3012                ),
3013                CssProperty::BorderLeftStyle(
3014                    StyleBorderLeftStyle {
3015                        inner: border.border_style,
3016                    }
3017                    .into(),
3018                ),
3019                CssProperty::BorderBottomStyle(
3020                    StyleBorderBottomStyle {
3021                        inner: border.border_style,
3022                    }
3023                    .into(),
3024                ),
3025                CssProperty::BorderTopWidth(
3026                    LayoutBorderTopWidth {
3027                        inner: border.border_width,
3028                    }
3029                    .into(),
3030                ),
3031                CssProperty::BorderRightWidth(
3032                    LayoutBorderRightWidth {
3033                        inner: border.border_width,
3034                    }
3035                    .into(),
3036                ),
3037                CssProperty::BorderLeftWidth(
3038                    LayoutBorderLeftWidth {
3039                        inner: border.border_width,
3040                    }
3041                    .into(),
3042                ),
3043                CssProperty::BorderBottomWidth(
3044                    LayoutBorderBottomWidth {
3045                        inner: border.border_width,
3046                    }
3047                    .into(),
3048                ),
3049            ])
3050        }
3051        BorderLeft => {
3052            let border = parse_style_border(value)?;
3053            Ok(vec![
3054                CssProperty::BorderLeftColor(
3055                    StyleBorderLeftColor {
3056                        inner: border.border_color,
3057                    }
3058                    .into(),
3059                ),
3060                CssProperty::BorderLeftStyle(
3061                    StyleBorderLeftStyle {
3062                        inner: border.border_style,
3063                    }
3064                    .into(),
3065                ),
3066                CssProperty::BorderLeftWidth(
3067                    LayoutBorderLeftWidth {
3068                        inner: border.border_width,
3069                    }
3070                    .into(),
3071                ),
3072            ])
3073        }
3074        BorderRight => {
3075            let border = parse_style_border(value)?;
3076            Ok(vec![
3077                CssProperty::BorderRightColor(
3078                    StyleBorderRightColor {
3079                        inner: border.border_color,
3080                    }
3081                    .into(),
3082                ),
3083                CssProperty::BorderRightStyle(
3084                    StyleBorderRightStyle {
3085                        inner: border.border_style,
3086                    }
3087                    .into(),
3088                ),
3089                CssProperty::BorderRightWidth(
3090                    LayoutBorderRightWidth {
3091                        inner: border.border_width,
3092                    }
3093                    .into(),
3094                ),
3095            ])
3096        }
3097        BorderTop => {
3098            let border = parse_style_border(value)?;
3099            Ok(vec![
3100                CssProperty::BorderTopColor(
3101                    StyleBorderTopColor {
3102                        inner: border.border_color,
3103                    }
3104                    .into(),
3105                ),
3106                CssProperty::BorderTopStyle(
3107                    StyleBorderTopStyle {
3108                        inner: border.border_style,
3109                    }
3110                    .into(),
3111                ),
3112                CssProperty::BorderTopWidth(
3113                    LayoutBorderTopWidth {
3114                        inner: border.border_width,
3115                    }
3116                    .into(),
3117                ),
3118            ])
3119        }
3120        BorderBottom => {
3121            let border = parse_style_border(value)?;
3122            Ok(vec![
3123                CssProperty::BorderBottomColor(
3124                    StyleBorderBottomColor {
3125                        inner: border.border_color,
3126                    }
3127                    .into(),
3128                ),
3129                CssProperty::BorderBottomStyle(
3130                    StyleBorderBottomStyle {
3131                        inner: border.border_style,
3132                    }
3133                    .into(),
3134                ),
3135                CssProperty::BorderBottomWidth(
3136                    LayoutBorderBottomWidth {
3137                        inner: border.border_width,
3138                    }
3139                    .into(),
3140                ),
3141            ])
3142        }
3143        BorderColor => {
3144            let colors = parse_style_border_color(value)?;
3145            Ok(vec![
3146                CssProperty::BorderTopColor(
3147                    StyleBorderTopColor { inner: colors.top }.into(),
3148                ),
3149                CssProperty::BorderRightColor(
3150                    StyleBorderRightColor { inner: colors.right }.into(),
3151                ),
3152                CssProperty::BorderBottomColor(
3153                    StyleBorderBottomColor { inner: colors.bottom }.into(),
3154                ),
3155                CssProperty::BorderLeftColor(
3156                    StyleBorderLeftColor { inner: colors.left }.into(),
3157                ),
3158            ])
3159        }
3160        BorderStyle => {
3161            let styles = parse_style_border_style(value)?;
3162            Ok(vec![
3163                CssProperty::BorderTopStyle(
3164                    StyleBorderTopStyle { inner: styles.top }.into(),
3165                ),
3166                CssProperty::BorderRightStyle(
3167                    StyleBorderRightStyle { inner: styles.right }.into(),
3168                ),
3169                CssProperty::BorderBottomStyle(
3170                    StyleBorderBottomStyle { inner: styles.bottom }.into(),
3171                ),
3172                CssProperty::BorderLeftStyle(
3173                    StyleBorderLeftStyle { inner: styles.left }.into(),
3174                ),
3175            ])
3176        }
3177        BorderWidth => {
3178            let widths = parse_style_border_width(value)?;
3179            Ok(vec![
3180                CssProperty::BorderTopWidth(
3181                    LayoutBorderTopWidth { inner: widths.top }.into(),
3182                ),
3183                CssProperty::BorderRightWidth(
3184                    LayoutBorderRightWidth { inner: widths.right }.into(),
3185                ),
3186                CssProperty::BorderBottomWidth(
3187                    LayoutBorderBottomWidth { inner: widths.bottom }.into(),
3188                ),
3189                CssProperty::BorderLeftWidth(
3190                    LayoutBorderLeftWidth { inner: widths.left }.into(),
3191                ),
3192            ])
3193        }
3194        BoxShadow => {
3195            let box_shadow = parse_style_box_shadow(value)?;
3196            Ok(vec![
3197                CssProperty::BoxShadowLeft(CssPropertyValue::Exact(box_shadow)),
3198                CssProperty::BoxShadowRight(CssPropertyValue::Exact(box_shadow)),
3199                CssProperty::BoxShadowTop(CssPropertyValue::Exact(box_shadow)),
3200                CssProperty::BoxShadowBottom(CssPropertyValue::Exact(box_shadow)),
3201            ])
3202        }
3203        BackgroundColor => {
3204            let color = parse_css_color(value)?;
3205            let vec: StyleBackgroundContentVec = vec![StyleBackgroundContent::Color(color)].into();
3206            Ok(vec![CssProperty::BackgroundContent(vec.into())])
3207        }
3208        BackgroundImage => {
3209            let background_content = parse_style_background_content(value)?;
3210            let vec: StyleBackgroundContentVec = vec![background_content].into();
3211            Ok(vec![CssProperty::BackgroundContent(vec.into())])
3212        }
3213        Background => {
3214            let background_content = parse_style_background_content_multiple(value)?;
3215            Ok(vec![CssProperty::BackgroundContent(
3216                background_content.into(),
3217            )])
3218        }
3219        Flex => {
3220            // parse shorthand into grow/shrink/basis
3221            let parts: Vec<&str> = value.split_whitespace().collect();
3222            if parts.len() == 1 && parts[0] == "none" {
3223                return Ok(vec![
3224                    CssProperty::FlexGrow(
3225                        LayoutFlexGrow {
3226                            inner: crate::props::basic::length::FloatValue::const_new(0),
3227                        }
3228                        .into(),
3229                    ),
3230                    CssProperty::FlexShrink(
3231                        LayoutFlexShrink {
3232                            inner: crate::props::basic::length::FloatValue::const_new(0),
3233                        }
3234                        .into(),
3235                    ),
3236                    CssProperty::FlexBasis(LayoutFlexBasis::Auto.into()),
3237                ]);
3238            }
3239            if parts.len() == 1 {
3240                // try grow or basis
3241                if let Ok(g) = parse_layout_flex_grow(parts[0]) {
3242                    return Ok(vec![CssProperty::FlexGrow(g.into())]);
3243                }
3244                if let Ok(b) = parse_layout_flex_basis(parts[0]) {
3245                    return Ok(vec![CssProperty::FlexBasis(b.into())]);
3246                }
3247            }
3248            if parts.len() == 2 {
3249                if let (Ok(g), Ok(b)) = (
3250                    parse_layout_flex_grow(parts[0]),
3251                    parse_layout_flex_basis(parts[1]),
3252                ) {
3253                    return Ok(vec![
3254                        CssProperty::FlexGrow(g.into()),
3255                        CssProperty::FlexBasis(b.into()),
3256                    ]);
3257                }
3258                if let (Ok(g), Ok(s)) = (
3259                    parse_layout_flex_grow(parts[0]),
3260                    parse_layout_flex_shrink(parts[1]),
3261                ) {
3262                    return Ok(vec![
3263                        CssProperty::FlexGrow(g.into()),
3264                        CssProperty::FlexShrink(s.into()),
3265                    ]);
3266                }
3267            }
3268            if parts.len() == 3 {
3269                let g = parse_layout_flex_grow(parts[0])?;
3270                let s = parse_layout_flex_shrink(parts[1])?;
3271                let b = parse_layout_flex_basis(parts[2])?;
3272                return Ok(vec![
3273                    CssProperty::FlexGrow(g.into()),
3274                    CssProperty::FlexShrink(s.into()),
3275                    CssProperty::FlexBasis(b.into()),
3276                ]);
3277            }
3278            return Err(CssParsingError::InvalidValue(InvalidValueErr(value)));
3279        }
3280        Grid => {
3281            // minimal: try to parse as grid-template and set both columns and rows
3282            let tpl = parse_grid_template(value)?;
3283            Ok(vec![
3284                CssProperty::GridTemplateColumns(tpl.clone().into()),
3285                CssProperty::GridTemplateRows(tpl.into()),
3286            ])
3287        }
3288        Gap => {
3289            let parts: Vec<&str> = value.split_whitespace().collect();
3290            if parts.len() == 1 {
3291                let g = parse_layout_gap(parts[0])?;
3292                return Ok(vec![
3293                    CssProperty::RowGap(LayoutRowGap { inner: g.inner }.into()),
3294                    CssProperty::ColumnGap(LayoutColumnGap { inner: g.inner }.into()),
3295                ]);
3296            } else if parts.len() == 2 {
3297                let row = parse_layout_gap(parts[0])?;
3298                let col = parse_layout_gap(parts[1])?;
3299                return Ok(vec![
3300                    CssProperty::RowGap(LayoutRowGap { inner: row.inner }.into()),
3301                    CssProperty::ColumnGap(LayoutColumnGap { inner: col.inner }.into()),
3302                ]);
3303            } else {
3304                return Err(CssParsingError::InvalidValue(InvalidValueErr(value)));
3305            }
3306        }
3307        GridGap => {
3308            let parts: Vec<&str> = value.split_whitespace().collect();
3309            if parts.len() == 1 {
3310                let g = parse_layout_gap(parts[0])?;
3311                return Ok(vec![
3312                    CssProperty::RowGap(LayoutRowGap { inner: g.inner }.into()),
3313                    CssProperty::ColumnGap(LayoutColumnGap { inner: g.inner }.into()),
3314                ]);
3315            } else if parts.len() == 2 {
3316                let row = parse_layout_gap(parts[0])?;
3317                let col = parse_layout_gap(parts[1])?;
3318                return Ok(vec![
3319                    CssProperty::RowGap(LayoutRowGap { inner: row.inner }.into()),
3320                    CssProperty::ColumnGap(LayoutColumnGap { inner: col.inner }.into()),
3321                ]);
3322            } else {
3323                return Err(CssParsingError::InvalidValue(InvalidValueErr(value)));
3324            }
3325        }
3326        Font => {
3327            let fam = parse_style_font_family(value)?;
3328            Ok(vec![CssProperty::Font(fam.into())])
3329        }
3330        Columns => {
3331            let mut props = Vec::new();
3332            for part in value.split_whitespace() {
3333                if let Ok(width) = parse_column_width(part) {
3334                    props.push(CssProperty::ColumnWidth(width.into()));
3335                } else if let Ok(count) = parse_column_count(part) {
3336                    props.push(CssProperty::ColumnCount(count.into()));
3337                } else {
3338                    return Err(CssParsingError::InvalidValue(InvalidValueErr(value)));
3339                }
3340            }
3341            Ok(props)
3342        }
3343        GridArea => {
3344            // CSS grid-area shorthand: grid-area: <name>
3345            // Expands to grid-row: <name> / <name> and grid-column: <name> / <name>
3346            // This tells taffy to resolve the named area via NamedLineResolver.
3347            //
3348            // Full syntax: grid-area: row-start / column-start / row-end / column-end
3349            // But for named areas, typically just: grid-area: <name>
3350            let parts: Vec<&str> = value.split('/').map(|s| s.trim()).collect();
3351            let (row_start, col_start, row_end, col_end) = match parts.len() {
3352                1 => (parts[0], parts[0], parts[0], parts[0]),
3353                2 => (parts[0], parts[1], parts[0], parts[1]),
3354                3 => (parts[0], parts[1], parts[2], parts[1]),
3355                4 => (parts[0], parts[1], parts[2], parts[3]),
3356                _ => return Err(CssParsingError::InvalidValue(InvalidValueErr(value))),
3357            };
3358            let parse_line = |s: &str| -> Result<GridLine, CssParsingError<'_>> {
3359                parse_grid_line_owned(s.trim()).map_err(|_| CssParsingError::InvalidValue(InvalidValueErr(value)))
3360            };
3361            Ok(vec![
3362                CssProperty::GridRow(CssPropertyValue::Exact(GridPlacement {
3363                    grid_start: parse_line(row_start)?,
3364                    grid_end: parse_line(row_end)?,
3365                })),
3366                CssProperty::GridColumn(CssPropertyValue::Exact(GridPlacement {
3367                    grid_start: parse_line(col_start)?,
3368                    grid_end: parse_line(col_end)?,
3369                })),
3370            ])
3371        }
3372        ColumnRule => {
3373            let border = parse_style_border(value)?;
3374            Ok(vec![
3375                CssProperty::ColumnRuleWidth(
3376                    ColumnRuleWidth {
3377                        inner: border.border_width,
3378                    }
3379                    .into(),
3380                ),
3381                CssProperty::ColumnRuleStyle(
3382                    ColumnRuleStyle {
3383                        inner: border.border_style,
3384                    }
3385                    .into(),
3386                ),
3387                CssProperty::ColumnRuleColor(
3388                    ColumnRuleColor {
3389                        inner: border.border_color,
3390                    }
3391                    .into(),
3392                ),
3393            ])
3394        }
3395    }
3396}
3397
3398// Re-add the From implementations for convenience
3399macro_rules! impl_from_css_prop {
3400    ($a:ident, $b:ident:: $enum_type:ident) => {
3401        impl From<$a> for $b {
3402            fn from(e: $a) -> Self {
3403                $b::$enum_type(CssPropertyValue::from(e))
3404            }
3405        }
3406    };
3407}
3408
3409impl_from_css_prop!(CaretColor, CssProperty::CaretColor);
3410impl_from_css_prop!(CaretWidth, CssProperty::CaretWidth);
3411impl_from_css_prop!(CaretAnimationDuration, CssProperty::CaretAnimationDuration);
3412impl_from_css_prop!(
3413    SelectionBackgroundColor,
3414    CssProperty::SelectionBackgroundColor
3415);
3416impl_from_css_prop!(SelectionColor, CssProperty::SelectionColor);
3417impl_from_css_prop!(SelectionRadius, CssProperty::SelectionRadius);
3418impl_from_css_prop!(StyleTextColor, CssProperty::TextColor);
3419impl_from_css_prop!(StyleFontSize, CssProperty::FontSize);
3420impl_from_css_prop!(StyleFontFamilyVec, CssProperty::FontFamily);
3421impl_from_css_prop!(StyleTextAlign, CssProperty::TextAlign);
3422impl_from_css_prop!(LayoutTextJustify, CssProperty::TextJustify);
3423impl_from_css_prop!(StyleVerticalAlign, CssProperty::VerticalAlign);
3424impl_from_css_prop!(StyleLetterSpacing, CssProperty::LetterSpacing);
3425impl_from_css_prop!(StyleTextIndent, CssProperty::TextIndent);
3426impl_from_css_prop!(StyleInitialLetter, CssProperty::InitialLetter);
3427impl_from_css_prop!(StyleLineClamp, CssProperty::LineClamp);
3428impl_from_css_prop!(StyleHangingPunctuation, CssProperty::HangingPunctuation);
3429impl_from_css_prop!(StyleTextCombineUpright, CssProperty::TextCombineUpright);
3430impl_from_css_prop!(StyleExclusionMargin, CssProperty::ExclusionMargin);
3431impl_from_css_prop!(StyleHyphenationLanguage, CssProperty::HyphenationLanguage);
3432impl_from_css_prop!(StyleLineHeight, CssProperty::LineHeight);
3433impl_from_css_prop!(StyleWordSpacing, CssProperty::WordSpacing);
3434impl_from_css_prop!(StyleTabSize, CssProperty::TabSize);
3435impl_from_css_prop!(StyleCursor, CssProperty::Cursor);
3436impl_from_css_prop!(LayoutDisplay, CssProperty::Display);
3437impl_from_css_prop!(LayoutFloat, CssProperty::Float);
3438impl_from_css_prop!(LayoutBoxSizing, CssProperty::BoxSizing);
3439impl_from_css_prop!(LayoutWidth, CssProperty::Width);
3440impl_from_css_prop!(LayoutHeight, CssProperty::Height);
3441impl_from_css_prop!(LayoutMinWidth, CssProperty::MinWidth);
3442impl_from_css_prop!(LayoutMinHeight, CssProperty::MinHeight);
3443impl_from_css_prop!(LayoutMaxWidth, CssProperty::MaxWidth);
3444impl_from_css_prop!(LayoutMaxHeight, CssProperty::MaxHeight);
3445impl_from_css_prop!(LayoutPosition, CssProperty::Position);
3446impl_from_css_prop!(LayoutTop, CssProperty::Top);
3447impl_from_css_prop!(LayoutRight, CssProperty::Right);
3448impl_from_css_prop!(LayoutLeft, CssProperty::Left);
3449impl_from_css_prop!(LayoutInsetBottom, CssProperty::Bottom);
3450impl_from_css_prop!(LayoutFlexWrap, CssProperty::FlexWrap);
3451impl_from_css_prop!(LayoutFlexDirection, CssProperty::FlexDirection);
3452impl_from_css_prop!(LayoutFlexGrow, CssProperty::FlexGrow);
3453impl_from_css_prop!(LayoutFlexShrink, CssProperty::FlexShrink);
3454impl_from_css_prop!(LayoutFlexBasis, CssProperty::FlexBasis);
3455impl_from_css_prop!(LayoutJustifyContent, CssProperty::JustifyContent);
3456impl_from_css_prop!(LayoutAlignItems, CssProperty::AlignItems);
3457impl_from_css_prop!(LayoutAlignContent, CssProperty::AlignContent);
3458impl_from_css_prop!(LayoutColumnGap, CssProperty::ColumnGap);
3459impl_from_css_prop!(LayoutRowGap, CssProperty::RowGap);
3460impl_from_css_prop!(LayoutGridAutoFlow, CssProperty::GridAutoFlow);
3461impl_from_css_prop!(LayoutJustifySelf, CssProperty::JustifySelf);
3462impl_from_css_prop!(LayoutJustifyItems, CssProperty::JustifyItems);
3463impl_from_css_prop!(LayoutGap, CssProperty::Gap);
3464impl_from_css_prop!(LayoutAlignSelf, CssProperty::AlignSelf);
3465impl_from_css_prop!(LayoutWritingMode, CssProperty::WritingMode);
3466impl_from_css_prop!(LayoutClear, CssProperty::Clear);
3467impl_from_css_prop!(StyleBackgroundContentVec, CssProperty::BackgroundContent);
3468
3469impl_from_css_prop!(StyleBackgroundPositionVec, CssProperty::BackgroundPosition);
3470impl_from_css_prop!(StyleBackgroundSizeVec, CssProperty::BackgroundSize);
3471impl_from_css_prop!(StyleBackgroundRepeatVec, CssProperty::BackgroundRepeat);
3472impl_from_css_prop!(LayoutPaddingTop, CssProperty::PaddingTop);
3473impl_from_css_prop!(LayoutPaddingLeft, CssProperty::PaddingLeft);
3474impl_from_css_prop!(LayoutPaddingRight, CssProperty::PaddingRight);
3475impl_from_css_prop!(LayoutPaddingBottom, CssProperty::PaddingBottom);
3476impl_from_css_prop!(LayoutPaddingInlineStart, CssProperty::PaddingInlineStart);
3477impl_from_css_prop!(LayoutPaddingInlineEnd, CssProperty::PaddingInlineEnd);
3478impl_from_css_prop!(LayoutMarginTop, CssProperty::MarginTop);
3479impl_from_css_prop!(LayoutMarginLeft, CssProperty::MarginLeft);
3480impl_from_css_prop!(LayoutMarginRight, CssProperty::MarginRight);
3481impl_from_css_prop!(LayoutMarginBottom, CssProperty::MarginBottom);
3482impl_from_css_prop!(StyleBorderTopLeftRadius, CssProperty::BorderTopLeftRadius);
3483impl_from_css_prop!(StyleBorderTopRightRadius, CssProperty::BorderTopRightRadius);
3484impl_from_css_prop!(
3485    StyleBorderBottomLeftRadius,
3486    CssProperty::BorderBottomLeftRadius
3487);
3488impl_from_css_prop!(
3489    StyleBorderBottomRightRadius,
3490    CssProperty::BorderBottomRightRadius
3491);
3492impl_from_css_prop!(StyleBorderTopColor, CssProperty::BorderTopColor);
3493impl_from_css_prop!(StyleBorderRightColor, CssProperty::BorderRightColor);
3494impl_from_css_prop!(StyleBorderLeftColor, CssProperty::BorderLeftColor);
3495impl_from_css_prop!(StyleBorderBottomColor, CssProperty::BorderBottomColor);
3496impl_from_css_prop!(StyleBorderTopStyle, CssProperty::BorderTopStyle);
3497impl_from_css_prop!(StyleBorderRightStyle, CssProperty::BorderRightStyle);
3498impl_from_css_prop!(StyleBorderLeftStyle, CssProperty::BorderLeftStyle);
3499impl_from_css_prop!(StyleBorderBottomStyle, CssProperty::BorderBottomStyle);
3500impl_from_css_prop!(LayoutBorderTopWidth, CssProperty::BorderTopWidth);
3501impl_from_css_prop!(LayoutBorderRightWidth, CssProperty::BorderRightWidth);
3502impl_from_css_prop!(LayoutBorderLeftWidth, CssProperty::BorderLeftWidth);
3503impl_from_css_prop!(LayoutBorderBottomWidth, CssProperty::BorderBottomWidth);
3504impl_from_css_prop!(ScrollbarStyle, CssProperty::Scrollbar);
3505impl_from_css_prop!(LayoutScrollbarWidth, CssProperty::ScrollbarWidth);
3506impl_from_css_prop!(StyleScrollbarColor, CssProperty::ScrollbarColor);
3507impl_from_css_prop!(StyleOpacity, CssProperty::Opacity);
3508impl_from_css_prop!(StyleVisibility, CssProperty::Visibility);
3509impl_from_css_prop!(StyleTransformVec, CssProperty::Transform);
3510impl_from_css_prop!(StyleTransformOrigin, CssProperty::TransformOrigin);
3511impl_from_css_prop!(StylePerspectiveOrigin, CssProperty::PerspectiveOrigin);
3512impl_from_css_prop!(StyleBackfaceVisibility, CssProperty::BackfaceVisibility);
3513impl_from_css_prop!(StyleMixBlendMode, CssProperty::MixBlendMode);
3514impl_from_css_prop!(StyleHyphens, CssProperty::Hyphens);
3515impl_from_css_prop!(StyleDirection, CssProperty::Direction);
3516impl_from_css_prop!(StyleWhiteSpace, CssProperty::WhiteSpace);
3517impl_from_css_prop!(PageBreak, CssProperty::BreakBefore);
3518impl_from_css_prop!(BreakInside, CssProperty::BreakInside);
3519impl_from_css_prop!(Widows, CssProperty::Widows);
3520impl_from_css_prop!(Orphans, CssProperty::Orphans);
3521impl_from_css_prop!(BoxDecorationBreak, CssProperty::BoxDecorationBreak);
3522impl_from_css_prop!(ColumnCount, CssProperty::ColumnCount);
3523impl_from_css_prop!(ColumnWidth, CssProperty::ColumnWidth);
3524impl_from_css_prop!(ColumnSpan, CssProperty::ColumnSpan);
3525impl_from_css_prop!(ColumnFill, CssProperty::ColumnFill);
3526impl_from_css_prop!(ColumnRuleWidth, CssProperty::ColumnRuleWidth);
3527impl_from_css_prop!(ColumnRuleStyle, CssProperty::ColumnRuleStyle);
3528impl_from_css_prop!(ColumnRuleColor, CssProperty::ColumnRuleColor);
3529impl_from_css_prop!(FlowInto, CssProperty::FlowInto);
3530impl_from_css_prop!(FlowFrom, CssProperty::FlowFrom);
3531impl_from_css_prop!(ShapeOutside, CssProperty::ShapeOutside);
3532impl_from_css_prop!(ShapeInside, CssProperty::ShapeInside);
3533impl_from_css_prop!(ClipPath, CssProperty::ClipPath);
3534impl_from_css_prop!(ShapeMargin, CssProperty::ShapeMargin);
3535impl_from_css_prop!(ShapeImageThreshold, CssProperty::ShapeImageThreshold);
3536impl_from_css_prop!(Content, CssProperty::Content);
3537impl_from_css_prop!(CounterReset, CssProperty::CounterReset);
3538impl_from_css_prop!(CounterIncrement, CssProperty::CounterIncrement);
3539impl_from_css_prop!(StyleListStyleType, CssProperty::ListStyleType);
3540impl_from_css_prop!(StyleListStylePosition, CssProperty::ListStylePosition);
3541impl_from_css_prop!(StringSet, CssProperty::StringSet);
3542impl_from_css_prop!(LayoutTableLayout, CssProperty::TableLayout);
3543impl_from_css_prop!(StyleBorderCollapse, CssProperty::BorderCollapse);
3544impl_from_css_prop!(LayoutBorderSpacing, CssProperty::BorderSpacing);
3545impl_from_css_prop!(StyleCaptionSide, CssProperty::CaptionSide);
3546impl_from_css_prop!(StyleEmptyCells, CssProperty::EmptyCells);
3547
3548impl CssProperty {
3549    pub fn key(&self) -> &'static str {
3550        self.get_type().to_str()
3551    }
3552
3553    pub fn value(&self) -> String {
3554        match self {
3555            CssProperty::CaretColor(v) => v.get_css_value_fmt(),
3556            CssProperty::CaretWidth(v) => v.get_css_value_fmt(),
3557            CssProperty::CaretAnimationDuration(v) => v.get_css_value_fmt(),
3558            CssProperty::SelectionBackgroundColor(v) => v.get_css_value_fmt(),
3559            CssProperty::SelectionColor(v) => v.get_css_value_fmt(),
3560            CssProperty::SelectionRadius(v) => v.get_css_value_fmt(),
3561            CssProperty::TextJustify(v) => v.get_css_value_fmt(),
3562            CssProperty::LayoutTextJustify(v) => format!("{:?}", v),
3563            CssProperty::TextColor(v) => v.get_css_value_fmt(),
3564            CssProperty::FontSize(v) => v.get_css_value_fmt(),
3565            CssProperty::FontFamily(v) => v.get_css_value_fmt(),
3566            CssProperty::TextAlign(v) => v.get_css_value_fmt(),
3567            CssProperty::LetterSpacing(v) => v.get_css_value_fmt(),
3568            CssProperty::TextIndent(v) => v.get_css_value_fmt(),
3569            CssProperty::InitialLetter(v) => v.get_css_value_fmt(),
3570            CssProperty::LineClamp(v) => v.get_css_value_fmt(),
3571            CssProperty::HangingPunctuation(v) => v.get_css_value_fmt(),
3572            CssProperty::TextCombineUpright(v) => v.get_css_value_fmt(),
3573            CssProperty::ExclusionMargin(v) => v.get_css_value_fmt(),
3574            CssProperty::HyphenationLanguage(v) => v.get_css_value_fmt(),
3575            CssProperty::LineHeight(v) => v.get_css_value_fmt(),
3576            CssProperty::WordSpacing(v) => v.get_css_value_fmt(),
3577            CssProperty::TabSize(v) => v.get_css_value_fmt(),
3578            CssProperty::Cursor(v) => v.get_css_value_fmt(),
3579            CssProperty::Display(v) => v.get_css_value_fmt(),
3580            CssProperty::Float(v) => v.get_css_value_fmt(),
3581            CssProperty::BoxSizing(v) => v.get_css_value_fmt(),
3582            CssProperty::Width(v) => v.get_css_value_fmt(),
3583            CssProperty::Height(v) => v.get_css_value_fmt(),
3584            CssProperty::MinWidth(v) => v.get_css_value_fmt(),
3585            CssProperty::MinHeight(v) => v.get_css_value_fmt(),
3586            CssProperty::MaxWidth(v) => v.get_css_value_fmt(),
3587            CssProperty::MaxHeight(v) => v.get_css_value_fmt(),
3588            CssProperty::Position(v) => v.get_css_value_fmt(),
3589            CssProperty::Top(v) => v.get_css_value_fmt(),
3590            CssProperty::Right(v) => v.get_css_value_fmt(),
3591            CssProperty::Left(v) => v.get_css_value_fmt(),
3592            CssProperty::Bottom(v) => v.get_css_value_fmt(),
3593            CssProperty::ZIndex(v) => v.get_css_value_fmt(),
3594            CssProperty::FlexWrap(v) => v.get_css_value_fmt(),
3595            CssProperty::FlexDirection(v) => v.get_css_value_fmt(),
3596            CssProperty::FlexGrow(v) => v.get_css_value_fmt(),
3597            CssProperty::FlexShrink(v) => v.get_css_value_fmt(),
3598            CssProperty::FlexBasis(v) => v.get_css_value_fmt(),
3599            CssProperty::JustifyContent(v) => v.get_css_value_fmt(),
3600            CssProperty::AlignItems(v) => v.get_css_value_fmt(),
3601            CssProperty::AlignContent(v) => v.get_css_value_fmt(),
3602            CssProperty::ColumnGap(v) => v.get_css_value_fmt(),
3603            CssProperty::RowGap(v) => v.get_css_value_fmt(),
3604            CssProperty::GridTemplateColumns(v) => v.get_css_value_fmt(),
3605            CssProperty::GridTemplateRows(v) => v.get_css_value_fmt(),
3606            CssProperty::GridAutoFlow(v) => v.get_css_value_fmt(),
3607            CssProperty::JustifySelf(v) => v.get_css_value_fmt(),
3608            CssProperty::JustifyItems(v) => v.get_css_value_fmt(),
3609            CssProperty::Gap(v) => v.get_css_value_fmt(),
3610            CssProperty::GridGap(v) => v.get_css_value_fmt(),
3611            CssProperty::AlignSelf(v) => v.get_css_value_fmt(),
3612            CssProperty::Font(v) => v.get_css_value_fmt(),
3613            CssProperty::GridAutoColumns(v) => v.get_css_value_fmt(),
3614            CssProperty::GridAutoRows(v) => v.get_css_value_fmt(),
3615            CssProperty::GridColumn(v) => v.get_css_value_fmt(),
3616            CssProperty::GridRow(v) => v.get_css_value_fmt(),
3617            CssProperty::GridTemplateAreas(v) => v.get_css_value_fmt(),
3618            CssProperty::WritingMode(v) => v.get_css_value_fmt(),
3619            CssProperty::Clear(v) => v.get_css_value_fmt(),
3620            CssProperty::BackgroundContent(v) => v.get_css_value_fmt(),
3621            CssProperty::BackgroundPosition(v) => v.get_css_value_fmt(),
3622            CssProperty::BackgroundSize(v) => v.get_css_value_fmt(),
3623            CssProperty::BackgroundRepeat(v) => v.get_css_value_fmt(),
3624            CssProperty::OverflowX(v) => v.get_css_value_fmt(),
3625            CssProperty::OverflowY(v) => v.get_css_value_fmt(),
3626            CssProperty::PaddingTop(v) => v.get_css_value_fmt(),
3627            CssProperty::PaddingLeft(v) => v.get_css_value_fmt(),
3628            CssProperty::PaddingRight(v) => v.get_css_value_fmt(),
3629            CssProperty::PaddingBottom(v) => v.get_css_value_fmt(),
3630            CssProperty::PaddingInlineStart(v) => v.get_css_value_fmt(),
3631            CssProperty::PaddingInlineEnd(v) => v.get_css_value_fmt(),
3632            CssProperty::MarginTop(v) => v.get_css_value_fmt(),
3633            CssProperty::MarginLeft(v) => v.get_css_value_fmt(),
3634            CssProperty::MarginRight(v) => v.get_css_value_fmt(),
3635            CssProperty::MarginBottom(v) => v.get_css_value_fmt(),
3636            CssProperty::BorderTopLeftRadius(v) => v.get_css_value_fmt(),
3637            CssProperty::BorderTopRightRadius(v) => v.get_css_value_fmt(),
3638            CssProperty::BorderBottomLeftRadius(v) => v.get_css_value_fmt(),
3639            CssProperty::BorderBottomRightRadius(v) => v.get_css_value_fmt(),
3640            CssProperty::BorderTopColor(v) => v.get_css_value_fmt(),
3641            CssProperty::BorderRightColor(v) => v.get_css_value_fmt(),
3642            CssProperty::BorderLeftColor(v) => v.get_css_value_fmt(),
3643            CssProperty::BorderBottomColor(v) => v.get_css_value_fmt(),
3644            CssProperty::BorderTopStyle(v) => v.get_css_value_fmt(),
3645            CssProperty::BorderRightStyle(v) => v.get_css_value_fmt(),
3646            CssProperty::BorderLeftStyle(v) => v.get_css_value_fmt(),
3647            CssProperty::BorderBottomStyle(v) => v.get_css_value_fmt(),
3648            CssProperty::BorderTopWidth(v) => v.get_css_value_fmt(),
3649            CssProperty::BorderRightWidth(v) => v.get_css_value_fmt(),
3650            CssProperty::BorderLeftWidth(v) => v.get_css_value_fmt(),
3651            CssProperty::BorderBottomWidth(v) => v.get_css_value_fmt(),
3652            CssProperty::BoxShadowLeft(v) => v.get_css_value_fmt(),
3653            CssProperty::BoxShadowRight(v) => v.get_css_value_fmt(),
3654            CssProperty::BoxShadowTop(v) => v.get_css_value_fmt(),
3655            CssProperty::BoxShadowBottom(v) => v.get_css_value_fmt(),
3656            CssProperty::Scrollbar(v) => v.get_css_value_fmt(),
3657            CssProperty::ScrollbarWidth(v) => v.get_css_value_fmt(),
3658            CssProperty::ScrollbarColor(v) => v.get_css_value_fmt(),
3659            CssProperty::Opacity(v) => v.get_css_value_fmt(),
3660            CssProperty::Visibility(v) => v.get_css_value_fmt(),
3661            CssProperty::Transform(v) => v.get_css_value_fmt(),
3662            CssProperty::TransformOrigin(v) => v.get_css_value_fmt(),
3663            CssProperty::PerspectiveOrigin(v) => v.get_css_value_fmt(),
3664            CssProperty::BackfaceVisibility(v) => v.get_css_value_fmt(),
3665            CssProperty::MixBlendMode(v) => v.get_css_value_fmt(),
3666            CssProperty::Filter(v) => v.get_css_value_fmt(),
3667            CssProperty::BackdropFilter(v) => v.get_css_value_fmt(),
3668            CssProperty::TextShadow(v) => v.get_css_value_fmt(),
3669            CssProperty::Hyphens(v) => v.get_css_value_fmt(),
3670            CssProperty::Direction(v) => v.get_css_value_fmt(),
3671            CssProperty::UserSelect(v) => v.get_css_value_fmt(),
3672            CssProperty::TextDecoration(v) => v.get_css_value_fmt(),
3673            CssProperty::WhiteSpace(v) => v.get_css_value_fmt(),
3674            CssProperty::BreakBefore(v) => v.get_css_value_fmt(),
3675            CssProperty::BreakAfter(v) => v.get_css_value_fmt(),
3676            CssProperty::BreakInside(v) => v.get_css_value_fmt(),
3677            CssProperty::Orphans(v) => v.get_css_value_fmt(),
3678            CssProperty::Widows(v) => v.get_css_value_fmt(),
3679            CssProperty::BoxDecorationBreak(v) => v.get_css_value_fmt(),
3680            CssProperty::ColumnCount(v) => v.get_css_value_fmt(),
3681            CssProperty::ColumnWidth(v) => v.get_css_value_fmt(),
3682            CssProperty::ColumnSpan(v) => v.get_css_value_fmt(),
3683            CssProperty::ColumnFill(v) => v.get_css_value_fmt(),
3684            CssProperty::ColumnRuleWidth(v) => v.get_css_value_fmt(),
3685            CssProperty::ColumnRuleStyle(v) => v.get_css_value_fmt(),
3686            CssProperty::ColumnRuleColor(v) => v.get_css_value_fmt(),
3687            CssProperty::FlowInto(v) => v.get_css_value_fmt(),
3688            CssProperty::FlowFrom(v) => v.get_css_value_fmt(),
3689            CssProperty::ShapeOutside(v) => v.get_css_value_fmt(),
3690            CssProperty::ShapeInside(v) => v.get_css_value_fmt(),
3691            CssProperty::ClipPath(v) => v.get_css_value_fmt(),
3692            CssProperty::ShapeMargin(v) => v.get_css_value_fmt(),
3693            CssProperty::ShapeImageThreshold(v) => v.get_css_value_fmt(),
3694            CssProperty::Content(v) => v.get_css_value_fmt(),
3695            CssProperty::CounterReset(v) => v.get_css_value_fmt(),
3696            CssProperty::CounterIncrement(v) => v.get_css_value_fmt(),
3697            CssProperty::ListStyleType(v) => v.get_css_value_fmt(),
3698            CssProperty::ListStylePosition(v) => v.get_css_value_fmt(),
3699            CssProperty::StringSet(v) => v.get_css_value_fmt(),
3700            CssProperty::TableLayout(v) => v.get_css_value_fmt(),
3701            CssProperty::BorderCollapse(v) => v.get_css_value_fmt(),
3702            CssProperty::BorderSpacing(v) => v.get_css_value_fmt(),
3703            CssProperty::CaptionSide(v) => v.get_css_value_fmt(),
3704            CssProperty::EmptyCells(v) => v.get_css_value_fmt(),
3705            CssProperty::FontWeight(v) => v.get_css_value_fmt(),
3706            CssProperty::FontStyle(v) => v.get_css_value_fmt(),
3707            CssProperty::VerticalAlign(v) => v.get_css_value_fmt(),
3708        }
3709    }
3710
3711    pub fn format_css(&self) -> String {
3712        format!("{}: {};", self.key(), self.value())
3713    }
3714
3715    pub fn interpolate(
3716        &self,
3717        other: &Self,
3718        t: f32,
3719        interpolate_resolver: &InterpolateResolver,
3720    ) -> Self {
3721        if t <= 0.0 {
3722            return self.clone();
3723        } else if t >= 1.0 {
3724            return other.clone();
3725        }
3726
3727        // Map from linear interpolation function to Easing curve
3728        let t: f32 = interpolate_resolver.interpolate_func.evaluate(t as f64);
3729
3730        let t = t.max(0.0).min(1.0);
3731
3732        match (self, other) {
3733            (CssProperty::TextColor(col_start), CssProperty::TextColor(col_end)) => {
3734                let col_start = col_start.get_property().copied().unwrap_or_default();
3735                let col_end = col_end.get_property().copied().unwrap_or_default();
3736                CssProperty::text_color(col_start.interpolate(&col_end, t))
3737            }
3738            (CssProperty::FontSize(fs_start), CssProperty::FontSize(fs_end)) => {
3739                let fs_start = fs_start.get_property().copied().unwrap_or_default();
3740                let fs_end = fs_end.get_property().copied().unwrap_or_default();
3741                CssProperty::font_size(fs_start.interpolate(&fs_end, t))
3742            }
3743            (CssProperty::LetterSpacing(ls_start), CssProperty::LetterSpacing(ls_end)) => {
3744                let ls_start = ls_start.get_property().copied().unwrap_or_default();
3745                let ls_end = ls_end.get_property().copied().unwrap_or_default();
3746                CssProperty::letter_spacing(ls_start.interpolate(&ls_end, t))
3747            }
3748            (CssProperty::TextIndent(ti_start), CssProperty::TextIndent(ti_end)) => {
3749                let ti_start = ti_start.get_property().copied().unwrap_or_default();
3750                let ti_end = ti_end.get_property().copied().unwrap_or_default();
3751                CssProperty::text_indent(ti_start.interpolate(&ti_end, t))
3752            }
3753            (CssProperty::LineHeight(lh_start), CssProperty::LineHeight(lh_end)) => {
3754                let lh_start = lh_start.get_property().copied().unwrap_or_default();
3755                let lh_end = lh_end.get_property().copied().unwrap_or_default();
3756                CssProperty::line_height(lh_start.interpolate(&lh_end, t))
3757            }
3758            (CssProperty::WordSpacing(ws_start), CssProperty::WordSpacing(ws_end)) => {
3759                let ws_start = ws_start.get_property().copied().unwrap_or_default();
3760                let ws_end = ws_end.get_property().copied().unwrap_or_default();
3761                CssProperty::word_spacing(ws_start.interpolate(&ws_end, t))
3762            }
3763            (CssProperty::TabSize(tw_start), CssProperty::TabSize(tw_end)) => {
3764                let tw_start = tw_start.get_property().copied().unwrap_or_default();
3765                let tw_end = tw_end.get_property().copied().unwrap_or_default();
3766                CssProperty::tab_size(tw_start.interpolate(&tw_end, t))
3767            }
3768            (CssProperty::Width(start), CssProperty::Width(end)) => {
3769                let start =
3770                    start
3771                        .get_property()
3772                        .cloned()
3773                        .unwrap_or(LayoutWidth::Px(PixelValue::px(
3774                            interpolate_resolver.current_rect_width,
3775                        )));
3776                let end = end.get_property().cloned().unwrap_or_default();
3777                CssProperty::Width(CssPropertyValue::Exact(start.interpolate(&end, t)))
3778            }
3779            (CssProperty::Height(start), CssProperty::Height(end)) => {
3780                let start =
3781                    start
3782                        .get_property()
3783                        .cloned()
3784                        .unwrap_or(LayoutHeight::Px(PixelValue::px(
3785                            interpolate_resolver.current_rect_height,
3786                        )));
3787                let end = end.get_property().cloned().unwrap_or_default();
3788                CssProperty::Height(CssPropertyValue::Exact(start.interpolate(&end, t)))
3789            }
3790            (CssProperty::MinWidth(start), CssProperty::MinWidth(end)) => {
3791                let start = start.get_property().copied().unwrap_or_default();
3792                let end = end.get_property().copied().unwrap_or_default();
3793                CssProperty::MinWidth(CssPropertyValue::Exact(start.interpolate(&end, t)))
3794            }
3795            (CssProperty::MinHeight(start), CssProperty::MinHeight(end)) => {
3796                let start = start.get_property().copied().unwrap_or_default();
3797                let end = end.get_property().copied().unwrap_or_default();
3798                CssProperty::MinHeight(CssPropertyValue::Exact(start.interpolate(&end, t)))
3799            }
3800            (CssProperty::MaxWidth(start), CssProperty::MaxWidth(end)) => {
3801                let start = start.get_property().copied().unwrap_or_default();
3802                let end = end.get_property().copied().unwrap_or_default();
3803                CssProperty::MaxWidth(CssPropertyValue::Exact(start.interpolate(&end, t)))
3804            }
3805            (CssProperty::MaxHeight(start), CssProperty::MaxHeight(end)) => {
3806                let start = start.get_property().copied().unwrap_or_default();
3807                let end = end.get_property().copied().unwrap_or_default();
3808                CssProperty::MaxHeight(CssPropertyValue::Exact(start.interpolate(&end, t)))
3809            }
3810            (CssProperty::Top(start), CssProperty::Top(end)) => {
3811                let start = start.get_property().copied().unwrap_or_default();
3812                let end = end.get_property().copied().unwrap_or_default();
3813                CssProperty::Top(CssPropertyValue::Exact(start.interpolate(&end, t)))
3814            }
3815            (CssProperty::Right(start), CssProperty::Right(end)) => {
3816                let start = start.get_property().copied().unwrap_or_default();
3817                let end = end.get_property().copied().unwrap_or_default();
3818                CssProperty::Right(CssPropertyValue::Exact(start.interpolate(&end, t)))
3819            }
3820            (CssProperty::Left(start), CssProperty::Left(end)) => {
3821                let start = start.get_property().copied().unwrap_or_default();
3822                let end = end.get_property().copied().unwrap_or_default();
3823                CssProperty::Left(CssPropertyValue::Exact(start.interpolate(&end, t)))
3824            }
3825            (CssProperty::Bottom(start), CssProperty::Bottom(end)) => {
3826                let start = start.get_property().copied().unwrap_or_default();
3827                let end = end.get_property().copied().unwrap_or_default();
3828                CssProperty::Bottom(CssPropertyValue::Exact(start.interpolate(&end, t)))
3829            }
3830            (CssProperty::FlexGrow(start), CssProperty::FlexGrow(end)) => {
3831                let start = start.get_property().copied().unwrap_or_default();
3832                let end = end.get_property().copied().unwrap_or_default();
3833                CssProperty::FlexGrow(CssPropertyValue::Exact(start.interpolate(&end, t)))
3834            }
3835            (CssProperty::FlexShrink(start), CssProperty::FlexShrink(end)) => {
3836                let start = start.get_property().copied().unwrap_or_default();
3837                let end = end.get_property().copied().unwrap_or_default();
3838                CssProperty::FlexShrink(CssPropertyValue::Exact(start.interpolate(&end, t)))
3839            }
3840            (CssProperty::PaddingTop(start), CssProperty::PaddingTop(end)) => {
3841                let start = start.get_property().copied().unwrap_or_default();
3842                let end = end.get_property().copied().unwrap_or_default();
3843                CssProperty::PaddingTop(CssPropertyValue::Exact(start.interpolate(&end, t)))
3844            }
3845            (CssProperty::PaddingLeft(start), CssProperty::PaddingLeft(end)) => {
3846                let start = start.get_property().copied().unwrap_or_default();
3847                let end = end.get_property().copied().unwrap_or_default();
3848                CssProperty::PaddingLeft(CssPropertyValue::Exact(start.interpolate(&end, t)))
3849            }
3850            (CssProperty::PaddingRight(start), CssProperty::PaddingRight(end)) => {
3851                let start = start.get_property().copied().unwrap_or_default();
3852                let end = end.get_property().copied().unwrap_or_default();
3853                CssProperty::PaddingRight(CssPropertyValue::Exact(start.interpolate(&end, t)))
3854            }
3855            (CssProperty::PaddingBottom(start), CssProperty::PaddingBottom(end)) => {
3856                let start = start.get_property().copied().unwrap_or_default();
3857                let end = end.get_property().copied().unwrap_or_default();
3858                CssProperty::PaddingBottom(CssPropertyValue::Exact(start.interpolate(&end, t)))
3859            }
3860            (CssProperty::MarginTop(start), CssProperty::MarginTop(end)) => {
3861                let start = start.get_property().copied().unwrap_or_default();
3862                let end = end.get_property().copied().unwrap_or_default();
3863                CssProperty::MarginTop(CssPropertyValue::Exact(start.interpolate(&end, t)))
3864            }
3865            (CssProperty::MarginLeft(start), CssProperty::MarginLeft(end)) => {
3866                let start = start.get_property().copied().unwrap_or_default();
3867                let end = end.get_property().copied().unwrap_or_default();
3868                CssProperty::MarginLeft(CssPropertyValue::Exact(start.interpolate(&end, t)))
3869            }
3870            (CssProperty::MarginRight(start), CssProperty::MarginRight(end)) => {
3871                let start = start.get_property().copied().unwrap_or_default();
3872                let end = end.get_property().copied().unwrap_or_default();
3873                CssProperty::MarginRight(CssPropertyValue::Exact(start.interpolate(&end, t)))
3874            }
3875            (CssProperty::MarginBottom(start), CssProperty::MarginBottom(end)) => {
3876                let start = start.get_property().copied().unwrap_or_default();
3877                let end = end.get_property().copied().unwrap_or_default();
3878                CssProperty::MarginBottom(CssPropertyValue::Exact(start.interpolate(&end, t)))
3879            }
3880            (CssProperty::BorderTopLeftRadius(start), CssProperty::BorderTopLeftRadius(end)) => {
3881                let start = start.get_property().copied().unwrap_or_default();
3882                let end = end.get_property().copied().unwrap_or_default();
3883                CssProperty::BorderTopLeftRadius(CssPropertyValue::Exact(
3884                    start.interpolate(&end, t),
3885                ))
3886            }
3887            (CssProperty::BorderTopRightRadius(start), CssProperty::BorderTopRightRadius(end)) => {
3888                let start = start.get_property().copied().unwrap_or_default();
3889                let end = end.get_property().copied().unwrap_or_default();
3890                CssProperty::BorderTopRightRadius(CssPropertyValue::Exact(
3891                    start.interpolate(&end, t),
3892                ))
3893            }
3894            (
3895                CssProperty::BorderBottomLeftRadius(start),
3896                CssProperty::BorderBottomLeftRadius(end),
3897            ) => {
3898                let start = start.get_property().copied().unwrap_or_default();
3899                let end = end.get_property().copied().unwrap_or_default();
3900                CssProperty::BorderBottomLeftRadius(CssPropertyValue::Exact(
3901                    start.interpolate(&end, t),
3902                ))
3903            }
3904            (
3905                CssProperty::BorderBottomRightRadius(start),
3906                CssProperty::BorderBottomRightRadius(end),
3907            ) => {
3908                let start = start.get_property().copied().unwrap_or_default();
3909                let end = end.get_property().copied().unwrap_or_default();
3910                CssProperty::BorderBottomRightRadius(CssPropertyValue::Exact(
3911                    start.interpolate(&end, t),
3912                ))
3913            }
3914            (CssProperty::BorderTopColor(start), CssProperty::BorderTopColor(end)) => {
3915                let start = start.get_property().copied().unwrap_or_default();
3916                let end = end.get_property().copied().unwrap_or_default();
3917                CssProperty::BorderTopColor(CssPropertyValue::Exact(start.interpolate(&end, t)))
3918            }
3919            (CssProperty::BorderRightColor(start), CssProperty::BorderRightColor(end)) => {
3920                let start = start.get_property().copied().unwrap_or_default();
3921                let end = end.get_property().copied().unwrap_or_default();
3922                CssProperty::BorderRightColor(CssPropertyValue::Exact(start.interpolate(&end, t)))
3923            }
3924            (CssProperty::BorderLeftColor(start), CssProperty::BorderLeftColor(end)) => {
3925                let start = start.get_property().copied().unwrap_or_default();
3926                let end = end.get_property().copied().unwrap_or_default();
3927                CssProperty::BorderLeftColor(CssPropertyValue::Exact(start.interpolate(&end, t)))
3928            }
3929            (CssProperty::BorderBottomColor(start), CssProperty::BorderBottomColor(end)) => {
3930                let start = start.get_property().copied().unwrap_or_default();
3931                let end = end.get_property().copied().unwrap_or_default();
3932                CssProperty::BorderBottomColor(CssPropertyValue::Exact(start.interpolate(&end, t)))
3933            }
3934            (CssProperty::BorderTopWidth(start), CssProperty::BorderTopWidth(end)) => {
3935                let start = start.get_property().copied().unwrap_or_default();
3936                let end = end.get_property().copied().unwrap_or_default();
3937                CssProperty::BorderTopWidth(CssPropertyValue::Exact(start.interpolate(&end, t)))
3938            }
3939            (CssProperty::BorderRightWidth(start), CssProperty::BorderRightWidth(end)) => {
3940                let start = start.get_property().copied().unwrap_or_default();
3941                let end = end.get_property().copied().unwrap_or_default();
3942                CssProperty::BorderRightWidth(CssPropertyValue::Exact(start.interpolate(&end, t)))
3943            }
3944            (CssProperty::BorderLeftWidth(start), CssProperty::BorderLeftWidth(end)) => {
3945                let start = start.get_property().copied().unwrap_or_default();
3946                let end = end.get_property().copied().unwrap_or_default();
3947                CssProperty::BorderLeftWidth(CssPropertyValue::Exact(start.interpolate(&end, t)))
3948            }
3949            (CssProperty::BorderBottomWidth(start), CssProperty::BorderBottomWidth(end)) => {
3950                let start = start.get_property().copied().unwrap_or_default();
3951                let end = end.get_property().copied().unwrap_or_default();
3952                CssProperty::BorderBottomWidth(CssPropertyValue::Exact(start.interpolate(&end, t)))
3953            }
3954            (CssProperty::Opacity(start), CssProperty::Opacity(end)) => {
3955                let start = start.get_property().copied().unwrap_or_default();
3956                let end = end.get_property().copied().unwrap_or_default();
3957                CssProperty::Opacity(CssPropertyValue::Exact(start.interpolate(&end, t)))
3958            }
3959            (CssProperty::TransformOrigin(start), CssProperty::TransformOrigin(end)) => {
3960                let start = start.get_property().copied().unwrap_or_default();
3961                let end = end.get_property().copied().unwrap_or_default();
3962                CssProperty::TransformOrigin(CssPropertyValue::Exact(start.interpolate(&end, t)))
3963            }
3964            (CssProperty::PerspectiveOrigin(start), CssProperty::PerspectiveOrigin(end)) => {
3965                let start = start.get_property().copied().unwrap_or_default();
3966                let end = end.get_property().copied().unwrap_or_default();
3967                CssProperty::PerspectiveOrigin(CssPropertyValue::Exact(start.interpolate(&end, t)))
3968            }
3969            /*
3970            animate transform:
3971            CssProperty::Transform(CssPropertyValue<StyleTransformVec>),
3972
3973            animate box shadow:
3974            CssProperty::BoxShadowLeft(CssPropertyValue<StyleBoxShadow>),
3975            CssProperty::BoxShadowRight(CssPropertyValue<StyleBoxShadow>),
3976            CssProperty::BoxShadowTop(CssPropertyValue<StyleBoxShadow>),
3977            CssProperty::BoxShadowBottom(CssPropertyValue<StyleBoxShadow>),
3978
3979            animate background:
3980            CssProperty::BackgroundContent(CssPropertyValue<StyleBackgroundContentVec>),
3981            CssProperty::BackgroundPosition(CssPropertyValue<StyleBackgroundPositionVec>),
3982            CssProperty::BackgroundSize(CssPropertyValue<StyleBackgroundSizeVec>),
3983            */
3984            (_, _) => {
3985                // not animatable, fallback
3986                if t > 0.5 {
3987                    other.clone()
3988                } else {
3989                    self.clone()
3990                }
3991            }
3992        }
3993    }
3994
3995    /// Return the type (key) of this property as a statically typed enum
3996    pub const fn get_type(&self) -> CssPropertyType {
3997        match &self {
3998            CssProperty::CaretColor(_) => CssPropertyType::CaretColor,
3999            CssProperty::CaretWidth(_) => CssPropertyType::CaretWidth,
4000            CssProperty::CaretAnimationDuration(_) => CssPropertyType::CaretAnimationDuration,
4001            CssProperty::SelectionBackgroundColor(_) => CssPropertyType::SelectionBackgroundColor,
4002            CssProperty::SelectionColor(_) => CssPropertyType::SelectionColor,
4003            CssProperty::SelectionRadius(_) => CssPropertyType::SelectionRadius,
4004
4005            CssProperty::TextJustify(_) => CssPropertyType::TextJustify,
4006            CssProperty::LayoutTextJustify(_) => CssPropertyType::TextAlign, /* oder ggf. ein */
4007            // eigener Typ
4008            CssProperty::TextColor(_) => CssPropertyType::TextColor,
4009            CssProperty::FontSize(_) => CssPropertyType::FontSize,
4010            CssProperty::FontFamily(_) => CssPropertyType::FontFamily,
4011            CssProperty::FontWeight(_) => CssPropertyType::FontWeight,
4012            CssProperty::FontStyle(_) => CssPropertyType::FontStyle,
4013            CssProperty::TextAlign(_) => CssPropertyType::TextAlign,
4014            CssProperty::VerticalAlign(_) => CssPropertyType::VerticalAlign,
4015            CssProperty::LetterSpacing(_) => CssPropertyType::LetterSpacing,
4016            CssProperty::TextIndent(_) => CssPropertyType::TextIndent,
4017            CssProperty::InitialLetter(_) => CssPropertyType::InitialLetter,
4018            CssProperty::LineClamp(_) => CssPropertyType::LineClamp,
4019            CssProperty::HangingPunctuation(_) => CssPropertyType::HangingPunctuation,
4020            CssProperty::TextCombineUpright(_) => CssPropertyType::TextCombineUpright,
4021            CssProperty::ExclusionMargin(_) => CssPropertyType::ExclusionMargin,
4022            CssProperty::HyphenationLanguage(_) => CssPropertyType::HyphenationLanguage,
4023            CssProperty::LineHeight(_) => CssPropertyType::LineHeight,
4024            CssProperty::WordSpacing(_) => CssPropertyType::WordSpacing,
4025            CssProperty::TabSize(_) => CssPropertyType::TabSize,
4026            CssProperty::Cursor(_) => CssPropertyType::Cursor,
4027            CssProperty::Display(_) => CssPropertyType::Display,
4028            CssProperty::Float(_) => CssPropertyType::Float,
4029            CssProperty::BoxSizing(_) => CssPropertyType::BoxSizing,
4030            CssProperty::Width(_) => CssPropertyType::Width,
4031            CssProperty::Height(_) => CssPropertyType::Height,
4032            CssProperty::MinWidth(_) => CssPropertyType::MinWidth,
4033            CssProperty::MinHeight(_) => CssPropertyType::MinHeight,
4034            CssProperty::MaxWidth(_) => CssPropertyType::MaxWidth,
4035            CssProperty::MaxHeight(_) => CssPropertyType::MaxHeight,
4036            CssProperty::Position(_) => CssPropertyType::Position,
4037            CssProperty::Top(_) => CssPropertyType::Top,
4038            CssProperty::Right(_) => CssPropertyType::Right,
4039            CssProperty::Left(_) => CssPropertyType::Left,
4040            CssProperty::Bottom(_) => CssPropertyType::Bottom,
4041            CssProperty::ZIndex(_) => CssPropertyType::ZIndex,
4042            CssProperty::FlexWrap(_) => CssPropertyType::FlexWrap,
4043            CssProperty::FlexDirection(_) => CssPropertyType::FlexDirection,
4044            CssProperty::FlexGrow(_) => CssPropertyType::FlexGrow,
4045            CssProperty::FlexShrink(_) => CssPropertyType::FlexShrink,
4046            CssProperty::FlexBasis(_) => CssPropertyType::FlexBasis,
4047            CssProperty::JustifyContent(_) => CssPropertyType::JustifyContent,
4048            CssProperty::AlignItems(_) => CssPropertyType::AlignItems,
4049            CssProperty::AlignContent(_) => CssPropertyType::AlignContent,
4050            CssProperty::ColumnGap(_) => CssPropertyType::ColumnGap,
4051            CssProperty::RowGap(_) => CssPropertyType::RowGap,
4052            CssProperty::GridTemplateColumns(_) => CssPropertyType::GridTemplateColumns,
4053            CssProperty::GridTemplateRows(_) => CssPropertyType::GridTemplateRows,
4054            CssProperty::GridAutoColumns(_) => CssPropertyType::GridAutoColumns,
4055            CssProperty::GridAutoRows(_) => CssPropertyType::GridAutoRows,
4056            CssProperty::GridColumn(_) => CssPropertyType::GridColumn,
4057            CssProperty::GridAutoFlow(_) => CssPropertyType::GridAutoFlow,
4058            CssProperty::JustifySelf(_) => CssPropertyType::JustifySelf,
4059            CssProperty::JustifyItems(_) => CssPropertyType::JustifyItems,
4060            CssProperty::Gap(_) => CssPropertyType::Gap,
4061            CssProperty::GridGap(_) => CssPropertyType::GridGap,
4062            CssProperty::AlignSelf(_) => CssPropertyType::AlignSelf,
4063            CssProperty::Font(_) => CssPropertyType::Font,
4064            CssProperty::GridRow(_) => CssPropertyType::GridRow,
4065            CssProperty::GridTemplateAreas(_) => CssPropertyType::GridTemplateAreas,
4066            CssProperty::WritingMode(_) => CssPropertyType::WritingMode,
4067            CssProperty::Clear(_) => CssPropertyType::Clear,
4068            CssProperty::BackgroundContent(_) => CssPropertyType::BackgroundContent,
4069            CssProperty::BackgroundPosition(_) => CssPropertyType::BackgroundPosition,
4070            CssProperty::BackgroundSize(_) => CssPropertyType::BackgroundSize,
4071            CssProperty::BackgroundRepeat(_) => CssPropertyType::BackgroundRepeat,
4072            CssProperty::OverflowX(_) => CssPropertyType::OverflowX,
4073            CssProperty::OverflowY(_) => CssPropertyType::OverflowY,
4074            CssProperty::PaddingTop(_) => CssPropertyType::PaddingTop,
4075            CssProperty::PaddingLeft(_) => CssPropertyType::PaddingLeft,
4076            CssProperty::PaddingRight(_) => CssPropertyType::PaddingRight,
4077            CssProperty::PaddingBottom(_) => CssPropertyType::PaddingBottom,
4078            CssProperty::PaddingInlineStart(_) => CssPropertyType::PaddingInlineStart,
4079            CssProperty::PaddingInlineEnd(_) => CssPropertyType::PaddingInlineEnd,
4080            CssProperty::MarginTop(_) => CssPropertyType::MarginTop,
4081            CssProperty::MarginLeft(_) => CssPropertyType::MarginLeft,
4082            CssProperty::MarginRight(_) => CssPropertyType::MarginRight,
4083            CssProperty::MarginBottom(_) => CssPropertyType::MarginBottom,
4084            CssProperty::BorderTopLeftRadius(_) => CssPropertyType::BorderTopLeftRadius,
4085            CssProperty::BorderTopRightRadius(_) => CssPropertyType::BorderTopRightRadius,
4086            CssProperty::BorderBottomLeftRadius(_) => CssPropertyType::BorderBottomLeftRadius,
4087            CssProperty::BorderBottomRightRadius(_) => CssPropertyType::BorderBottomRightRadius,
4088            CssProperty::BorderTopColor(_) => CssPropertyType::BorderTopColor,
4089            CssProperty::BorderRightColor(_) => CssPropertyType::BorderRightColor,
4090            CssProperty::BorderLeftColor(_) => CssPropertyType::BorderLeftColor,
4091            CssProperty::BorderBottomColor(_) => CssPropertyType::BorderBottomColor,
4092            CssProperty::BorderTopStyle(_) => CssPropertyType::BorderTopStyle,
4093            CssProperty::BorderRightStyle(_) => CssPropertyType::BorderRightStyle,
4094            CssProperty::BorderLeftStyle(_) => CssPropertyType::BorderLeftStyle,
4095            CssProperty::BorderBottomStyle(_) => CssPropertyType::BorderBottomStyle,
4096            CssProperty::BorderTopWidth(_) => CssPropertyType::BorderTopWidth,
4097            CssProperty::BorderRightWidth(_) => CssPropertyType::BorderRightWidth,
4098            CssProperty::BorderLeftWidth(_) => CssPropertyType::BorderLeftWidth,
4099            CssProperty::BorderBottomWidth(_) => CssPropertyType::BorderBottomWidth,
4100            CssProperty::BoxShadowLeft(_) => CssPropertyType::BoxShadowLeft,
4101            CssProperty::BoxShadowRight(_) => CssPropertyType::BoxShadowRight,
4102            CssProperty::BoxShadowTop(_) => CssPropertyType::BoxShadowTop,
4103            CssProperty::BoxShadowBottom(_) => CssPropertyType::BoxShadowBottom,
4104            CssProperty::Scrollbar(_) => CssPropertyType::Scrollbar,
4105            CssProperty::ScrollbarWidth(_) => CssPropertyType::ScrollbarWidth,
4106            CssProperty::ScrollbarColor(_) => CssPropertyType::ScrollbarColor,
4107            CssProperty::Opacity(_) => CssPropertyType::Opacity,
4108            CssProperty::Visibility(_) => CssPropertyType::Visibility,
4109            CssProperty::Transform(_) => CssPropertyType::Transform,
4110            CssProperty::PerspectiveOrigin(_) => CssPropertyType::PerspectiveOrigin,
4111            CssProperty::TransformOrigin(_) => CssPropertyType::TransformOrigin,
4112            CssProperty::BackfaceVisibility(_) => CssPropertyType::BackfaceVisibility,
4113            CssProperty::MixBlendMode(_) => CssPropertyType::MixBlendMode,
4114            CssProperty::Filter(_) => CssPropertyType::Filter,
4115            CssProperty::BackdropFilter(_) => CssPropertyType::BackdropFilter,
4116            CssProperty::TextShadow(_) => CssPropertyType::TextShadow,
4117            CssProperty::WhiteSpace(_) => CssPropertyType::WhiteSpace,
4118            CssProperty::Hyphens(_) => CssPropertyType::Hyphens,
4119            CssProperty::Direction(_) => CssPropertyType::Direction,
4120            CssProperty::UserSelect(_) => CssPropertyType::UserSelect,
4121            CssProperty::TextDecoration(_) => CssPropertyType::TextDecoration,
4122            CssProperty::BreakBefore(_) => CssPropertyType::BreakBefore,
4123            CssProperty::BreakAfter(_) => CssPropertyType::BreakAfter,
4124            CssProperty::BreakInside(_) => CssPropertyType::BreakInside,
4125            CssProperty::Orphans(_) => CssPropertyType::Orphans,
4126            CssProperty::Widows(_) => CssPropertyType::Widows,
4127            CssProperty::BoxDecorationBreak(_) => CssPropertyType::BoxDecorationBreak,
4128            CssProperty::ColumnCount(_) => CssPropertyType::ColumnCount,
4129            CssProperty::ColumnWidth(_) => CssPropertyType::ColumnWidth,
4130            CssProperty::ColumnSpan(_) => CssPropertyType::ColumnSpan,
4131            CssProperty::ColumnFill(_) => CssPropertyType::ColumnFill,
4132            CssProperty::ColumnRuleWidth(_) => CssPropertyType::ColumnRuleWidth,
4133            CssProperty::ColumnRuleStyle(_) => CssPropertyType::ColumnRuleStyle,
4134            CssProperty::ColumnRuleColor(_) => CssPropertyType::ColumnRuleColor,
4135            CssProperty::FlowInto(_) => CssPropertyType::FlowInto,
4136            CssProperty::FlowFrom(_) => CssPropertyType::FlowFrom,
4137            CssProperty::ShapeOutside(_) => CssPropertyType::ShapeOutside,
4138            CssProperty::ShapeInside(_) => CssPropertyType::ShapeInside,
4139            CssProperty::ClipPath(_) => CssPropertyType::ClipPath,
4140            CssProperty::ShapeMargin(_) => CssPropertyType::ShapeMargin,
4141            CssProperty::ShapeImageThreshold(_) => CssPropertyType::ShapeImageThreshold,
4142            CssProperty::Content(_) => CssPropertyType::Content,
4143            CssProperty::CounterReset(_) => CssPropertyType::CounterReset,
4144            CssProperty::CounterIncrement(_) => CssPropertyType::CounterIncrement,
4145            CssProperty::ListStyleType(_) => CssPropertyType::ListStyleType,
4146            CssProperty::ListStylePosition(_) => CssPropertyType::ListStylePosition,
4147            CssProperty::StringSet(_) => CssPropertyType::StringSet,
4148            CssProperty::TableLayout(_) => CssPropertyType::TableLayout,
4149            CssProperty::BorderCollapse(_) => CssPropertyType::BorderCollapse,
4150            CssProperty::BorderSpacing(_) => CssPropertyType::BorderSpacing,
4151            CssProperty::CaptionSide(_) => CssPropertyType::CaptionSide,
4152            CssProperty::EmptyCells(_) => CssPropertyType::EmptyCells,
4153            CssProperty::FontWeight(_) => CssPropertyType::FontWeight,
4154            CssProperty::FontStyle(_) => CssPropertyType::FontStyle,
4155        }
4156    }
4157
4158    // const constructors for easier API access
4159
4160    pub const fn none(prop_type: CssPropertyType) -> Self {
4161        css_property_from_type!(prop_type, None)
4162    }
4163    pub const fn auto(prop_type: CssPropertyType) -> Self {
4164        css_property_from_type!(prop_type, Auto)
4165    }
4166    pub const fn initial(prop_type: CssPropertyType) -> Self {
4167        css_property_from_type!(prop_type, Initial)
4168    }
4169    pub const fn inherit(prop_type: CssPropertyType) -> Self {
4170        css_property_from_type!(prop_type, Inherit)
4171    }
4172
4173    pub const fn text_color(input: StyleTextColor) -> Self {
4174        CssProperty::TextColor(CssPropertyValue::Exact(input))
4175    }
4176    pub const fn font_size(input: StyleFontSize) -> Self {
4177        CssProperty::FontSize(CssPropertyValue::Exact(input))
4178    }
4179    pub const fn font_family(input: StyleFontFamilyVec) -> Self {
4180        CssProperty::FontFamily(CssPropertyValue::Exact(input))
4181    }
4182    pub const fn font_weight(input: StyleFontWeight) -> Self {
4183        CssProperty::FontWeight(CssPropertyValue::Exact(input))
4184    }
4185    pub const fn font_style(input: StyleFontStyle) -> Self {
4186        CssProperty::FontStyle(CssPropertyValue::Exact(input))
4187    }
4188    pub const fn text_align(input: StyleTextAlign) -> Self {
4189        CssProperty::TextAlign(CssPropertyValue::Exact(input))
4190    }
4191    pub const fn text_justify(input: LayoutTextJustify) -> Self {
4192        CssProperty::TextJustify(CssPropertyValue::Exact(input))
4193    }
4194    pub const fn vertical_align(input: StyleVerticalAlign) -> Self {
4195        CssProperty::VerticalAlign(CssPropertyValue::Exact(input))
4196    }
4197    pub const fn letter_spacing(input: StyleLetterSpacing) -> Self {
4198        CssProperty::LetterSpacing(CssPropertyValue::Exact(input))
4199    }
4200    pub const fn text_indent(input: StyleTextIndent) -> Self {
4201        CssProperty::TextIndent(CssPropertyValue::Exact(input))
4202    }
4203    pub const fn line_height(input: StyleLineHeight) -> Self {
4204        CssProperty::LineHeight(CssPropertyValue::Exact(input))
4205    }
4206    pub const fn word_spacing(input: StyleWordSpacing) -> Self {
4207        CssProperty::WordSpacing(CssPropertyValue::Exact(input))
4208    }
4209    pub const fn tab_size(input: StyleTabSize) -> Self {
4210        CssProperty::TabSize(CssPropertyValue::Exact(input))
4211    }
4212    pub const fn cursor(input: StyleCursor) -> Self {
4213        CssProperty::Cursor(CssPropertyValue::Exact(input))
4214    }
4215    pub const fn user_select(input: StyleUserSelect) -> Self {
4216        CssProperty::UserSelect(CssPropertyValue::Exact(input))
4217    }
4218    pub const fn text_decoration(input: StyleTextDecoration) -> Self {
4219        CssProperty::TextDecoration(CssPropertyValue::Exact(input))
4220    }
4221    pub const fn display(input: LayoutDisplay) -> Self {
4222        CssProperty::Display(CssPropertyValue::Exact(input))
4223    }
4224    pub const fn box_sizing(input: LayoutBoxSizing) -> Self {
4225        CssProperty::BoxSizing(CssPropertyValue::Exact(input))
4226    }
4227    pub const fn width(input: LayoutWidth) -> Self {
4228        CssProperty::Width(CssPropertyValue::Exact(input))
4229    }
4230    pub const fn height(input: LayoutHeight) -> Self {
4231        CssProperty::Height(CssPropertyValue::Exact(input))
4232    }
4233    pub const fn min_width(input: LayoutMinWidth) -> Self {
4234        CssProperty::MinWidth(CssPropertyValue::Exact(input))
4235    }
4236    pub const fn caret_color(input: CaretColor) -> Self {
4237        CssProperty::CaretColor(CssPropertyValue::Exact(input))
4238    }
4239    pub const fn caret_width(input: CaretWidth) -> Self {
4240        CssProperty::CaretWidth(CssPropertyValue::Exact(input))
4241    }
4242    pub const fn caret_animation_duration(input: CaretAnimationDuration) -> Self {
4243        CssProperty::CaretAnimationDuration(CssPropertyValue::Exact(input))
4244    }
4245    pub const fn selection_background_color(input: SelectionBackgroundColor) -> Self {
4246        CssProperty::SelectionBackgroundColor(CssPropertyValue::Exact(input))
4247    }
4248    pub const fn selection_color(input: SelectionColor) -> Self {
4249        CssProperty::SelectionColor(CssPropertyValue::Exact(input))
4250    }
4251    pub const fn min_height(input: LayoutMinHeight) -> Self {
4252        CssProperty::MinHeight(CssPropertyValue::Exact(input))
4253    }
4254    pub const fn max_width(input: LayoutMaxWidth) -> Self {
4255        CssProperty::MaxWidth(CssPropertyValue::Exact(input))
4256    }
4257    pub const fn max_height(input: LayoutMaxHeight) -> Self {
4258        CssProperty::MaxHeight(CssPropertyValue::Exact(input))
4259    }
4260    pub const fn position(input: LayoutPosition) -> Self {
4261        CssProperty::Position(CssPropertyValue::Exact(input))
4262    }
4263    pub const fn top(input: LayoutTop) -> Self {
4264        CssProperty::Top(CssPropertyValue::Exact(input))
4265    }
4266    pub const fn right(input: LayoutRight) -> Self {
4267        CssProperty::Right(CssPropertyValue::Exact(input))
4268    }
4269    pub const fn left(input: LayoutLeft) -> Self {
4270        CssProperty::Left(CssPropertyValue::Exact(input))
4271    }
4272    pub const fn bottom(input: LayoutInsetBottom) -> Self {
4273        CssProperty::Bottom(CssPropertyValue::Exact(input))
4274    }
4275    pub const fn z_index(input: LayoutZIndex) -> Self {
4276        CssProperty::ZIndex(CssPropertyValue::Exact(input))
4277    }
4278    pub const fn flex_wrap(input: LayoutFlexWrap) -> Self {
4279        CssProperty::FlexWrap(CssPropertyValue::Exact(input))
4280    }
4281    pub const fn flex_direction(input: LayoutFlexDirection) -> Self {
4282        CssProperty::FlexDirection(CssPropertyValue::Exact(input))
4283    }
4284    pub const fn flex_grow(input: LayoutFlexGrow) -> Self {
4285        CssProperty::FlexGrow(CssPropertyValue::Exact(input))
4286    }
4287    pub const fn flex_shrink(input: LayoutFlexShrink) -> Self {
4288        CssProperty::FlexShrink(CssPropertyValue::Exact(input))
4289    }
4290    pub const fn justify_content(input: LayoutJustifyContent) -> Self {
4291        CssProperty::JustifyContent(CssPropertyValue::Exact(input))
4292    }
4293    pub const fn grid_auto_flow(input: LayoutGridAutoFlow) -> Self {
4294        CssProperty::GridAutoFlow(CssPropertyValue::Exact(input))
4295    }
4296    pub const fn justify_self(input: LayoutJustifySelf) -> Self {
4297        CssProperty::JustifySelf(CssPropertyValue::Exact(input))
4298    }
4299    pub const fn justify_items(input: LayoutJustifyItems) -> Self {
4300        CssProperty::JustifyItems(CssPropertyValue::Exact(input))
4301    }
4302    pub const fn gap(input: LayoutGap) -> Self {
4303        CssProperty::Gap(CssPropertyValue::Exact(input))
4304    }
4305    pub const fn grid_gap(input: LayoutGap) -> Self {
4306        CssProperty::GridGap(CssPropertyValue::Exact(input))
4307    }
4308    pub const fn align_self(input: LayoutAlignSelf) -> Self {
4309        CssProperty::AlignSelf(CssPropertyValue::Exact(input))
4310    }
4311    pub const fn font(input: StyleFontFamilyVec) -> Self {
4312        CssProperty::Font(StyleFontValue::Exact(input))
4313    }
4314    pub const fn align_items(input: LayoutAlignItems) -> Self {
4315        CssProperty::AlignItems(CssPropertyValue::Exact(input))
4316    }
4317    pub const fn align_content(input: LayoutAlignContent) -> Self {
4318        CssProperty::AlignContent(CssPropertyValue::Exact(input))
4319    }
4320    pub const fn background_content(input: StyleBackgroundContentVec) -> Self {
4321        CssProperty::BackgroundContent(CssPropertyValue::Exact(input))
4322    }
4323    pub const fn background_position(input: StyleBackgroundPositionVec) -> Self {
4324        CssProperty::BackgroundPosition(CssPropertyValue::Exact(input))
4325    }
4326    pub const fn background_size(input: StyleBackgroundSizeVec) -> Self {
4327        CssProperty::BackgroundSize(CssPropertyValue::Exact(input))
4328    }
4329    pub const fn background_repeat(input: StyleBackgroundRepeatVec) -> Self {
4330        CssProperty::BackgroundRepeat(CssPropertyValue::Exact(input))
4331    }
4332    pub const fn overflow_x(input: LayoutOverflow) -> Self {
4333        CssProperty::OverflowX(CssPropertyValue::Exact(input))
4334    }
4335    pub const fn overflow_y(input: LayoutOverflow) -> Self {
4336        CssProperty::OverflowY(CssPropertyValue::Exact(input))
4337    }
4338    pub const fn padding_top(input: LayoutPaddingTop) -> Self {
4339        CssProperty::PaddingTop(CssPropertyValue::Exact(input))
4340    }
4341    pub const fn padding_left(input: LayoutPaddingLeft) -> Self {
4342        CssProperty::PaddingLeft(CssPropertyValue::Exact(input))
4343    }
4344    pub const fn padding_right(input: LayoutPaddingRight) -> Self {
4345        CssProperty::PaddingRight(CssPropertyValue::Exact(input))
4346    }
4347    pub const fn padding_bottom(input: LayoutPaddingBottom) -> Self {
4348        CssProperty::PaddingBottom(CssPropertyValue::Exact(input))
4349    }
4350    pub const fn margin_top(input: LayoutMarginTop) -> Self {
4351        CssProperty::MarginTop(CssPropertyValue::Exact(input))
4352    }
4353    pub const fn margin_left(input: LayoutMarginLeft) -> Self {
4354        CssProperty::MarginLeft(CssPropertyValue::Exact(input))
4355    }
4356    pub const fn margin_right(input: LayoutMarginRight) -> Self {
4357        CssProperty::MarginRight(CssPropertyValue::Exact(input))
4358    }
4359    pub const fn margin_bottom(input: LayoutMarginBottom) -> Self {
4360        CssProperty::MarginBottom(CssPropertyValue::Exact(input))
4361    }
4362    pub const fn border_top_left_radius(input: StyleBorderTopLeftRadius) -> Self {
4363        CssProperty::BorderTopLeftRadius(CssPropertyValue::Exact(input))
4364    }
4365    pub const fn border_top_right_radius(input: StyleBorderTopRightRadius) -> Self {
4366        CssProperty::BorderTopRightRadius(CssPropertyValue::Exact(input))
4367    }
4368    pub const fn border_bottom_left_radius(input: StyleBorderBottomLeftRadius) -> Self {
4369        CssProperty::BorderBottomLeftRadius(CssPropertyValue::Exact(input))
4370    }
4371    pub const fn border_bottom_right_radius(input: StyleBorderBottomRightRadius) -> Self {
4372        CssProperty::BorderBottomRightRadius(CssPropertyValue::Exact(input))
4373    }
4374    pub const fn border_top_color(input: StyleBorderTopColor) -> Self {
4375        CssProperty::BorderTopColor(CssPropertyValue::Exact(input))
4376    }
4377    pub const fn border_right_color(input: StyleBorderRightColor) -> Self {
4378        CssProperty::BorderRightColor(CssPropertyValue::Exact(input))
4379    }
4380    pub const fn border_left_color(input: StyleBorderLeftColor) -> Self {
4381        CssProperty::BorderLeftColor(CssPropertyValue::Exact(input))
4382    }
4383    pub const fn border_bottom_color(input: StyleBorderBottomColor) -> Self {
4384        CssProperty::BorderBottomColor(CssPropertyValue::Exact(input))
4385    }
4386    pub const fn border_top_style(input: StyleBorderTopStyle) -> Self {
4387        CssProperty::BorderTopStyle(CssPropertyValue::Exact(input))
4388    }
4389    pub const fn border_right_style(input: StyleBorderRightStyle) -> Self {
4390        CssProperty::BorderRightStyle(CssPropertyValue::Exact(input))
4391    }
4392    pub const fn border_left_style(input: StyleBorderLeftStyle) -> Self {
4393        CssProperty::BorderLeftStyle(CssPropertyValue::Exact(input))
4394    }
4395    pub const fn border_bottom_style(input: StyleBorderBottomStyle) -> Self {
4396        CssProperty::BorderBottomStyle(CssPropertyValue::Exact(input))
4397    }
4398    pub const fn border_top_width(input: LayoutBorderTopWidth) -> Self {
4399        CssProperty::BorderTopWidth(CssPropertyValue::Exact(input))
4400    }
4401    pub const fn border_right_width(input: LayoutBorderRightWidth) -> Self {
4402        CssProperty::BorderRightWidth(CssPropertyValue::Exact(input))
4403    }
4404    pub const fn border_left_width(input: LayoutBorderLeftWidth) -> Self {
4405        CssProperty::BorderLeftWidth(CssPropertyValue::Exact(input))
4406    }
4407    pub const fn border_bottom_width(input: LayoutBorderBottomWidth) -> Self {
4408        CssProperty::BorderBottomWidth(CssPropertyValue::Exact(input))
4409    }
4410    pub const fn box_shadow_left(input: StyleBoxShadow) -> Self {
4411        CssProperty::BoxShadowLeft(CssPropertyValue::Exact(input))
4412    }
4413    pub const fn box_shadow_right(input: StyleBoxShadow) -> Self {
4414        CssProperty::BoxShadowRight(CssPropertyValue::Exact(input))
4415    }
4416    pub const fn box_shadow_top(input: StyleBoxShadow) -> Self {
4417        CssProperty::BoxShadowTop(CssPropertyValue::Exact(input))
4418    }
4419    pub const fn box_shadow_bottom(input: StyleBoxShadow) -> Self {
4420        CssProperty::BoxShadowBottom(CssPropertyValue::Exact(input))
4421    }
4422    pub const fn opacity(input: StyleOpacity) -> Self {
4423        CssProperty::Opacity(CssPropertyValue::Exact(input))
4424    }
4425    pub const fn visibility(input: StyleVisibility) -> Self {
4426        CssProperty::Visibility(CssPropertyValue::Exact(input))
4427    }
4428    pub const fn transform(input: StyleTransformVec) -> Self {
4429        CssProperty::Transform(CssPropertyValue::Exact(input))
4430    }
4431    pub const fn transform_origin(input: StyleTransformOrigin) -> Self {
4432        CssProperty::TransformOrigin(CssPropertyValue::Exact(input))
4433    }
4434    pub const fn perspective_origin(input: StylePerspectiveOrigin) -> Self {
4435        CssProperty::PerspectiveOrigin(CssPropertyValue::Exact(input))
4436    }
4437    pub const fn backface_visiblity(input: StyleBackfaceVisibility) -> Self {
4438        CssProperty::BackfaceVisibility(CssPropertyValue::Exact(input))
4439    }
4440
4441    // New DTP const fn constructors
4442    pub const fn break_before(input: PageBreak) -> Self {
4443        CssProperty::BreakBefore(CssPropertyValue::Exact(input))
4444    }
4445    pub const fn break_after(input: PageBreak) -> Self {
4446        CssProperty::BreakAfter(CssPropertyValue::Exact(input))
4447    }
4448    pub const fn break_inside(input: BreakInside) -> Self {
4449        CssProperty::BreakInside(CssPropertyValue::Exact(input))
4450    }
4451    pub const fn orphans(input: Orphans) -> Self {
4452        CssProperty::Orphans(CssPropertyValue::Exact(input))
4453    }
4454    pub const fn widows(input: Widows) -> Self {
4455        CssProperty::Widows(CssPropertyValue::Exact(input))
4456    }
4457    pub const fn box_decoration_break(input: BoxDecorationBreak) -> Self {
4458        CssProperty::BoxDecorationBreak(CssPropertyValue::Exact(input))
4459    }
4460    pub const fn column_count(input: ColumnCount) -> Self {
4461        CssProperty::ColumnCount(CssPropertyValue::Exact(input))
4462    }
4463    pub const fn column_width(input: ColumnWidth) -> Self {
4464        CssProperty::ColumnWidth(CssPropertyValue::Exact(input))
4465    }
4466    pub const fn column_span(input: ColumnSpan) -> Self {
4467        CssProperty::ColumnSpan(CssPropertyValue::Exact(input))
4468    }
4469    pub const fn column_fill(input: ColumnFill) -> Self {
4470        CssProperty::ColumnFill(CssPropertyValue::Exact(input))
4471    }
4472    pub const fn column_rule_width(input: ColumnRuleWidth) -> Self {
4473        CssProperty::ColumnRuleWidth(CssPropertyValue::Exact(input))
4474    }
4475    pub const fn column_rule_style(input: ColumnRuleStyle) -> Self {
4476        CssProperty::ColumnRuleStyle(CssPropertyValue::Exact(input))
4477    }
4478    pub const fn column_rule_color(input: ColumnRuleColor) -> Self {
4479        CssProperty::ColumnRuleColor(CssPropertyValue::Exact(input))
4480    }
4481    pub const fn flow_into(input: FlowInto) -> Self {
4482        CssProperty::FlowInto(CssPropertyValue::Exact(input))
4483    }
4484    pub const fn flow_from(input: FlowFrom) -> Self {
4485        CssProperty::FlowFrom(CssPropertyValue::Exact(input))
4486    }
4487    pub const fn shape_outside(input: ShapeOutside) -> Self {
4488        CssProperty::ShapeOutside(CssPropertyValue::Exact(input))
4489    }
4490    pub const fn shape_inside(input: ShapeInside) -> Self {
4491        CssProperty::ShapeInside(CssPropertyValue::Exact(input))
4492    }
4493    pub const fn clip_path(input: ClipPath) -> Self {
4494        CssProperty::ClipPath(CssPropertyValue::Exact(input))
4495    }
4496    pub const fn shape_margin(input: ShapeMargin) -> Self {
4497        CssProperty::ShapeMargin(CssPropertyValue::Exact(input))
4498    }
4499    pub const fn shape_image_threshold(input: ShapeImageThreshold) -> Self {
4500        CssProperty::ShapeImageThreshold(CssPropertyValue::Exact(input))
4501    }
4502    pub const fn content(input: Content) -> Self {
4503        CssProperty::Content(CssPropertyValue::Exact(input))
4504    }
4505    pub const fn counter_reset(input: CounterReset) -> Self {
4506        CssProperty::CounterReset(CssPropertyValue::Exact(input))
4507    }
4508    pub const fn counter_increment(input: CounterIncrement) -> Self {
4509        CssProperty::CounterIncrement(CssPropertyValue::Exact(input))
4510    }
4511    pub const fn list_style_type(input: StyleListStyleType) -> Self {
4512        CssProperty::ListStyleType(CssPropertyValue::Exact(input))
4513    }
4514    pub const fn list_style_position(input: StyleListStylePosition) -> Self {
4515        CssProperty::ListStylePosition(CssPropertyValue::Exact(input))
4516    }
4517    pub const fn string_set(input: StringSet) -> Self {
4518        CssProperty::StringSet(CssPropertyValue::Exact(input))
4519    }
4520    pub const fn table_layout(input: LayoutTableLayout) -> Self {
4521        CssProperty::TableLayout(CssPropertyValue::Exact(input))
4522    }
4523    pub const fn border_collapse(input: StyleBorderCollapse) -> Self {
4524        CssProperty::BorderCollapse(CssPropertyValue::Exact(input))
4525    }
4526    pub const fn border_spacing(input: LayoutBorderSpacing) -> Self {
4527        CssProperty::BorderSpacing(CssPropertyValue::Exact(input))
4528    }
4529    pub const fn caption_side(input: StyleCaptionSide) -> Self {
4530        CssProperty::CaptionSide(CssPropertyValue::Exact(input))
4531    }
4532    pub const fn empty_cells(input: StyleEmptyCells) -> Self {
4533        CssProperty::EmptyCells(CssPropertyValue::Exact(input))
4534    }
4535
4536    pub const fn as_z_index(&self) -> Option<&LayoutZIndexValue> {
4537        match self {
4538            CssProperty::ZIndex(f) => Some(f),
4539            _ => None,
4540        }
4541    }
4542
4543    pub const fn as_flex_basis(&self) -> Option<&LayoutFlexBasisValue> {
4544        match self {
4545            CssProperty::FlexBasis(f) => Some(f),
4546            _ => None,
4547        }
4548    }
4549
4550    pub const fn as_column_gap(&self) -> Option<&LayoutColumnGapValue> {
4551        match self {
4552            CssProperty::ColumnGap(f) => Some(f),
4553            _ => None,
4554        }
4555    }
4556
4557    pub const fn as_row_gap(&self) -> Option<&LayoutRowGapValue> {
4558        match self {
4559            CssProperty::RowGap(f) => Some(f),
4560            _ => None,
4561        }
4562    }
4563
4564    pub const fn as_grid_template_columns(&self) -> Option<&LayoutGridTemplateColumnsValue> {
4565        match self {
4566            CssProperty::GridTemplateColumns(f) => Some(f),
4567            _ => None,
4568        }
4569    }
4570
4571    pub const fn as_grid_template_rows(&self) -> Option<&LayoutGridTemplateRowsValue> {
4572        match self {
4573            CssProperty::GridTemplateRows(f) => Some(f),
4574            _ => None,
4575        }
4576    }
4577
4578    pub const fn as_grid_auto_columns(&self) -> Option<&LayoutGridAutoColumnsValue> {
4579        match self {
4580            CssProperty::GridAutoColumns(f) => Some(f),
4581            _ => None,
4582        }
4583    }
4584
4585    pub const fn as_grid_auto_rows(&self) -> Option<&LayoutGridAutoRowsValue> {
4586        match self {
4587            CssProperty::GridAutoRows(f) => Some(f),
4588            _ => None,
4589        }
4590    }
4591
4592    pub const fn as_grid_column(&self) -> Option<&LayoutGridColumnValue> {
4593        match self {
4594            CssProperty::GridColumn(f) => Some(f),
4595            _ => None,
4596        }
4597    }
4598
4599    pub const fn as_grid_row(&self) -> Option<&LayoutGridRowValue> {
4600        match self {
4601            CssProperty::GridRow(f) => Some(f),
4602            _ => None,
4603        }
4604    }
4605
4606    pub const fn as_writing_mode(&self) -> Option<&LayoutWritingModeValue> {
4607        match self {
4608            CssProperty::WritingMode(f) => Some(f),
4609            _ => None,
4610        }
4611    }
4612
4613    pub const fn as_clear(&self) -> Option<&LayoutClearValue> {
4614        match self {
4615            CssProperty::Clear(f) => Some(f),
4616            _ => None,
4617        }
4618    }
4619
4620    pub const fn as_layout_text_justify(&self) -> Option<&LayoutTextJustifyValue> {
4621        match self {
4622            CssProperty::LayoutTextJustify(f) => Some(f),
4623            _ => None,
4624        }
4625    }
4626
4627    pub const fn as_scrollbar(&self) -> Option<&ScrollbarStyleValue> {
4628        match self {
4629            CssProperty::Scrollbar(f) => Some(f),
4630            _ => None,
4631        }
4632    }
4633
4634    pub const fn as_visibility(&self) -> Option<&StyleVisibilityValue> {
4635        match self {
4636            CssProperty::Visibility(f) => Some(f),
4637            _ => None,
4638        }
4639    }
4640
4641    pub const fn as_background_content(&self) -> Option<&StyleBackgroundContentVecValue> {
4642        match self {
4643            CssProperty::BackgroundContent(f) => Some(f),
4644            _ => None,
4645        }
4646    }
4647    pub const fn as_text_justify(&self) -> Option<&LayoutTextJustifyValue> {
4648        match self {
4649            CssProperty::TextJustify(f) => Some(f),
4650            _ => None,
4651        }
4652    }
4653    pub const fn as_caret_color(&self) -> Option<&CaretColorValue> {
4654        match self {
4655            CssProperty::CaretColor(f) => Some(f),
4656            _ => None,
4657        }
4658    }
4659    pub const fn as_caret_width(&self) -> Option<&CaretWidthValue> {
4660        match self {
4661            CssProperty::CaretWidth(f) => Some(f),
4662            _ => None,
4663        }
4664    }
4665    pub const fn as_caret_animation_duration(&self) -> Option<&CaretAnimationDurationValue> {
4666        match self {
4667            CssProperty::CaretAnimationDuration(f) => Some(f),
4668            _ => None,
4669        }
4670    }
4671    pub const fn as_selection_background_color(&self) -> Option<&SelectionBackgroundColorValue> {
4672        match self {
4673            CssProperty::SelectionBackgroundColor(f) => Some(f),
4674            _ => None,
4675        }
4676    }
4677    pub const fn as_selection_color(&self) -> Option<&SelectionColorValue> {
4678        match self {
4679            CssProperty::SelectionColor(f) => Some(f),
4680            _ => None,
4681        }
4682    }
4683    pub const fn as_selection_radius(&self) -> Option<&SelectionRadiusValue> {
4684        match self {
4685            CssProperty::SelectionRadius(f) => Some(f),
4686            _ => None,
4687        }
4688    }
4689    pub const fn as_background_position(&self) -> Option<&StyleBackgroundPositionVecValue> {
4690        match self {
4691            CssProperty::BackgroundPosition(f) => Some(f),
4692            _ => None,
4693        }
4694    }
4695    pub const fn as_background_size(&self) -> Option<&StyleBackgroundSizeVecValue> {
4696        match self {
4697            CssProperty::BackgroundSize(f) => Some(f),
4698            _ => None,
4699        }
4700    }
4701    pub const fn as_background_repeat(&self) -> Option<&StyleBackgroundRepeatVecValue> {
4702        match self {
4703            CssProperty::BackgroundRepeat(f) => Some(f),
4704            _ => None,
4705        }
4706    }
4707
4708    pub const fn as_grid_auto_flow(&self) -> Option<&LayoutGridAutoFlowValue> {
4709        match self {
4710            CssProperty::GridAutoFlow(f) => Some(f),
4711            _ => None,
4712        }
4713    }
4714    pub const fn as_justify_self(&self) -> Option<&LayoutJustifySelfValue> {
4715        match self {
4716            CssProperty::JustifySelf(f) => Some(f),
4717            _ => None,
4718        }
4719    }
4720    pub const fn as_justify_items(&self) -> Option<&LayoutJustifyItemsValue> {
4721        match self {
4722            CssProperty::JustifyItems(f) => Some(f),
4723            _ => None,
4724        }
4725    }
4726    pub const fn as_gap(&self) -> Option<&LayoutGapValue> {
4727        match self {
4728            CssProperty::Gap(f) => Some(f),
4729            _ => None,
4730        }
4731    }
4732    pub const fn as_grid_gap(&self) -> Option<&LayoutGapValue> {
4733        match self {
4734            CssProperty::GridGap(f) => Some(f),
4735            _ => None,
4736        }
4737    }
4738    pub const fn as_align_self(&self) -> Option<&LayoutAlignSelfValue> {
4739        match self {
4740            CssProperty::AlignSelf(f) => Some(f),
4741            _ => None,
4742        }
4743    }
4744    pub const fn as_font(&self) -> Option<&StyleFontValue> {
4745        match self {
4746            CssProperty::Font(f) => Some(f),
4747            _ => None,
4748        }
4749    }
4750    pub const fn as_font_size(&self) -> Option<&StyleFontSizeValue> {
4751        match self {
4752            CssProperty::FontSize(f) => Some(f),
4753            _ => None,
4754        }
4755    }
4756    pub const fn as_font_family(&self) -> Option<&StyleFontFamilyVecValue> {
4757        match self {
4758            CssProperty::FontFamily(f) => Some(f),
4759            _ => None,
4760        }
4761    }
4762    pub const fn as_font_weight(&self) -> Option<&StyleFontWeightValue> {
4763        match self {
4764            CssProperty::FontWeight(f) => Some(f),
4765            _ => None,
4766        }
4767    }
4768    pub const fn as_font_style(&self) -> Option<&StyleFontStyleValue> {
4769        match self {
4770            CssProperty::FontStyle(f) => Some(f),
4771            _ => None,
4772        }
4773    }
4774    pub const fn as_text_color(&self) -> Option<&StyleTextColorValue> {
4775        match self {
4776            CssProperty::TextColor(f) => Some(f),
4777            _ => None,
4778        }
4779    }
4780    pub const fn as_text_align(&self) -> Option<&StyleTextAlignValue> {
4781        match self {
4782            CssProperty::TextAlign(f) => Some(f),
4783            _ => None,
4784        }
4785    }
4786    pub const fn as_vertical_align(&self) -> Option<&StyleVerticalAlignValue> {
4787        match self {
4788            CssProperty::VerticalAlign(f) => Some(f),
4789            _ => None,
4790        }
4791    }
4792    pub const fn as_line_height(&self) -> Option<&StyleLineHeightValue> {
4793        match self {
4794            CssProperty::LineHeight(f) => Some(f),
4795            _ => None,
4796        }
4797    }
4798    pub const fn as_text_indent(&self) -> Option<&StyleTextIndentValue> {
4799        match self {
4800            CssProperty::TextIndent(f) => Some(f),
4801            _ => None,
4802        }
4803    }
4804    pub const fn as_initial_letter(&self) -> Option<&StyleInitialLetterValue> {
4805        match self {
4806            CssProperty::InitialLetter(f) => Some(f),
4807            _ => None,
4808        }
4809    }
4810    pub const fn as_line_clamp(&self) -> Option<&StyleLineClampValue> {
4811        match self {
4812            CssProperty::LineClamp(f) => Some(f),
4813            _ => None,
4814        }
4815    }
4816    pub const fn as_hanging_punctuation(&self) -> Option<&StyleHangingPunctuationValue> {
4817        match self {
4818            CssProperty::HangingPunctuation(f) => Some(f),
4819            _ => None,
4820        }
4821    }
4822    pub const fn as_text_combine_upright(&self) -> Option<&StyleTextCombineUprightValue> {
4823        match self {
4824            CssProperty::TextCombineUpright(f) => Some(f),
4825            _ => None,
4826        }
4827    }
4828    pub const fn as_exclusion_margin(&self) -> Option<&StyleExclusionMarginValue> {
4829        match self {
4830            CssProperty::ExclusionMargin(f) => Some(f),
4831            _ => None,
4832        }
4833    }
4834    pub const fn as_hyphenation_language(&self) -> Option<&StyleHyphenationLanguageValue> {
4835        match self {
4836            CssProperty::HyphenationLanguage(f) => Some(f),
4837            _ => None,
4838        }
4839    }
4840    pub const fn as_letter_spacing(&self) -> Option<&StyleLetterSpacingValue> {
4841        match self {
4842            CssProperty::LetterSpacing(f) => Some(f),
4843            _ => None,
4844        }
4845    }
4846    pub const fn as_word_spacing(&self) -> Option<&StyleWordSpacingValue> {
4847        match self {
4848            CssProperty::WordSpacing(f) => Some(f),
4849            _ => None,
4850        }
4851    }
4852    pub const fn as_tab_size(&self) -> Option<&StyleTabSizeValue> {
4853        match self {
4854            CssProperty::TabSize(f) => Some(f),
4855            _ => None,
4856        }
4857    }
4858    pub const fn as_cursor(&self) -> Option<&StyleCursorValue> {
4859        match self {
4860            CssProperty::Cursor(f) => Some(f),
4861            _ => None,
4862        }
4863    }
4864    pub const fn as_box_shadow_left(&self) -> Option<&StyleBoxShadowValue> {
4865        match self {
4866            CssProperty::BoxShadowLeft(f) => Some(f),
4867            _ => None,
4868        }
4869    }
4870    pub const fn as_box_shadow_right(&self) -> Option<&StyleBoxShadowValue> {
4871        match self {
4872            CssProperty::BoxShadowRight(f) => Some(f),
4873            _ => None,
4874        }
4875    }
4876    pub const fn as_box_shadow_top(&self) -> Option<&StyleBoxShadowValue> {
4877        match self {
4878            CssProperty::BoxShadowTop(f) => Some(f),
4879            _ => None,
4880        }
4881    }
4882    pub const fn as_box_shadow_bottom(&self) -> Option<&StyleBoxShadowValue> {
4883        match self {
4884            CssProperty::BoxShadowBottom(f) => Some(f),
4885            _ => None,
4886        }
4887    }
4888    pub const fn as_border_top_color(&self) -> Option<&StyleBorderTopColorValue> {
4889        match self {
4890            CssProperty::BorderTopColor(f) => Some(f),
4891            _ => None,
4892        }
4893    }
4894    pub const fn as_border_left_color(&self) -> Option<&StyleBorderLeftColorValue> {
4895        match self {
4896            CssProperty::BorderLeftColor(f) => Some(f),
4897            _ => None,
4898        }
4899    }
4900    pub const fn as_border_right_color(&self) -> Option<&StyleBorderRightColorValue> {
4901        match self {
4902            CssProperty::BorderRightColor(f) => Some(f),
4903            _ => None,
4904        }
4905    }
4906    pub const fn as_border_bottom_color(&self) -> Option<&StyleBorderBottomColorValue> {
4907        match self {
4908            CssProperty::BorderBottomColor(f) => Some(f),
4909            _ => None,
4910        }
4911    }
4912    pub const fn as_border_top_style(&self) -> Option<&StyleBorderTopStyleValue> {
4913        match self {
4914            CssProperty::BorderTopStyle(f) => Some(f),
4915            _ => None,
4916        }
4917    }
4918    pub const fn as_border_left_style(&self) -> Option<&StyleBorderLeftStyleValue> {
4919        match self {
4920            CssProperty::BorderLeftStyle(f) => Some(f),
4921            _ => None,
4922        }
4923    }
4924    pub const fn as_border_right_style(&self) -> Option<&StyleBorderRightStyleValue> {
4925        match self {
4926            CssProperty::BorderRightStyle(f) => Some(f),
4927            _ => None,
4928        }
4929    }
4930    pub const fn as_border_bottom_style(&self) -> Option<&StyleBorderBottomStyleValue> {
4931        match self {
4932            CssProperty::BorderBottomStyle(f) => Some(f),
4933            _ => None,
4934        }
4935    }
4936    pub const fn as_border_top_left_radius(&self) -> Option<&StyleBorderTopLeftRadiusValue> {
4937        match self {
4938            CssProperty::BorderTopLeftRadius(f) => Some(f),
4939            _ => None,
4940        }
4941    }
4942    pub const fn as_border_top_right_radius(&self) -> Option<&StyleBorderTopRightRadiusValue> {
4943        match self {
4944            CssProperty::BorderTopRightRadius(f) => Some(f),
4945            _ => None,
4946        }
4947    }
4948    pub const fn as_border_bottom_left_radius(&self) -> Option<&StyleBorderBottomLeftRadiusValue> {
4949        match self {
4950            CssProperty::BorderBottomLeftRadius(f) => Some(f),
4951            _ => None,
4952        }
4953    }
4954    pub const fn as_border_bottom_right_radius(
4955        &self,
4956    ) -> Option<&StyleBorderBottomRightRadiusValue> {
4957        match self {
4958            CssProperty::BorderBottomRightRadius(f) => Some(f),
4959            _ => None,
4960        }
4961    }
4962    pub const fn as_opacity(&self) -> Option<&StyleOpacityValue> {
4963        match self {
4964            CssProperty::Opacity(f) => Some(f),
4965            _ => None,
4966        }
4967    }
4968    pub const fn as_transform(&self) -> Option<&StyleTransformVecValue> {
4969        match self {
4970            CssProperty::Transform(f) => Some(f),
4971            _ => None,
4972        }
4973    }
4974    pub const fn as_transform_origin(&self) -> Option<&StyleTransformOriginValue> {
4975        match self {
4976            CssProperty::TransformOrigin(f) => Some(f),
4977            _ => None,
4978        }
4979    }
4980    pub const fn as_perspective_origin(&self) -> Option<&StylePerspectiveOriginValue> {
4981        match self {
4982            CssProperty::PerspectiveOrigin(f) => Some(f),
4983            _ => None,
4984        }
4985    }
4986    pub const fn as_backface_visibility(&self) -> Option<&StyleBackfaceVisibilityValue> {
4987        match self {
4988            CssProperty::BackfaceVisibility(f) => Some(f),
4989            _ => None,
4990        }
4991    }
4992    pub const fn as_mix_blend_mode(&self) -> Option<&StyleMixBlendModeValue> {
4993        match self {
4994            CssProperty::MixBlendMode(f) => Some(f),
4995            _ => None,
4996        }
4997    }
4998    pub const fn as_filter(&self) -> Option<&StyleFilterVecValue> {
4999        match self {
5000            CssProperty::Filter(f) => Some(f),
5001            _ => None,
5002        }
5003    }
5004    pub const fn as_backdrop_filter(&self) -> Option<&StyleFilterVecValue> {
5005        match self {
5006            CssProperty::BackdropFilter(f) => Some(f),
5007            _ => None,
5008        }
5009    }
5010    pub const fn as_text_shadow(&self) -> Option<&StyleBoxShadowValue> {
5011        match self {
5012            CssProperty::TextShadow(f) => Some(f),
5013            _ => None,
5014        }
5015    }
5016
5017    // functions that downcast to the concrete CSS type (layout)
5018
5019    pub const fn as_display(&self) -> Option<&LayoutDisplayValue> {
5020        match self {
5021            CssProperty::Display(f) => Some(f),
5022            _ => None,
5023        }
5024    }
5025    pub const fn as_float(&self) -> Option<&LayoutFloatValue> {
5026        match self {
5027            CssProperty::Float(f) => Some(f),
5028            _ => None,
5029        }
5030    }
5031    pub const fn as_box_sizing(&self) -> Option<&LayoutBoxSizingValue> {
5032        match self {
5033            CssProperty::BoxSizing(f) => Some(f),
5034            _ => None,
5035        }
5036    }
5037    pub const fn as_width(&self) -> Option<&LayoutWidthValue> {
5038        match self {
5039            CssProperty::Width(f) => Some(f),
5040            _ => None,
5041        }
5042    }
5043    pub const fn as_height(&self) -> Option<&LayoutHeightValue> {
5044        match self {
5045            CssProperty::Height(f) => Some(f),
5046            _ => None,
5047        }
5048    }
5049    pub const fn as_min_width(&self) -> Option<&LayoutMinWidthValue> {
5050        match self {
5051            CssProperty::MinWidth(f) => Some(f),
5052            _ => None,
5053        }
5054    }
5055    pub const fn as_min_height(&self) -> Option<&LayoutMinHeightValue> {
5056        match self {
5057            CssProperty::MinHeight(f) => Some(f),
5058            _ => None,
5059        }
5060    }
5061    pub const fn as_max_width(&self) -> Option<&LayoutMaxWidthValue> {
5062        match self {
5063            CssProperty::MaxWidth(f) => Some(f),
5064            _ => None,
5065        }
5066    }
5067    pub const fn as_max_height(&self) -> Option<&LayoutMaxHeightValue> {
5068        match self {
5069            CssProperty::MaxHeight(f) => Some(f),
5070            _ => None,
5071        }
5072    }
5073    pub const fn as_position(&self) -> Option<&LayoutPositionValue> {
5074        match self {
5075            CssProperty::Position(f) => Some(f),
5076            _ => None,
5077        }
5078    }
5079    pub const fn as_top(&self) -> Option<&LayoutTopValue> {
5080        match self {
5081            CssProperty::Top(f) => Some(f),
5082            _ => None,
5083        }
5084    }
5085    pub const fn as_bottom(&self) -> Option<&LayoutInsetBottomValue> {
5086        match self {
5087            CssProperty::Bottom(f) => Some(f),
5088            _ => None,
5089        }
5090    }
5091    pub const fn as_right(&self) -> Option<&LayoutRightValue> {
5092        match self {
5093            CssProperty::Right(f) => Some(f),
5094            _ => None,
5095        }
5096    }
5097    pub const fn as_left(&self) -> Option<&LayoutLeftValue> {
5098        match self {
5099            CssProperty::Left(f) => Some(f),
5100            _ => None,
5101        }
5102    }
5103    pub const fn as_padding_top(&self) -> Option<&LayoutPaddingTopValue> {
5104        match self {
5105            CssProperty::PaddingTop(f) => Some(f),
5106            _ => None,
5107        }
5108    }
5109    pub const fn as_padding_bottom(&self) -> Option<&LayoutPaddingBottomValue> {
5110        match self {
5111            CssProperty::PaddingBottom(f) => Some(f),
5112            _ => None,
5113        }
5114    }
5115    pub const fn as_padding_left(&self) -> Option<&LayoutPaddingLeftValue> {
5116        match self {
5117            CssProperty::PaddingLeft(f) => Some(f),
5118            _ => None,
5119        }
5120    }
5121    pub const fn as_padding_right(&self) -> Option<&LayoutPaddingRightValue> {
5122        match self {
5123            CssProperty::PaddingRight(f) => Some(f),
5124            _ => None,
5125        }
5126    }
5127    pub const fn as_margin_top(&self) -> Option<&LayoutMarginTopValue> {
5128        match self {
5129            CssProperty::MarginTop(f) => Some(f),
5130            _ => None,
5131        }
5132    }
5133    pub const fn as_margin_bottom(&self) -> Option<&LayoutMarginBottomValue> {
5134        match self {
5135            CssProperty::MarginBottom(f) => Some(f),
5136            _ => None,
5137        }
5138    }
5139    pub const fn as_margin_left(&self) -> Option<&LayoutMarginLeftValue> {
5140        match self {
5141            CssProperty::MarginLeft(f) => Some(f),
5142            _ => None,
5143        }
5144    }
5145    pub const fn as_margin_right(&self) -> Option<&LayoutMarginRightValue> {
5146        match self {
5147            CssProperty::MarginRight(f) => Some(f),
5148            _ => None,
5149        }
5150    }
5151    pub const fn as_border_top_width(&self) -> Option<&LayoutBorderTopWidthValue> {
5152        match self {
5153            CssProperty::BorderTopWidth(f) => Some(f),
5154            _ => None,
5155        }
5156    }
5157    pub const fn as_border_left_width(&self) -> Option<&LayoutBorderLeftWidthValue> {
5158        match self {
5159            CssProperty::BorderLeftWidth(f) => Some(f),
5160            _ => None,
5161        }
5162    }
5163    pub const fn as_border_right_width(&self) -> Option<&LayoutBorderRightWidthValue> {
5164        match self {
5165            CssProperty::BorderRightWidth(f) => Some(f),
5166            _ => None,
5167        }
5168    }
5169    pub const fn as_border_bottom_width(&self) -> Option<&LayoutBorderBottomWidthValue> {
5170        match self {
5171            CssProperty::BorderBottomWidth(f) => Some(f),
5172            _ => None,
5173        }
5174    }
5175    pub const fn as_overflow_x(&self) -> Option<&LayoutOverflowValue> {
5176        match self {
5177            CssProperty::OverflowX(f) => Some(f),
5178            _ => None,
5179        }
5180    }
5181    pub const fn as_overflow_y(&self) -> Option<&LayoutOverflowValue> {
5182        match self {
5183            CssProperty::OverflowY(f) => Some(f),
5184            _ => None,
5185        }
5186    }
5187    pub const fn as_flex_direction(&self) -> Option<&LayoutFlexDirectionValue> {
5188        match self {
5189            CssProperty::FlexDirection(f) => Some(f),
5190            _ => None,
5191        }
5192    }
5193    pub const fn as_direction(&self) -> Option<&StyleDirectionValue> {
5194        match self {
5195            CssProperty::Direction(f) => Some(f),
5196            _ => None,
5197        }
5198    }
5199    pub const fn as_user_select(&self) -> Option<&StyleUserSelectValue> {
5200        match self {
5201            CssProperty::UserSelect(f) => Some(f),
5202            _ => None,
5203        }
5204    }
5205    pub const fn as_text_decoration(&self) -> Option<&StyleTextDecorationValue> {
5206        match self {
5207            CssProperty::TextDecoration(f) => Some(f),
5208            _ => None,
5209        }
5210    }
5211    pub const fn as_hyphens(&self) -> Option<&StyleHyphensValue> {
5212        match self {
5213            CssProperty::Hyphens(f) => Some(f),
5214            _ => None,
5215        }
5216    }
5217    pub const fn as_white_space(&self) -> Option<&StyleWhiteSpaceValue> {
5218        match self {
5219            CssProperty::WhiteSpace(f) => Some(f),
5220            _ => None,
5221        }
5222    }
5223    pub const fn as_flex_wrap(&self) -> Option<&LayoutFlexWrapValue> {
5224        match self {
5225            CssProperty::FlexWrap(f) => Some(f),
5226            _ => None,
5227        }
5228    }
5229    pub const fn as_flex_grow(&self) -> Option<&LayoutFlexGrowValue> {
5230        match self {
5231            CssProperty::FlexGrow(f) => Some(f),
5232            _ => None,
5233        }
5234    }
5235    pub const fn as_flex_shrink(&self) -> Option<&LayoutFlexShrinkValue> {
5236        match self {
5237            CssProperty::FlexShrink(f) => Some(f),
5238            _ => None,
5239        }
5240    }
5241    pub const fn as_justify_content(&self) -> Option<&LayoutJustifyContentValue> {
5242        match self {
5243            CssProperty::JustifyContent(f) => Some(f),
5244            _ => None,
5245        }
5246    }
5247    pub const fn as_align_items(&self) -> Option<&LayoutAlignItemsValue> {
5248        match self {
5249            CssProperty::AlignItems(f) => Some(f),
5250            _ => None,
5251        }
5252    }
5253    pub const fn as_align_content(&self) -> Option<&LayoutAlignContentValue> {
5254        match self {
5255            CssProperty::AlignContent(f) => Some(f),
5256            _ => None,
5257        }
5258    }
5259    pub const fn as_break_before(&self) -> Option<&PageBreakValue> {
5260        match self {
5261            CssProperty::BreakBefore(f) => Some(f),
5262            _ => None,
5263        }
5264    }
5265    pub const fn as_break_after(&self) -> Option<&PageBreakValue> {
5266        match self {
5267            CssProperty::BreakAfter(f) => Some(f),
5268            _ => None,
5269        }
5270    }
5271    pub const fn as_break_inside(&self) -> Option<&BreakInsideValue> {
5272        match self {
5273            CssProperty::BreakInside(f) => Some(f),
5274            _ => None,
5275        }
5276    }
5277    pub const fn as_orphans(&self) -> Option<&OrphansValue> {
5278        match self {
5279            CssProperty::Orphans(f) => Some(f),
5280            _ => None,
5281        }
5282    }
5283    pub const fn as_widows(&self) -> Option<&WidowsValue> {
5284        match self {
5285            CssProperty::Widows(f) => Some(f),
5286            _ => None,
5287        }
5288    }
5289    pub const fn as_box_decoration_break(&self) -> Option<&BoxDecorationBreakValue> {
5290        match self {
5291            CssProperty::BoxDecorationBreak(f) => Some(f),
5292            _ => None,
5293        }
5294    }
5295    pub const fn as_column_count(&self) -> Option<&ColumnCountValue> {
5296        match self {
5297            CssProperty::ColumnCount(f) => Some(f),
5298            _ => None,
5299        }
5300    }
5301    pub const fn as_column_width(&self) -> Option<&ColumnWidthValue> {
5302        match self {
5303            CssProperty::ColumnWidth(f) => Some(f),
5304            _ => None,
5305        }
5306    }
5307    pub const fn as_column_span(&self) -> Option<&ColumnSpanValue> {
5308        match self {
5309            CssProperty::ColumnSpan(f) => Some(f),
5310            _ => None,
5311        }
5312    }
5313    pub const fn as_column_fill(&self) -> Option<&ColumnFillValue> {
5314        match self {
5315            CssProperty::ColumnFill(f) => Some(f),
5316            _ => None,
5317        }
5318    }
5319    pub const fn as_column_rule_width(&self) -> Option<&ColumnRuleWidthValue> {
5320        match self {
5321            CssProperty::ColumnRuleWidth(f) => Some(f),
5322            _ => None,
5323        }
5324    }
5325    pub const fn as_column_rule_style(&self) -> Option<&ColumnRuleStyleValue> {
5326        match self {
5327            CssProperty::ColumnRuleStyle(f) => Some(f),
5328            _ => None,
5329        }
5330    }
5331    pub const fn as_column_rule_color(&self) -> Option<&ColumnRuleColorValue> {
5332        match self {
5333            CssProperty::ColumnRuleColor(f) => Some(f),
5334            _ => None,
5335        }
5336    }
5337    pub const fn as_flow_into(&self) -> Option<&FlowIntoValue> {
5338        match self {
5339            CssProperty::FlowInto(f) => Some(f),
5340            _ => None,
5341        }
5342    }
5343    pub const fn as_flow_from(&self) -> Option<&FlowFromValue> {
5344        match self {
5345            CssProperty::FlowFrom(f) => Some(f),
5346            _ => None,
5347        }
5348    }
5349    pub const fn as_shape_outside(&self) -> Option<&ShapeOutsideValue> {
5350        match self {
5351            CssProperty::ShapeOutside(f) => Some(f),
5352            _ => None,
5353        }
5354    }
5355    pub const fn as_shape_inside(&self) -> Option<&ShapeInsideValue> {
5356        match self {
5357            CssProperty::ShapeInside(f) => Some(f),
5358            _ => None,
5359        }
5360    }
5361    pub const fn as_clip_path(&self) -> Option<&ClipPathValue> {
5362        match self {
5363            CssProperty::ClipPath(f) => Some(f),
5364            _ => None,
5365        }
5366    }
5367    pub const fn as_shape_margin(&self) -> Option<&ShapeMarginValue> {
5368        match self {
5369            CssProperty::ShapeMargin(f) => Some(f),
5370            _ => None,
5371        }
5372    }
5373    pub const fn as_shape_image_threshold(&self) -> Option<&ShapeImageThresholdValue> {
5374        match self {
5375            CssProperty::ShapeImageThreshold(f) => Some(f),
5376            _ => None,
5377        }
5378    }
5379    pub const fn as_content(&self) -> Option<&ContentValue> {
5380        match self {
5381            CssProperty::Content(f) => Some(f),
5382            _ => None,
5383        }
5384    }
5385    pub const fn as_counter_reset(&self) -> Option<&CounterResetValue> {
5386        match self {
5387            CssProperty::CounterReset(f) => Some(f),
5388            _ => None,
5389        }
5390    }
5391    pub const fn as_counter_increment(&self) -> Option<&CounterIncrementValue> {
5392        match self {
5393            CssProperty::CounterIncrement(f) => Some(f),
5394            _ => None,
5395        }
5396    }
5397    pub const fn as_list_style_type(&self) -> Option<&StyleListStyleTypeValue> {
5398        match self {
5399            CssProperty::ListStyleType(f) => Some(f),
5400            _ => None,
5401        }
5402    }
5403    pub const fn as_list_style_position(&self) -> Option<&StyleListStylePositionValue> {
5404        match self {
5405            CssProperty::ListStylePosition(f) => Some(f),
5406            _ => None,
5407        }
5408    }
5409    pub const fn as_string_set(&self) -> Option<&StringSetValue> {
5410        match self {
5411            CssProperty::StringSet(f) => Some(f),
5412            _ => None,
5413        }
5414    }
5415    pub const fn as_table_layout(&self) -> Option<&LayoutTableLayoutValue> {
5416        match self {
5417            CssProperty::TableLayout(f) => Some(f),
5418            _ => None,
5419        }
5420    }
5421    pub const fn as_border_collapse(&self) -> Option<&StyleBorderCollapseValue> {
5422        match self {
5423            CssProperty::BorderCollapse(f) => Some(f),
5424            _ => None,
5425        }
5426    }
5427    pub const fn as_border_spacing(&self) -> Option<&LayoutBorderSpacingValue> {
5428        match self {
5429            CssProperty::BorderSpacing(f) => Some(f),
5430            _ => None,
5431        }
5432    }
5433    pub const fn as_caption_side(&self) -> Option<&StyleCaptionSideValue> {
5434        match self {
5435            CssProperty::CaptionSide(f) => Some(f),
5436            _ => None,
5437        }
5438    }
5439    pub const fn as_empty_cells(&self) -> Option<&StyleEmptyCellsValue> {
5440        match self {
5441            CssProperty::EmptyCells(f) => Some(f),
5442            _ => None,
5443        }
5444    }
5445
5446    pub const fn as_scrollbar_width(&self) -> Option<&LayoutScrollbarWidthValue> {
5447        match self {
5448            CssProperty::ScrollbarWidth(f) => Some(f),
5449            _ => None,
5450        }
5451    }
5452    pub const fn as_scrollbar_color(&self) -> Option<&StyleScrollbarColorValue> {
5453        match self {
5454            CssProperty::ScrollbarColor(f) => Some(f),
5455            _ => None,
5456        }
5457    }
5458
5459    pub fn is_initial(&self) -> bool {
5460        use self::CssProperty::*;
5461        match self {
5462            CaretColor(c) => c.is_initial(),
5463            CaretWidth(c) => c.is_initial(),
5464            CaretAnimationDuration(c) => c.is_initial(),
5465            SelectionBackgroundColor(c) => c.is_initial(),
5466            SelectionColor(c) => c.is_initial(),
5467            SelectionRadius(c) => c.is_initial(),
5468            TextJustify(c) => c.is_initial(),
5469            LayoutTextJustify(_) => false,
5470            TextColor(c) => c.is_initial(),
5471            FontSize(c) => c.is_initial(),
5472            FontFamily(c) => c.is_initial(),
5473            TextAlign(c) => c.is_initial(),
5474            LetterSpacing(c) => c.is_initial(),
5475            TextIndent(c) => c.is_initial(),
5476            InitialLetter(c) => c.is_initial(),
5477            LineClamp(c) => c.is_initial(),
5478            HangingPunctuation(c) => c.is_initial(),
5479            TextCombineUpright(c) => c.is_initial(),
5480            ExclusionMargin(c) => c.is_initial(),
5481            HyphenationLanguage(c) => c.is_initial(),
5482            LineHeight(c) => c.is_initial(),
5483            WordSpacing(c) => c.is_initial(),
5484            TabSize(c) => c.is_initial(),
5485            Cursor(c) => c.is_initial(),
5486            Display(c) => c.is_initial(),
5487            Float(c) => c.is_initial(),
5488            BoxSizing(c) => c.is_initial(),
5489            Width(c) => c.is_initial(),
5490            Height(c) => c.is_initial(),
5491            MinWidth(c) => c.is_initial(),
5492            MinHeight(c) => c.is_initial(),
5493            MaxWidth(c) => c.is_initial(),
5494            MaxHeight(c) => c.is_initial(),
5495            Position(c) => c.is_initial(),
5496            Top(c) => c.is_initial(),
5497            Right(c) => c.is_initial(),
5498            Left(c) => c.is_initial(),
5499            Bottom(c) => c.is_initial(),
5500            ZIndex(c) => c.is_initial(),
5501            FlexWrap(c) => c.is_initial(),
5502            FlexDirection(c) => c.is_initial(),
5503            FlexGrow(c) => c.is_initial(),
5504            FlexShrink(c) => c.is_initial(),
5505            FlexBasis(c) => c.is_initial(),
5506            JustifyContent(c) => c.is_initial(),
5507            AlignItems(c) => c.is_initial(),
5508            AlignContent(c) => c.is_initial(),
5509            ColumnGap(c) => c.is_initial(),
5510            RowGap(c) => c.is_initial(),
5511            GridTemplateColumns(c) => c.is_initial(),
5512            GridTemplateRows(c) => c.is_initial(),
5513            GridAutoFlow(c) => c.is_initial(),
5514            JustifySelf(c) => c.is_initial(),
5515            JustifyItems(c) => c.is_initial(),
5516            Gap(c) => c.is_initial(),
5517            GridGap(c) => c.is_initial(),
5518            AlignSelf(c) => c.is_initial(),
5519            Font(c) => c.is_initial(),
5520            GridAutoColumns(c) => c.is_initial(),
5521            GridAutoRows(c) => c.is_initial(),
5522            GridColumn(c) => c.is_initial(),
5523            GridRow(c) => c.is_initial(),
5524            GridTemplateAreas(c) => c.is_initial(),
5525            WritingMode(c) => c.is_initial(),
5526            Clear(c) => c.is_initial(),
5527            BackgroundContent(c) => c.is_initial(),
5528            BackgroundPosition(c) => c.is_initial(),
5529            BackgroundSize(c) => c.is_initial(),
5530            BackgroundRepeat(c) => c.is_initial(),
5531            OverflowX(c) => c.is_initial(),
5532            OverflowY(c) => c.is_initial(),
5533            PaddingTop(c) => c.is_initial(),
5534            PaddingLeft(c) => c.is_initial(),
5535            PaddingRight(c) => c.is_initial(),
5536            PaddingBottom(c) => c.is_initial(),
5537            PaddingInlineStart(c) => c.is_initial(),
5538            PaddingInlineEnd(c) => c.is_initial(),
5539            MarginTop(c) => c.is_initial(),
5540            MarginLeft(c) => c.is_initial(),
5541            MarginRight(c) => c.is_initial(),
5542            MarginBottom(c) => c.is_initial(),
5543            BorderTopLeftRadius(c) => c.is_initial(),
5544            BorderTopRightRadius(c) => c.is_initial(),
5545            BorderBottomLeftRadius(c) => c.is_initial(),
5546            BorderBottomRightRadius(c) => c.is_initial(),
5547            BorderTopColor(c) => c.is_initial(),
5548            BorderRightColor(c) => c.is_initial(),
5549            BorderLeftColor(c) => c.is_initial(),
5550            BorderBottomColor(c) => c.is_initial(),
5551            BorderTopStyle(c) => c.is_initial(),
5552            BorderRightStyle(c) => c.is_initial(),
5553            BorderLeftStyle(c) => c.is_initial(),
5554            BorderBottomStyle(c) => c.is_initial(),
5555            BorderTopWidth(c) => c.is_initial(),
5556            BorderRightWidth(c) => c.is_initial(),
5557            BorderLeftWidth(c) => c.is_initial(),
5558            BorderBottomWidth(c) => c.is_initial(),
5559            BoxShadowLeft(c) => c.is_initial(),
5560            BoxShadowRight(c) => c.is_initial(),
5561            BoxShadowTop(c) => c.is_initial(),
5562            BoxShadowBottom(c) => c.is_initial(),
5563            Scrollbar(c) => c.is_initial(),
5564            ScrollbarWidth(c) => c.is_initial(),
5565            ScrollbarColor(c) => c.is_initial(),
5566            Opacity(c) => c.is_initial(),
5567            Visibility(c) => c.is_initial(),
5568            Transform(c) => c.is_initial(),
5569            TransformOrigin(c) => c.is_initial(),
5570            PerspectiveOrigin(c) => c.is_initial(),
5571            BackfaceVisibility(c) => c.is_initial(),
5572            MixBlendMode(c) => c.is_initial(),
5573            Filter(c) => c.is_initial(),
5574            BackdropFilter(c) => c.is_initial(),
5575            TextShadow(c) => c.is_initial(),
5576            WhiteSpace(c) => c.is_initial(),
5577            Direction(c) => c.is_initial(),
5578            UserSelect(c) => c.is_initial(),
5579            TextDecoration(c) => c.is_initial(),
5580            Hyphens(c) => c.is_initial(),
5581            BreakBefore(c) => c.is_initial(),
5582            BreakAfter(c) => c.is_initial(),
5583            BreakInside(c) => c.is_initial(),
5584            Orphans(c) => c.is_initial(),
5585            Widows(c) => c.is_initial(),
5586            BoxDecorationBreak(c) => c.is_initial(),
5587            ColumnCount(c) => c.is_initial(),
5588            ColumnWidth(c) => c.is_initial(),
5589            ColumnSpan(c) => c.is_initial(),
5590            ColumnFill(c) => c.is_initial(),
5591            ColumnRuleWidth(c) => c.is_initial(),
5592            ColumnRuleStyle(c) => c.is_initial(),
5593            ColumnRuleColor(c) => c.is_initial(),
5594            FlowInto(c) => c.is_initial(),
5595            FlowFrom(c) => c.is_initial(),
5596            ShapeOutside(c) => c.is_initial(),
5597            ShapeInside(c) => c.is_initial(),
5598            ClipPath(c) => c.is_initial(),
5599            ShapeMargin(c) => c.is_initial(),
5600            ShapeImageThreshold(c) => c.is_initial(),
5601            Content(c) => c.is_initial(),
5602            CounterReset(c) => c.is_initial(),
5603            CounterIncrement(c) => c.is_initial(),
5604            ListStyleType(c) => c.is_initial(),
5605            ListStylePosition(c) => c.is_initial(),
5606            StringSet(c) => c.is_initial(),
5607            TableLayout(c) => c.is_initial(),
5608            BorderCollapse(c) => c.is_initial(),
5609            BorderSpacing(c) => c.is_initial(),
5610            CaptionSide(c) => c.is_initial(),
5611            EmptyCells(c) => c.is_initial(),
5612            FontWeight(c) => c.is_initial(),
5613            FontStyle(c) => c.is_initial(),
5614            VerticalAlign(c) => c.is_initial(),
5615        }
5616    }
5617
5618    pub const fn const_none(prop_type: CssPropertyType) -> Self {
5619        css_property_from_type!(prop_type, None)
5620    }
5621    pub const fn const_auto(prop_type: CssPropertyType) -> Self {
5622        css_property_from_type!(prop_type, Auto)
5623    }
5624    pub const fn const_initial(prop_type: CssPropertyType) -> Self {
5625        css_property_from_type!(prop_type, Initial)
5626    }
5627    pub const fn const_inherit(prop_type: CssPropertyType) -> Self {
5628        css_property_from_type!(prop_type, Inherit)
5629    }
5630
5631    pub const fn const_text_color(input: StyleTextColor) -> Self {
5632        CssProperty::TextColor(StyleTextColorValue::Exact(input))
5633    }
5634    pub const fn const_font_size(input: StyleFontSize) -> Self {
5635        CssProperty::FontSize(StyleFontSizeValue::Exact(input))
5636    }
5637    pub const fn const_font_family(input: StyleFontFamilyVec) -> Self {
5638        CssProperty::FontFamily(StyleFontFamilyVecValue::Exact(input))
5639    }
5640    pub const fn const_text_align(input: StyleTextAlign) -> Self {
5641        CssProperty::TextAlign(StyleTextAlignValue::Exact(input))
5642    }
5643    pub const fn const_vertical_align(input: StyleVerticalAlign) -> Self {
5644        CssProperty::VerticalAlign(StyleVerticalAlignValue::Exact(input))
5645    }
5646    pub const fn const_letter_spacing(input: StyleLetterSpacing) -> Self {
5647        CssProperty::LetterSpacing(StyleLetterSpacingValue::Exact(input))
5648    }
5649    pub const fn const_text_indent(input: StyleTextIndent) -> Self {
5650        CssProperty::TextIndent(StyleTextIndentValue::Exact(input))
5651    }
5652    pub const fn const_line_height(input: StyleLineHeight) -> Self {
5653        CssProperty::LineHeight(StyleLineHeightValue::Exact(input))
5654    }
5655    pub const fn const_word_spacing(input: StyleWordSpacing) -> Self {
5656        CssProperty::WordSpacing(StyleWordSpacingValue::Exact(input))
5657    }
5658    pub const fn const_tab_size(input: StyleTabSize) -> Self {
5659        CssProperty::TabSize(StyleTabSizeValue::Exact(input))
5660    }
5661    pub const fn const_cursor(input: StyleCursor) -> Self {
5662        CssProperty::Cursor(StyleCursorValue::Exact(input))
5663    }
5664    pub const fn const_display(input: LayoutDisplay) -> Self {
5665        CssProperty::Display(LayoutDisplayValue::Exact(input))
5666    }
5667    pub const fn const_float(input: LayoutFloat) -> Self {
5668        CssProperty::Float(LayoutFloatValue::Exact(input))
5669    }
5670    pub const fn const_box_sizing(input: LayoutBoxSizing) -> Self {
5671        CssProperty::BoxSizing(LayoutBoxSizingValue::Exact(input))
5672    }
5673    pub const fn const_width(input: LayoutWidth) -> Self {
5674        CssProperty::Width(LayoutWidthValue::Exact(input))
5675    }
5676    pub const fn const_height(input: LayoutHeight) -> Self {
5677        CssProperty::Height(LayoutHeightValue::Exact(input))
5678    }
5679    pub const fn const_min_width(input: LayoutMinWidth) -> Self {
5680        CssProperty::MinWidth(LayoutMinWidthValue::Exact(input))
5681    }
5682    pub const fn const_min_height(input: LayoutMinHeight) -> Self {
5683        CssProperty::MinHeight(LayoutMinHeightValue::Exact(input))
5684    }
5685    pub const fn const_max_width(input: LayoutMaxWidth) -> Self {
5686        CssProperty::MaxWidth(LayoutMaxWidthValue::Exact(input))
5687    }
5688    pub const fn const_max_height(input: LayoutMaxHeight) -> Self {
5689        CssProperty::MaxHeight(LayoutMaxHeightValue::Exact(input))
5690    }
5691    pub const fn const_position(input: LayoutPosition) -> Self {
5692        CssProperty::Position(LayoutPositionValue::Exact(input))
5693    }
5694    pub const fn const_top(input: LayoutTop) -> Self {
5695        CssProperty::Top(LayoutTopValue::Exact(input))
5696    }
5697    pub const fn const_right(input: LayoutRight) -> Self {
5698        CssProperty::Right(LayoutRightValue::Exact(input))
5699    }
5700    pub const fn const_left(input: LayoutLeft) -> Self {
5701        CssProperty::Left(LayoutLeftValue::Exact(input))
5702    }
5703    pub const fn const_bottom(input: LayoutInsetBottom) -> Self {
5704        CssProperty::Bottom(LayoutInsetBottomValue::Exact(input))
5705    }
5706    pub const fn const_flex_wrap(input: LayoutFlexWrap) -> Self {
5707        CssProperty::FlexWrap(LayoutFlexWrapValue::Exact(input))
5708    }
5709    pub const fn const_flex_direction(input: LayoutFlexDirection) -> Self {
5710        CssProperty::FlexDirection(LayoutFlexDirectionValue::Exact(input))
5711    }
5712    pub const fn const_flex_grow(input: LayoutFlexGrow) -> Self {
5713        CssProperty::FlexGrow(LayoutFlexGrowValue::Exact(input))
5714    }
5715    pub const fn const_flex_shrink(input: LayoutFlexShrink) -> Self {
5716        CssProperty::FlexShrink(LayoutFlexShrinkValue::Exact(input))
5717    }
5718    pub const fn const_justify_content(input: LayoutJustifyContent) -> Self {
5719        CssProperty::JustifyContent(LayoutJustifyContentValue::Exact(input))
5720    }
5721    pub const fn const_align_items(input: LayoutAlignItems) -> Self {
5722        CssProperty::AlignItems(LayoutAlignItemsValue::Exact(input))
5723    }
5724    pub const fn const_align_content(input: LayoutAlignContent) -> Self {
5725        CssProperty::AlignContent(LayoutAlignContentValue::Exact(input))
5726    }
5727    pub const fn const_background_content(input: StyleBackgroundContentVec) -> Self {
5728        CssProperty::BackgroundContent(StyleBackgroundContentVecValue::Exact(input))
5729    }
5730    pub const fn const_background_position(input: StyleBackgroundPositionVec) -> Self {
5731        CssProperty::BackgroundPosition(StyleBackgroundPositionVecValue::Exact(input))
5732    }
5733    pub const fn const_background_size(input: StyleBackgroundSizeVec) -> Self {
5734        CssProperty::BackgroundSize(StyleBackgroundSizeVecValue::Exact(input))
5735    }
5736    pub const fn const_background_repeat(input: StyleBackgroundRepeatVec) -> Self {
5737        CssProperty::BackgroundRepeat(StyleBackgroundRepeatVecValue::Exact(input))
5738    }
5739    pub const fn const_overflow_x(input: LayoutOverflow) -> Self {
5740        CssProperty::OverflowX(LayoutOverflowValue::Exact(input))
5741    }
5742    pub const fn const_overflow_y(input: LayoutOverflow) -> Self {
5743        CssProperty::OverflowY(LayoutOverflowValue::Exact(input))
5744    }
5745    pub const fn const_padding_top(input: LayoutPaddingTop) -> Self {
5746        CssProperty::PaddingTop(LayoutPaddingTopValue::Exact(input))
5747    }
5748    pub const fn const_padding_left(input: LayoutPaddingLeft) -> Self {
5749        CssProperty::PaddingLeft(LayoutPaddingLeftValue::Exact(input))
5750    }
5751    pub const fn const_padding_right(input: LayoutPaddingRight) -> Self {
5752        CssProperty::PaddingRight(LayoutPaddingRightValue::Exact(input))
5753    }
5754    pub const fn const_padding_bottom(input: LayoutPaddingBottom) -> Self {
5755        CssProperty::PaddingBottom(LayoutPaddingBottomValue::Exact(input))
5756    }
5757    pub const fn const_margin_top(input: LayoutMarginTop) -> Self {
5758        CssProperty::MarginTop(LayoutMarginTopValue::Exact(input))
5759    }
5760    pub const fn const_margin_left(input: LayoutMarginLeft) -> Self {
5761        CssProperty::MarginLeft(LayoutMarginLeftValue::Exact(input))
5762    }
5763    pub const fn const_margin_right(input: LayoutMarginRight) -> Self {
5764        CssProperty::MarginRight(LayoutMarginRightValue::Exact(input))
5765    }
5766    pub const fn const_margin_bottom(input: LayoutMarginBottom) -> Self {
5767        CssProperty::MarginBottom(LayoutMarginBottomValue::Exact(input))
5768    }
5769    pub const fn const_border_top_left_radius(input: StyleBorderTopLeftRadius) -> Self {
5770        CssProperty::BorderTopLeftRadius(StyleBorderTopLeftRadiusValue::Exact(input))
5771    }
5772    pub const fn const_border_top_right_radius(input: StyleBorderTopRightRadius) -> Self {
5773        CssProperty::BorderTopRightRadius(StyleBorderTopRightRadiusValue::Exact(input))
5774    }
5775    pub const fn const_border_bottom_left_radius(input: StyleBorderBottomLeftRadius) -> Self {
5776        CssProperty::BorderBottomLeftRadius(StyleBorderBottomLeftRadiusValue::Exact(input))
5777    }
5778    pub const fn const_border_bottom_right_radius(input: StyleBorderBottomRightRadius) -> Self {
5779        CssProperty::BorderBottomRightRadius(StyleBorderBottomRightRadiusValue::Exact(input))
5780    }
5781    pub const fn const_border_top_color(input: StyleBorderTopColor) -> Self {
5782        CssProperty::BorderTopColor(StyleBorderTopColorValue::Exact(input))
5783    }
5784    pub const fn const_border_right_color(input: StyleBorderRightColor) -> Self {
5785        CssProperty::BorderRightColor(StyleBorderRightColorValue::Exact(input))
5786    }
5787    pub const fn const_border_left_color(input: StyleBorderLeftColor) -> Self {
5788        CssProperty::BorderLeftColor(StyleBorderLeftColorValue::Exact(input))
5789    }
5790    pub const fn const_border_bottom_color(input: StyleBorderBottomColor) -> Self {
5791        CssProperty::BorderBottomColor(StyleBorderBottomColorValue::Exact(input))
5792    }
5793    pub const fn const_border_top_style(input: StyleBorderTopStyle) -> Self {
5794        CssProperty::BorderTopStyle(StyleBorderTopStyleValue::Exact(input))
5795    }
5796    pub const fn const_border_right_style(input: StyleBorderRightStyle) -> Self {
5797        CssProperty::BorderRightStyle(StyleBorderRightStyleValue::Exact(input))
5798    }
5799    pub const fn const_border_left_style(input: StyleBorderLeftStyle) -> Self {
5800        CssProperty::BorderLeftStyle(StyleBorderLeftStyleValue::Exact(input))
5801    }
5802    pub const fn const_border_bottom_style(input: StyleBorderBottomStyle) -> Self {
5803        CssProperty::BorderBottomStyle(StyleBorderBottomStyleValue::Exact(input))
5804    }
5805    pub const fn const_border_top_width(input: LayoutBorderTopWidth) -> Self {
5806        CssProperty::BorderTopWidth(LayoutBorderTopWidthValue::Exact(input))
5807    }
5808    pub const fn const_border_right_width(input: LayoutBorderRightWidth) -> Self {
5809        CssProperty::BorderRightWidth(LayoutBorderRightWidthValue::Exact(input))
5810    }
5811    pub const fn const_border_left_width(input: LayoutBorderLeftWidth) -> Self {
5812        CssProperty::BorderLeftWidth(LayoutBorderLeftWidthValue::Exact(input))
5813    }
5814    pub const fn const_border_bottom_width(input: LayoutBorderBottomWidth) -> Self {
5815        CssProperty::BorderBottomWidth(LayoutBorderBottomWidthValue::Exact(input))
5816    }
5817    pub const fn const_box_shadow_left(input: StyleBoxShadow) -> Self {
5818        CssProperty::BoxShadowLeft(StyleBoxShadowValue::Exact(input))
5819    }
5820    pub const fn const_box_shadow_right(input: StyleBoxShadow) -> Self {
5821        CssProperty::BoxShadowRight(StyleBoxShadowValue::Exact(input))
5822    }
5823    pub const fn const_box_shadow_top(input: StyleBoxShadow) -> Self {
5824        CssProperty::BoxShadowTop(StyleBoxShadowValue::Exact(input))
5825    }
5826    pub const fn const_box_shadow_bottom(input: StyleBoxShadow) -> Self {
5827        CssProperty::BoxShadowBottom(StyleBoxShadowValue::Exact(input))
5828    }
5829    pub const fn const_opacity(input: StyleOpacity) -> Self {
5830        CssProperty::Opacity(StyleOpacityValue::Exact(input))
5831    }
5832    pub const fn const_transform(input: StyleTransformVec) -> Self {
5833        CssProperty::Transform(StyleTransformVecValue::Exact(input))
5834    }
5835    pub const fn const_transform_origin(input: StyleTransformOrigin) -> Self {
5836        CssProperty::TransformOrigin(StyleTransformOriginValue::Exact(input))
5837    }
5838    pub const fn const_perspective_origin(input: StylePerspectiveOrigin) -> Self {
5839        CssProperty::PerspectiveOrigin(StylePerspectiveOriginValue::Exact(input))
5840    }
5841    pub const fn const_backface_visiblity(input: StyleBackfaceVisibility) -> Self {
5842        CssProperty::BackfaceVisibility(StyleBackfaceVisibilityValue::Exact(input))
5843    }
5844    pub const fn const_break_before(input: PageBreak) -> Self {
5845        CssProperty::BreakBefore(PageBreakValue::Exact(input))
5846    }
5847    pub const fn const_break_after(input: PageBreak) -> Self {
5848        CssProperty::BreakAfter(PageBreakValue::Exact(input))
5849    }
5850    pub const fn const_break_inside(input: BreakInside) -> Self {
5851        CssProperty::BreakInside(BreakInsideValue::Exact(input))
5852    }
5853    pub const fn const_orphans(input: Orphans) -> Self {
5854        CssProperty::Orphans(OrphansValue::Exact(input))
5855    }
5856    pub const fn const_widows(input: Widows) -> Self {
5857        CssProperty::Widows(WidowsValue::Exact(input))
5858    }
5859    pub const fn const_box_decoration_break(input: BoxDecorationBreak) -> Self {
5860        CssProperty::BoxDecorationBreak(BoxDecorationBreakValue::Exact(input))
5861    }
5862    pub const fn const_column_count(input: ColumnCount) -> Self {
5863        CssProperty::ColumnCount(ColumnCountValue::Exact(input))
5864    }
5865    pub const fn const_column_width(input: ColumnWidth) -> Self {
5866        CssProperty::ColumnWidth(ColumnWidthValue::Exact(input))
5867    }
5868    pub const fn const_column_span(input: ColumnSpan) -> Self {
5869        CssProperty::ColumnSpan(ColumnSpanValue::Exact(input))
5870    }
5871    pub const fn const_column_fill(input: ColumnFill) -> Self {
5872        CssProperty::ColumnFill(ColumnFillValue::Exact(input))
5873    }
5874    pub const fn const_column_rule_width(input: ColumnRuleWidth) -> Self {
5875        CssProperty::ColumnRuleWidth(ColumnRuleWidthValue::Exact(input))
5876    }
5877    pub const fn const_column_rule_style(input: ColumnRuleStyle) -> Self {
5878        CssProperty::ColumnRuleStyle(ColumnRuleStyleValue::Exact(input))
5879    }
5880    pub const fn const_column_rule_color(input: ColumnRuleColor) -> Self {
5881        CssProperty::ColumnRuleColor(ColumnRuleColorValue::Exact(input))
5882    }
5883    pub const fn const_flow_into(input: FlowInto) -> Self {
5884        CssProperty::FlowInto(FlowIntoValue::Exact(input))
5885    }
5886    pub const fn const_flow_from(input: FlowFrom) -> Self {
5887        CssProperty::FlowFrom(FlowFromValue::Exact(input))
5888    }
5889    pub const fn const_shape_outside(input: ShapeOutside) -> Self {
5890        CssProperty::ShapeOutside(ShapeOutsideValue::Exact(input))
5891    }
5892    pub const fn const_shape_inside(input: ShapeInside) -> Self {
5893        CssProperty::ShapeInside(ShapeInsideValue::Exact(input))
5894    }
5895    pub const fn const_clip_path(input: ClipPath) -> Self {
5896        CssProperty::ClipPath(ClipPathValue::Exact(input))
5897    }
5898    pub const fn const_shape_margin(input: ShapeMargin) -> Self {
5899        CssProperty::ShapeMargin(ShapeMarginValue::Exact(input))
5900    }
5901    pub const fn const_shape_image_threshold(input: ShapeImageThreshold) -> Self {
5902        CssProperty::ShapeImageThreshold(ShapeImageThresholdValue::Exact(input))
5903    }
5904    pub const fn const_content(input: Content) -> Self {
5905        CssProperty::Content(ContentValue::Exact(input))
5906    }
5907    pub const fn const_counter_reset(input: CounterReset) -> Self {
5908        CssProperty::CounterReset(CounterResetValue::Exact(input))
5909    }
5910    pub const fn const_counter_increment(input: CounterIncrement) -> Self {
5911        CssProperty::CounterIncrement(CounterIncrementValue::Exact(input))
5912    }
5913    pub const fn const_list_style_type(input: StyleListStyleType) -> Self {
5914        CssProperty::ListStyleType(StyleListStyleTypeValue::Exact(input))
5915    }
5916    pub const fn const_list_style_position(input: StyleListStylePosition) -> Self {
5917        CssProperty::ListStylePosition(StyleListStylePositionValue::Exact(input))
5918    }
5919    pub const fn const_string_set(input: StringSet) -> Self {
5920        CssProperty::StringSet(StringSetValue::Exact(input))
5921    }
5922    pub const fn const_table_layout(input: LayoutTableLayout) -> Self {
5923        CssProperty::TableLayout(LayoutTableLayoutValue::Exact(input))
5924    }
5925    pub const fn const_border_collapse(input: StyleBorderCollapse) -> Self {
5926        CssProperty::BorderCollapse(StyleBorderCollapseValue::Exact(input))
5927    }
5928    pub const fn const_border_spacing(input: LayoutBorderSpacing) -> Self {
5929        CssProperty::BorderSpacing(LayoutBorderSpacingValue::Exact(input))
5930    }
5931    pub const fn const_caption_side(input: StyleCaptionSide) -> Self {
5932        CssProperty::CaptionSide(StyleCaptionSideValue::Exact(input))
5933    }
5934    pub const fn const_empty_cells(input: StyleEmptyCells) -> Self {
5935        CssProperty::EmptyCells(StyleEmptyCellsValue::Exact(input))
5936    }
5937}
5938
5939pub fn format_static_css_prop(prop: &CssProperty, tabs: usize) -> String {
5940    match prop {
5941        CssProperty::CaretColor(p) => format!(
5942            "CssProperty::CaretColor({})",
5943            print_css_property_value(p, tabs, "CaretColor")
5944        ),
5945        CssProperty::CaretWidth(p) => format!(
5946            "CssProperty::CaretWidth({})",
5947            print_css_property_value(p, tabs, "CaretWidth")
5948        ),
5949        CssProperty::CaretAnimationDuration(p) => format!(
5950            "CssProperty::CaretAnimationDuration({})",
5951            print_css_property_value(p, tabs, "CaretAnimationDuration")
5952        ),
5953        CssProperty::SelectionBackgroundColor(p) => format!(
5954            "CssProperty::SelectionBackgroundColor({})",
5955            print_css_property_value(p, tabs, "SelectionBackgroundColor")
5956        ),
5957        CssProperty::SelectionColor(p) => format!(
5958            "CssProperty::SelectionColor({})",
5959            print_css_property_value(p, tabs, "SelectionColor")
5960        ),
5961        CssProperty::SelectionRadius(p) => format!(
5962            "CssProperty::SelectionRadius({})",
5963            print_css_property_value(p, tabs, "SelectionRadius")
5964        ),
5965        CssProperty::TextJustify(p) => format!(
5966            "CssProperty::TextJustify({})",
5967            print_css_property_value(p, tabs, "LayoutTextJustify")
5968        ),
5969        CssProperty::LayoutTextJustify(j) => format!(
5970            "CssProperty::LayoutTextJustify({})",
5971            print_css_property_value(j, tabs, "LayoutText")
5972        ),
5973        CssProperty::TextColor(p) => format!(
5974            "CssProperty::TextColor({})",
5975            print_css_property_value(p, tabs, "StyleTextColor")
5976        ),
5977        CssProperty::FontSize(p) => format!(
5978            "CssProperty::FontSize({})",
5979            print_css_property_value(p, tabs, "StyleFontSize")
5980        ),
5981        CssProperty::FontFamily(p) => format!(
5982            "CssProperty::FontFamily({})",
5983            print_css_property_value(p, tabs, "StyleFontFamilyVec")
5984        ),
5985        CssProperty::TextAlign(p) => format!(
5986            "CssProperty::TextAlign({})",
5987            print_css_property_value(p, tabs, "StyleTextAlign")
5988        ),
5989        CssProperty::VerticalAlign(p) => format!(
5990            "CssProperty::VerticalAlign({})",
5991            print_css_property_value(p, tabs, "StyleVerticalAlign")
5992        ),
5993        CssProperty::LetterSpacing(p) => format!(
5994            "CssProperty::LetterSpacing({})",
5995            print_css_property_value(p, tabs, "StyleLetterSpacing")
5996        ),
5997        CssProperty::TextIndent(p) => format!(
5998            "CssProperty::TextIndent({})",
5999            print_css_property_value(p, tabs, "StyleTextIndent")
6000        ),
6001        CssProperty::InitialLetter(p) => format!(
6002            "CssProperty::InitialLetter({})",
6003            print_css_property_value(p, tabs, "StyleInitialLetter")
6004        ),
6005        CssProperty::LineClamp(p) => format!(
6006            "CssProperty::LineClamp({})",
6007            print_css_property_value(p, tabs, "StyleLineClamp")
6008        ),
6009        CssProperty::HangingPunctuation(p) => format!(
6010            "CssProperty::HangingPunctuation({})",
6011            print_css_property_value(p, tabs, "StyleHangingPunctuation")
6012        ),
6013        CssProperty::TextCombineUpright(p) => format!(
6014            "CssProperty::TextCombineUpright({})",
6015            print_css_property_value(p, tabs, "StyleTextCombineUpright")
6016        ),
6017        CssProperty::ExclusionMargin(p) => format!(
6018            "CssProperty::ExclusionMargin({})",
6019            print_css_property_value(p, tabs, "StyleExclusionMargin")
6020        ),
6021        CssProperty::HyphenationLanguage(p) => format!(
6022            "CssProperty::HyphenationLanguage({})",
6023            print_css_property_value(p, tabs, "StyleHyphenationLanguage")
6024        ),
6025        CssProperty::LineHeight(p) => format!(
6026            "CssProperty::LineHeight({})",
6027            print_css_property_value(p, tabs, "StyleLineHeight")
6028        ),
6029        CssProperty::WordSpacing(p) => format!(
6030            "CssProperty::WordSpacing({})",
6031            print_css_property_value(p, tabs, "StyleWordSpacing")
6032        ),
6033        CssProperty::TabSize(p) => format!(
6034            "CssProperty::TabSize({})",
6035            print_css_property_value(p, tabs, "StyleTabSize")
6036        ),
6037        CssProperty::Cursor(p) => format!(
6038            "CssProperty::Cursor({})",
6039            print_css_property_value(p, tabs, "StyleCursor")
6040        ),
6041        CssProperty::Display(p) => format!(
6042            "CssProperty::Display({})",
6043            print_css_property_value(p, tabs, "LayoutDisplay")
6044        ),
6045        CssProperty::Float(p) => format!(
6046            "CssProperty::Float({})",
6047            print_css_property_value(p, tabs, "LayoutFloat")
6048        ),
6049        CssProperty::BoxSizing(p) => format!(
6050            "CssProperty::BoxSizing({})",
6051            print_css_property_value(p, tabs, "LayoutBoxSizing")
6052        ),
6053        CssProperty::Width(p) => format!(
6054            "CssProperty::Width({})",
6055            print_css_property_value(p, tabs, "LayoutWidth")
6056        ),
6057        CssProperty::Height(p) => format!(
6058            "CssProperty::Height({})",
6059            print_css_property_value(p, tabs, "LayoutHeight")
6060        ),
6061        CssProperty::MinWidth(p) => format!(
6062            "CssProperty::MinWidth({})",
6063            print_css_property_value(p, tabs, "LayoutMinWidth")
6064        ),
6065        CssProperty::MinHeight(p) => format!(
6066            "CssProperty::MinHeight({})",
6067            print_css_property_value(p, tabs, "LayoutMinHeight")
6068        ),
6069        CssProperty::MaxWidth(p) => format!(
6070            "CssProperty::MaxWidth({})",
6071            print_css_property_value(p, tabs, "LayoutMaxWidth")
6072        ),
6073        CssProperty::MaxHeight(p) => format!(
6074            "CssProperty::MaxHeight({})",
6075            print_css_property_value(p, tabs, "LayoutMaxHeight")
6076        ),
6077        CssProperty::Position(p) => format!(
6078            "CssProperty::Position({})",
6079            print_css_property_value(p, tabs, "LayoutPosition")
6080        ),
6081        CssProperty::Top(p) => format!(
6082            "CssProperty::Top({})",
6083            print_css_property_value(p, tabs, "LayoutTop")
6084        ),
6085        CssProperty::Right(p) => format!(
6086            "CssProperty::Right({})",
6087            print_css_property_value(p, tabs, "LayoutRight")
6088        ),
6089        CssProperty::Left(p) => format!(
6090            "CssProperty::Left({})",
6091            print_css_property_value(p, tabs, "LayoutLeft")
6092        ),
6093        CssProperty::Bottom(p) => format!(
6094            "CssProperty::Bottom({})",
6095            print_css_property_value(p, tabs, "LayoutInsetBottom")
6096        ),
6097        CssProperty::ZIndex(p) => format!(
6098            "CssProperty::ZIndex({})",
6099            print_css_property_value(p, tabs, "LayoutZIndex")
6100        ),
6101        CssProperty::FlexWrap(p) => format!(
6102            "CssProperty::FlexWrap({})",
6103            print_css_property_value(p, tabs, "LayoutFlexWrap")
6104        ),
6105        CssProperty::FlexDirection(p) => format!(
6106            "CssProperty::FlexDirection({})",
6107            print_css_property_value(p, tabs, "LayoutFlexDirection")
6108        ),
6109        CssProperty::FlexGrow(p) => format!(
6110            "CssProperty::FlexGrow({})",
6111            print_css_property_value(p, tabs, "LayoutFlexGrow")
6112        ),
6113        CssProperty::FlexShrink(p) => format!(
6114            "CssProperty::FlexShrink({})",
6115            print_css_property_value(p, tabs, "LayoutFlexShrink")
6116        ),
6117        CssProperty::JustifyContent(p) => format!(
6118            "CssProperty::JustifyContent({})",
6119            print_css_property_value(p, tabs, "LayoutJustifyContent")
6120        ),
6121        CssProperty::AlignItems(p) => format!(
6122            "CssProperty::AlignItems({})",
6123            print_css_property_value(p, tabs, "LayoutAlignItems")
6124        ),
6125        CssProperty::AlignContent(p) => format!(
6126            "CssProperty::AlignContent({})",
6127            print_css_property_value(p, tabs, "LayoutAlignContent")
6128        ),
6129        CssProperty::BackgroundContent(p) => format!(
6130            "CssProperty::BackgroundContent({})",
6131            print_css_property_value(p, tabs, "StyleBackgroundContentVec")
6132        ),
6133        CssProperty::BackgroundPosition(p) => format!(
6134            "CssProperty::BackgroundPosition({})",
6135            print_css_property_value(p, tabs, "StyleBackgroundPositionVec")
6136        ),
6137        CssProperty::BackgroundSize(p) => format!(
6138            "CssProperty::BackgroundSize({})",
6139            print_css_property_value(p, tabs, "StyleBackgroundSizeVec")
6140        ),
6141        CssProperty::BackgroundRepeat(p) => format!(
6142            "CssProperty::BackgroundRepeat({})",
6143            print_css_property_value(p, tabs, "StyleBackgroundRepeatVec")
6144        ),
6145        CssProperty::OverflowX(p) => format!(
6146            "CssProperty::OverflowX({})",
6147            print_css_property_value(p, tabs, "LayoutOverflow")
6148        ),
6149        CssProperty::OverflowY(p) => format!(
6150            "CssProperty::OverflowY({})",
6151            print_css_property_value(p, tabs, "LayoutOverflow")
6152        ),
6153        CssProperty::PaddingTop(p) => format!(
6154            "CssProperty::PaddingTop({})",
6155            print_css_property_value(p, tabs, "LayoutPaddingTop")
6156        ),
6157        CssProperty::PaddingLeft(p) => format!(
6158            "CssProperty::PaddingLeft({})",
6159            print_css_property_value(p, tabs, "LayoutPaddingLeft")
6160        ),
6161        CssProperty::PaddingRight(p) => format!(
6162            "CssProperty::PaddingRight({})",
6163            print_css_property_value(p, tabs, "LayoutPaddingRight")
6164        ),
6165        CssProperty::PaddingBottom(p) => format!(
6166            "CssProperty::PaddingBottom({})",
6167            print_css_property_value(p, tabs, "LayoutPaddingBottom")
6168        ),
6169        CssProperty::PaddingInlineStart(p) => format!(
6170            "CssProperty::PaddingInlineStart({})",
6171            print_css_property_value(p, tabs, "LayoutPaddingInlineStart")
6172        ),
6173        CssProperty::PaddingInlineEnd(p) => format!(
6174            "CssProperty::PaddingInlineEnd({})",
6175            print_css_property_value(p, tabs, "LayoutPaddingInlineEnd")
6176        ),
6177        CssProperty::MarginTop(p) => format!(
6178            "CssProperty::MarginTop({})",
6179            print_css_property_value(p, tabs, "LayoutMarginTop")
6180        ),
6181        CssProperty::MarginLeft(p) => format!(
6182            "CssProperty::MarginLeft({})",
6183            print_css_property_value(p, tabs, "LayoutMarginLeft")
6184        ),
6185        CssProperty::MarginRight(p) => format!(
6186            "CssProperty::MarginRight({})",
6187            print_css_property_value(p, tabs, "LayoutMarginRight")
6188        ),
6189        CssProperty::MarginBottom(p) => format!(
6190            "CssProperty::MarginBottom({})",
6191            print_css_property_value(p, tabs, "LayoutMarginBottom")
6192        ),
6193        CssProperty::BorderTopLeftRadius(p) => format!(
6194            "CssProperty::BorderTopLeftRadius({})",
6195            print_css_property_value(p, tabs, "StyleBorderTopLeftRadius")
6196        ),
6197        CssProperty::BorderTopRightRadius(p) => format!(
6198            "CssProperty::BorderTopRightRadius({})",
6199            print_css_property_value(p, tabs, "StyleBorderTopRightRadius")
6200        ),
6201        CssProperty::BorderBottomLeftRadius(p) => format!(
6202            "CssProperty::BorderBottomLeftRadius({})",
6203            print_css_property_value(p, tabs, "StyleBorderBottomLeftRadius")
6204        ),
6205        CssProperty::BorderBottomRightRadius(p) => format!(
6206            "CssProperty::BorderBottomRightRadius({})",
6207            print_css_property_value(p, tabs, "StyleBorderBottomRightRadius")
6208        ),
6209        CssProperty::BorderTopColor(p) => format!(
6210            "CssProperty::BorderTopColor({})",
6211            print_css_property_value(p, tabs, "StyleBorderTopColor")
6212        ),
6213        CssProperty::BorderRightColor(p) => format!(
6214            "CssProperty::BorderRightColor({})",
6215            print_css_property_value(p, tabs, "StyleBorderRightColor")
6216        ),
6217        CssProperty::BorderLeftColor(p) => format!(
6218            "CssProperty::BorderLeftColor({})",
6219            print_css_property_value(p, tabs, "StyleBorderLeftColor")
6220        ),
6221        CssProperty::BorderBottomColor(p) => format!(
6222            "CssProperty::BorderBottomColor({})",
6223            print_css_property_value(p, tabs, "StyleBorderBottomColor")
6224        ),
6225        CssProperty::BorderTopStyle(p) => format!(
6226            "CssProperty::BorderTopStyle({})",
6227            print_css_property_value(p, tabs, "StyleBorderTopStyle")
6228        ),
6229        CssProperty::BorderRightStyle(p) => format!(
6230            "CssProperty::BorderRightStyle({})",
6231            print_css_property_value(p, tabs, "StyleBorderRightStyle")
6232        ),
6233        CssProperty::BorderLeftStyle(p) => format!(
6234            "CssProperty::BorderLeftStyle({})",
6235            print_css_property_value(p, tabs, "StyleBorderLeftStyle")
6236        ),
6237        CssProperty::BorderBottomStyle(p) => format!(
6238            "CssProperty::BorderBottomStyle({})",
6239            print_css_property_value(p, tabs, "StyleBorderBottomStyle")
6240        ),
6241        CssProperty::BorderTopWidth(p) => format!(
6242            "CssProperty::BorderTopWidth({})",
6243            print_css_property_value(p, tabs, "LayoutBorderTopWidth")
6244        ),
6245        CssProperty::BorderRightWidth(p) => format!(
6246            "CssProperty::BorderRightWidth({})",
6247            print_css_property_value(p, tabs, "LayoutBorderRightWidth")
6248        ),
6249        CssProperty::BorderLeftWidth(p) => format!(
6250            "CssProperty::BorderLeftWidth({})",
6251            print_css_property_value(p, tabs, "LayoutBorderLeftWidth")
6252        ),
6253        CssProperty::BorderBottomWidth(p) => format!(
6254            "CssProperty::BorderBottomWidth({})",
6255            print_css_property_value(p, tabs, "LayoutBorderBottomWidth")
6256        ),
6257        CssProperty::BoxShadowLeft(p) => format!(
6258            "CssProperty::BoxShadowLeft({})",
6259            print_css_property_value(p, tabs, "StyleBoxShadow")
6260        ),
6261        CssProperty::BoxShadowRight(p) => format!(
6262            "CssProperty::BoxShadowRight({})",
6263            print_css_property_value(p, tabs, "StyleBoxShadow")
6264        ),
6265        CssProperty::BoxShadowTop(p) => format!(
6266            "CssProperty::BoxShadowTop({})",
6267            print_css_property_value(p, tabs, "StyleBoxShadow")
6268        ),
6269        CssProperty::BoxShadowBottom(p) => format!(
6270            "CssProperty::BoxShadowBottom({})",
6271            print_css_property_value(p, tabs, "StyleBoxShadow")
6272        ),
6273        CssProperty::ScrollbarWidth(p) => format!(
6274            "CssProperty::ScrollbarWidth({})",
6275            print_css_property_value(p, tabs, "LayoutScrollbarWidth")
6276        ),
6277        CssProperty::ScrollbarColor(p) => format!(
6278            "CssProperty::ScrollbarColor({})",
6279            print_css_property_value(p, tabs, "StyleScrollbarColor")
6280        ),
6281        CssProperty::Scrollbar(p) => format!(
6282            "CssProperty::Scrollbar({})",
6283            print_css_property_value(p, tabs, "Scrollbar")
6284        ),
6285        CssProperty::Opacity(p) => format!(
6286            "CssProperty::Opacity({})",
6287            print_css_property_value(p, tabs, "StyleOpacity")
6288        ),
6289        CssProperty::Visibility(p) => format!(
6290            "CssProperty::Visibility({})",
6291            print_css_property_value(p, tabs, "StyleVisibility")
6292        ),
6293        CssProperty::Transform(p) => format!(
6294            "CssProperty::Transform({})",
6295            print_css_property_value(p, tabs, "StyleTransformVec")
6296        ),
6297        CssProperty::TransformOrigin(p) => format!(
6298            "CssProperty::TransformOrigin({})",
6299            print_css_property_value(p, tabs, "StyleTransformOrigin")
6300        ),
6301        CssProperty::PerspectiveOrigin(p) => format!(
6302            "CssProperty::PerspectiveOrigin({})",
6303            print_css_property_value(p, tabs, "StylePerspectiveOrigin")
6304        ),
6305        CssProperty::BackfaceVisibility(p) => format!(
6306            "CssProperty::BackfaceVisibility({})",
6307            print_css_property_value(p, tabs, "StyleBackfaceVisibility")
6308        ),
6309        CssProperty::MixBlendMode(p) => format!(
6310            "CssProperty::MixBlendMode({})",
6311            print_css_property_value(p, tabs, "StyleMixBlendMode")
6312        ),
6313        CssProperty::Filter(p) => format!(
6314            "CssProperty::Filter({})",
6315            print_css_property_value(p, tabs, "StyleFilterVec")
6316        ),
6317        CssProperty::BackdropFilter(p) => format!(
6318            "CssProperty::Filter({})",
6319            print_css_property_value(p, tabs, "StyleFilterVec")
6320        ),
6321        CssProperty::TextShadow(p) => format!(
6322            "CssProperty::TextShadow({})",
6323            print_css_property_value(p, tabs, "StyleBoxShadow")
6324        ),
6325        CssProperty::Hyphens(p) => format!(
6326            "CssProperty::Hyphens({})",
6327            print_css_property_value(p, tabs, "StyleHyphens")
6328        ),
6329        CssProperty::Direction(p) => format!(
6330            "CssProperty::Direction({})",
6331            print_css_property_value(p, tabs, "Direction")
6332        ),
6333        CssProperty::UserSelect(p) => format!(
6334            "CssProperty::UserSelect({})",
6335            print_css_property_value(p, tabs, "StyleUserSelect")
6336        ),
6337        CssProperty::TextDecoration(p) => format!(
6338            "CssProperty::TextDecoration({})",
6339            print_css_property_value(p, tabs, "StyleTextDecoration")
6340        ),
6341        CssProperty::WhiteSpace(p) => format!(
6342            "CssProperty::WhiteSpace({})",
6343            print_css_property_value(p, tabs, "WhiteSpace")
6344        ),
6345        CssProperty::FlexBasis(p) => format!(
6346            "CssProperty::FlexBasis({})",
6347            print_css_property_value(p, tabs, "LayoutFlexBasis")
6348        ),
6349        CssProperty::ColumnGap(p) => format!(
6350            "CssProperty::ColumnGap({})",
6351            print_css_property_value(p, tabs, "LayoutColumnGap")
6352        ),
6353        CssProperty::RowGap(p) => format!(
6354            "CssProperty::RowGap({})",
6355            print_css_property_value(p, tabs, "LayoutRowGap")
6356        ),
6357        CssProperty::GridTemplateColumns(p) => format!(
6358            "CssProperty::GridTemplateColumns({})",
6359            print_css_property_value(p, tabs, "LayoutGridTemplateColumns")
6360        ),
6361        CssProperty::GridTemplateRows(p) => format!(
6362            "CssProperty::GridTemplateRows({})",
6363            print_css_property_value(p, tabs, "LayoutGridTemplateRows")
6364        ),
6365        CssProperty::GridAutoFlow(p) => format!(
6366            "CssProperty::GridAutoFlow({})",
6367            print_css_property_value(p, tabs, "LayoutGridAutoFlow")
6368        ),
6369        CssProperty::JustifySelf(p) => format!(
6370            "CssProperty::JustifySelf({})",
6371            print_css_property_value(p, tabs, "LayoutJustifySelf")
6372        ),
6373        CssProperty::JustifyItems(p) => format!(
6374            "CssProperty::JustifyItems({})",
6375            print_css_property_value(p, tabs, "LayoutJustifyItems")
6376        ),
6377        CssProperty::Gap(p) => format!(
6378            "CssProperty::Gap({})",
6379            print_css_property_value(p, tabs, "LayoutGap")
6380        ),
6381        CssProperty::GridGap(p) => format!(
6382            "CssProperty::GridGap({})",
6383            print_css_property_value(p, tabs, "LayoutGap")
6384        ),
6385        CssProperty::AlignSelf(p) => format!(
6386            "CssProperty::AlignSelf({})",
6387            print_css_property_value(p, tabs, "LayoutAlignSelf")
6388        ),
6389        CssProperty::Font(p) => format!(
6390            "CssProperty::Font({})",
6391            print_css_property_value(p, tabs, "StyleFontFamilyVec")
6392        ),
6393        CssProperty::GridAutoRows(p) => format!(
6394            "CssProperty::GridAutoRows({})",
6395            print_css_property_value(p, tabs, "LayoutGridAutoRows")
6396        ),
6397        CssProperty::GridAutoColumns(p) => format!(
6398            "CssProperty::GridAutoColumns({})",
6399            print_css_property_value(p, tabs, "LayoutGridAutoColumns")
6400        ),
6401        CssProperty::GridRow(p) => format!(
6402            "CssProperty::GridRow({})",
6403            print_css_property_value(p, tabs, "LayoutGridRow")
6404        ),
6405        CssProperty::GridColumn(p) => format!(
6406            "CssProperty::GridColumn({})",
6407            print_css_property_value(p, tabs, "LayoutGridColumn")
6408        ),
6409        CssProperty::GridTemplateAreas(p) => format!(
6410            "CssProperty::GridTemplateAreas({})",
6411            print_css_property_value(p, tabs, "GridTemplateAreas")
6412        ),
6413        CssProperty::WritingMode(p) => format!(
6414            "CssProperty::WritingMode({})",
6415            print_css_property_value(p, tabs, "LayoutWritingMode")
6416        ),
6417        CssProperty::Clear(p) => format!(
6418            "CssProperty::Clear({})",
6419            print_css_property_value(p, tabs, "LayoutClear")
6420        ),
6421        CssProperty::BreakBefore(p) => format!(
6422            "CssProperty::BreakBefore({})",
6423            print_css_property_value(p, tabs, "PageBreak")
6424        ),
6425        CssProperty::BreakAfter(p) => format!(
6426            "CssProperty::BreakAfter({})",
6427            print_css_property_value(p, tabs, "PageBreak")
6428        ),
6429        CssProperty::BreakInside(p) => format!(
6430            "CssProperty::BreakInside({})",
6431            print_css_property_value(p, tabs, "BreakInside")
6432        ),
6433        CssProperty::Orphans(p) => format!(
6434            "CssProperty::Orphans({})",
6435            print_css_property_value(p, tabs, "Orphans")
6436        ),
6437        CssProperty::Widows(p) => format!(
6438            "CssProperty::Widows({})",
6439            print_css_property_value(p, tabs, "Widows")
6440        ),
6441        CssProperty::BoxDecorationBreak(p) => format!(
6442            "CssProperty::BoxDecorationBreak({})",
6443            print_css_property_value(p, tabs, "BoxDecorationBreak")
6444        ),
6445        CssProperty::ColumnCount(p) => format!(
6446            "CssProperty::ColumnCount({})",
6447            print_css_property_value(p, tabs, "ColumnCount")
6448        ),
6449        CssProperty::ColumnWidth(p) => format!(
6450            "CssProperty::ColumnWidth({})",
6451            print_css_property_value(p, tabs, "ColumnWidth")
6452        ),
6453        CssProperty::ColumnSpan(p) => format!(
6454            "CssProperty::ColumnSpan({})",
6455            print_css_property_value(p, tabs, "ColumnSpan")
6456        ),
6457        CssProperty::ColumnFill(p) => format!(
6458            "CssProperty::ColumnFill({})",
6459            print_css_property_value(p, tabs, "ColumnFill")
6460        ),
6461        CssProperty::ColumnRuleWidth(p) => format!(
6462            "CssProperty::ColumnRuleWidth({})",
6463            print_css_property_value(p, tabs, "ColumnRuleWidth")
6464        ),
6465        CssProperty::ColumnRuleStyle(p) => format!(
6466            "CssProperty::ColumnRuleStyle({})",
6467            print_css_property_value(p, tabs, "ColumnRuleStyle")
6468        ),
6469        CssProperty::ColumnRuleColor(p) => format!(
6470            "CssProperty::ColumnRuleColor({})",
6471            print_css_property_value(p, tabs, "ColumnRuleColor")
6472        ),
6473        CssProperty::FlowInto(p) => format!(
6474            "CssProperty::FlowInto({})",
6475            print_css_property_value(p, tabs, "FlowInto")
6476        ),
6477        CssProperty::FlowFrom(p) => format!(
6478            "CssProperty::FlowFrom({})",
6479            print_css_property_value(p, tabs, "FlowFrom")
6480        ),
6481        CssProperty::ShapeOutside(p) => format!(
6482            "CssProperty::ShapeOutside({})",
6483            print_css_property_value(p, tabs, "ShapeOutside")
6484        ),
6485        CssProperty::ShapeInside(p) => format!(
6486            "CssProperty::ShapeInside({})",
6487            print_css_property_value(p, tabs, "ShapeInside")
6488        ),
6489        CssProperty::ClipPath(p) => format!(
6490            "CssProperty::ClipPath({})",
6491            print_css_property_value(p, tabs, "ClipPath")
6492        ),
6493        CssProperty::ShapeMargin(p) => format!(
6494            "CssProperty::ShapeMargin({})",
6495            print_css_property_value(p, tabs, "ShapeMargin")
6496        ),
6497        CssProperty::ShapeImageThreshold(p) => format!(
6498            "CssProperty::ShapeImageThreshold({})",
6499            print_css_property_value(p, tabs, "ShapeImageThreshold")
6500        ),
6501        CssProperty::Content(p) => format!(
6502            "CssProperty::Content({})",
6503            print_css_property_value(p, tabs, "Content")
6504        ),
6505        CssProperty::CounterReset(p) => format!(
6506            "CssProperty::CounterReset({})",
6507            print_css_property_value(p, tabs, "CounterReset")
6508        ),
6509        CssProperty::CounterIncrement(p) => format!(
6510            "CssProperty::CounterIncrement({})",
6511            print_css_property_value(p, tabs, "CounterIncrement")
6512        ),
6513        CssProperty::ListStyleType(p) => format!(
6514            "CssProperty::ListStyleType({})",
6515            print_css_property_value(p, tabs, "StyleListStyleType")
6516        ),
6517        CssProperty::ListStylePosition(p) => format!(
6518            "CssProperty::ListStylePosition({})",
6519            print_css_property_value(p, tabs, "StyleListStylePosition")
6520        ),
6521        CssProperty::StringSet(p) => format!(
6522            "CssProperty::StringSet({})",
6523            print_css_property_value(p, tabs, "StringSet")
6524        ),
6525        CssProperty::TableLayout(p) => format!(
6526            "CssProperty::TableLayout({})",
6527            print_css_property_value(p, tabs, "LayoutTableLayout")
6528        ),
6529        CssProperty::BorderCollapse(p) => format!(
6530            "CssProperty::BorderCollapse({})",
6531            print_css_property_value(p, tabs, "StyleBorderCollapse")
6532        ),
6533        CssProperty::BorderSpacing(p) => format!(
6534            "CssProperty::BorderSpacing({})",
6535            print_css_property_value(p, tabs, "LayoutBorderSpacing")
6536        ),
6537        CssProperty::CaptionSide(p) => format!(
6538            "CssProperty::CaptionSide({})",
6539            print_css_property_value(p, tabs, "StyleCaptionSide")
6540        ),
6541        CssProperty::EmptyCells(p) => format!(
6542            "CssProperty::EmptyCells({})",
6543            print_css_property_value(p, tabs, "StyleEmptyCells")
6544        ),
6545        CssProperty::FontWeight(p) => format!(
6546            "CssProperty::FontWeight({})",
6547            print_css_property_value(p, tabs, "StyleFontWeight")
6548        ),
6549        CssProperty::FontStyle(p) => format!(
6550            "CssProperty::FontStyle({})",
6551            print_css_property_value(p, tabs, "StyleFontStyle")
6552        ),
6553    }
6554}
6555
6556fn print_css_property_value<T: FormatAsRustCode>(
6557    prop_val: &CssPropertyValue<T>,
6558    tabs: usize,
6559    property_value_type: &'static str,
6560) -> String {
6561    match prop_val {
6562        CssPropertyValue::Auto => format!("{}Value::Auto", property_value_type),
6563        CssPropertyValue::None => format!("{}Value::None", property_value_type),
6564        CssPropertyValue::Initial => format!("{}Value::Initial", property_value_type),
6565        CssPropertyValue::Inherit => format!("{}Value::Inherit", property_value_type),
6566        CssPropertyValue::Revert => format!("{}Value::Revert", property_value_type),
6567        CssPropertyValue::Unset => format!("{}Value::Unset", property_value_type),
6568        CssPropertyValue::Exact(t) => format!(
6569            "{}Value::Exact({})",
6570            property_value_type,
6571            t.format_as_rust_code(tabs)
6572        ),
6573    }
6574}