Bug 1776074 part 4: Use references instead of pointers for nsPrintObject::Init's Document and nsDocShell args (and in callers). r=emilio

This patch doesn't change behavior. It just changes to c++ reference types and
code-comments to indicate where we know that pointers have been null-checked
(and removes some null-checks that now become trivially-unnecessary).

I've added code-comments to justify why we know these args are non-null.
Generally, `nsPrintObject::Init`'s args are null-checked by the caller, except
in one case (in `nsPrintJob::DoCommonPrint`) where the Document* pointer in
question was _not_ directly null-checked by the caller. But fortunately, it is
null-checked earlier, higher up in the call-stack.  So, this patch simply
propagates the C++ reference type-conversion up to that point for additional
clarity.

Differential Revision: https://phabricator.services.mozilla.com/D150078
This commit is contained in:
Daniel Holbert
2022-06-23 22:56:59 +00:00
parent 2578254c73
commit 574940c643
5 changed files with 26 additions and 22 deletions

View File

@@ -2934,7 +2934,9 @@ nsDocumentViewer::Print(nsIPrintSettings* aPrintSettings,
}
mPrintJob = printJob;
rv = printJob->Print(mDocument, aPrintSettings, aRemotePrintJob,
// Note: mDocument was null-checked earlier in this function.
rv = printJob->Print(*mDocument, aPrintSettings, aRemotePrintJob,
aWebProgressListener);
if (NS_WARN_IF(NS_FAILED(rv))) {
OnDonePrinting();
@@ -2979,7 +2981,8 @@ nsDocumentViewer::PrintPreview(nsIPrintSettings* aPrintSettings,
}
mPrintJob = printJob;
rv = printJob->PrintPreview(doc, aPrintSettings, aWebProgressListener,
// Note: doc is known-non-null via NS_ENSURE_STATE null-check above.
rv = printJob->PrintPreview(*doc, aPrintSettings, aWebProgressListener,
std::move(aCallback));
if (NS_WARN_IF(NS_FAILED(rv))) {
OnDonePrinting();