aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2025-02-11 22:43:58 +0100
committerbptato <nincsnevem662@gmail.com>2025-02-11 22:43:58 +0100
commit7dccd37dc8f431486fbab0048cd8cc13f9523c61 (patch)
treece9a8addef119470e427d7607d62f01a9c84d9ef
parent6ad9176b251bdc869cb371b527ee65c9e0c8f62e (diff)
downloadchawan-7dccd37dc8f431486fbab0048cd8cc13f9523c61.tar.gz
render: fix a visibility bug
-rw-r--r--src/css/render.nim14
-rw-r--r--test/layout/visibility-switch-in-inline-box.expected1
-rw-r--r--test/layout/visibility-switch-in-inline-box.html8
3 files changed, 15 insertions, 8 deletions
diff --git a/src/css/render.nim b/src/css/render.nim
index c7777813..241167bb 100644
--- a/src/css/render.nim
+++ b/src/css/render.nim
@@ -498,16 +498,14 @@ proc renderBlockBox(grid: var FlexibleGrid; state: var RenderState;
offset.x += box.state.size.w div 2
grid.setText(state, s, offset, box.computed.toFormat(), box.element)
if opacity != 0: #TODO this isn't right...
- for child in box.children:
- if child of InlineBox:
- #TODO move this outside the InlineBox check?
- if box.computed{"visibility"} == VisibilityVisible and
- state.clipBox.start.x < state.clipBox.send.x and
- state.clipBox.start.y < state.clipBox.send.y:
+ if state.clipBox.start.x < state.clipBox.send.x and
+ state.clipBox.start.y < state.clipBox.send.y:
+ for child in box.children:
+ if child of InlineBox:
grid.renderInlineBox(state, InlineBox(child), offset,
rgba(0, 0, 0, 0))
- else:
- grid.renderBlockBox(state, BlockBox(child), offset)
+ else:
+ grid.renderBlockBox(state, BlockBox(child), offset)
if hasClipBox:
discard state.clipBoxes.pop()
if position != PositionStatic:
diff --git a/test/layout/visibility-switch-in-inline-box.expected b/test/layout/visibility-switch-in-inline-box.expected
new file mode 100644
index 00000000..9daeafb9
--- /dev/null
+++ b/test/layout/visibility-switch-in-inline-box.expected
@@ -0,0 +1 @@
+test
diff --git a/test/layout/visibility-switch-in-inline-box.html b/test/layout/visibility-switch-in-inline-box.html
new file mode 100644
index 00000000..a382ccae
--- /dev/null
+++ b/test/layout/visibility-switch-in-inline-box.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<div style="visibility: hidden">
+<span>
+<div style="visibility: visible">
+test
+</div>
+</span>
+</div>