Skip to content

Commit

Permalink
vaev: Update from upstream.
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepy-monax committed Nov 15, 2024
1 parent df715a4 commit f2e1b9c
Show file tree
Hide file tree
Showing 17 changed files with 155 additions and 19 deletions.
27 changes: 19 additions & 8 deletions src/web/vaev-base/align.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
namespace Vaev::Style {

struct [[gnu::packed]] Align {
enum Perfix : u8 {
enum Prefix : u8 {
NO_PREFIX,

LEGACY,
Expand Down Expand Up @@ -50,23 +50,23 @@ struct [[gnu::packed]] Align {
_LEN1,
};

Perfix perfix : 2;
Prefix prefix : 2;
Keywords keyword : 6;

constexpr Align() : perfix(NO_PREFIX), keyword(NO_KEYWORD) {}
constexpr Align() : prefix(NO_PREFIX), keyword(NO_KEYWORD) {}

constexpr Align(Perfix perfix) : perfix(perfix), keyword(NO_KEYWORD) {}
constexpr Align(Prefix prefix) : prefix(prefix), keyword(NO_KEYWORD) {}

constexpr Align(Keywords keyword) : perfix(NO_PREFIX), keyword(keyword) {}
constexpr Align(Keywords keyword) : prefix(NO_PREFIX), keyword(keyword) {}

constexpr Align(Perfix perfix, Keywords keyword) : perfix(perfix), keyword(keyword) {}
constexpr Align(Prefix prefix, Keywords keyword) : prefix(prefix), keyword(keyword) {}

bool operator==(Perfix perfix) const { return this->perfix == perfix; }
bool operator==(Prefix prefix) const { return this->prefix == prefix; }

bool operator==(Keywords keyword) const { return this->keyword == keyword; }

void repr(Io::Emit &e) const {
e("{} {}", perfix, keyword);
e("{} {}", prefix, keyword);
}
};

Expand All @@ -88,6 +88,17 @@ struct AlignProps {

// https://drafts.csswg.org/css-align-3/#propdef-align-items
Align alignItems;

void repr(Io::Emit &e) const {
e("(aligns");
e(" alignContent={}", alignContent);
e(" justifyContent={}", justifyContent);
e(" justifySelf={}", justifySelf);
e(" alignSelf={}", alignSelf);
e(" justifyItems={}", justifyItems);
e(" alignItems={}", alignItems);
e(")");
}
};

} // namespace Vaev::Style
21 changes: 21 additions & 0 deletions src/web/vaev-base/background.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,25 @@ enum struct BackgroundAttachment {
SCROLL,
FIXED,
LOCAL,

_LEN
};

struct BackgroundPosition {
enum struct HorizontalAnchor {
LEFT,
CENTER,
RIGHT,

_LEN0
};

enum struct VerticalPosition {
TOP,
CENTER,
BOTTOM,

_LEN1
};

HorizontalAnchor horizontalAnchor;
Expand Down Expand Up @@ -59,6 +65,9 @@ struct BackgroundPosition {
case HorizontalAnchor::RIGHT:
e("right");
break;

default:
unreachable();
}

e(" ");
Expand All @@ -73,6 +82,9 @@ struct BackgroundPosition {
case VerticalPosition::BOTTOM:
e("bottom");
break;

default:
unreachable();
}

e(" ");
Expand Down Expand Up @@ -115,6 +127,15 @@ struct BackgroundProps {
BackgroundAttachment attachment;
BackgroundPosition position;
BackgroundRepeat repeat;

void repr(Io::Emit &e) const {
e("(background");
e(" fill={}", fill);
e(" attachment={}", attachment);
e(" position={}", position);
e(" repeat={}", repeat);
e(")");
}
};

} // namespace Vaev
10 changes: 10 additions & 0 deletions src/web/vaev-base/borders.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ struct BorderProps {
break;
}
}

void repr(Io::Emit &e) const {
e("(border");
e(" top={}", top);
e(" start={}", start);
e(" bottom={}", bottom);
e(" end={}", end);
e(" radii={}", radii);
e(")");
}
};

} // namespace Vaev
8 changes: 4 additions & 4 deletions src/web/vaev-base/color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
namespace Vaev {

Opt<Color> parseNamedColor(Str name) {
if (name == "transparent")
if (eqCi(name, "transparent"s))
return TRANSPARENT;

if (name == "currentColor")
if (eqCi(name, "currentColor"s))
return Color::CURRENT;

#define COLOR(ID, NAME, ...) \
if (name == #NAME) \
#define COLOR(ID, NAME, ...) \
if (eqCi(name, #NAME ""s)) \
return ID;
#include "defs/colors.inc"
#undef COLOR
Expand Down
12 changes: 10 additions & 2 deletions src/web/vaev-base/flex.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#pragma once

#include "length.h"
#include "percent.h"
#include "width.h"

namespace Vaev {
Expand Down Expand Up @@ -65,6 +63,16 @@ struct FlexProps {
return direction == FlexDirection::ROW or
direction == FlexDirection::ROW_REVERSE;
}

void repr(Io::Emit &e) const {
e("(flex");
e(" direction={}", direction);
e(" wrap={}", wrap);
e(" basis={}", basis);
e(" grow={}", grow);
e(" shrink={}", shrink);
e(")");
}
};

} // namespace Vaev
10 changes: 10 additions & 0 deletions src/web/vaev-base/font.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,16 @@ struct FontProps {
FontWidth width;
FontStyle style;
FontSize size;

void repr(Io::Emit &e) const {
e("(font");
e(" families={}", families);
e(" weight={}", weight);
e(" width={}", width);
e(" style={}", style);
e(" size={}", size);
e(")");
}
};

} // namespace Vaev
13 changes: 13 additions & 0 deletions src/web/vaev-base/overflow.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include <karm-io/emit.h>

namespace Vaev {

// https://www.w3.org/TR/css-overflow/#overflow-control
Expand All @@ -8,13 +10,24 @@ enum struct Overflow {
HIDDEN,
SCROLL,
AUTO,

_LEN
};

struct Overflows {
Overflow x = Overflow::VISIBLE;
Overflow y = Overflow::VISIBLE;
Overflow block = Overflow::VISIBLE;
Overflow inline_ = Overflow::VISIBLE;

void repr(Io::Emit &e) const {
e("(overflows");
e(" x={}", x);
e(" y={}", y);
e(" block={}", block);
e(" inline={}", inline_);
e(")");
}
};

} // namespace Vaev
12 changes: 12 additions & 0 deletions src/web/vaev-base/sizing.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@ struct SizingProps {
Size const maxSize(Axis axis) const {
return axis == Axis::HORIZONTAL ? maxWidth : maxHeight;
}

void repr(Io::Emit &e) const {
e("(sizing");
e(" boxSizing={}", boxSizing);
e(" width={}", width);
e(" height={}", height);
e(" minWidth={}", minWidth);
e(" minHeight={}", minHeight);
e(" maxWidth={}", maxWidth);
e(" maxHeight={}", maxHeight);
e(")");
}
};

} // namespace Vaev
9 changes: 9 additions & 0 deletions src/web/vaev-base/table.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ struct TableProps {
CaptionSide captionSide = CaptionSide::TOP;
BorderSpacing spacing = {0_px, 0_px};
BorderCollapse collapse = BorderCollapse::SEPARATE;

void repr(Io::Emit &e) const {
e("(table");
e(" tableLayout={}", tableLayout);
e(" captionSide={}", captionSide);
e(" spacing={}", spacing);
e(" collapse={}", collapse);
e(")");
}
};

} // namespace Vaev
10 changes: 10 additions & 0 deletions src/web/vaev-base/text.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include <karm-io/emit.h>

namespace Vaev {

// CSS Text Module Level 4
Expand Down Expand Up @@ -51,6 +53,14 @@ struct TextProps {
TextAlign align = TextAlign::START;
TextTransform transform;
WhiteSpace whiteSpace = WhiteSpace::NORMAL;

void repr(Io::Emit &e) const {
e("(text");
e(" align: {}", align);
e(" transform: {}", transform);
e(" whiteSpace: {}", whiteSpace);
e(")");
}
};

} // namespace Vaev
2 changes: 2 additions & 0 deletions src/web/vaev-base/visibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ enum struct Visibility {
VISIBLE,
HIDDEN,
COLLAPSE,

_LEN
};

} // namespace Vaev
Binary file added src/web/vaev-browser/main/res/images/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/web/vaev-browser/main/res/images/icon.qoi
Binary file not shown.
4 changes: 2 additions & 2 deletions src/web/vaev-driver/render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static void _collectStyle(Markup::Node const &node, Style::StyleBook &sb) {
RenderResult render(Markup::Document const &dom, Style::Media const &media, Vec2Px viewport) {
Style::StyleBook stylebook;
stylebook.add(
fetchStylesheet("bundle://vaev-view/user-agent.css"_url)
fetchStylesheet("bundle://vaev-driver/user-agent.css"_url)
.take("user agent stylesheet not available")
);

Expand Down Expand Up @@ -122,7 +122,7 @@ RenderResult render(Markup::Document const &dom, Style::Media const &media, Vec2
RenderResult render(Markup::Document &dom, Style::Media const &media, Print::PaperStock paper) {
Style::StyleBook stylebook;
stylebook.add(
fetchStylesheet("bundle://vaev-view/user-agent.css"_url)
fetchStylesheet("bundle://vaev-driver/user-agent.css"_url)
.take("user agent stylesheet not available")
);

Expand Down
File renamed without changes.
30 changes: 30 additions & 0 deletions src/web/vaev-style/computed.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,36 @@ struct Computed {
font = parent.font;
text = parent.text;
}

void repr(Io::Emit &e) const {
e("(computed");
e(" color: {}", color);
e(" opacity: {}", opacity);
e(" aligns: {}", aligns);
e(" gaps: {}", gaps);
e(" backgrounds: {}", backgrounds);
e(" borders: {}", borders);
e(" margin: {}", margin);
e(" padding: {}", padding);
e(" sizing: {}", sizing);
e(" overflows: {}", overflows);
e(" position: {}", position);
e(" offsets: {}", offsets);
e(" writingMode: {}", writingMode);
e(" direction: {}", direction);
e(" display: {}", display);
e(" order: {}", order);
e(" visibility: {}", visibility);
e(" table: {}", table);
e(" font: {}", font);
e(" text: {}", text);
e(" flex: {}", flex);
e(" break: {}", break_);
e(" float: {}", float_);
e(" clear: {}", clear);
e(" zIndex: {}", zIndex);
e(")");
}
};

} // namespace Vaev::Style
6 changes: 3 additions & 3 deletions src/web/vaev-style/values.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ Res<Align> ValueParser<Align>::parse(Cursor<Css::Sst> &c) {
Align align;

if (c.skip(Css::Token::ident("legacy"))) {
align.perfix = Align::Perfix::LEGACY;
align.prefix = Align::Prefix::LEGACY;
} else if (c.skip(Css::Token::ident("safe"))) {
align.perfix = Align::Perfix::SAFE;
align.prefix = Align::Prefix::SAFE;
} else if (c.skip(Css::Token::ident("unsafe"))) {
align.perfix = Align::Perfix::UNSAFE;
align.prefix = Align::Prefix::UNSAFE;
}

if (c.skip(Css::Token::ident("auto"))) {
Expand Down

0 comments on commit f2e1b9c

Please sign in to comment.