/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #pragma once #include namespace facebook::react { /** * All CSS properties,including CSS,and React-Native specific shorthands * https://www.w3.org/TR/css-cascade-4/#css-property */ enum class CSSProp { AlignContent, AlignItems, AlignSelf, AspectRatio, BorderBlockEndStyle, BorderBlockEndWidth, BorderBlockStartStyle, BorderBlockStartWidth, BorderBlockStyle, BorderBlockWidth, BorderBottomLeftRadius, BorderBottomRightRadius, BorderBottomStyle, BorderBottomWidth, BorderEndEndRadius, BorderEndStartRadius, BorderEndWidth, BorderHorizontalWidth, BorderInlineEndStyle, BorderInlineEndWidth, BorderInlineStartStyle, BorderInlineStartWidth, BorderInlineStyle, BorderInlineWidth, BorderLeftStyle, BorderLeftWidth, BorderRadius, BorderRightStyle, BorderRightWidth, BorderStartEndRadius, BorderStartStartRadius, BorderStartWidth, BorderStyle, BorderTopLeftRadius, BorderTopRightRadius, BorderTopStyle, BorderTopWidth, BorderVerticalWidth, BorderWidth, Bottom, ColumnGap, Direction, Display, End, Flex, FlexBasis, FlexDirection, FlexGrow, FlexShrink, FlexWrap, Gap, Height, Inset, InsetBlock, InsetBlockEnd, InsetBlockStart, InsetInline, InsetInlineEnd, InsetInlineStart, JustifyContent, Left, Margin, MarginBlock, MarginBlockEnd, MarginBlockStart, MarginBottom, MarginEnd, MarginHorizontal, MarginInline, MarginInlineEnd, MarginInlineStart, MarginLeft, MarginRight, MarginStart, MarginTop, MarginVertical, MaxHeight, MaxWidth, MinHeight, MinWidth, Opacity, Overflow, Padding, PaddingBlock, PaddingBlockEnd, PaddingBlockStart, PaddingBottom, PaddingEnd, PaddingHorizontal, PaddingInline, PaddingInlineEnd, PaddingInlineStart, PaddingLeft, PaddingRight, PaddingStart, PaddingTop, PaddingVertical, Position, Right, RowGap, Start, Top, Width, // Please update "kCSSPropCount" if adding a new prop to the end }; /** * The total number of CSS properties. */ constexpr auto kCSSPropCount = to_underlying(CSSProp::Width) + 1; /** * CSSPropDefinition associates a CSSProp to its * supported data types, Keyword, and other behaviors. */ template struct CSSPropDefinition {}; template using CSSDeclaredValue = typename CSSPropDefinition

::DeclaredValue; template using CSSSpecifiedValue = typename CSSPropDefinition

::SpecifiedValue; template using CSSComputedValue = typename CSSPropDefinition

