Skip to main content

hpx_browser/css_cascade/
initial.rs

1use crate::css_values::{
2    property::{CssValue, LineHeight, PropertyId},
3    types::{color::Color, display::*, font::*, length::*},
4};
5
6pub fn initial_value(property: &PropertyId) -> CssValue {
7    match property {
8        PropertyId::Display => CssValue::Display(Display::Inline),
9        PropertyId::Position => CssValue::Position(Position::Static),
10        PropertyId::Width | PropertyId::Height => {
11            CssValue::LengthPercentageAuto(LengthPercentageAuto::Auto)
12        }
13        PropertyId::MinWidth | PropertyId::MinHeight => {
14            CssValue::LengthPercentageAuto(LengthPercentageAuto::Auto)
15        }
16        PropertyId::MaxWidth | PropertyId::MaxHeight => {
17            CssValue::LengthPercentageAuto(LengthPercentageAuto::Auto)
18        }
19        PropertyId::MarginTop
20        | PropertyId::MarginRight
21        | PropertyId::MarginBottom
22        | PropertyId::MarginLeft => {
23            CssValue::LengthPercentageAuto(LengthPercentageAuto::Length(Length::Zero))
24        }
25        PropertyId::PaddingTop
26        | PropertyId::PaddingRight
27        | PropertyId::PaddingBottom
28        | PropertyId::PaddingLeft => {
29            CssValue::LengthPercentage(LengthPercentage::Length(Length::Zero))
30        }
31        PropertyId::BorderTopWidth
32        | PropertyId::BorderRightWidth
33        | PropertyId::BorderBottomWidth
34        | PropertyId::BorderLeftWidth => CssValue::Length(Length::Px(3.0)),
35        PropertyId::BoxSizing => CssValue::BoxSizing(BoxSizing::ContentBox),
36        PropertyId::OverflowX | PropertyId::OverflowY => CssValue::Overflow(Overflow::Visible),
37        PropertyId::Float => CssValue::Float(Float::None),
38        PropertyId::Clear => CssValue::Clear(Clear::None),
39        PropertyId::FlexDirection => CssValue::FlexDirection(FlexDirection::Row),
40        PropertyId::FlexWrap => CssValue::FlexWrap(FlexWrap::Nowrap),
41        PropertyId::FlexGrow => CssValue::Number(0.0),
42        PropertyId::FlexShrink => CssValue::Number(1.0),
43        PropertyId::FlexBasis => CssValue::LengthPercentageAuto(LengthPercentageAuto::Auto),
44        PropertyId::AlignItems => CssValue::Alignment(AlignmentValue::Normal),
45        PropertyId::AlignSelf => CssValue::Alignment(AlignmentValue::Normal),
46        PropertyId::AlignContent => CssValue::Alignment(AlignmentValue::Normal),
47        PropertyId::JustifyContent => CssValue::Alignment(AlignmentValue::Normal),
48        PropertyId::JustifyItems => CssValue::Alignment(AlignmentValue::Normal),
49        PropertyId::JustifySelf => CssValue::Alignment(AlignmentValue::Normal),
50        PropertyId::Gap | PropertyId::RowGap | PropertyId::ColumnGap => {
51            CssValue::LengthPercentage(LengthPercentage::Length(Length::Zero))
52        }
53        PropertyId::FontSize => {
54            CssValue::LengthPercentage(LengthPercentage::Length(Length::Px(16.0)))
55        }
56        PropertyId::FontFamily => {
57            CssValue::FontFamily(vec![FontFamily::Generic(GenericFamily::Serif)])
58        }
59        PropertyId::FontWeight => CssValue::FontWeight(FontWeight::Normal),
60        PropertyId::FontStyle => CssValue::FontStyle(FontStyle::Normal),
61        PropertyId::LineHeight => CssValue::LineHeight(LineHeight::Normal),
62        PropertyId::TextAlign => CssValue::TextAlign(TextAlign::Start),
63        PropertyId::WhiteSpace => CssValue::WhiteSpace(WhiteSpace::Normal),
64        PropertyId::Color => CssValue::Color(Color::Rgba {
65            r: 0,
66            g: 0,
67            b: 0,
68            a: 1.0,
69        }),
70        PropertyId::BackgroundColor => CssValue::Color(Color::Transparent),
71        PropertyId::Visibility => CssValue::Visibility(Visibility::Visible),
72        PropertyId::Opacity => CssValue::Number(1.0),
73        PropertyId::ZIndex => CssValue::Integer(0),
74        PropertyId::ContentVisibility => CssValue::ContentVisibility(ContentVisibility::Visible),
75        PropertyId::Transform => CssValue::Transform(vec![]),
76        PropertyId::Custom(_) => CssValue::Inherit,
77    }
78}