diff options
author | bptato <nincsnevem662@gmail.com> | 2025-01-21 19:14:37 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2025-01-21 19:21:27 +0100 |
commit | 3caeb2c1277e857179fdb5b8c9d39b1a5f22391f (patch) | |
tree | fa89a91f0cb594f8aa6b8ba01569d2cb510a8234 | |
parent | 9159f6a76e14225d7ceeee55defbde2e335c5d3e (diff) | |
download | chawan-3caeb2c1277e857179fdb5b8c9d39b1a5f22391f.tar.gz |
render: actually fix the "extra unnecessary line" bug
Plus remove addLines, it's no longer very useful.
32 files changed, 4 insertions, 38 deletions
diff --git a/src/css/render.nim b/src/css/render.nim index 0da28fe4..0e34dce3 100644 --- a/src/css/render.nim +++ b/src/css/render.nim @@ -74,9 +74,6 @@ func findFormatN*(line: FlexibleLine; pos: int): int = inc i return i -proc addLines(grid: var FlexibleGrid; n: int) = - grid.setLen(grid.len + n) - proc insertFormat(line: var FlexibleLine; i: int; cell: FormatCell) = line.formats.insert(cell, i) @@ -268,8 +265,8 @@ proc setText(grid: var FlexibleGrid; state: var RenderState; s: string; if i < j: let y = (offset.y div state.attrs.ppl).toInt # make sure we have line y - if grid.high < y: - grid.addLines(y - grid.high) + if grid.len < y + 1: + grid.setLen(y + 1) grid[y].setText1(s.toOpenArray(i, j - 1), x, targetX, format, node) proc paintBackground(grid: var FlexibleGrid; state: var RenderState; @@ -291,7 +288,7 @@ proc paintBackground(grid: var FlexibleGrid; state: var RenderState; if starty >= endy or startx >= endx: return if grid.len < endy: # make sure we have line y - 1 - grid.addLines(endy - grid.high) + grid.setLen(endy) var format = Format(bgcolor: color) for line in grid.toOpenArray(starty, endy - 1).mitems: # Make sure line.width() >= endx @@ -534,6 +531,6 @@ proc renderDocument*(grid: var FlexibleGrid; bgcolor: var CellColor; stack.sort(proc(x, y: StackItem): int = cmp(x.index, y.index)) state.nstack = @[] if grid.len == 0: - grid.addLines(1) + grid.setLen(1) bgcolor = state.bgcolor images = state.images diff --git a/test/layout/acid1.color.expected b/test/layout/acid1.color.expected index f4eabf5f..2463efd2 100644 --- a/test/layout/acid1.color.expected +++ b/test/layout/acid1.color.expected @@ -35,4 +35,3 @@ [48;2;0;0;255m [38;2;0;0;0m[48;2;255;255;255mthe pixel) from this [38;2;161;162;0mreference rendering,[38;2;0;0;0m (except font rasterization and form widgets). All[38;2;139;139;139m [39m[49m [48;2;0;0;255m [38;2;0;0;0m[48;2;255;255;255mdiscrepancies should be traceable to CSS1 implementation shortcomings. Once you have finished[38;2;139;139;139m [39m[49m [48;2;0;0;255m [38;2;0;0;0m[48;2;255;255;255mevaluating this test, you can return to the [38;2;161;162;0mparent page[38;2;0;0;0m.[38;2;139;139;139m [39m[49m - diff --git a/test/layout/bfc-child-after-float-overflows-parent.color.expected b/test/layout/bfc-child-after-float-overflows-parent.color.expected index c6426e9d..c0ca94c4 100644 --- a/test/layout/bfc-child-after-float-overflows-parent.color.expected +++ b/test/layout/bfc-child-after-float-overflows-parent.color.expected @@ -1,3 +1,2 @@ float [48;2;255;0;0mtest [49m - diff --git a/test/layout/colored-inline-block-squares.color.expected b/test/layout/colored-inline-block-squares.color.expected index 1e805e94..36176633 100644 --- a/test/layout/colored-inline-block-squares.color.expected +++ b/test/layout/colored-inline-block-squares.color.expected @@ -33,4 +33,3 @@ one [48;2;0;0;255m? [49m [48;2;0;0;255m? [48;2;255;0;0m [49m [48;2;255;0;0m [49m [48;2;255;0;0m [49m - diff --git a/test/layout/flex-column-width-stretch.color.expected b/test/layout/flex-column-width-stretch.color.expected index a52ec5dc..55269c3f 100644 --- a/test/layout/flex-column-width-stretch.color.expected +++ b/test/layout/flex-column-width-stretch.color.expected @@ -1,2 +1 @@ [48;2;0;128;0mtest 1 [49m - diff --git a/test/layout/flex-item-indefinite-size-with-min-max-bounds.color.expected b/test/layout/flex-item-indefinite-size-with-min-max-bounds.color.expected index 00b23149..024f9872 100644 --- a/test/layout/flex-item-indefinite-size-with-min-max-bounds.color.expected +++ b/test/layout/flex-item-indefinite-size-with-min-max-bounds.color.expected @@ -1,3 +1,2 @@ [48;2;0;128;0mtest test [49mtest [48;2;0;128;0mtest test [49mtest - diff --git a/test/layout/flex-item-margin-collapsing.color.expected b/test/layout/flex-item-margin-collapsing.color.expected index e38eebc4..1b425afe 100644 --- a/test/layout/flex-item-margin-collapsing.color.expected +++ b/test/layout/flex-item-margin-collapsing.color.expected @@ -14,4 +14,3 @@ [48;2;0;0;255m [49m [48;2;0;0;255m [49m [48;2;255;0;0m [49m - diff --git a/test/layout/flex-items-cross-margin.color.expected b/test/layout/flex-items-cross-margin.color.expected index 8751cbec..482c862d 100644 --- a/test/layout/flex-items-cross-margin.color.expected +++ b/test/layout/flex-items-cross-margin.color.expected @@ -4,4 +4,3 @@ [48;2;0;128;0m [48;2;0;0;255m [49m [48;2;0;128;0m • [48;2;255;0;0mtesting[48;2;0;128;0m [48;2;0;0;255m [49m [48;2;0;0;255m [49m - diff --git a/test/layout/flex-main-padding-border-box.color.expected b/test/layout/flex-main-padding-border-box.color.expected index 29e30647..995590db 100644 --- a/test/layout/flex-main-padding-border-box.color.expected +++ b/test/layout/flex-main-padding-border-box.color.expected @@ -1,2 +1 @@ [48;2;255;0;0mtest [49m - diff --git a/test/layout/flex-max-content-over-min-height.color.expected b/test/layout/flex-max-content-over-min-height.color.expected index 61202521..795ee8e3 100644 --- a/test/layout/flex-max-content-over-min-height.color.expected +++ b/test/layout/flex-max-content-over-min-height.color.expected @@ -1,4 +1,3 @@ test [48;2;255;0;0mt[49mest [48;2;255;0;0m [49m - diff --git a/test/layout/flex-min-max-sizes.color.expected b/test/layout/flex-min-max-sizes.color.expected index ae3ee9a3..0499ed50 100644 --- a/test/layout/flex-min-max-sizes.color.expected +++ b/test/layout/flex-min-max-sizes.color.expected @@ -9,4 +9,3 @@ [38;2;130;130;130m[48;2;240;248;255m [39m[49m [38;2;130;130;130m[48;2;240;248;255m [39m[49m [38;2;130;130;130m[48;2;240;248;255m [39m[49m - diff --git a/test/layout/flex-no-shrink-padding-cancels-out-parent-margin.color.expected b/test/layout/flex-no-shrink-padding-cancels-out-parent-margin.color.expected index de757ffa..3e987e83 100644 --- a/test/layout/flex-no-shrink-padding-cancels-out-parent-margin.color.expected +++ b/test/layout/flex-no-shrink-padding-cancels-out-parent-margin.color.expected @@ -1,4 +1,3 @@ [48;2;255;0;0m aaaa aaaa[49m [48;2;255;0;0mtest [49m [48;2;0;0;255mtest [49m - diff --git a/test/layout/flex-shrink-overconstrained.color.expected b/test/layout/flex-shrink-overconstrained.color.expected index 82c615f0..fef2b0b6 100644 --- a/test/layout/flex-shrink-overconstrained.color.expected +++ b/test/layout/flex-shrink-overconstrained.color.expected @@ -3,4 +3,3 @@ [48;2;255;0;0m1111 1111 [38;2;95;95;95m[48;2;255;192;203mtest test test test test [39m[49m [48;2;255;0;0m1111 1111 [38;2;95;95;95m[48;2;255;192;203mtest test [39m[49m [48;2;255;0;0m1111 [38;2;95;95;95m[48;2;255;192;203m [39m[49m - diff --git a/test/layout/flex-wrap-in-nowrap.color.expected b/test/layout/flex-wrap-in-nowrap.color.expected index d68eff74..4f98b307 100644 --- a/test/layout/flex-wrap-in-nowrap.color.expected +++ b/test/layout/flex-wrap-in-nowrap.color.expected @@ -13,4 +13,3 @@ [48;2;255;0;0m [48;2;0;128;0m [49m [48;2;255;0;0m [48;2;0;128;0m [49m [48;2;255;0;0m [48;2;0;128;0m [49m - diff --git a/test/layout/flexbox-simple-flex-grow-and-height.color.expected b/test/layout/flexbox-simple-flex-grow-and-height.color.expected index f8a29147..a481748a 100644 --- a/test/layout/flexbox-simple-flex-grow-and-height.color.expected +++ b/test/layout/flexbox-simple-flex-grow-and-height.color.expected @@ -9,4 +9,3 @@ [38;2;95;95;95m[48;2;255;192;203m [39m[49m [38;2;95;95;95m[48;2;255;192;203m [39m[49m [38;2;95;95;95m[48;2;255;192;203m [39m[49m - diff --git a/test/layout/float-child-percentage-width-ignored.color.expected b/test/layout/float-child-percentage-width-ignored.color.expected index 5d875773..3d2e1f0a 100644 --- a/test/layout/float-child-percentage-width-ignored.color.expected +++ b/test/layout/float-child-percentage-width-ignored.color.expected @@ -1,2 +1 @@ [48;2;255;0;0mtest[49m - diff --git a/test/layout/float-reposition-with-left-padding-fills-space.color.expected b/test/layout/float-reposition-with-left-padding-fills-space.color.expected index 4e703901..cb3a6169 100644 --- a/test/layout/float-reposition-with-left-padding-fills-space.color.expected +++ b/test/layout/float-reposition-with-left-padding-fills-space.color.expected @@ -1,2 +1 @@ [48;2;128;0;128m [48;2;0;0;255mtest test test [48;2;128;0;128m [49m - diff --git a/test/layout/float-text-align-right.color.expected b/test/layout/float-text-align-right.color.expected index bcb22cf8..a2cce81d 100644 --- a/test/layout/float-text-align-right.color.expected +++ b/test/layout/float-text-align-right.color.expected @@ -1,2 +1 @@ [48;2;255;0;0mfloat float float[49m test[48;2;255;0;0mfloat[49m - diff --git a/test/layout/inline-flex-grow-item.color.expected b/test/layout/inline-flex-grow-item.color.expected index d4f36598..2cfe12a0 100644 --- a/test/layout/inline-flex-grow-item.color.expected +++ b/test/layout/inline-flex-grow-item.color.expected @@ -1,2 +1 @@ [48;2;0;128;0mtest[49m - diff --git a/test/layout/inline-float-right-in-stretch.color.expected b/test/layout/inline-float-right-in-stretch.color.expected index d2538aa6..dc86afa9 100644 --- a/test/layout/inline-float-right-in-stretch.color.expected +++ b/test/layout/inline-float-right-in-stretch.color.expected @@ -1,2 +1 @@ [48;2;255;0;0mhello [49mworld test - diff --git a/test/layout/intrinsic-min-width-overflows-parent-perc-width-after-float.color.expected b/test/layout/intrinsic-min-width-overflows-parent-perc-width-after-float.color.expected index cd858133..6d0dea91 100644 --- a/test/layout/intrinsic-min-width-overflows-parent-perc-width-after-float.color.expected +++ b/test/layout/intrinsic-min-width-overflows-parent-perc-width-after-float.color.expected @@ -1,4 +1,3 @@ right [48;2;128;0;128m [49m [48;2;255;0;0mtest test test test test test test test test test test test test test test test [49mtest test test test test test test test test test test test test test test - diff --git a/test/layout/max-width-sets-main-width-indefinite-parent.color.expected b/test/layout/max-width-sets-main-width-indefinite-parent.color.expected index 9ef30269..bf5c795f 100644 --- a/test/layout/max-width-sets-main-width-indefinite-parent.color.expected +++ b/test/layout/max-width-sets-main-width-indefinite-parent.color.expected @@ -1,2 +1 @@ [48;2;0;0;255mtesting testing testing testing testing[49m - diff --git a/test/layout/min-max-width.color.expected b/test/layout/min-max-width.color.expected index de5f4496..13cc8400 100644 --- a/test/layout/min-max-width.color.expected +++ b/test/layout/min-max-width.color.expected @@ -31,4 +31,3 @@ [48;2;0;128;0mwo[49mrd. [48;2;128;0;128mII [49m [48;2;255;0;0mmin-width beats max-width [49m - diff --git a/test/layout/nested-flex-direction-swap-padding-overflow.color.expected b/test/layout/nested-flex-direction-swap-padding-overflow.color.expected index fd65de93..9619e210 100644 --- a/test/layout/nested-flex-direction-swap-padding-overflow.color.expected +++ b/test/layout/nested-flex-direction-swap-padding-overflow.color.expected @@ -6,4 +6,3 @@ [48;2;255;0;0m test [49m [48;2;255;0;0m test [49m [48;2;255;0;0m test [49m - diff --git a/test/layout/nth-child.color.expected b/test/layout/nth-child.color.expected index de99ff28..b97a9239 100644 --- a/test/layout/nth-child.color.expected +++ b/test/layout/nth-child.color.expected @@ -28,4 +28,3 @@ [48;2;0;0;0m [38;2;255;40;40m3. test[39m [49m [48;2;0;0;0m [38;2;255;40;40m4. test[39m [49m [48;2;0;0;0m [38;2;255;40;40m5. test[39m [49m - diff --git a/test/layout/overlapping-double-width-chars.color.expected b/test/layout/overlapping-double-width-chars.color.expected index 3d30b50f..fdd18032 100644 --- a/test/layout/overlapping-double-width-chars.color.expected +++ b/test/layout/overlapping-double-width-chars.color.expected @@ -1,2 +1 @@ [48;2;255;0;0mう い [49m - diff --git a/test/layout/padding-counted-for-intrinisc-min-width.color.expected b/test/layout/padding-counted-for-intrinisc-min-width.color.expected index 7252c405..03003cfc 100644 --- a/test/layout/padding-counted-for-intrinisc-min-width.color.expected +++ b/test/layout/padding-counted-for-intrinisc-min-width.color.expected @@ -1,2 +1 @@ [48;2;255;0;0m a [49m test - diff --git a/test/layout/position-absolute-float-subtracted-from-available-space.color.expected b/test/layout/position-absolute-float-subtracted-from-available-space.color.expected index 120e6324..25a3dbdf 100644 --- a/test/layout/position-absolute-float-subtracted-from-available-space.color.expected +++ b/test/layout/position-absolute-float-subtracted-from-available-space.color.expected @@ -3,4 +3,3 @@ [48;2;128;0;128m test test test [49m [48;2;128;0;128m test test test [49m [48;2;128;0;128m test test [49m - diff --git a/test/layout/position.color.expected b/test/layout/position.color.expected index dd312c5a..9858c33a 100644 --- a/test/layout/position.color.expected +++ b/test/layout/position.color.expected @@ -5,4 +5,3 @@ [48;2;255;0;0mtest test test [49m [48;2;0;0;255mtest [49m - diff --git a/test/layout/table-colwidth-overconstrained-too-small.color.expected b/test/layout/table-colwidth-overconstrained-too-small.color.expected index 979feeea..7769b665 100644 --- a/test/layout/table-colwidth-overconstrained-too-small.color.expected +++ b/test/layout/table-colwidth-overconstrained-too-small.color.expected @@ -1,2 +1 @@ [48;2;255;0;0me [49m [48;2;0;128;0mh? [49m - diff --git a/test/layout/table-overlapping-rowspan-and-colspan.expected b/test/layout/table-overlapping-rowspan-and-colspan.expected index 442b1372..29de252d 100644 --- a/test/layout/table-overlapping-rowspan-and-colspan.expected +++ b/test/layout/table-overlapping-rowspan-and-colspan.expected @@ -1,3 +1,2 @@ test test col2 test col4 - diff --git a/test/layout/underline-does-not-escape-background-switch.color.expected b/test/layout/underline-does-not-escape-background-switch.color.expected index 0d27f448..3b1b6947 100644 --- a/test/layout/underline-does-not-escape-background-switch.color.expected +++ b/test/layout/underline-does-not-escape-background-switch.color.expected @@ -1,2 +1 @@ [4m[48;2;255;0;0mtest[24m[48;2;0;0;255m [49m - |