about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-07-02 19:46:53 +0200
committerbptato <nincsnevem662@gmail.com>2024-07-02 19:48:27 +0200
commitd015cf8c497869113e7a8d849ba6cae2f3db071b (patch)
tree8b91d428a55edbd62fa25754c53f58b15457caae /src
parent02b549ee0c7bda8ad110eba6aac14bafb10d45e3 (diff)
downloadchawan-d015cf8c497869113e7a8d849ba6cae2f3db071b.tar.gz
layout: fix positioning bug
top/left/right/bottom should only be used in renderdocument with
position: absolute.
Diffstat (limited to 'src')
-rw-r--r--src/layout/renderdocument.nim9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/layout/renderdocument.nim b/src/layout/renderdocument.nim
index c247a7fe..0652e888 100644
--- a/src/layout/renderdocument.nim
+++ b/src/layout/renderdocument.nim
@@ -411,10 +411,11 @@ proc renderBlockBox(grid: var FlexibleGrid; state: var RenderState;
     if box == nil: # positioned marker
       discard state.absolutePos.pop()
       continue
-    if not box.computed{"left"}.auto or not box.computed{"right"}.auto:
-      offset.x = state.absolutePos[^1].x
-    if not box.computed{"top"}.auto or not box.computed{"bottom"}.auto:
-      offset.y = state.absolutePos[^1].y
+    if box.computed{"position"} == PositionAbsolute:
+      if not box.computed{"left"}.auto or not box.computed{"right"}.auto:
+        offset.x = state.absolutePos[^1].x
+      if not box.computed{"top"}.auto or not box.computed{"bottom"}.auto:
+        offset.y = state.absolutePos[^1].y
     offset += box.state.offset
     if box.computed{"position"} != PositionStatic:
       state.absolutePos.add(offset)