diff options
author | bptato <nincsnevem662@gmail.com> | 2025-02-19 20:16:34 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2025-02-19 20:33:40 +0100 |
commit | 24bdc0f1f85192467526ccd7a6df2cdf7de2d0db (patch) | |
tree | f93803c019d520eba7fc099a2703b21fa6934cc6 | |
parent | 0014b67f76598ed1881d7c91a6bbbf1d70131c83 (diff) | |
download | chawan-24bdc0f1f85192467526ccd7a6df2cdf7de2d0db.tar.gz |
render: propagate offset to positioned block child before clip box inheritance
also, fix a typo
-rw-r--r-- | src/css/render.nim | 15 | ||||
-rw-r--r-- | test/layout/overflow-hidden-centered-inline-block.expected | 1 | ||||
-rw-r--r-- | test/layout/overflow-hidden-centered-inline-block.html | 5 | ||||
-rw-r--r-- | todo | 3 |
4 files changed, 16 insertions, 8 deletions
diff --git a/src/css/render.nim b/src/css/render.nim index d613fb9c..3065a5d6 100644 --- a/src/css/render.nim +++ b/src/css/render.nim @@ -424,7 +424,7 @@ proc inheritClipBox(box: BlockBox; parent: CSSBox) = clipBox.send.x = min(offset.x + box.state.size.w, clipBox.send.x) else: # scroll like clipBox.start.x = max(min(offset.x, clipBox.start.x), 0) - clipBox.send.x = max(offset.x + box.state.size.w, clipBox.start.x) + clipBox.send.x = max(offset.x + box.state.size.w, clipBox.send.x) if overflowY in OverflowHiddenLike: clipBox.start.y = max(offset.y, clipBox.start.y) clipBox.send.y = min(offset.y + box.state.size.h, clipBox.send.y) @@ -435,9 +435,9 @@ proc renderBlock(grid: var FlexibleGrid; state: var RenderState; if box.positioned and not pass2: return let offset = offset + box.state.offset - box.render.offset = offset - box.render.positioned = true if not pass2: + box.render.offset = offset + box.render.positioned = true box.inheritClipBox(box.parent) let opacity = box.computed{"opacity"} if box.computed{"visibility"} == VisibilityVisible and opacity != 0: @@ -493,7 +493,8 @@ proc resolveBlockParent(box: CSSBox): BlockBox = break it = it.parent var toPosition: seq[BlockBox] = @[] - let findPositioned = box.computed{"position"} in PositionAbsoluteFixed + let findPositioned = box.positioned and + box.computed{"position"} in PositionAbsoluteFixed var it2 {.cursor.} = it var parent {.cursor.}: CSSBox = nil while it2 != nil: @@ -516,7 +517,11 @@ proc resolveBlockParent(box: CSSBox): BlockBox = parent = it if box of BlockBox: let box = BlockBox(box) - box.render.clipBox = DefaultClipBox + box.render = BoxRenderState( + positioned: true, + offset: offset + box.state.offset, + clipBox: DefaultClipBox + ) if findPositioned: box.inheritClipBox(it2) else: diff --git a/test/layout/overflow-hidden-centered-inline-block.expected b/test/layout/overflow-hidden-centered-inline-block.expected new file mode 100644 index 00000000..fbf587ea --- /dev/null +++ b/test/layout/overflow-hidden-centered-inline-block.expected @@ -0,0 +1 @@ + test test test diff --git a/test/layout/overflow-hidden-centered-inline-block.html b/test/layout/overflow-hidden-centered-inline-block.html new file mode 100644 index 00000000..028fded6 --- /dev/null +++ b/test/layout/overflow-hidden-centered-inline-block.html @@ -0,0 +1,5 @@ +<!DOCTYPE html> +<div style="text-align: center; width: 30ch"> +<div style="position: relative; display: inline-block; overflow: hidden"> +<div> +test test test diff --git a/todo b/todo index c54696a9..dc012e55 100644 --- a/todo +++ b/todo @@ -92,8 +92,6 @@ layout: behavior, it's easier to just backpressure input - frame, iframe - z order - * for positioned it's almost perfect, but can't do negative - z-index * for images it's straight up broken - grid images: @@ -102,5 +100,4 @@ man: - add a DOM -> man page converter so that we do not depend on pandoc for man page conversion tests: -- network/XHR (make net test async?) - pager? (how?) |