aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2025-01-21 19:14:37 +0100
committerbptato <nincsnevem662@gmail.com>2025-01-21 19:21:27 +0100
commit3caeb2c1277e857179fdb5b8c9d39b1a5f22391f (patch)
treefa89a91f0cb594f8aa6b8ba01569d2cb510a8234
parent9159f6a76e14225d7ceeee55defbde2e335c5d3e (diff)
downloadchawan-3caeb2c1277e857179fdb5b8c9d39b1a5f22391f.tar.gz
render: actually fix the "extra unnecessary line" bug
Plus remove addLines, it's no longer very useful.
-rw-r--r--src/css/render.nim11
-rw-r--r--test/layout/acid1.color.expected1
-rw-r--r--test/layout/bfc-child-after-float-overflows-parent.color.expected1
-rw-r--r--test/layout/colored-inline-block-squares.color.expected1
-rw-r--r--test/layout/flex-column-width-stretch.color.expected1
-rw-r--r--test/layout/flex-item-indefinite-size-with-min-max-bounds.color.expected1
-rw-r--r--test/layout/flex-item-margin-collapsing.color.expected1
-rw-r--r--test/layout/flex-items-cross-margin.color.expected1
-rw-r--r--test/layout/flex-main-padding-border-box.color.expected1
-rw-r--r--test/layout/flex-max-content-over-min-height.color.expected1
-rw-r--r--test/layout/flex-min-max-sizes.color.expected1
-rw-r--r--test/layout/flex-no-shrink-padding-cancels-out-parent-margin.color.expected1
-rw-r--r--test/layout/flex-shrink-overconstrained.color.expected1
-rw-r--r--test/layout/flex-wrap-in-nowrap.color.expected1
-rw-r--r--test/layout/flexbox-simple-flex-grow-and-height.color.expected1
-rw-r--r--test/layout/float-child-percentage-width-ignored.color.expected1
-rw-r--r--test/layout/float-reposition-with-left-padding-fills-space.color.expected1
-rw-r--r--test/layout/float-text-align-right.color.expected1
-rw-r--r--test/layout/inline-flex-grow-item.color.expected1
-rw-r--r--test/layout/inline-float-right-in-stretch.color.expected1
-rw-r--r--test/layout/intrinsic-min-width-overflows-parent-perc-width-after-float.color.expected1
-rw-r--r--test/layout/max-width-sets-main-width-indefinite-parent.color.expected1
-rw-r--r--test/layout/min-max-width.color.expected1
-rw-r--r--test/layout/nested-flex-direction-swap-padding-overflow.color.expected1
-rw-r--r--test/layout/nth-child.color.expected1
-rw-r--r--test/layout/overlapping-double-width-chars.color.expected1
-rw-r--r--test/layout/padding-counted-for-intrinisc-min-width.color.expected1
-rw-r--r--test/layout/position-absolute-float-subtracted-from-available-space.color.expected1
-rw-r--r--test/layout/position.color.expected1
-rw-r--r--test/layout/table-colwidth-overconstrained-too-small.color.expected1
-rw-r--r--test/layout/table-overlapping-rowspan-and-colspan.expected1
-rw-r--r--test/layout/underline-does-not-escape-background-switch.color.expected1
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 @@
 the pixel) from this reference rendering, (except font rasterization and form widgets). All 
 discrepancies should be traceable to CSS1 implementation shortcomings. Once you have finished 
 evaluating this test, you can return to the parent page. 
-
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
test 
-
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 ?  ?
 
 
 
-
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 @@
test 1 
-
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 @@
test test test
test test test
-
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 @@
 
 
 
-
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 @@
  
 • testing  
 
-
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 @@
test 
-
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
test
 
-
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 @@
 
 
 
-
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 @@
 aaaa aaaa
test 
test 
-
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 @@
1111 1111 test test test test test 
1111 1111 test test 
1111  
-
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 @@
  
  
  
-
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 @@
 
 
 
-
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 @@
test
-
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 @@
 test test test  
-
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 @@
float float float testfloat
-
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 @@
test
-
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 @@
hello world 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
 
test test test test test test test test test test test test test test test test test 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 @@
testing testing testing testing testing
-
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 @@
word.
II 
min-width beats max-width 
-
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 @@
 test 
 test 
 test 
-
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 @@
 3. test 
 4. test 
 5. test 
-
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 @@
う い 
-
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 @@
 a  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 @@
 test test test 
 test test test 
 test test 
-
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 @@
test test test 
test 
-
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 @@
e  h? 
-
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 @@
test 
-