Re: WebPrintAPI Proposal
<julian.viereck <at> googlemail.com>
2012-04-16 21:00:46 GMT
While thinking about what a proposal to WHATWG about the printCallback-API should look like, I've came
across the following edgecases.
* the context passed to the mozPrintCallback function has a `canvas` property. I think this `canvas`
property should not exist on the mozPrintCallback passed in `ctx` and should return `undefined.
What should this canvas be? If it's the canvas of the print-document, performing operations like
`appendChild` to the HTML tree, that gets printed, can cause issues, as it's assumed that this tree is
static and can't change. On the other side, the `canvas` might refer to the canvas in the DOM, but this
canvas was removed in the meantime (= during the time frame the printing starts and the callback is called)
maybe .
Instead, I propose the second argument passed to the callback should contain the `width`, `height`, `id`
and `name` of the canvas as at the beginning of the printing process.
The usage of the mozPrintCallback might then look like this:
canvas.mozPrintCallback = function(ctx, obj) {
console.log(obj.width, obj.height, obj.id, obj.name);
// ...
}
* The current implementation sets the size of the rendering context to the size of the actual canvas on the
screen if in preview. The canvas context is then scaled, such that the behavior of the canvas context
"feels" the same in normal DOM usage. While this works, this might cause problems when using
`getImageData` on the canvas.
Imagine the print preview has a zoom set to 10%. If the canvas has normally a width of 100px, it might now only
have 10px in preview. The internal used context of the canvas is then only 10px in width, but if the user
requests imageData with width 50px, this gets mapped down to 5px (due to internal scaling). But then the
(Continue reading)