diff options
author | bptato <nincsnevem662@gmail.com> | 2025-01-29 19:39:31 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2025-01-29 19:45:06 +0100 |
commit | dfb3453b3c1220f0efa50aff8d57c27da86a543f (patch) | |
tree | e1c3df46c6b5a3d84524e8b8e5e8a0d720c18ee8 | |
parent | 95cafdfbed807053325cdf08027e45256356106f (diff) | |
download | chawan-dfb3453b3c1220f0efa50aff8d57c27da86a543f.tar.gz |
render: fix OOB panic with scroll container outside the canvas
clipBox must not be allowed to start outside the canvas, or paintBackground will happily try to setTextStr in a negative position.
-rw-r--r-- | src/css/render.nim | 2 | ||||
-rw-r--r-- | test/layout/overflow-scroll-starts-outside-canvas.expected | 1 | ||||
-rw-r--r-- | test/layout/overflow-scroll-starts-outside-canvas.html | 3 |
3 files changed, 5 insertions, 1 deletions
diff --git a/src/css/render.nim b/src/css/render.nim index 4d86c73c..e7cd3595 100644 --- a/src/css/render.nim +++ b/src/css/render.nim @@ -456,7 +456,7 @@ proc renderBlockBox(grid: var FlexibleGrid; state: var RenderState; clipBox.start.x = max(offset.x, clipBox.start.x) clipBox.send.x = min(offset.x + box.state.size.w, clipBox.send.x) else: # scroll like - clipBox.start.x = min(offset.x, clipBox.start.x) + clipBox.start.x = max(min(offset.x, clipBox.start.x), 0) clipBox.send.x = max(offset.x + box.state.size.w, clipBox.start.x) if overflowY in OverflowHiddenLike: clipBox.start.y = max(offset.y, clipBox.start.y) diff --git a/test/layout/overflow-scroll-starts-outside-canvas.expected b/test/layout/overflow-scroll-starts-outside-canvas.expected new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/test/layout/overflow-scroll-starts-outside-canvas.expected @@ -0,0 +1 @@ + diff --git a/test/layout/overflow-scroll-starts-outside-canvas.html b/test/layout/overflow-scroll-starts-outside-canvas.html new file mode 100644 index 00000000..b26a4a96 --- /dev/null +++ b/test/layout/overflow-scroll-starts-outside-canvas.html @@ -0,0 +1,3 @@ +<div style="background: red; width: 4ch; overflow: scroll; margin-left: -4ch"> +test +</div> |