Skip to content

Commit

Permalink
vaev-style: Added the suffix Props to grouping of computed properties.
Browse files Browse the repository at this point in the history
This reduces the amount of name conflicts with rendering types.
  • Loading branch information
sleepy-monax committed Oct 31, 2024
1 parent d6f2afb commit 590f6f6
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/vaev-base/align.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ struct [[gnu::packed]] Align {
}
};

struct Aligns {
struct AlignProps {
// https://drafts.csswg.org/css-align-3/#propdef-align-content
Align alignContent;

Expand Down
2 changes: 1 addition & 1 deletion src/vaev-base/background.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ struct BackgroundRepeat {
}
};

struct Background {
struct BackgroundProps {
Color fill;
BackgroundAttachment attachment;
BackgroundPosition position;
Expand Down
2 changes: 1 addition & 1 deletion src/vaev-base/borders.h
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
2 changes: 1 addition & 1 deletion src/vaev-base/break.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/vaev-base/flex.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct FlexBasis {
}
};

struct Flex {
struct FlexProps {
FlexDirection direction = FlexDirection::ROW;
FlexWrap wrap = FlexWrap::NOWRAP;
FlexBasis basis = Width{Width::AUTO};
Expand Down
2 changes: 1 addition & 1 deletion src/vaev-base/font.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ struct FontSource {
}
};

struct Font {
struct FontProps {
Vec<String> families;
FontWeight weight;
FontWidth width;
Expand Down
3 changes: 2 additions & 1 deletion src/vaev-base/sizing.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ struct Size {
}
};

struct Sizing {
struct SizingProps {
BoxSizing boxSizing;
Size width, height;
Size minWidth, minHeight;
Size maxWidth, maxHeight;
Expand Down
2 changes: 1 addition & 1 deletion src/vaev-base/table.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct BorderSpacing {
}
};

struct Table {
struct TableProps {
TableLayout tableLayout = TableLayout::AUTO;
CaptionSide captionSide = CaptionSide::TOP;
BorderSpacing spacing = {Px{0}, Px{0}};
Expand Down
2 changes: 1 addition & 1 deletion src/vaev-base/text.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ enum struct TextTransform {
_LEN,
};

struct Text {
struct TextProps {
TextTransform transform;
};

Expand Down
4 changes: 2 additions & 2 deletions src/vaev-layout/flex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Vaev::Layout {

struct FlexItem {
Box *box;
Flex flex;
FlexProps flex;

// these 2 sizes do NOT account margins
Vec2Px usedSize;
Expand Down Expand Up @@ -380,7 +380,7 @@ struct FlexLine {
};

struct FlexFormatingContext {
Flex _flex;
FlexProps _flex;

// https://www.w3.org/TR/css-flexbox-1/#layout-algorithm

Expand Down
19 changes: 9 additions & 10 deletions src/vaev-style/computed.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@ struct Computed {
Color color;
Number opacity;

Aligns aligns;
AlignProps aligns;
Math::Vec2<PercentOr<Length>> gaps;

Vec<Background> backgrounds;
Cow<Borders> borders;
Vec<BackgroundProps> backgrounds;
Cow<BorderProps> borders;
Cow<Margin> margin;
Cow<Padding> padding;
BoxSizing boxSizing;
Cow<Sizing> sizing;
Cow<SizingProps> sizing;
Overflows overflows;

// 9.3 Positioning schemes
Expand All @@ -55,15 +54,15 @@ struct Computed {
Integer order;
Visibility visibility;
// https://w3.org/TR/css-tables-3/#table-structure
Cow<Table> table;
Cow<TableProps> table;

// CSS Fonts Module Level 4
// https://www.w3.org/TR/css-fonts-4/
Cow<Font> font;
Cow<Text> text;
Cow<FontProps> font;
Cow<TextProps> text;

Cow<Flex> flex;
Cow<Break> break_;
Cow<FlexProps> flex;
Cow<BreakProps> break_;

Float float_ = Float::NONE;
Clear clear = Clear::NONE;
Expand Down
12 changes: 6 additions & 6 deletions src/vaev-style/styles.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -927,7 +927,7 @@ struct BorderProp {

// https://www.w3.org/TR/css-backgrounds-3/#border-width
struct BorderWidthProp {
Math::Insets<Length> value = Borders::MEDIUM;
Math::Insets<Length> value = BorderProps::MEDIUM;

static constexpr Str name() { return "border-width"; }

Expand Down Expand Up @@ -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<Css::Sst> &c) {
Expand Down

0 comments on commit 590f6f6

Please sign in to comment.