From 7dccd37dc8f431486fbab0048cd8cc13f9523c61 Mon Sep 17 00:00:00 2001 From: bptato Date: Tue, 11 Feb 2025 22:43:58 +0100 Subject: render: fix a visibility bug --- src/css/render.nim | 14 ++++++-------- test/layout/visibility-switch-in-inline-box.expected | 1 + test/layout/visibility-switch-in-inline-box.html | 8 ++++++++ 3 files changed, 15 insertions(+), 8 deletions(-) create mode 100644 test/layout/visibility-switch-in-inline-box.expected create mode 100644 test/layout/visibility-switch-in-inline-box.html 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 @@ + +
+ +
+test +
+
+
-- cgit