I'm pretty close to have `async` support done for the mozPrintCallback, but I'm 
stuck with a problem that I don't know how to solve best.

Here is some very basic background to understand my problem:

- I've implemented a new function 
`nsSimplePageSequenceFrame::PrePrintNextPage()` that is called from the 
nsPrintEngine/nsPagePrintTimer to deter if the current page is ready for 
printing. If the function returns `true`, 
nsSimplePageSequenceFrame::PrintNextPage() is executed that does the actual 
printing to the page.
- PrePrintNextPage does the canvas-surface-replacement to replace the pixel 
based surface by a vector one that is used for printing. If there are no canvas 
with a mozPrintCallback or the page doesn't get printed, it returns true. 
Otherwise, it waits until on all canvas with a mozPrintCallback the `done()` 
function is called.

[I have the two current function PrePrintNextPage() and PrintNextPage() here: 
https://gist.github.com/2483955#L611]

The problem is now in the "canvas-surface-replacement": The 
"renderingSurface->CreateSimilarSurface()" function call only returns  a 
vector-based surface iff "dc->BeginPage()" was called at least once before. 
However, for the first page, this is not the case (as "PrePrintNextPage()" is 
called before "PrintNextPage()", which does the call to dc->BeginPage()).

An easy solution might be to "move all the code from the beginning of 
`PrintNextPage` until the dc->BeginPage() into the "PrePrintNextPage()" 
function. Then, before a similar surface is created, a dc->BeginPage() call 
already happened. To do this, I need some more clarification on this code:

    
http://mxr.mozilla.org/mozilla-central/source/layout/generic/nsSimplePageSequence.cpp#620

* can PresContext()->IsRootPaginatedDocument() be false at any time? The 
`PrintNextPage()` function is only called for printing to paper - it's not 
called for preview. Therefore, the PresContext is always a paginatedDocument?
* the function might call `dc->BeginPage()` multiple times. Shouldn't this 
function add only one page to the output? Is this a bug or a feature?
* was this code in "PrintNextPage()" used once for rendering the preview window 
output as well (which is longer the case if I read the code right)? Are the two 
points I've listed above left over from sharing the same function and can be 
removed now?

 Best,

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

Reply via email to