diff options
Diffstat (limited to 'src/css')
| -rw-r--r-- | src/css/layout.nim | 2 | ||||
| -rw-r--r-- | src/css/render.nim | 12 |
2 files changed, 11 insertions, 3 deletions
diff --git a/src/css/layout.nim b/src/css/layout.nim index fe5afdcc..2e1fcd03 100644 --- a/src/css/layout.nim +++ b/src/css/layout.nim @@ -1599,7 +1599,7 @@ proc addInlineImage(ictx: var InlineContext; state: var InlineState; let atom = InlineAtom( t: iatImage, bmp: bmp, - size: size(w = int(bmp.width), h = int(bmp.height)) #TODO overflow + size: size(w = bmp.width, h = bmp.height) #TODO overflow ) let computed = state.fragment.computed let lctx = ictx.lctx diff --git a/src/css/render.nim b/src/css/render.nim index 8e8185dc..d7d57e35 100644 --- a/src/css/render.nim +++ b/src/css/render.nim @@ -230,6 +230,8 @@ type PosBitmap* = ref object x*: int y*: int + offx*: int + offy*: int width*: int height*: int bmp*: NetworkBitmap @@ -367,9 +369,15 @@ proc renderInlineFragment(grid: var FlexibleGrid; state: var RenderState; # "paint" background, i.e. add formatting (but don't actually color it) grid.paintBackground(state, defaultColor, x1, y1, x2, y2, fragment.node, noPaint = true) + let x = (offset.x div state.attrs.ppc).toInt + let y = (offset.y div state.attrs.ppl).toInt + let offx = (offset.x - x.toLayoutUnit * state.attrs.ppc).toInt + let offy = (offset.y - y.toLayoutUnit * state.attrs.ppl).toInt state.images.add(PosBitmap( - x: (offset.x div state.attrs.ppc).toInt, - y: (offset.y div state.attrs.ppl).toInt, + x: x, + y: y, + offx: offx, + offy: offy, width: atom.size.w.toInt, height: atom.size.h.toInt, bmp: atom.bmp |