diff options
author | bptato <nincsnevem662@gmail.com> | 2023-07-27 17:24:49 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-07-27 17:24:49 +0200 |
commit | 1e0506adb18b38fb7b187a4d81e39b8d6a1e23a4 (patch) | |
tree | cc2aa3d6a936405abf4169659619ff26b25c813e /src | |
parent | cc1f9deac1b671e8d8c4956d8f14ce24bc0fdc9d (diff) | |
download | chawan-1e0506adb18b38fb7b187a4d81e39b8d6a1e23a4.tar.gz |
layout: do not treat inline padding as spacing
So e.g. padding: 1px does not inhibit automatic addition of spaces for inline blocks.
Diffstat (limited to 'src')
-rw-r--r-- | src/layout/engine.nim | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/layout/engine.nim b/src/layout/engine.nim index 9f4eff0a..812c05e8 100644 --- a/src/layout/engine.nim +++ b/src/layout/engine.nim @@ -892,8 +892,9 @@ proc buildInline(ictx: InlineContext, box: InlineBoxBuilder) = let padding_left = box.computed{"padding-left"}.px(ictx.viewport, ictx.availableWidth) - if padding_left > 0: - ictx.currentLine.addSpacing(padding_left, ictx.cellheight, paddingformat) + # Padding should not be treated as whitespace, so we just increase line + # width instead of adding fake spacing. + ictx.currentLine.width += padding_left assert not (box.children.len > 0 and box.text.len > 0) for text in box.text: @@ -917,9 +918,9 @@ proc buildInline(ictx: InlineContext, box: InlineBoxBuilder) = if box.splitend: let padding_right = box.computed{"padding-right"}.px(ictx.viewport, ictx.availableWidth) - if padding_right > 0: - ictx.currentLine.addSpacing(padding_right, - max(ictx.currentLine.height, 1), paddingformat) + # Padding should not be treated as whitespace, so we just increase line + # width instead of adding fake spacing. + ictx.currentLine.width += padding_right let margin_right = box.computed{"margin-right"}.px(ictx.viewport, ictx.availableWidth) ictx.currentLine.width += margin_right |