From e04dd6678d392e79c214e2037448301c409815a2 Mon Sep 17 00:00:00 2001 From: Jonathan Watt Date: Tue, 9 Jan 2018 22:21:53 +0000 Subject: [PATCH] Bug 1430682 - Use OwningNonNull for nsPagePrintTimer::mDocViewerPrint and remove null checks. r=bobowen MozReview-Commit-ID: 5CPaYTA2PrC --- layout/printing/nsPagePrintTimer.cpp | 32 +++++++++++++--------------- layout/printing/nsPagePrintTimer.h | 7 +++--- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/layout/printing/nsPagePrintTimer.cpp b/layout/printing/nsPagePrintTimer.cpp index ba28020ee5ce..411a748ceba0 100644 --- a/layout/printing/nsPagePrintTimer.cpp +++ b/layout/printing/nsPagePrintTimer.cpp @@ -140,24 +140,22 @@ nsPagePrintTimer::Notify(nsITimer *timer) } } - if (mDocViewerPrint) { - bool donePrePrint = true; - // Don't start to pre-print if we're waiting on the parent still. - if (mPrintJob && !mWaitingForRemotePrint) { - donePrePrint = mPrintJob->PrePrintPage(); - } - - if (donePrePrint && !mWaitingForRemotePrint) { - StopWatchDogTimer(); - // Pass nullptr here since name already was set in constructor. - mDocument->Dispatch(TaskCategory::Other, do_AddRef(this)); - } else { - // Start the watch dog if we're waiting for preprint to ensure that if any - // mozPrintCallbacks take to long we error out. - StartWatchDogTimer(); - } - + bool donePrePrint = true; + // Don't start to pre-print if we're waiting on the parent still. + if (mPrintJob && !mWaitingForRemotePrint) { + donePrePrint = mPrintJob->PrePrintPage(); } + + if (donePrePrint && !mWaitingForRemotePrint) { + StopWatchDogTimer(); + // Pass nullptr here since name already was set in constructor. + mDocument->Dispatch(TaskCategory::Other, do_AddRef(this)); + } else { + // Start the watch dog if we're waiting for preprint to ensure that if any + // mozPrintCallbacks take to long we error out. + StartWatchDogTimer(); + } + return NS_OK; } diff --git a/layout/printing/nsPagePrintTimer.h b/layout/printing/nsPagePrintTimer.h index 069007327de4..b37014a7b166 100644 --- a/layout/printing/nsPagePrintTimer.h +++ b/layout/printing/nsPagePrintTimer.h @@ -12,6 +12,7 @@ #include "nsIDocumentViewerPrint.h" #include "nsPrintObject.h" #include "mozilla/Attributes.h" +#include "mozilla/OwningNonNull.h" #include "nsThreadUtils.h" class nsPrintJob; @@ -33,7 +34,7 @@ public: uint32_t aDelay) : Runnable("nsPagePrintTimer") , mPrintJob(aPrintJob) - , mDocViewerPrint(aDocViewerPrint) + , mDocViewerPrint(*aDocViewerPrint) , mDocument(aDocument) , mDelay(aDelay) , mFiringCount(0) @@ -41,7 +42,7 @@ public: , mWatchDogCount(0) , mDone(false) { - MOZ_ASSERT(aDocument); + MOZ_ASSERT(aDocViewerPrint && aDocument); mDocViewerPrint->IncrementDestroyBlockedCount(); } @@ -71,7 +72,7 @@ private: void Fail(); nsPrintJob* mPrintJob; - nsCOMPtr mDocViewerPrint; + const mozilla::OwningNonNull mDocViewerPrint; nsCOMPtr mDocument; nsCOMPtr mTimer; nsCOMPtr mWatchDogTimer;