diff options
author | bptato <nincsnevem662@gmail.com> | 2025-01-06 16:31:10 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2025-01-06 16:31:10 +0100 |
commit | e066acad98c510cfd9bd2593affcbb9673c93dca (patch) | |
tree | b2c3da955eb887ca8fc1ad880968650e18f4e7c7 /src | |
parent | 9ae109b366c7a933965ff506a7ce275a7abe71ed (diff) | |
download | chawan-e066acad98c510cfd9bd2593affcbb9673c93dca.tar.gz |
layout: wrap on inline floats that exceed the line's length
In this case, it seems we have to wrap. (It's still not quite there; replace flow-root with inline-box to see another interesting bug...)
Diffstat (limited to 'src')
-rw-r--r-- | src/css/layout.nim | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/css/layout.nim b/src/css/layout.nim index 2cbf5190..6fea80e3 100644 --- a/src/css/layout.nim +++ b/src/css/layout.nim @@ -1414,9 +1414,6 @@ proc layoutInline(bctx: var BlockContext; box: BlockBox; sizes: ResolvedSizes) = # rarely enough. let floats = move(ictx.unpositionedFloats) var space = sizes.space - #TODO there is still a bug here: if the parent's size is - # fit-content, then floats should trigger a re-layout in the - # *parent*. if space.w.t != scStretch: space.w = stretch(ictx.state.size.w) ictx = bctx.initInlineContext(space, bfcOffset, sizes.padding, box.computed) @@ -1493,12 +1490,15 @@ proc addInlineFloat(ictx: var InlineContext; state: var InlineState; box: BlockBox) = let lctx = ictx.lctx let sizes = lctx.resolveFloatSizes(ictx.space, box.computed) - box.state = BoxLayoutState() let offset = offset( x = sizes.margin.left, y = ictx.lbstate.offsety + sizes.margin.top ) lctx.layoutRootBlock(box, offset, sizes) + if ictx.space.w.t == scStretch and + ictx.lbstate.size.w + box.state.size.w > ictx.space.w.u: + ictx.finishLine(state, wrap = true) + box.state.offset.y = ictx.lbstate.offsety + sizes.margin.top ictx.lbstate.size.w += box.state.size.w # Note that by now, the top y offset is always resolved. ictx.unpositionedFloats.add(InlineUnpositionedFloat( |