author | Jonathan Watt <jwatt@jwatt.org> |
Fri, 26 Apr 2019 11:43:15 +0100 | |
changeset 473740 | 6001201d1ad7d7c5a2d2d28fdaeb82f25bb570ea |
parent 473739 | 1327c28c7bd14cf2b4e8de9e6e33b19d7514a7f7 |
child 473741 | 944f0cf988f6384155932ae0048ac6b9d06636d8 |
push id | 113106 |
push user | jwatt@jwatt.org |
push date | Tue, 14 May 2019 15:00:14 +0000 |
treeherder | mozilla-inbound@944f0cf988f6 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | bobowen |
bugs | 1551538 |
milestone | 68.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
layout/printing/nsPrintJob.cpp | file | annotate | diff | comparison | revisions | |
layout/printing/nsPrintJob.h | file | annotate | diff | comparison | revisions |
--- a/layout/printing/nsPrintJob.cpp +++ b/layout/printing/nsPrintJob.cpp @@ -1882,22 +1882,22 @@ nsresult nsPrintJob::InitPrintDocConstru // So, we should grab it with local variable. RefPtr<nsPrintData> printData = mPrt; rv = ReflowDocList(printData->mPrintObject, DoSetPixelScale()); NS_ENSURE_SUCCESS(rv, rv); FirePrintPreviewUpdateEvent(); if (mLoadCounter == 0) { - AfterNetworkPrint(aHandleError); + ResumePrintAfterResourcesLoaded(aHandleError); } return rv; } -nsresult nsPrintJob::AfterNetworkPrint(bool aHandleError) { +nsresult nsPrintJob::ResumePrintAfterResourcesLoaded(bool aCleanupOnError) { // If Destroy() has already been called, mPtr is nullptr. Then, the instance // needs to do nothing anymore in this method. // Note: it shouldn't be possible for mPrt->mPrintObject to be null; we // just check it for good measure, as we check its owner. // Note: it shouldn't be possible for mPrt->mPrintObject->mDocShell to be // null; we just check it for good measure, as we check its owner. if (!mPrt || NS_WARN_IF(!mPrt->mPrintObject) || NS_WARN_IF(!mPrt->mPrintObject->mDocShell)) { @@ -1913,19 +1913,19 @@ nsresult nsPrintJob::AfterNetworkPrint(b nsresult rv; if (mIsDoingPrinting) { rv = DocumentReadyForPrinting(); } else { rv = FinishPrintPreview(); } /* cleaup on failure + notify user */ - if (aHandleError && NS_FAILED(rv)) { + if (aCleanupOnError && NS_FAILED(rv)) { NS_WARNING_ASSERTION(rv == NS_ERROR_ABORT, - "nsPrintJob::AfterNetworkPrint failed"); + "nsPrintJob::ResumePrintAfterResourcesLoaded failed"); CleanupOnFailure(rv, !mIsDoingPrinting); } return rv; } //////////////////////////////////////////////////////////////////////////////// // nsIWebProgressListener @@ -1942,17 +1942,17 @@ nsPrintJob::OnStateChange(nsIWebProgress ++mLoadCounter; } else if (aStateFlags & STATE_STOP) { mDidLoadDataForPrinting = true; --mLoadCounter; // If all resources are loaded, then do a small timeout and if there // are still no new requests, then another reflow. if (mLoadCounter == 0) { - AfterNetworkPrint(true); + ResumePrintAfterResourcesLoaded(/* aCleanupOnError */ true); } } return NS_OK; } NS_IMETHODIMP nsPrintJob::OnProgressChange(nsIWebProgress* aWebProgress, nsIRequest* aRequest, int32_t aCurSelfProgress, int32_t aMaxSelfProgress,
--- a/layout/printing/nsPrintJob.h +++ b/layout/printing/nsPrintJob.h @@ -195,17 +195,26 @@ class nsPrintJob final : public nsIObser nsresult DoCommonPrint(bool aIsPrintPreview, nsIPrintSettings* aPrintSettings, nsIWebProgressListener* aWebProgressListener, mozilla::dom::Document* aDoc); void FirePrintCompletionEvent(); void DisconnectPagePrintTimer(); - nsresult AfterNetworkPrint(bool aHandleError); + /** + * This method is called to resume printing after all outstanding resources + * referenced by the static clone have finished loading. (It is possibly + * called synchronously if there are no resources to load.) While a static + * clone will generally just be able to reference the (already loaded) + * resources that the original document references, the static clone may + * reference additional resources that have not previously been loaded + * (if it has a 'print' style sheet, for example). + */ + nsresult ResumePrintAfterResourcesLoaded(bool aCleanupOnError); nsresult SetRootView(nsPrintObject* aPO, bool& aDoReturn, bool& aDocumentIsTopLevel, nsSize& aAdjSize); nsView* GetParentViewForRoot(); bool DoSetPixelScale(); void UpdateZoomRatio(nsPrintObject* aPO, bool aSetPixelScale); MOZ_CAN_RUN_SCRIPT_BOUNDARY nsresult ReconstructAndReflow(bool aDoSetPixelScale);