about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-04-11 12:32:49 +0200
committerbptato <nincsnevem662@gmail.com>2024-04-11 12:36:25 +0200
commit37546bb85efc292703289313c6c87798cd4ab20c (patch)
treec66af54a69b9051280edc6800744f0f63d3f6fd3
parent213e6083a68c8d09e1a928ef5fa49983bc818ee1 (diff)
downloadchawan-37546bb85efc292703289313c6c87798cd4ab20c.tar.gz
renderdocument: do not layout with styledRoot == nil
it can happen when do_reshape is called before any parsing happens.
-rw-r--r--src/layout/renderdocument.nim5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/layout/renderdocument.nim b/src/layout/renderdocument.nim
index d4dc377f..06a6992a 100644
--- a/src/layout/renderdocument.nim
+++ b/src/layout/renderdocument.nim
@@ -450,8 +450,11 @@ proc renderBlockBox(grid: var FlexibleGrid; state: var RenderState;
         stack.add((box.nested[i], offset))
 
 proc renderDocument*(grid: var FlexibleGrid; bgcolor: var CellColor;
-    styledRoot: StyledNode, attrsp: ptr WindowAttributes) =
+    styledRoot: StyledNode; attrsp: ptr WindowAttributes) =
   grid.setLen(0)
+  if styledRoot == nil:
+    # no HTML element when we run cascade; just clear all lines.
+    return
   var state = RenderState(
     absolutePos: @[Offset(x: 0, y: 0)],
     attrsp: attrsp