Bug 1661137 - Decrement the document viewer's destroy blocker earlier. r=bobowen

Do it as soon as we're done printing, rather than waiting until the
print timer dies.

Differential Revision: https://phabricator.services.mozilla.com/D88569
This commit is contained in:
Emilio Cobos Álvarez 2020-08-28 11:33:18 +00:00
Родитель 171d05204b
Коммит 1e6084fb60
3 изменённых файлов: 14 добавлений и 11 удалений

Просмотреть файл

@ -14,9 +14,16 @@ using namespace mozilla;
NS_IMPL_ISUPPORTS_INHERITED(nsPagePrintTimer, mozilla::Runnable,
nsITimerCallback)
nsPagePrintTimer::~nsPagePrintTimer() {
// This matches the IncrementDestroyBlockedCount call in the constructor.
mDocViewerPrint->DecrementDestroyBlockedCount();
nsPagePrintTimer::~nsPagePrintTimer() { Disconnect(); }
void nsPagePrintTimer::Disconnect() {
mPrintJob = nullptr;
mPrintObj = nullptr;
if (mDocViewerPrint) {
// This matches the IncrementDestroyBlockedCount call in the constructor.
mDocViewerPrint->DecrementDestroyBlockedCount();
mDocViewerPrint = nullptr;
}
}
nsresult nsPagePrintTimer::StartTimer(bool aUseDelay) {

Просмотреть файл

@ -30,7 +30,7 @@ class nsPagePrintTimer final : public mozilla::Runnable,
mozilla::dom::Document* aDocument, uint32_t aDelay)
: Runnable("nsPagePrintTimer"),
mPrintJob(aPrintJob),
mDocViewerPrint(*aDocViewerPrint),
mDocViewerPrint(aDocViewerPrint),
mDocument(aDocument),
mDelay(aDelay),
mFiringCount(0),
@ -52,10 +52,7 @@ class nsPagePrintTimer final : public mozilla::Runnable,
void WaitForRemotePrint();
void RemotePrintFinished();
void Disconnect() {
mPrintJob = nullptr;
mPrintObj = nullptr;
}
void Disconnect();
private:
~nsPagePrintTimer();
@ -66,7 +63,7 @@ class nsPagePrintTimer final : public mozilla::Runnable,
void Fail();
nsPrintJob* mPrintJob;
const mozilla::OwningNonNull<nsIDocumentViewerPrint> mDocViewerPrint;
nsCOMPtr<nsIDocumentViewerPrint> mDocViewerPrint;
RefPtr<mozilla::dom::Document> mDocument;
nsCOMPtr<nsITimer> mTimer;
nsCOMPtr<nsITimer> mWatchDogTimer;

Просмотреть файл

@ -2556,9 +2556,8 @@ nsresult nsPrintJob::StartPagePrintTimer(const UniquePtr<nsPrintObject>& aPO) {
nsCOMPtr<Document> doc = cv->GetDocument();
NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
RefPtr<nsPagePrintTimer> timer =
mPagePrintTimer =
new nsPagePrintTimer(this, mDocViewerPrint, doc, printPageDelay);
timer.forget(&mPagePrintTimer);
nsCOMPtr<nsIPrintSession> printSession;
nsresult rv =