about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2025-01-23 01:11:30 +0100
committerbptato <nincsnevem662@gmail.com>2025-01-23 01:13:48 +0100
commitd958d7d8761f70abbc66765e2e69a3bb67ff125d (patch)
tree9da4da49a6a4b44989d38e872be884b077ff5371 /src
parent7862eb840ad1964484352cdfa5458edda413fe0d (diff)
downloadchawan-d958d7d8761f70abbc66765e2e69a3bb67ff125d.tar.gz
layout: fix an absolute sizing bug
it's size.h, not size.w
Diffstat (limited to 'src')
-rw-r--r--src/css/layout.nim9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/css/layout.nim b/src/css/layout.nim
index 84b11c48..b2a45aa6 100644
--- a/src/css/layout.nim
+++ b/src/css/layout.nim
@@ -983,19 +983,18 @@ proc resolveAbsoluteWidth(sizes: var ResolvedSizes; size: Size;
 
 proc resolveAbsoluteHeight(sizes: var ResolvedSizes; size: Size;
     positioned: RelativeRect; computed: CSSValues; lctx: LayoutContext) =
+  let paddingSum = sizes.padding[dtVertical].sum()
   if computed{"height"}.u == clAuto:
-    let u = max(size.w - positioned[dtVertical].sum(), 0)
+    let u = max(size.h - positioned[dtVertical].sum(), 0)
     if computed{"top"}.u != clAuto and computed{"bottom"}.u != clAuto:
       # Both top and bottom are known, so we can calculate the height.
       # Well, but subtract padding and margin first.
-      sizes.space.h = stretch(u - sizes.padding[dtVertical].sum() -
-        sizes.margin[dtVertical].sum())
+      sizes.space.h = stretch(u - paddingSum - sizes.margin[dtVertical].sum())
     else:
       # The height is based on the content.
       sizes.space.h = maxContent()
   else:
-    let sizepx = computed{"height"}.spx(stretch(size.h), computed,
-      sizes.padding[dtVertical].sum())
+    let sizepx = computed{"height"}.spx(stretch(size.h), computed, paddingSum)
     sizes.space.h = stretch(sizepx)
 
 # Calculate and resolve available width & height for absolutely positioned