aboutsummaryrefslogtreecommitdiffstats
path: root/src/layout
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-07-25 23:10:32 +0200
committerbptato <nincsnevem662@gmail.com>2023-07-25 23:10:32 +0200
commitab7545d90ea7d45764d8358c32f719f40a050cda (patch)
treeb6c14289d038a9f81a61a220344f45b7efe9db8e /src/layout
parent1a4e10ad5e9145b39f95f42b52db8b720fa25354 (diff)
downloadchawan-ab7545d90ea7d45764d8358c32f719f40a050cda.tar.gz
layout: fix superfluous inline whitespace
computeShift now checks if the last inline atom is spacing, and if yes, it does not add more spacing. This fixes rendering of the following document: <span> a </span> <span> b </span>
Diffstat (limited to 'src/layout')
-rw-r--r--src/layout/engine.nim4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/layout/engine.nim b/src/layout/engine.nim
index 20793cbc..2498da49 100644
--- a/src/layout/engine.nim
+++ b/src/layout/engine.nim
@@ -80,7 +80,9 @@ func cellheight(ictx: InlineContext): LayoutUnit =
func computeShift(ictx: InlineContext, computed: CSSComputedValues):
LayoutUnit =
if ictx.whitespacenum > 0:
- if ictx.currentLine.atoms.len > 0 or computed.whitespacepre:
+ if ictx.currentLine.atoms.len > 0 and
+ not (ictx.currentLine.atoms[^1] of InlineSpacing) or
+ computed.whitespacepre:
let spacing = computed{"word-spacing"}
if spacing.auto:
return ictx.cellwidth * ictx.whitespacenum