From 590f6f6c77b061a59c538bd25fecd5374b024d9a Mon Sep 17 00:00:00 2001 From: VAN BOSSUYT Nicolas Date: Thu, 31 Oct 2024 14:01:11 +0100 Subject: [PATCH] vaev-style: Added the suffix Props to grouping of computed properties. This reduces the amount of name conflicts with rendering types. --- src/vaev-base/align.h | 2 +- src/vaev-base/background.h | 2 +- src/vaev-base/borders.h | 2 +- src/vaev-base/break.h | 2 +- src/vaev-base/flex.h | 2 +- src/vaev-base/font.h | 2 +- src/vaev-base/sizing.h | 3 ++- src/vaev-base/table.h | 2 +- src/vaev-base/text.h | 2 +- src/vaev-layout/flex.cpp | 4 ++-- src/vaev-style/computed.h | 19 +++++++++---------- src/vaev-style/styles.h | 12 ++++++------ 12 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/vaev-base/align.h b/src/vaev-base/align.h index 68eeffd..02a2b35 100644 --- a/src/vaev-base/align.h +++ b/src/vaev-base/align.h @@ -70,7 +70,7 @@ struct [[gnu::packed]] Align { } }; -struct Aligns { +struct AlignProps { // https://drafts.csswg.org/css-align-3/#propdef-align-content Align alignContent; diff --git a/src/vaev-base/background.h b/src/vaev-base/background.h index 5330d63..57d4a8d 100644 --- a/src/vaev-base/background.h +++ b/src/vaev-base/background.h @@ -110,7 +110,7 @@ struct BackgroundRepeat { } }; -struct Background { +struct BackgroundProps { Color fill; BackgroundAttachment attachment; BackgroundPosition position; diff --git a/src/vaev-base/borders.h b/src/vaev-base/borders.h index 2c590de..1ce3a49 100644 --- a/src/vaev-base/borders.h +++ b/src/vaev-base/borders.h @@ -43,7 +43,7 @@ struct Border { } }; -struct Borders { +struct BorderProps { static constexpr Length THIN = Px{1}; static constexpr Length MEDIUM = Px{3}; static constexpr Length THICK = Px{5}; diff --git a/src/vaev-base/break.h b/src/vaev-base/break.h index bcff941..4a0aca2 100644 --- a/src/vaev-base/break.h +++ b/src/vaev-base/break.h @@ -38,7 +38,7 @@ enum struct BreakInside { }; // https://www.w3.org/TR/css-break-3 -struct Break { +struct BreakProps { BreakBetween before = BreakBetween::AUTO; BreakBetween after = BreakBetween::AUTO; BreakInside inside = BreakInside::AUTO; diff --git a/src/vaev-base/flex.h b/src/vaev-base/flex.h index 0fab9e4..68b31fc 100644 --- a/src/vaev-base/flex.h +++ b/src/vaev-base/flex.h @@ -51,7 +51,7 @@ struct FlexBasis { } }; -struct Flex { +struct FlexProps { FlexDirection direction = FlexDirection::ROW; FlexWrap wrap = FlexWrap::NOWRAP; FlexBasis basis = Width{Width::AUTO}; diff --git a/src/vaev-base/font.h b/src/vaev-base/font.h index 67a26d8..d25becd 100644 --- a/src/vaev-base/font.h +++ b/src/vaev-base/font.h @@ -294,7 +294,7 @@ struct FontSource { } }; -struct Font { +struct FontProps { Vec families; FontWeight weight; FontWidth width; diff --git a/src/vaev-base/sizing.h b/src/vaev-base/sizing.h index 101bbca..f810a98 100644 --- a/src/vaev-base/sizing.h +++ b/src/vaev-base/sizing.h @@ -84,7 +84,8 @@ struct Size { } }; -struct Sizing { +struct SizingProps { + BoxSizing boxSizing; Size width, height; Size minWidth, minHeight; Size maxWidth, maxHeight; diff --git a/src/vaev-base/table.h b/src/vaev-base/table.h index b6ce9fd..e0dbf02 100644 --- a/src/vaev-base/table.h +++ b/src/vaev-base/table.h @@ -33,7 +33,7 @@ struct BorderSpacing { } }; -struct Table { +struct TableProps { TableLayout tableLayout = TableLayout::AUTO; CaptionSide captionSide = CaptionSide::TOP; BorderSpacing spacing = {Px{0}, Px{0}}; diff --git a/src/vaev-base/text.h b/src/vaev-base/text.h index 063a8bd..e02f619 100644 --- a/src/vaev-base/text.h +++ b/src/vaev-base/text.h @@ -17,7 +17,7 @@ enum struct TextTransform { _LEN, }; -struct Text { +struct TextProps { TextTransform transform; }; diff --git a/src/vaev-layout/flex.cpp b/src/vaev-layout/flex.cpp index 66eea43..e3c8e21 100644 --- a/src/vaev-layout/flex.cpp +++ b/src/vaev-layout/flex.cpp @@ -8,7 +8,7 @@ namespace Vaev::Layout { struct FlexItem { Box *box; - Flex flex; + FlexProps flex; // these 2 sizes do NOT account margins Vec2Px usedSize; @@ -380,7 +380,7 @@ struct FlexLine { }; struct FlexFormatingContext { - Flex _flex; + FlexProps _flex; // https://www.w3.org/TR/css-flexbox-1/#layout-algorithm diff --git a/src/vaev-style/computed.h b/src/vaev-style/computed.h index 8ba6e92..44ab979 100644 --- a/src/vaev-style/computed.h +++ b/src/vaev-style/computed.h @@ -28,15 +28,14 @@ struct Computed { Color color; Number opacity; - Aligns aligns; + AlignProps aligns; Math::Vec2> gaps; - Vec backgrounds; - Cow borders; + Vec backgrounds; + Cow borders; Cow margin; Cow padding; - BoxSizing boxSizing; - Cow sizing; + Cow sizing; Overflows overflows; // 9.3 Positioning schemes @@ -55,15 +54,15 @@ struct Computed { Integer order; Visibility visibility; // https://w3.org/TR/css-tables-3/#table-structure - Cow table; + Cow table; // CSS Fonts Module Level 4 // https://www.w3.org/TR/css-fonts-4/ - Cow font; - Cow text; + Cow font; + Cow text; - Cow flex; - Cow break_; + Cow flex; + Cow break_; Float float_ = Float::NONE; Clear clear = Clear::NONE; diff --git a/src/vaev-style/styles.h b/src/vaev-style/styles.h index e67b35a..1f341e4 100644 --- a/src/vaev-style/styles.h +++ b/src/vaev-style/styles.h @@ -554,7 +554,7 @@ struct BorderTopWidthProp { static constexpr Str name() { return "border-top-width"; } - static constexpr Length initial() { return Borders::MEDIUM; } + static constexpr Length initial() { return BorderProps::MEDIUM; } void apply(Computed &c) const { c.borders.cow().top.width = value; @@ -572,7 +572,7 @@ struct BorderRightWidthProp { static constexpr Str name() { return "border-right-width"; } - static constexpr Length initial() { return Borders::MEDIUM; } + static constexpr Length initial() { return BorderProps::MEDIUM; } void apply(Computed &c) const { c.borders.cow().end.width = value; @@ -590,7 +590,7 @@ struct BorderBottomWidthProp { static constexpr Str name() { return "border-bottom-width"; } - static constexpr Length initial() { return Borders::MEDIUM; } + static constexpr Length initial() { return BorderProps::MEDIUM; } void apply(Computed &c) const { c.borders.cow().bottom.width = value; @@ -608,7 +608,7 @@ struct BorderLeftWidthProp { static constexpr Str name() { return "border-left-width"; } - static constexpr Length initial() { return Borders::MEDIUM; } + static constexpr Length initial() { return BorderProps::MEDIUM; } void apply(Computed &c) const { c.borders.cow().start.width = value; @@ -927,7 +927,7 @@ struct BorderProp { // https://www.w3.org/TR/css-backgrounds-3/#border-width struct BorderWidthProp { - Math::Insets value = Borders::MEDIUM; + Math::Insets value = BorderProps::MEDIUM; static constexpr Str name() { return "border-width"; } @@ -1905,7 +1905,7 @@ struct BoxSizingProp { static constexpr BoxSizing initial() { return BoxSizing::CONTENT_BOX; } void apply(Computed &c) const { - c.boxSizing = value; + c.sizing.cow().boxSizing = value; } Res<> parse(Cursor &c) {