about summary refs log tree commit diff stats
path: root/src/layout/box.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-06-26 23:37:02 +0200
committerbptato <nincsnevem662@gmail.com>2024-06-27 00:00:48 +0200
commitf9734e2b3900781901bb5f268137bd9adbfc33ef (patch)
treead1cbd2b730c4504987e2d6dceecadce26c63df5 /src/layout/box.nim
parent274dffbd860f683027cbae62a6400e10687c8c35 (diff)
downloadchawan-f9734e2b3900781901bb5f268137bd9adbfc33ef.tar.gz
layout: inline fixes & improvements
* fix text-align breaking down in the presence of floats
* improve (and simplify) background color area painting

This greatly simplifies inline layout by removing the additional
text-align atom movement code and replacing it with a full re-layout
when needed. That re-layout only occurs in (rare) cases where the text
is likely to be relatively short anyway, so it's probably a win in any
remotely realistic layout.

This has also made it possible to at last merge the last three passes
(horizontal/vertical alignment and background painting) and drop that
weird synchronized tree + vector traversal.
Diffstat (limited to 'src/layout/box.nim')
-rw-r--r--src/layout/box.nim4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/layout/box.nim b/src/layout/box.nim
index 2c98aaed..4be02553 100644
--- a/src/layout/box.nim
+++ b/src/layout/box.nim
@@ -160,6 +160,10 @@ proc `+=`*(a: var Offset; b: Offset) =
   a.x += b.x
   a.y += b.y
 
+proc `-=`*(a: var Offset; b: Offset) =
+  a.x -= b.x
+  a.y -= b.y
+
 func left*(s: RelativeRect): LayoutUnit =
   return s[dtHorizontal].start