From 2c136265658450ea91cb81ee6b3a85198a0c4844 Mon Sep 17 00:00:00 2001 From: bptato Date: Sat, 8 Feb 2025 20:17:35 +0100 Subject: box: abstract over tree traversal --- src/server/buffer.nim | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'src/server/buffer.nim') diff --git a/src/server/buffer.nim b/src/server/buffer.nim index e34d88f6..dca85806 100644 --- a/src/server/buffer.nim +++ b/src/server/buffer.nim @@ -666,22 +666,10 @@ type GotoAnchorResult* = object focus*: ReadLineResult proc findAnchor(box: CSSBox; anchor: Element): Offset = - if box of InlineBox: - let ibox = InlineBox(box) - if ibox.t == ibtBox: - let off = ibox.box.findAnchor(anchor) - if off.y >= 0: - return off - elif ibox.t == ibtParent: - for child in ibox.children: - let off = child.findAnchor(anchor) - if off.y >= 0: - return off - else: - for child in BlockBox(box).children: - let off = child.findAnchor(anchor) - if off.y >= 0: - return off + for child in box.children: + let off = child.findAnchor(anchor) + if off.y >= 0: + return off if box.element == anchor: return box.render.offset return offset(-1, -1) -- cgit