diff options
-rw-r--r-- | src/layout/engine.nim | 5 | ||||
-rw-r--r-- | test/layout/float-with-margins.expected | 4 | ||||
-rw-r--r-- | test/layout/float-with-margins.html | 21 | ||||
-rw-r--r-- | test/layout/float_negative_margin.expected | 1 | ||||
-rw-r--r-- | test/layout/float_negative_margin.html | 13 |
5 files changed, 28 insertions, 16 deletions
diff --git a/src/layout/engine.nim b/src/layout/engine.nim index 89cfeab3..2fef28de 100644 --- a/src/layout/engine.nim +++ b/src/layout/engine.nim @@ -568,8 +568,9 @@ proc initLine(ictx: var InlineContext) = left = ex.offset.x + ex.size.w else: right = ex.offset.x - ictx.lbstate.size.w = left - bfcOffset.x - ictx.lbstate.availableWidth = right - bfcOffset.x + ictx.lbstate.size.w = max(left - bfcOffset.x, 0) + ictx.lbstate.availableWidth = min(right - bfcOffset.x, + ictx.lbstate.availableWidth) proc finishLine(ictx: var InlineContext; state: var InlineState; wrap: bool; force = false) = diff --git a/test/layout/float-with-margins.expected b/test/layout/float-with-margins.expected new file mode 100644 index 00000000..d45d0559 --- /dev/null +++ b/test/layout/float-with-margins.expected @@ -0,0 +1,4 @@ +testing aside +1 2 + 3 + 4 diff --git a/test/layout/float-with-margins.html b/test/layout/float-with-margins.html new file mode 100644 index 00000000..864a4e2b --- /dev/null +++ b/test/layout/float-with-margins.html @@ -0,0 +1,21 @@ +<!DOCTYPE html> +<html> +<body> +<div style="width: 20ch"> +<div style="float: left; width: 20ch"> +testing +</div> +<aside style="float: left; margin-right: -10ch"> +aside +</aside> +</div> +<br> +<!-- test if margins & padding do not get consumed after a float --> +<div style="float: left">1</div> +<div style="margin-left: 3ch; padding-left: 3ch"> +2<br> +3<br> +4 +</div> +</body> +</html> diff --git a/test/layout/float_negative_margin.expected b/test/layout/float_negative_margin.expected deleted file mode 100644 index 0b4af186..00000000 --- a/test/layout/float_negative_margin.expected +++ /dev/null @@ -1 +0,0 @@ -testing aside diff --git a/test/layout/float_negative_margin.html b/test/layout/float_negative_margin.html deleted file mode 100644 index 70dcfa0c..00000000 --- a/test/layout/float_negative_margin.html +++ /dev/null @@ -1,13 +0,0 @@ -<!DOCTYPE html> -<html> -<body> -<div style="width: 200px"> -<div style="float: left; width: 200px"> -testing -</div> -<aside style="float: left;margin-right: -100px;"> -aside -</aside> -</div> -</body> -</html> |