diff options
| -rw-r--r-- | src/css/layout.nim | 12 | ||||
| -rw-r--r-- | test/layout/absolute-size-depends-on-float-sibling.color.expected | 2 | ||||
| -rw-r--r-- | test/layout/absolute-size-depends-on-float-sibling.html | 4 |
3 files changed, 15 insertions, 3 deletions
diff --git a/src/css/layout.nim b/src/css/layout.nim index 1629e457..0e0edb88 100644 --- a/src/css/layout.nim +++ b/src/css/layout.nim @@ -1293,7 +1293,6 @@ proc popPositioned(lctx: LayoutContext; size: Size) = let item = lctx.positioned.pop() for it in item.queue: let child = it.child - lctx.pushPositioned() var positioned: RelativeRect var size = size #TODO this is very ugly. @@ -1325,7 +1324,6 @@ proc popPositioned(lctx: LayoutContext; size: Size) = sizes.margin.bottom else: child.state.offset.y += sizes.margin.top - lctx.popPositioned(child.state.size) proc queueAbsolute(lctx: LayoutContext; box: BlockBox; offset: Offset) = case box.computed{"position"} @@ -1557,7 +1555,15 @@ proc layoutFlow(bctx: var BlockContext; box: BlockBox; sizes: ResolvedSizes; # Reset parentBps to the previous node. bctx.parentBps = fstate.prevParentBps if box.computed{"position"} != PositionStatic: - bctx.lctx.popPositioned(box.state.size) + var size = box.state.size + if bctx.parentBps == nil: + # We have a bit of an ordering problem here: layoutRootBlock + # computes our final height, but we already want to pop the + # positioned box here. + # I'll just replicate what layoutRootBlock is doing until I find a + # better solution... + size.h = max(size.h, bctx.maxFloatHeight) + bctx.lctx.popPositioned(size) proc layoutListItem(bctx: var BlockContext; box: BlockBox; sizes: ResolvedSizes) = diff --git a/test/layout/absolute-size-depends-on-float-sibling.color.expected b/test/layout/absolute-size-depends-on-float-sibling.color.expected new file mode 100644 index 00000000..ace9adb1 --- /dev/null +++ b/test/layout/absolute-size-depends-on-float-sibling.color.expected @@ -0,0 +1,2 @@ +[48;2;255;0;0m [49m test +[48;2;255;0;0m [49m diff --git a/test/layout/absolute-size-depends-on-float-sibling.html b/test/layout/absolute-size-depends-on-float-sibling.html new file mode 100644 index 00000000..cf005c73 --- /dev/null +++ b/test/layout/absolute-size-depends-on-float-sibling.html @@ -0,0 +1,4 @@ +<!DOCTYPE html> +<div style="position: absolute; width: 10ch"> +<div style="float: right; margin-bottom: 1em">test</div> +<div style="position: absolute; background: red; width: 2ch; top: 0; bottom: 0"></div> |