diff options
author | bptato <nincsnevem662@gmail.com> | 2024-03-30 02:27:13 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-03-30 02:34:59 +0100 |
commit | 40e79dd4b42f4d93a8de8e24786e450b59ddc4de (patch) | |
tree | db6b29558c2aaaea3e7a2e80c61e155587e61ae0 | |
parent | b3cf0be08e9b67361d307e463a907a6b4d35a859 (diff) | |
download | chawan-40e79dd4b42f4d93a8de8e24786e450b59ddc4de.tar.gz |
layout: fix float positioning with margins
Here we are restricting the float to the same width constraint as its parent, so we must add offset.x both when the float is larger than this constraint *and* when the float fits into the constraint. An example of what this fixes: <div style="padding-left: 10em; background: green"> <div style="float: right; background: red"> wat ^ previously the float was positioned as if the padding had been on the *right*, because it did not take into account offset.x.
-rw-r--r-- | src/layout/engine.nim | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/layout/engine.nim b/src/layout/engine.nim index 79822cd0..66e0589b 100644 --- a/src/layout/engine.nim +++ b/src/layout/engine.nim @@ -1296,7 +1296,7 @@ func findNextFloatOffset(bctx: BlockContext; offset: Offset; size: Size; # Algorithm originally from QEmacs. var y = offset.y let leftStart = offset.x - let rightStart = max(offset.x + size.w, space.w.u) + let rightStart = offset.x + max(size.w, space.w.u) while true: var left = leftStart var right = rightStart |