::ComputedValue; /** * Whether to behave in accordance with W3C specs, or to incorporate React * Native specific tweaks to defaults and computation. */ enum class CSSFlavor { W3C, ReactNative, }; /** * CSS "align-content" property. * https://www.w3.org/TR/css-flexbox-1/#align-content-property * https://www.w3.org/TR/css-align-3/#align-justify-content */ template <> struct CSSPropDefinition { constexpr static std::string_view kName = "alignContent"; enum class Keyword : std::underlying_type_t { Center = to_underlying(CSSKeyword::Center), FlexEnd = to_underlying(CSSKeyword::FlexEnd), FlexStart = to_underlying(CSSKeyword::FlexStart), SpaceAround = to_underlying(CSSKeyword::SpaceAround), SpaceBetween = to_underlying(CSSKeyword::SpaceBetween), SpaceEvenly = to_underlying(CSSKeyword::SpaceEvenly), Stretch = to_underlying(CSSKeyword::Stretch), Start = to_underlying(CSSKeyword::Start), End = to_underlying(CSSKeyword::End), }; using DeclaredValue = CSSValueVariant; using SpecifiedValue = CSSValueVariant; using ComputedValue = CSSValueVariant; constexpr static bool isInherited() { return false; } constexpr static DeclaredValue initialValue(CSSFlavor flavor) { return flavor == CSSFlavor::W3C ? DeclaredValue::keyword(Keyword::Stretch) : DeclaredValue::keyword(Keyword::FlexStart); } }; /** * CSS "align-items" property. * https://www.w3.org/TR/css-flexbox-1/#align-items-property * https://www.w3.org/TR/css-align-3/#align-items-property */ template <> struct CSSPropDefinition { constexpr static std::string_view kName = "alignItems"; enum class Keyword : std::underlying_type_t { Baseline = to_underlying(CSSKeyword::Baseline), Center = to_underlying(CSSKeyword::Center), FlexEnd = to_underlying(CSSKeyword::FlexEnd), FlexStart = to_underlying(CSSKeyword::FlexStart), Stretch = to_underlying(CSSKeyword::Stretch), Start = to_underlying(CSSKeyword::Start), End = to_underlying(CSSKeyword::End), }; using DeclaredValue = CSSValueVariant; using SpecifiedValue = CSSValueVariant; using ComputedValue = CSSValueVariant; constexpr static bool isInherited() { return false; } constexpr static DeclaredValue initialValue(CSSFlavor /*flavor*/) { return DeclaredValue::keyword(Keyword::Stretch); } }; /** * CSS "align-self" property. * https://www.w3.org/TR/css-flexbox-1/#propdef-align-self * https://www.w3.org/TR/css-align-3/#align-self-property */ template <> struct CSSPropDefinition { constexpr static std::string_view kName = "alignSelf"; enum class Keyword : std::underlying_type_t { Auto = to_underlying(CSSKeyword::Auto), Baseline = to_underlying(CSSKeyword::Baseline), Center = to_underlying(CSSKeyword::Center), FlexEnd = to_underlying(CSSKeyword::FlexEnd), FlexStart = to_underlying(CSSKeyword::FlexStart), Stretch = to_underlying(CSSKeyword::Stretch), Start = to_underlying(CSSKeyword::Start), End = to_underlying(CSSKeyword::End), }; using DeclaredValue = CSSValueVariant; using SpecifiedValue = CSSValueVariant; using ComputedValue = CSSValueVariant; constexpr static bool isInherited() { return false; } constexpr static DeclaredValue initialValue(CSSFlavor /*flavor*/) { return DeclaredValue::keyword(Keyword::Auto); } }; /** * CSS "aspect-ratio" property. * https://www.w3.org/TR/css-sizing-4/#aspect-ratio */ template <> struct CSSPropDefinition { constexpr static std::string_view kName = "aspectRatio"; enum class Keyword : std::underlying_type_t { Auto = to_underlying(CSSKeyword::Auto), }; using DeclaredValue = CSSValueVariant; using SpecifiedValue = CSSValueVariant; using ComputedValue = CSSValueVariant; constexpr static bool isInherited() { return false; } constexpr static DeclaredValue initialValue(CSSFlavor /*flavor*/) { return DeclaredValue::keyword(Keyword::Auto); } }; /** * CSS "border-radius" properties * https://www.w3.org/TR/css-backgrounds-3/#border-radius */ template <> struct CSSPropDefinition { constexpr static std::string_view kName = "borderRadius"; using DeclaredValue = CSSValueVariant; using SpecifiedValue = CSSValueVariant; using ComputedValue = CSSValueVariant; constexpr static bool isInherited() { return false; } constexpr static DeclaredValue initialValue(CSSFlavor /*flavor*/) { return DeclaredValue::length(0.0f, CSSLengthUnit::Px); } }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "borderTopLeftRadius"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "borderTopRightRadius"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "borderBottomLeftRadius"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "borderBottomRightRadius"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "borderStartStartRadius"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "borderStartEndRadius"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "borderEndStartRadius"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "borderEndEndRadius"; }; /** * CSS "border-style" properties * https://www.w3.org/TR/css-backgrounds-3/#border-style */ template <> struct CSSPropDefinition { constexpr static std::string_view kName = "borderStyle"; enum class Keyword : std::underlying_type_t { None = to_underlying(CSSKeyword::None), Hidden = to_underlying(CSSKeyword::Hidden), Dotted = to_underlying(CSSKeyword::Dotted), Dashed = to_underlying(CSSKeyword::Dashed), Solid = to_underlying(CSSKeyword::Solid), Double = to_underlying(CSSKeyword::Double), Groove = to_underlying(CSSKeyword::Groove), Ridge = to_underlying(CSSKeyword::Ridge), Inset = to_underlying(CSSKeyword::Inset), Outset = to_underlying(CSSKeyword::Outset), }; using DeclaredValue = CSSValueVariant; using SpecifiedValue = CSSValueVariant; using ComputedValue = CSSValueVariant; constexpr static bool isInherited() { return false; } constexpr static DeclaredValue initialValue(CSSFlavor flavor) { return flavor == CSSFlavor::W3C ? DeclaredValue::keyword(Keyword::None) : DeclaredValue::keyword(Keyword::Solid); } }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "borderBlockEndStyle"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "borderBlockStartStyle"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "borderBlockStyle"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "borderBottomStyle"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "borderInlineEndStyle"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "borderInlineStartStyle"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "borderInlineStyle"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "borderLeftStyle"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "borderRightStyle"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "borderTopStyle"; }; /** * CSS "border-width" properties * https://www.w3.org/TR/css-backgrounds-3/#border-width */ template <> struct CSSPropDefinition { constexpr static std::string_view kName = "borderWidth"; enum class Keyword : std::underlying_type_t { Thin = to_underlying(CSSKeyword::Thin), Medium = to_underlying(CSSKeyword::Medium), Thick = to_underlying(CSSKeyword::Thick), }; using DeclaredValue = CSSValueVariant; using SpecifiedValue = CSSValueVariant; using ComputedValue = CSSValueVariant; constexpr static bool isInherited() { return false; } constexpr static DeclaredValue initialValue(CSSFlavor flavor) { return flavor == CSSFlavor::W3C ? DeclaredValue::keyword(Keyword::Medium) : DeclaredValue::length(0.0f, CSSLengthUnit::Px); } }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "borderBlockEndWidth"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "borderBlockStartWidth"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "borderBlockWidth"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "borderBottomWidth"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "borderEndWidth"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "borderHorizontalWidth"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "borderInlineEndWidth"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "borderInlineStartWidth"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "borderInlineWidth"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "borderLeftWidth"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "borderRightWidth"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "borderStartWidth"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "borderTopWidth"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "borderVerticalWidth"; }; /** * CSS "direction" property. * https://www.w3.org/TR/css-writing-modes-3/#direction */ template <> struct CSSPropDefinition { constexpr static std::string_view kName = "direction"; enum class Keyword : std::underlying_type_t { Ltr = to_underlying(CSSKeyword::Ltr), Rtl = to_underlying(CSSKeyword::Rtl), }; using DeclaredValue = CSSValueVariant; using SpecifiedValue = CSSValueVariant; using ComputedValue = CSSValueVariant; constexpr static bool isInherited() { return true; } constexpr static DeclaredValue initialValue(CSSFlavor /*flavor*/) { return DeclaredValue::keyword(Keyword::Ltr); } }; /** * CSS "display" property. * https://www.w3.org/TR/css-display-3/#display-type */ template <> struct CSSPropDefinition { constexpr static std::string_view kName = "display"; enum class Keyword : std::underlying_type_t { None = to_underlying(CSSKeyword::None), Contents = to_underlying(CSSKeyword::Contents), Inline = to_underlying(CSSKeyword::Inline), Block = to_underlying(CSSKeyword::Block), InlineBlock = to_underlying(CSSKeyword::InlineBlock), Flex = to_underlying(CSSKeyword::Flex), InlineFlex = to_underlying(CSSKeyword::InlineFlex), Grid = to_underlying(CSSKeyword::Grid), InlineGrid = to_underlying(CSSKeyword::InlineGrid), }; using DeclaredValue = CSSValueVariant; using SpecifiedValue = CSSValueVariant; using ComputedValue = CSSValueVariant; constexpr static bool isInherited() { return false; } constexpr static DeclaredValue initialValue(CSSFlavor flavor) { return flavor == CSSFlavor::W3C ? DeclaredValue::keyword(Keyword::Inline) : DeclaredValue::keyword(Keyword::Flex); } }; /** * CSS "flex" shorthand property. * https://www.w3.org/TR/css-flexbox-1/#flex-property * * React Native's interpretation of this prop is currently different than in * CSS. https://reactnative.dev/docs/layout-props#flex */ template <> struct CSSPropDefinition { constexpr static std::string_view kName = "flex"; enum class Keyword : std::underlying_type_t { Auto = to_underlying(CSSKeyword::Auto), None = to_underlying(CSSKeyword::None), }; using DeclaredValue = CSSValueVariant; using SpecifiedValue = CSSValueVariant; using ComputedValue = CSSValueVariant; constexpr static bool isInherited() { return false; } constexpr static DeclaredValue initialValue(CSSFlavor /*flavor*/) { return DeclaredValue::number(0.0f); } }; /** * CSS "flex-basis" property. * https://www.w3.org/TR/css-flexbox-1/#flex-basis-property */ template <> struct CSSPropDefinition { constexpr static std::string_view kName = "flexBasis"; enum class Keyword : std::underlying_type_t { Auto = to_underlying(CSSKeyword::Auto), Content = to_underlying(CSSKeyword::Content), }; using DeclaredValue = CSSValueVariant; using SpecifiedValue = CSSValueVariant; using ComputedValue = CSSValueVariant; constexpr static bool isInherited() { return false; } constexpr static DeclaredValue initialValue(CSSFlavor /*flavor*/) { return DeclaredValue::keyword(Keyword::Auto); } }; /** * CSS "flex-direction" property. * https://www.w3.org/TR/css-flexbox-1/#flex-direction-property */ template <> struct CSSPropDefinition { constexpr static std::string_view kName = "flexDirection"; enum class Keyword : std::underlying_type_t { Row = to_underlying(CSSKeyword::Row), RowReverse = to_underlying(CSSKeyword::RowReverse), Column = to_underlying(CSSKeyword::Column), ColumnReverse = to_underlying(CSSKeyword::ColumnReverse), }; using DeclaredValue = CSSValueVariant; using SpecifiedValue = CSSValueVariant; using ComputedValue = CSSValueVariant; constexpr static bool isInherited() { return false; } constexpr static DeclaredValue initialValue(CSSFlavor flavor) { return flavor == CSSFlavor::W3C ? DeclaredValue::keyword(Keyword::Row) : DeclaredValue::keyword(Keyword::Column); } }; /** * CSS "flex-grow" property. * https://www.w3.org/TR/css-flexbox-1/#flex-grow-property */ template <> struct CSSPropDefinition { constexpr static std::string_view kName = "flexGrow"; using DeclaredValue = CSSValueVariant; using SpecifiedValue = CSSValueVariant; using ComputedValue = CSSValueVariant; constexpr static bool isInherited() { return false; } constexpr static DeclaredValue initialValue(CSSFlavor /*flavor*/) { return DeclaredValue::number(0.0f); } }; /** * CSS "flex-shrink" property. * https://www.w3.org/TR/css-flexbox-1/#flex-shrink-property */ template <> struct CSSPropDefinition { constexpr static std::string_view kName = "flexShrink"; using DeclaredValue = CSSValueVariant; using SpecifiedValue = CSSValueVariant; using ComputedValue = CSSValueVariant; constexpr static bool isInherited() { return false; } constexpr static DeclaredValue initialValue(CSSFlavor flavor) { return flavor == CSSFlavor::W3C ? DeclaredValue::number(1.0f) : DeclaredValue::number(0.0f); } }; /** * CSS "flex-wrap" property. * https://www.w3.org/TR/css-flexbox-1/#flex-wrap-property */ template <> struct CSSPropDefinition { constexpr static std::string_view kName = "flexWrap"; enum class Keyword : std::underlying_type_t { NoWrap = to_underlying(CSSKeyword::NoWrap), Wrap = to_underlying(CSSKeyword::Wrap), WrapReverse = to_underlying(CSSKeyword::WrapReverse), }; using DeclaredValue = CSSValueVariant; using SpecifiedValue = CSSValueVariant; using ComputedValue = CSSValueVariant; constexpr static bool isInherited() { return false; } constexpr static DeclaredValue initialValue(CSSFlavor /*flavor*/) { return DeclaredValue::keyword(Keyword::NoWrap); } }; /** * CSS gutter properties. * https://www.w3.org/TR/css-align-3/#column-row-gap */ template <> struct CSSPropDefinition { constexpr static std::string_view kName = "gap"; enum class Keyword : std::underlying_type_t { Normal = to_underlying(CSSKeyword::Normal), }; using DeclaredValue = CSSValueVariant; using SpecifiedValue = CSSValueVariant; using ComputedValue = CSSValueVariant; constexpr static bool isInherited() { return false; } constexpr static DeclaredValue initialValue(CSSFlavor /*flavor*/) { return DeclaredValue::keyword(Keyword::Normal); } }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "columnGap"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "rowGap"; }; /** * CSS sizing properties * https://www.w3.org/TR/css-sizing-3/#sizing-properties */ template <> struct CSSPropDefinition { constexpr static std::string_view kName = "height"; enum class Keyword : std::underlying_type_t { Auto = to_underlying(CSSKeyword::Auto), MaxContent = to_underlying(CSSKeyword::MaxContent), MinContent = to_underlying(CSSKeyword::MinContent), }; using DeclaredValue = CSSValueVariant; using SpecifiedValue = CSSValueVariant; using ComputedValue = CSSValueVariant; constexpr static bool isInherited() { return false; } constexpr static DeclaredValue initialValue(CSSFlavor /*flavor*/) { return DeclaredValue::keyword(Keyword::Auto); } }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "width"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "minWidth"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "minHeight"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "maxWidth"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "maxHeight"; }; /** * CSS box inset properties * https://drafts.csswg.org/css-position-3/#insets */ template <> struct CSSPropDefinition { constexpr static std::string_view kName = "inset"; enum class Keyword : std::underlying_type_t { Auto = to_underlying(CSSKeyword::Auto), }; using DeclaredValue = CSSValueVariant; using SpecifiedValue = CSSValueVariant; using ComputedValue = CSSValueVariant; constexpr static bool isInherited() { return false; } constexpr static DeclaredValue initialValue(CSSFlavor /*flavor*/) { return DeclaredValue::keyword(Keyword::Auto); } }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "top"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "right"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "bottom"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "left"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "start"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "end"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "insetBlock"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "insetBlockEnd"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "insetBlockStart"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "insetInline"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "insetInlineEnd"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "insetInlineStart"; }; /** * CSS "justify-content" property. * https://www.w3.org/TR/css-flexbox-1/#justify-content-property * https://www.w3.org/TR/css-align-3/#align-justify-content */ template <> struct CSSPropDefinition { constexpr static std::string_view kName = "justifyContent"; enum class Keyword : std::underlying_type_t { Center = to_underlying(CSSKeyword::Center), FlexEnd = to_underlying(CSSKeyword::FlexEnd), FlexStart = to_underlying(CSSKeyword::FlexStart), SpaceAround = to_underlying(CSSKeyword::SpaceAround), SpaceBetween = to_underlying(CSSKeyword::SpaceBetween), SpaceEvenly = to_underlying(CSSKeyword::SpaceEvenly), Start = to_underlying(CSSKeyword::Start), End = to_underlying(CSSKeyword::End), }; using DeclaredValue = CSSValueVariant; using SpecifiedValue = CSSValueVariant; using ComputedValue = CSSValueVariant; constexpr static bool isInherited() { return false; } constexpr static DeclaredValue initialValue(CSSFlavor /*flavor*/) { return DeclaredValue::keyword(Keyword::FlexStart); } }; /** * CSS "margin" properties * https://www.w3.org/TR/css-box-4/#margins */ template <> struct CSSPropDefinition { constexpr static std::string_view kName = "margin"; enum class Keyword : std::underlying_type_t { Auto = to_underlying(CSSKeyword::Auto), }; using DeclaredValue = CSSValueVariant; using SpecifiedValue = CSSValueVariant; using ComputedValue = CSSValueVariant; constexpr static bool isInherited() { return false; } constexpr static DeclaredValue initialValue(CSSFlavor /*flavor*/) { return DeclaredValue::length(0.0f, CSSLengthUnit::Px); } }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "marginBlock"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "marginBlockEnd"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "marginBlockStart"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "marginBottom"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "marginEnd"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "marginHorizontal"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "marginInline"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "marginInlineEnd"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "marginInlineStart"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "marginLeft"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "marginRight"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "marginStart"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "marginTop"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "marginVertical"; }; /** * CSS "opacity" property * https://www.w3.org/TR/css-color-3/#transparency */ template <> struct CSSPropDefinition { constexpr static std::string_view kName = "opacity"; using DeclaredValue = CSSValueVariant; using SpecifiedValue = CSSValueVariant; using ComputedValue = CSSValueVariant; constexpr static bool isInherited() { return false; } constexpr static DeclaredValue initialValue(CSSFlavor /*flavor*/) { return DeclaredValue::number(1.0f); } }; /** * CSS "overflow" property. * https://www.w3.org/TR/css-overflow-3/#overflow-control */ template <> struct CSSPropDefinition { constexpr static std::string_view kName = "overflow"; enum class Keyword : std::underlying_type_t { Auto = to_underlying(CSSKeyword::Auto), Clip = to_underlying(CSSKeyword::Clip), Hidden = to_underlying(CSSKeyword::Hidden), Scroll = to_underlying(CSSKeyword::Scroll), Visible = to_underlying(CSSKeyword::Visible), }; using DeclaredValue = CSSValueVariant; using SpecifiedValue = CSSValueVariant; using ComputedValue = CSSValueVariant; constexpr static bool isInherited() { return false; } constexpr static DeclaredValue initialValue(CSSFlavor /*flavor*/) { return DeclaredValue::keyword(Keyword::Visible); } }; /** * CSS padding properties * https://www.w3.org/TR/css-box-4/#paddings */ template <> struct CSSPropDefinition { constexpr static std::string_view kName = "padding"; using DeclaredValue = CSSValueVariant; using SpecifiedValue = CSSValueVariant; using ComputedValue = CSSValueVariant; constexpr static bool isInherited() { return false; } constexpr static DeclaredValue initialValue(CSSFlavor /*flavor*/) { return DeclaredValue::length(0.0f, CSSLengthUnit::Px); } }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "paddingBlock"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "paddingBlockEnd"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "paddingBlockStart"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "paddingBottom"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "paddingEnd"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "paddingHorizontal"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "paddingInline"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "paddingInlineEnd"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "paddingInlineStart"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "paddingLeft"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "paddingRight"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "paddingStart"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "paddingTop"; }; template <> struct CSSPropDefinition : CSSPropDefinition { constexpr static std::string_view kName = "paddingVertical"; }; /** * CSS "position" property. * https://www.w3.org/TR/css-position-3/#position-property */ template <> struct CSSPropDefinition { constexpr static std::string_view kName = "position"; enum class Keyword : std::underlying_type_t { Static = to_underlying(CSSKeyword::Static), Relative = to_underlying(CSSKeyword::Relative), Absolute = to_underlying(CSSKeyword::Absolute), Fixed = to_underlying(CSSKeyword::Fixed), Sticky = to_underlying(CSSKeyword::Sticky), }; using DeclaredValue = CSSValueVariant; using SpecifiedValue = CSSValueVariant; using ComputedValue = CSSValueVariant; constexpr static bool isInherited() { return false; } constexpr static DeclaredValue initialValue(CSSFlavor flavor) { return flavor == CSSFlavor::W3C ? DeclaredValue::keyword(Keyword::Static) : DeclaredValue::keyword(Keyword::Relative); } }; } // namespace facebook::react