On 03/18/2012 11:03 PM, [email protected] wrote:
On Sunday, March 18, 2012 6:59:14 PM UTC+1, smaug wrote:
On 03/15/2012 09:08 PM, [email protected] wrote:
   > Right now, execution of page JS is suspended for the course of the print
operation.  (Within the cloned document, that is.  Although there are
still comments within layout/printing that suggest that the
document-cloning project is incomplete.)  If we want to allow the UI to
process events *during* the painting of one page, your "paint this
canvas now" API is going to need some sort of interruptibility.  Off the
top of my head I don't know what that ought to look like.

If you say the JS is suspended, is it still able to call a callback on the 
canvas element that does the drawing while the print is taking place?


JS in the cloned document is suspended. JS in the cloned document never
runs. The callback would run in the original document, and possibly
update the cloned document (if needed).

If I get that picture right, here is what would happen during printing:

1) the document is cloned, printing is started on the cloned document
2) while printing the cloned document, a canvas element is detected
3) for this canvas in the cloned document, the canvas object in the original 
document is looked up
4) on the original canvas, it's checked if the canvas has a callback specified 
doing the special print drawing
5a) If true: this callback is called on the original document passing over a 
context that knows how to render directly to the printer
5b) If false: the canvas data as available in the cloned document is printed 
(like it is done right now)

For step 3, is it possible to find the corresponding "original" canvas based on 
the canvas in the cloned document?
Right now no, but that would be easy to add. Just add a member variable
to nsHTMLCanvasElement and make it point to the original element in
nsHTMLCanvasElement::CopyInnerTo

Is it possible to call a JS function on the original object like required in 
step 5a)?
That should be easy.


How much is this possible if the original document structure has changed 
already?
In general cloned document doesn't really care about the original
document. That was the reason for cloning; original document can
continue to execute JS etc, and clone will be printed.
So, if there is a strong reference from cloned canvas to the original,
everything should just work fine.



Also, the callback is called within the original document, that might have 
changed already compared to the cloned document.
This might be confusing for developers. Is this a problem or just something to 
tell the developers that this might be the case and it should be all fine?

We may want to add some new events, since afterprint fires too early
for this stuff. There could be some asyncronous afterprintprocessed event.

Or, hmm, could we add some mapping from canvas to callback, but not
really register the callback to canvas?
Something like:
window.setAlternativePrintHandler(somecanvasElement, callback);
Then define that so that right after beforeprint event the callback is
stored in a list which will be called during printing, regardless
whether the original canvas is in the document anymore.


_______________________________________________
dev-tech-layout mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-layout

Reply via email to