aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2025-01-03 23:25:25 +0100
committerbptato <nincsnevem662@gmail.com>2025-01-03 23:25:25 +0100
commit9f7289b063eb863523e5a0d4cbe7c707b48af225 (patch)
tree33f4420ff44a956945ceaeb3de9c9f32f965c2f0
parente548f28c298abf5122d3f3af117b39f08e916d88 (diff)
downloadchawan-9f7289b063eb863523e5a0d4cbe7c707b48af225.tar.gz
layout: respect margin-top of root box
-rw-r--r--src/css/layout.nim2
-rw-r--r--test/layout/root-box-margin-respected.expected2
-rw-r--r--test/layout/root-box-margin-respected.html2
3 files changed, 5 insertions, 1 deletions
diff --git a/src/css/layout.nim b/src/css/layout.nim
index ff982b57..3a6b3bf5 100644
--- a/src/css/layout.nim
+++ b/src/css/layout.nim
@@ -3428,7 +3428,7 @@ proc layout*(root: StyledNode; attrsp: ptr WindowAttributes): BlockBox =
ctx.buildBlock()
let sizes = lctx.resolveBlockSizes(space, box.computed)
# the bottom margin is unused.
- lctx.layoutRootBlock(box, offset(x = 0, y = 0), sizes)
+ lctx.layoutRootBlock(box, offset(x = 0, y = sizes.margin.top), sizes)
var size = size(w = attrsp[].widthPx, h = attrsp[].heightPx)
# Last absolute layer.
lctx.popPositioned(size)
diff --git a/test/layout/root-box-margin-respected.expected b/test/layout/root-box-margin-respected.expected
new file mode 100644
index 00000000..46a4aa21
--- /dev/null
+++ b/test/layout/root-box-margin-respected.expected
@@ -0,0 +1,2 @@
+
+ test
diff --git a/test/layout/root-box-margin-respected.html b/test/layout/root-box-margin-respected.html
new file mode 100644
index 00000000..2486ac9b
--- /dev/null
+++ b/test/layout/root-box-margin-respected.html
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<html style="margin: 1em">test</html>