aboutsummaryrefslogtreecommitdiff
path: root/www/waterfox/files/patch-bug1426087
blob: abd09689e666b567adea9d8fe229964687b7c1eb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
commit 1b9a43c32852
Author: Bob Owen <bobowencode@gmail.com>
Date:   Fri Jan 12 10:17:36 2018 +0000

    Bug 1426087 - Decrement nsDocumentViewer::mDestroyRefCount in a separate function. r=jwatt, a=ritu
    
    --HG--
    extra : source : 86d41b5efe074f6988085082df9ef537eee0813a
---
 layout/base/nsDocumentViewer.cpp     |  7 ++++++-
 layout/base/nsIDocumentViewerPrint.h |  2 ++
 layout/printing/nsPagePrintTimer.cpp | 10 ++--------
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git layout/base/nsDocumentViewer.cpp layout/base/nsDocumentViewer.cpp
index 4fe03d3f7f88..58690001ad73 100644
--- layout/base/nsDocumentViewer.cpp
+++ layout/base/nsDocumentViewer.cpp
@@ -1665,7 +1665,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;
   }
 
@@ -4471,6 +4470,12 @@ nsDocumentViewer::IncrementDestroyRefCount()
   ++mDestroyRefCount;
 }
 
+void
+nsDocumentViewer::DecrementDestroyRefCount()
+{
+  --mDestroyRefCount;
+}
+
 //------------------------------------------------------------
 
 #if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW)
diff --git layout/base/nsIDocumentViewerPrint.h layout/base/nsIDocumentViewerPrint.h
index 874ee31e5344..e6ac5318f20c 100644
--- layout/base/nsIDocumentViewerPrint.h
+++ layout/base/nsIDocumentViewerPrint.h
@@ -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; \
diff --git layout/printing/nsPagePrintTimer.cpp layout/printing/nsPagePrintTimer.cpp
index 2a29bc85111c..25458b95b3b0 100644
--- layout/printing/nsPagePrintTimer.cpp
+++ layout/printing/nsPagePrintTimer.cpp
@@ -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