aboutsummaryrefslogtreecommitdiffstats
path: root/src/render
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2022-07-20 23:03:21 +0200
committerbptato <nincsnevem662@gmail.com>2022-07-20 23:03:21 +0200
commit062027c84176f8a6fa8870d7c527ece3aee7b519 (patch)
tree0c81375df962c79ceef5580c9579dbc9aeadc6a8 /src/render
parente2b52fdf1def543a7199a4f0aa639e65afb22463 (diff)
downloadchawan-062027c84176f8a6fa8870d7c527ece3aee7b519.tar.gz
Refactor some layout engine types, fix list-item
Diffstat (limited to 'src/render')
-rw-r--r--src/render/renderdocument.nim17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/render/renderdocument.nim b/src/render/renderdocument.nim
index d2239416..54628946 100644
--- a/src/render/renderdocument.nim
+++ b/src/render/renderdocument.nim
@@ -201,7 +201,7 @@ proc paintBackground(lines: var FlexibleGrid, color: CSSColor, startx, starty, e
inc y
-proc renderBlockContext(grid: var FlexibleGrid, ctx: BlockContext, x, y: int, term: TermAttributes)
+proc renderBlockContext(grid: var FlexibleGrid, ctx: BlockBox, x, y: int, term: TermAttributes)
proc renderInlineContext(grid: var FlexibleGrid, ctx: InlineContext, x, y: int, term: TermAttributes) =
let x = x + ctx.offset.x
@@ -215,8 +215,8 @@ proc renderInlineContext(grid: var FlexibleGrid, ctx: InlineContext, x, y: int,
grid.addLine()
for atom in line.atoms:
- if atom of InlineBlock:
- let iblock = InlineBlock(atom)
+ if atom of InlineBlockBox:
+ let iblock = InlineBlockBox(atom)
grid.renderBlockContext(iblock.bctx, x + iblock.offset.x, y + iblock.offset.y, term)
elif atom of InlineWord:
let word = InlineWord(atom)
@@ -225,8 +225,8 @@ proc renderInlineContext(grid: var FlexibleGrid, ctx: InlineContext, x, y: int,
let spacing = InlineSpacing(atom)
grid.setSpacing(spacing, x, y, term)
-proc renderBlockContext(grid: var FlexibleGrid, ctx: BlockContext, x, y: int, term: TermAttributes) =
- var stack = newSeqOfCap[(BlockContext, int, int)](100)
+proc renderBlockContext(grid: var FlexibleGrid, ctx: BlockBox, x, y: int, term: TermAttributes) =
+ var stack = newSeqOfCap[(BlockBox, int, int)](100)
stack.add((ctx, x, y))
while stack.len > 0:
@@ -237,9 +237,10 @@ proc renderBlockContext(grid: var FlexibleGrid, ctx: BlockContext, x, y: int, te
if ctx.computed{"background-color"}.rgba.a != 0: #TODO color blending
grid.paintBackground(ctx.computed{"background-color"}, x, y, x + ctx.width, y + ctx.height, term)
- if ctx of ListItem:
- let ctx = ListItem(ctx)
- grid.renderInlineContext(ctx.marker, x - ctx.marker.maxwidth, y, term)
+ if ctx of ListItemBox:
+ let ctx = ListItemBox(ctx)
+ if ctx.marker != nil:
+ grid.renderInlineContext(ctx.marker, x - ctx.marker.maxwidth, y, term)
if ctx.inline != nil:
assert ctx.nested.len == 0