aboutsummaryrefslogtreecommitdiffstats
path: root/src/layout/engine.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-11-02 17:05:13 +0100
committerbptato <nincsnevem662@gmail.com>2024-11-02 17:07:08 +0100
commit32391be24d45184b3bba3df6989037cab36f9269 (patch)
treea78e450fd3ff270d41ac5d71ae5f451ee3598dcf /src/layout/engine.nim
parentbdb953704fa8ad56babf1e6935281aa7c18f5cd3 (diff)
downloadchawan-32391be24d45184b3bba3df6989037cab36f9269.tar.gz
layout: remove inline rounding
It broke styles like "margin-top: -5px; padding-top: 5px", because the margin would be taken as-is, and the padding rounded to 0. Now they cancel each other out again. (I think I had added this to reduce error caused by line-height, but we don't have line-height anymore.)
Diffstat (limited to 'src/layout/engine.nim')
-rw-r--r--src/layout/engine.nim5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/layout/engine.nim b/src/layout/engine.nim
index 9f176437..4c1fcc28 100644
--- a/src/layout/engine.nim
+++ b/src/layout/engine.nim
@@ -454,7 +454,7 @@ proc shiftAtoms(ictx: var InlineContext; marginTop: LayoutUnit) =
let offsetyShifted = shiftTop + offsety
var areaY: LayoutUnit = 0
for i, atom in ictx.lbstate.atoms:
- atom.offset.y = (atom.offset.y + offsetyShifted).round(cellHeight)
+ atom.offset.y = atom.offset.y + offsetyShifted
areaY = max(atom.offset.y, areaY)
#TODO why not offsetyShifted here?
let minHeight = atom.offset.y - offsety + atom.size.h
@@ -513,12 +513,11 @@ proc alignLine(ictx: var InlineContext) =
let ch = ictx.cellHeight.toLayoutUnit()
ictx.lbstate.size.h = ch
# Baseline is what we computed in addAtom, or cell height if that's greater.
- ictx.lbstate.baseline = max(ictx.lbstate.baseline, ch).round(ictx.cellHeight)
+ ictx.lbstate.baseline = max(ictx.lbstate.baseline, ch)
# Resize according to the baseline and atom sizes.
ictx.lbstate.size.h = ictx.lbstate.resizeLine(ictx.lctx)
# Now we can calculate the actual position of atoms inside the line.
let marginTop = ictx.lbstate.positionAtoms(ictx.lctx)
- #TODO this does not really work with rounding :/
ictx.lbstate.baseline += ictx.lbstate.paddingTop
# Finally, offset all atoms' y position by the largest top margin and the
# line box's top padding.