From 39e2ef5207ad13c34de00c8cc998e434eeb42ab7 Mon Sep 17 00:00:00 2001 From: bptato Date: Sun, 12 Nov 2023 02:58:00 +0100 Subject: layout: refactor flow margin propagation, sizing * Blocks are now positioned before their text contents would be layouted * Untangle calcAvailableSpaceSizes's results from BlockBox * Move a couple of objects from box -> engine * Use Size in a few more places * Set display to block if float is not none --- src/render/renderdocument.nim | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/render/renderdocument.nim') diff --git a/src/render/renderdocument.nim b/src/render/renderdocument.nim index 27435633..b6bd1743 100644 --- a/src/render/renderdocument.nim +++ b/src/render/renderdocument.nim @@ -339,8 +339,8 @@ proc renderBlockBox(grid: var FlexibleGrid, box: BlockBox, x, y: LayoutUnit, if box.computed{"background-color"}.a != 0: #TODO color blending let ix = toInt(x) let iy = toInt(y) - let iex = toInt(x + box.width) - let iey = toInt(y + box.height) + let iex = toInt(x + box.size.w) + let iey = toInt(y + box.size.h) grid.paintBackground(box.computed{"background-color"}, ix, iy, iex, iey, box.node, window) if box.computed{"background-image"}.t == CONTENT_IMAGE and box.computed{"background-image"}.s != "": @@ -348,10 +348,10 @@ proc renderBlockBox(grid: var FlexibleGrid, box: BlockBox, x, y: LayoutUnit, let s = "[img]" let w = s.len * window.ppc var ix = x - if box.width < w: + if box.size.w < w: # text is larger than image; center it to minimize error ix -= w div 2 - ix += box.width div 2 + ix += box.size.w div 2 let x = toInt(ix div window.ppc) let y = toInt(y div window.ppl) if y >= 0 and x + w >= 0: @@ -360,7 +360,7 @@ proc renderBlockBox(grid: var FlexibleGrid, box: BlockBox, x, y: LayoutUnit, if box of ListItemBox: let box = ListItemBox(box) if box.marker != nil: - grid.renderInlineContext(box.marker, x - box.marker.width, y, window) + grid.renderInlineContext(box.marker, x - box.marker.size.w, y, window) if box.inline != nil: assert box.nested.len == 0 -- cgit 1.4.1-2-gfad0