Bug 1274079 - Ensure that after dispatching beforeprint, we have still valid ContentViewer to print. r=bz, a=sledru
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Tue, 02 Aug 2016 21:41:51 +0300
changeset 342429 2b53363331a6162efc75d9488f17b33101649b64
parent 342428 878f4c530d611318aec18c207c846dc1bca20778
child 342430 ec3fd2a8ca6d1f69b3864d15b142784e1d1f72bb
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, sledru
bugs1274079
milestone49.0
Bug 1274079 - Ensure that after dispatching beforeprint, we have still valid ContentViewer to print. r=bz, a=sledru
layout/base/nsDocumentViewer.cpp
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -3743,16 +3743,19 @@ nsDocumentViewer::PrintPreview(nsIPrintS
   nsCOMPtr<nsPIDOMWindowOuter> window = do_QueryInterface(aChildDOMWin);
   MOZ_ASSERT(window);
   nsCOMPtr<nsIDocument> doc = window->GetDoc();
   NS_ENSURE_STATE(doc);
 
   nsAutoPtr<nsPrintEventDispatcher> beforeAndAfterPrint(
     new nsPrintEventDispatcher(doc));
   NS_ENSURE_STATE(!GetIsPrinting());
+  // beforeprint event may have caused ContentViewer to be shutdown.
+  NS_ENSURE_STATE(mContainer);
+  NS_ENSURE_STATE(mDeviceContext);
   if (!mPrintEngine) {
     mPrintEngine = new nsPrintEngine();
 
     rv = mPrintEngine->Initialize(this, mContainer, doc,
                                   float(mDeviceContext->AppUnitsPerCSSInch()) /
                                   float(mDeviceContext->AppUnitsPerDevPixel()) /
                                   mPageZoom,
 #ifdef DEBUG