Bug 1274079 - Ensure that after dispatching beforeprint, we have still valid ContentViewer to print. r=bz, a=ritu
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Tue, 02 Aug 2016 21:41:51 +0300
changeset 347808 b0b057f49fa609dd1295452759226aa6cc933034
parent 347807 fceb720697c7934ff1b50d4ff3a6a8b3aec736d6
child 347809 4306add4a88a27e7fac9ff603c987f9bf444d267
push id6389
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:38:22 +0000
treeherdermozilla-beta@01d67bfe6c81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, ritu
bugs1274079
milestone50.0a2
Bug 1274079 - Ensure that after dispatching beforeprint, we have still valid ContentViewer to print. r=bz, a=ritu
layout/base/nsDocumentViewer.cpp
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -3723,16 +3723,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