From d0e403c54d0bfced06e868f54af425906b98d588 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Sun, 21 Nov 2010 22:12:39 +0100 Subject: [PATCH] [broadway] Fix up scrolling --- gdk/broadway/broadway.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/gdk/broadway/broadway.js b/gdk/broadway/broadway.js index 7941c13fe4..4e5fbee140 100644 --- a/gdk/broadway/broadway.js +++ b/gdk/broadway/broadway.js @@ -179,6 +179,10 @@ function handleCommands(cmd_obj) var context = surfaces[id]; context.save(); + var minx; + var miny; + var maxx; + var maxy; for (var r = 0; r < nrects; r++) { var x = base64_16(cmd, i); i = i + 3; @@ -189,6 +193,22 @@ function handleCommands(cmd_obj) var h = base64_16(cmd, i); i = i + 3; context.rect(x, y, w, h); + + if (r == 0) { + minx = x; + miny = y; + maxx = x + w; + maxy = y + h; + } else { + if (x < minx) + minx = x; + if (y < miny) + miny = y; + if (x + w > maxx) + maxx = x + w; + if (y + h > maxy) + maxy = y + h; + } } context.clip() @@ -198,7 +218,9 @@ function handleCommands(cmd_obj) var dy = base64_16s(cmd, i); i = i + 3; - context.drawImage(context.canvas, dx, dy, context.canvas.width, context.canvas.height); + context.drawImage(context.canvas, + minx - dx, miny - dy, maxx - minx, maxy - miny, + minx, miny, maxx - minx, maxy - miny); context.restore(); break;