mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-28 21:28:55 +00:00
Bug 1655179 - Don't attach a progress listener until we've started to set up the print presentation. r=smaug
This is afaict a pre-existing (conceptual) issue before my patch, but it was only theoretical because @font-face loads are triggered from styling / layout, so we wouldn't trigger them until we initialize the document. The print setup may be asynchronous (via nsPrintJob::Observe -> InitPrintDocConstruction -> ReflowDocList). If we get the load event sooner than that, then we'd try to start printing before we've ever called ReflowDocList which is what sets everything up. Thus we'd assert in debug builds here: https://searchfox.org/mozilla-central/rev/828f2319c0195d7f561ed35533aef6fe183e68e3/layout/printing/nsPrintJob.cpp#1453-1457 And crash in ReconstructAndReflow in release builds. We don't care about what goes on before we start setting up the presentation of the document, so defer setting up the web-progress-listener until we do that. Differential Revision: https://phabricator.services.mozilla.com/D84905
This commit is contained in:
parent
305d2fd10d
commit
e925bb5087
@ -908,14 +908,6 @@ nsresult nsPrintJob::DoCommonPrint(bool aIsPrintPreview,
|
||||
|
||||
MOZ_TRY(EnablePOsForPrinting());
|
||||
|
||||
// Attach progressListener to catch network requests.
|
||||
mDidLoadDataForPrinting = false;
|
||||
|
||||
nsCOMPtr<nsIWebProgress> webProgress =
|
||||
do_QueryInterface(printData->mPrintObject->mDocShell);
|
||||
webProgress->AddProgressListener(static_cast<nsIWebProgressListener*>(this),
|
||||
nsIWebProgress::NOTIFY_STATE_REQUEST);
|
||||
|
||||
if (mIsCreatingPrintPreview) {
|
||||
bool notifyOnInit = false;
|
||||
ShowPrintProgress(false, notifyOnInit);
|
||||
@ -1676,6 +1668,14 @@ nsresult nsPrintJob::InitPrintDocConstruction(bool aHandleError) {
|
||||
// So, we should grab it with local variable.
|
||||
RefPtr<nsPrintData> printData = mPrt;
|
||||
|
||||
// Attach progressListener to catch network requests.
|
||||
mDidLoadDataForPrinting = false;
|
||||
|
||||
nsCOMPtr<nsIWebProgress> webProgress =
|
||||
do_QueryInterface(printData->mPrintObject->mDocShell);
|
||||
webProgress->AddProgressListener(static_cast<nsIWebProgressListener*>(this),
|
||||
nsIWebProgress::NOTIFY_STATE_REQUEST);
|
||||
|
||||
MOZ_TRY(ReflowDocList(printData->mPrintObject, DoSetPixelScale()));
|
||||
|
||||
FirePrintPreviewUpdateEvent();
|
||||
|
Loading…
x
Reference in New Issue
Block a user