diff options
-rw-r--r-- | src/layout/box.nim | 3 | ||||
-rw-r--r-- | src/layout/engine.nim | 8 |
2 files changed, 11 insertions, 0 deletions
diff --git a/src/layout/box.nim b/src/layout/box.nim index c2b6a449..583e0d75 100644 --- a/src/layout/box.nim +++ b/src/layout/box.nim @@ -118,6 +118,9 @@ type viewport*: Viewport offset*: Offset + #TODO this should not be needed. + was_positioned*: bool + # This is the padding width/height. width*: int height*: int diff --git a/src/layout/engine.nim b/src/layout/engine.nim index eebc7ef0..02e7398e 100644 --- a/src/layout/engine.nim +++ b/src/layout/engine.nim @@ -839,6 +839,12 @@ proc positionBlocks(box: BlockBox) = template defer_out_of_flow() = # Skip absolute, fixed, sticky while i < box.nested.len: + if box.nested[i].was_positioned: # already positioned, ignore. + #TODO: this is actually an ugly hack to avoid absolute boxes being + # positioned twice. A proper fix would be to appropriately place + # them in the tree *before* positioning (i.e. in buildBlock.) + inc i + continue case box.nested[i].computed{"position"} of POSITION_STATIC, POSITION_RELATIVE: break @@ -916,6 +922,7 @@ proc positionBlocks(box: BlockBox) = child.offset.x += child.margin_left if box.computed{"position"} == POSITION_RELATIVE: box.positionRelative(child) + child.was_positioned = true #TODO see above box.height += box.padding_bottom @@ -926,6 +933,7 @@ proc positionBlocks(box: BlockBox) = box.width += box.padding_right for child in deferred: + child.was_positioned = true #TODO see above case child.computed{"position"} of POSITION_ABSOLUTE: positionAbsolute(child) |