From 32391be24d45184b3bba3df6989037cab36f9269 Mon Sep 17 00:00:00 2001 From: bptato Date: Sat, 2 Nov 2024 17:05:13 +0100 Subject: 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.) --- src/layout/engine.nim | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/layout/engine.nim') 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. -- cgit