Bug 1399787 - Part 12. Delay dispatching FinalizePrint message until the last page was processed. r=jwatt

For the last page, here is the final three messages sent between the content
process, RemotePrintJobChild, and the chrome process, RemotePrintJobParent, for
printing:
1. The content process sends *ProcessPage* to the chrome process via
   SendProcessPrint to request the chrome process print the last page.
2. The content process sends *FinalizePrint* to the chrome process via
   SendFinalizePrint to notify the chrome that there are no more outstanding
   print requests, and that the chrome process can release interal resource
   now.
3. The content process receive PageProcessed message from the chrome process.

This calling sequence is fine for sync style PrintTarget (even though the
FinalizePrint message is sent out a bit ealy). Since a sync PrintTarget
completes its print task right after receiving *ProcessPage* message in #1,
sending FinalizePrint before getting PageProcessed response is harmless.

But this message dispatching sequence does cause a problem for async style
PrintTargetEMF. After getting a message sent in #2, PrintTargetEMF release all
resources before getting a EMF conversion response from the PDFium process. So
the last page can not be printed correctly. This patch reorder the #2 and #3
message, that is to send FinalizePrint after the content process received
PageProcessed message of the last page.

MozReview-Commit-ID: 9ZVSrFnuHBU

--HG--
extra : rebase_source : 2b4f9efa1352f7255576ae7c688c5a3750b7db42
extra : source : 70ce23becf8840408cd72e7f933a167090519c09
This commit is contained in:
cku 2017-11-06 16:28:51 +08:00
parent 5ea0bb1b75
commit 3e848a98ac
2 changed files with 9 additions and 6 deletions

View File

@ -80,12 +80,9 @@ nsPagePrintTimer::Run()
// donePrinting will be true if it completed successfully or
// if the printing was cancelled
donePrinting = !mPrintEngine || mPrintEngine->PrintPage(mPrintObj, inRange);
if (donePrinting) {
// now clean up print or print the next webshell
if (!mPrintEngine || mPrintEngine->DonePrintingPages(mPrintObj, NS_OK)) {
initNewTimer = false;
mDone = true;
}
if (mPrintEngine && donePrinting) {
initNewTimer = false;
mDone = true;
}
// Note that the Stop() destroys this after the print job finishes
@ -181,6 +178,11 @@ nsPagePrintTimer::RemotePrintFinished()
return;
}
// now clean up print or print the next webshell
if (mDone && mPrintEngine) {
mPrintEngine->DonePrintingPages(mPrintObj, NS_OK);
}
mWaitingForRemotePrint->SetTarget(
mDocument->EventTargetFor(mozilla::TaskCategory::Other));
mozilla::Unused <<

View File

@ -2794,6 +2794,7 @@ nsPrintEngine::PrintPage(nsPrintObject* aPO,
bool isCancelled = false;
printData->mPrintSettings->GetIsCancelled(&isCancelled);
if (isCancelled || printData->mIsAborted) {
DonePrintingPages(aPO, NS_OK);
return true;
}