aboutsummaryrefslogtreecommitdiffstats
path: root/src/layout
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-07-04 14:15:00 +0200
committerbptato <nincsnevem662@gmail.com>2023-07-04 14:15:00 +0200
commitba6ac8e07c6868c168a550f3d8ecbb2f8bf5c799 (patch)
tree2acf8f84072679a6ad9b0c78109369284ae657f6 /src/layout
parentb96d8cc51a7f469eaa5804c24a8b45cc4d5b3756 (diff)
downloadchawan-ba6ac8e07c6868c168a550f3d8ecbb2f8bf5c799.tar.gz
Fix table cellspacing not being counted in row width
Diffstat (limited to 'src/layout')
-rw-r--r--src/layout/engine.nim7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/layout/engine.nim b/src/layout/engine.nim
index 7cc6731d..7b13bbb5 100644
--- a/src/layout/engine.nim
+++ b/src/layout/engine.nim
@@ -985,6 +985,7 @@ proc preBuildTableRow(pctx: var TableContext, box: TableRowBoxBuilder,
let minw = box.xminwidth div colspan
let w = box.width div colspan
for i in n ..< n + colspan:
+ # Add spacing.
ctx.width += pctx.inlinespacing
pctx.cols[i].maxwidth = w
if pctx.cols[i].width < w:
@@ -1009,6 +1010,7 @@ proc preBuildTableRow(pctx: var TableContext, box: TableRowBoxBuilder,
pctx.cols[i].width = minw
ctx.reflow[i] = true
ctx.width += pctx.cols[i].width
+ # Add spacing to the right side.
ctx.width += pctx.inlinespacing
n += colspan
inc i
@@ -1026,6 +1028,8 @@ proc buildTableRow(pctx: TableContext, ctx: RowContext, parent: BlockBox,
var w: LayoutUnit = 0
for i in n ..< n + cellw.colspan:
w += pctx.cols[i].width
+ # Add inline spacing for merged columns.
+ w += pctx.inlinespacing * (cellw.colspan - 1) * 2
if cellw.reflow:
#TODO TODO TODO this is a hack, and it doesn't even work properly
let ocomputed = cellw.builder.computed
@@ -1102,6 +1106,7 @@ iterator rows(builder: TableBoxBuilder): BoxBuilder {.inline.} =
proc calcUnspecifiedColIndices(ctx: var TableContext, W: var LayoutUnit,
weight: var float64): seq[int] =
+ # Spacing for each column:
var avail = newSeqUninitialized[int](ctx.cols.len)
var i = 0
var j = 0
@@ -1153,6 +1158,8 @@ proc buildTableLayout(table: BlockBox, builder: TableBoxBuilder) =
if (table.contentWidth > ctx.maxwidth and (not table.shrink or not spec)) or
table.contentWidth < ctx.maxwidth:
var W = table.contentWidth
+ # Remove inline spacing from distributable width.
+ W -= ctx.cols.len * ctx.inlinespacing * 2
var weight: float64
var avail = ctx.calcUnspecifiedColIndices(W, weight)
var redo = true