diff options
author | bptato <nincsnevem662@gmail.com> | 2023-11-12 02:58:00 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-11-12 02:59:59 +0100 |
commit | 39e2ef5207ad13c34de00c8cc998e434eeb42ab7 (patch) | |
tree | 98cc813f4945327ef205708467676d43a8199c11 /src/render/renderdocument.nim | |
parent | a3bd24ae53ea4e1d1c77dfc5a1171a05b5d9ca18 (diff) | |
download | chawan-39e2ef5207ad13c34de00c8cc998e434eeb42ab7.tar.gz |
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
Diffstat (limited to 'src/render/renderdocument.nim')
-rw-r--r-- | src/render/renderdocument.nim | 10 |
1 files changed, 5 insertions, 5 deletions
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 |