Bug 1426087: Decrement nsDocumentViewer::mDestroyRefCount in a separate function. r=jwatt

This commit is contained in:
Bob Owen 2018-01-12 10:17:36 +00:00
Родитель 606547c9c7
Коммит 0521695fbd
3 изменённых файлов: 10 добавлений и 9 удалений

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

@ -1675,7 +1675,6 @@ nsDocumentViewer::Destroy()
// We also keep the viewer from being cached in session history, since
// we require all documents there to be sanitized.
if (mDestroyRefCount != 0) {
--mDestroyRefCount;
return NS_OK;
}
@ -4472,6 +4471,12 @@ nsDocumentViewer::IncrementDestroyRefCount()
++mDestroyRefCount;
}
void
nsDocumentViewer::DecrementDestroyRefCount()
{
--mDestroyRefCount;
}
//------------------------------------------------------------
#if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW)

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

@ -42,6 +42,7 @@ public:
virtual mozilla::StyleSetHandle CreateStyleSet(nsIDocument* aDocument) = 0;
virtual void IncrementDestroyRefCount() = 0;
virtual void DecrementDestroyRefCount() = 0;
virtual void ReturnToGalleyPresentation() = 0;
@ -76,6 +77,7 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIDocumentViewerPrint,
bool GetIsPrintPreview() override; \
mozilla::StyleSetHandle CreateStyleSet(nsIDocument* aDocument) override; \
void IncrementDestroyRefCount() override; \
void DecrementDestroyRefCount() override; \
void ReturnToGalleyPresentation() override; \
void OnDonePrinting() override; \
bool IsInitializedForPrintPreview() override; \

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

@ -17,14 +17,8 @@ NS_IMPL_ISUPPORTS_INHERITED(nsPagePrintTimer, mozilla::Runnable, nsITimerCallbac
nsPagePrintTimer::~nsPagePrintTimer()
{
// "Destroy" the document viewer; this normally doesn't actually
// destroy it because of the IncrementDestroyRefCount call below
// XXX This is messy; the document viewer should use a single approach
// to keep itself alive during printing
nsCOMPtr<nsIContentViewer> cv(do_QueryInterface(mDocViewerPrint));
if (cv) {
cv->Destroy();
}
// This matches the IncrementDestroyRefCount call in the constructor.
mDocViewerPrint->DecrementDestroyRefCount();
}
nsresult