about summary refs log tree commit diff stats
path: root/src/layout
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-03-02 04:00:16 +0100
committerbptato <nincsnevem662@gmail.com>2024-03-02 04:06:20 +0100
commitce95d6c7648c17885daba80b042b36d800e89b34 (patch)
tree4ccb38a425d165355fa154a85e9eb30cc7092e93 /src/layout
parent77e252b77463696880f1584890c2d95a6a34c377 (diff)
downloadchawan-ce95d6c7648c17885daba80b042b36d800e89b34.tar.gz
layout: fix float exclusion of other floats
> The right outer edge of a left-floating box may not be to the right
> of the left outer edge of any right-floating box that is next to
> it. Analogous rules hold for right-floating elements.

says the standard

therefore it does not really matter where the beginning of the float is;
if it's float: left, then `left' must be set to the right edge, and if
it's float: right, then `right' must be set to the left edge.

(this was breaking some negative margin float abominations such that
floats were suddenly overlapping and that's certainly not what we want)
Diffstat (limited to 'src/layout')
-rw-r--r--src/layout/engine.nim4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/layout/engine.nim b/src/layout/engine.nim
index 7e65bac6..28ade1c5 100644
--- a/src/layout/engine.nim
+++ b/src/layout/engine.nim
@@ -1229,9 +1229,9 @@ func findNextFloatOffset(bctx: BlockContext, offset: Offset, size: Size,
       let ey2 = ex.offset.y + ex.size.h
       if cy2 >= ex.offset.y and y < ey2:
         let ex2 = ex.offset.x + ex.size.w
-        if left + size.w >= ex.offset.x and left < ex2:
+        if ex.t == FLOAT_LEFT and left < ex2:
           left = ex2
-        if right + size.w > ex.offset.x and right <= ex2:
+        if ex.t == FLOAT_RIGHT and right > ex.offset.x:
           right = ex.offset.x
         miny = min(ey2, miny)
     if right - left >= size.w or miny == high(LayoutUnit):