diff options
author | bptato <nincsnevem662@gmail.com> | 2023-06-10 23:46:12 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-06-10 23:49:13 +0200 |
commit | 3a18dbf932ed9d9595099c59d4e01d2915734e36 (patch) | |
tree | c36f3539fc1c0b6188ce40fd246152c1c7283946 | |
parent | f981b996808394cb46a4e154ba51525b6574fddf (diff) | |
download | chawan-3a18dbf932ed9d9595099c59d4e01d2915734e36.tar.gz |
Fix -cha-center moving by negative x
In other words, if the element is wider than it's container, we don't do anything at all.
-rw-r--r-- | src/layout/engine.nim | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/layout/engine.nim b/src/layout/engine.nim index edc6c2b2..b5da155e 100644 --- a/src/layout/engine.nim +++ b/src/layout/engine.nim @@ -832,12 +832,10 @@ proc applyChildPosition(parent, child: BlockBox, spec: bool, x, y: var int, marg proc postAlignChild(box, child: BlockBox, width: int, spec: bool) = case box.computed{"text-align"} of TEXT_ALIGN_CHA_CENTER: - child.offset.x += width div 2 - child.offset.x -= child.width div 2 + child.offset.x += max(width div 2 - child.width div 2, 0) of TEXT_ALIGN_CHA_LEFT: discard of TEXT_ALIGN_CHA_RIGHT: - child.offset.x += width - child.offset.x -= child.width + child.offset.x += max(width - child.width, 0) else: child.offset.x += child.margin_left |