Skip to content

Commit

Permalink
web-render: Scafolding the visual formatting model.
Browse files Browse the repository at this point in the history
  • Loading branch information
sleepy-monax committed Apr 16, 2024
1 parent 0ed35a0 commit 06699d7
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/web/web-css/computed-values.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

namespace Web::Css {

/// CSS Computed Style
struct ComputedValues {
};

} // namespace Web::Css
91 changes: 91 additions & 0 deletions src/web/web-render/box.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#pragma once

#include <karm-layout/spacing.h>
#include <karm-math/rect.h>
#include <web-css/computed-values.h>
#include <web-dom/element.h>

namespace Web::Render {

// 9 MARK: Visual formatting model
// https://www.w3.org/TR/CSS22/visuren.html

struct Box {
Strong<Dom::Element> _el;
Strong<Css::ComputedValues> _style;

Math::Rectf _bound{};
Layout::Spacingf _margin{};
Layout::Spacingf _padding{};
Layout::Spacingf _border{};

Box(Strong<Dom::Element> el, Strong<Css::ComputedValues> style)
: _el(el), _style(style) {
}

virtual ~Box() = default;
};

struct ParentBox {
virtual ~ParentBox() = default;
};

// https://www.w3.org/TR/CSS22/visuren.html#block-level
struct BlockLevelBox :
public Box {
};

// https://www.w3.org/TR/CSS22/visuren.html#block-boxes
struct BlockContainerBox :
public ParentBox {
};

// https://www.w3.org/TR/CSS22/visuren.html#block-boxes
struct BlockBox :
public BlockLevelBox,
public BlockContainerBox {
};

// https://www.w3.org/TR/CSS22/visuren.html#inline-formatting
struct LineBox :
public ParentBox {
};

// https://www.w3.org/TR/CSS22/visuren.html#anonymous-block-level
struct InlineLevelBox :
public Box {
};

// https://www.w3.org/TR/CSS22/visuren.html#anonymous-block-level
struct InlineBox :
public InlineLevelBox,
public ParentBox {
};

// https://www.w3.org/TR/CSS22/visuren.html#anonymous
class AnonymousInlineBoxes :
public InlineLevelBox {
};

// https://www.w3.org/TR/CSS22/visuren.html#inline-boxes
class AtomicInlineLevelBox :
public InlineLevelBox {
};

// https://www.w3.org/TR/CSS22/visuren.html#inline-boxes
class InlineBlockBox :
public AtomicInlineLevelBox,
public BlockContainerBox {
};

// https://www.w3.org/TR/CSS22/visuren.html#block-boxes
class ReplacedBox {
};

// https://www.w3.org/TR/CSS22/visuren.html#inline-boxes
class InlineReplacedBox :
public ReplacedBox,
public AtomicInlineLevelBox {
};

} // namespace Web::Render
7 changes: 7 additions & 0 deletions src/web/web-render/flex.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

#include "box.h"

namespace Web::Render {

} // namespace Web::Render
7 changes: 7 additions & 0 deletions src/web/web-render/grid.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

#include "box.h"

namespace Web::Render {

} // namespace Web::Render
13 changes: 13 additions & 0 deletions src/web/web-render/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "https://schemas.cute.engineering/stable/cutekit.manifest.component.v1",
"id": "web-render",
"type": "lib",
"description": "Implementation of the CSS Visual Formatting Model (https://www.w3.org/TR/CSS22/visuren.html)",
"requires": [
"karm-math",
"karm-layout",
"karm-gfx",
"web-dom",
"web-css"
]
}
7 changes: 7 additions & 0 deletions src/web/web-render/mathml.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

#include "box.h"

namespace Web::Render {

} // namespace Web::Render
7 changes: 7 additions & 0 deletions src/web/web-render/svg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

#include "box.h"

namespace Web::Render {

} // namespace Web::Render
10 changes: 10 additions & 0 deletions src/web/web-render/table.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#pragma once

#include "box.h"

namespace Web::Render {

// 17.2.1 MARK: Anonymous table objects
// https://www.w3.org/TR/CSS22/tables.html#anonymous-boxes

} // namespace Web::Render
5 changes: 3 additions & 2 deletions src/web/web-view/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
"$schema": "https://schemas.cute.engineering/stable/cutekit.manifest.component.v1",
"id": "web-view",
"type": "lib",
"description": "",
"description": "Web Content Host",
"requires": [
"karm-ui"
"karm-ui",
"web-render"
]
}

0 comments on commit 06699d7

Please sign in to comment.