From a5ed422c2ceab87b174bae276bd10095bd6bed2e Mon Sep 17 00:00:00 2001 From: bptato Date: Sat, 17 Feb 2024 01:20:17 +0100 Subject: More bgcolor fixes * fix accidental dependency on previously chosen bgcolor (ouch) * also draw empty background boxes for bgcolor-is-canvas boxes * remove unused variable --- src/render/renderdocument.nim | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src/render/renderdocument.nim') diff --git a/src/render/renderdocument.nim b/src/render/renderdocument.nim index 625984df..ed0bc809 100644 --- a/src/render/renderdocument.nim +++ b/src/render/renderdocument.nim @@ -284,7 +284,6 @@ type RenderState = object # https://drafts.csswg.org/css-position/#absolute-positioning-containing-block absolutePos: seq[Offset] bgcolor: CellColor - root: bool proc renderBlockBox(grid: var FlexibleGrid; state: var RenderState; box: BlockBox; offset: Offset; attrs: WindowAttributes) @@ -380,12 +379,12 @@ proc renderBlockBox(grid: var FlexibleGrid; state: var RenderState; state.absolutePos.add(offset) stack.add((nil, Offset(x: -1, y: -1))) - if box.computed{"-cha-bgcolor-is-canvas"} and - state.bgcolor == defaultColor: - #TODO bgimage - if box.computed{"background-color"}.a != 0: #TODO color blending - state.bgcolor = box.computed{"background-color"}.cellColor() - elif box.computed{"visibility"} == VISIBILITY_VISIBLE: + if box.computed{"visibility"} == VISIBILITY_VISIBLE: + if box.computed{"-cha-bgcolor-is-canvas"} and + state.bgcolor == defaultColor: + #TODO bgimage + if box.computed{"background-color"}.a != 0: #TODO color blending + state.bgcolor = box.computed{"background-color"}.cellColor() if box.computed{"background-color"}.a != 0: #TODO color blending let ix = toInt(offset.x) let iy = toInt(offset.y) @@ -429,9 +428,7 @@ proc renderDocument*(grid: var FlexibleGrid; bgcolor: var CellColor; styledRoot: StyledNode; attrs: WindowAttributes) = grid.setLen(0) var state = RenderState( - absolutePos: @[Offset(x: 0, y: 0)], - root: true, - bgcolor: bgcolor + absolutePos: @[Offset(x: 0, y: 0)] ) let rootBox = renderLayout(styledRoot, attrs) grid.renderBlockBox(state, rootBox, Offset(x: 0, y: 0), attrs) -- cgit 1.4.1-2-gfad0