Bug 664434 - Make sure to Destroy the old document when setting a new print document, r=roc
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Thu, 16 Jun 2011 21:20:13 +0300
changeset 71704 fb60f6e2f89ebe729b7e50e9c29b29551f372617
parent 71703 079c171b6323b3524294dc6c758ef00e84250d94
child 71705 97bf954c697028fafd1dda824ffa48ecf57d4063
push id159
push usereakhgari@mozilla.com
push dateTue, 16 Aug 2011 17:53:11 +0000
treeherdermozilla-beta@8786e3e49240 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs664434
milestone7.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 664434 - Make sure to Destroy the old document when setting a new print document, r=roc
layout/base/nsDocumentViewer.cpp
layout/printing/nsPrintData.cpp
layout/printing/nsPrintObject.cpp
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -1757,16 +1757,20 @@ DocumentViewerImpl::SetDocumentInternal(
                                         PRBool aForceReuseInnerWindow)
 {
 
   // Set new container
   nsCOMPtr<nsISupports> container = do_QueryReferent(mContainer);
   aDocument->SetContainer(container);
 
   if (mDocument != aDocument) {
+    if (mDocument->IsStaticDocument()) {
+      mDocument->SetScriptGlobalObject(nsnull);
+      mDocument->Destroy();
+    }
     // Replace the old document with the new one. Do this only when
     // the new document really is a new document.
     mDocument = aDocument;
 
     // Set the script global object on the new document
     nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(container);
     if (window) {
       window->SetNewDocument(aDocument, nsnull, aForceReuseInnerWindow);
--- a/layout/printing/nsPrintData.cpp
+++ b/layout/printing/nsPrintData.cpp
@@ -69,17 +69,17 @@ nsPrintData::nsPrintData(ePrintDataType 
   mPrintDocList(nsnull), mIsIFrameSelected(PR_FALSE),
   mIsParentAFrameSet(PR_FALSE), mOnStartSent(PR_FALSE),
   mIsAborted(PR_FALSE), mPreparingForPrint(PR_FALSE), mDocWasToBeDestroyed(PR_FALSE),
   mShrinkToFit(PR_FALSE), mPrintFrameType(nsIPrintSettings::kFramesAsIs), 
   mNumPrintablePages(0), mNumPagesPrinted(0),
   mShrinkRatio(1.0), mOrigDCScale(1.0), mPPEventListeners(NULL), 
   mBrandName(nsnull)
 {
-
+  MOZ_COUNT_CTOR(nsPrintData);
   nsCOMPtr<nsIStringBundle> brandBundle;
   nsCOMPtr<nsIStringBundleService> svc =
     mozilla::services::GetStringBundleService();
   if (svc) {
     svc->CreateBundle( "chrome://branding/locale/brand.properties", getter_AddRefs( brandBundle ) );
     if (brandBundle) {
       brandBundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(), &mBrandName );
     }
@@ -88,16 +88,17 @@ nsPrintData::nsPrintData(ePrintDataType 
   if (!mBrandName) {
     mBrandName = ToNewUnicode(NS_LITERAL_STRING("Mozilla Document"));
   }
 
 }
 
 nsPrintData::~nsPrintData()
 {
+  MOZ_COUNT_DTOR(nsPrintData);
   // remove the event listeners
   if (mPPEventListeners) {
     mPPEventListeners->RemoveListeners();
     NS_RELEASE(mPPEventListeners);
   }
 
   // Only Send an OnEndPrinting if we have started printing
   if (mOnStartSent && mType != eIsPrintPreview) {
--- a/layout/printing/nsPrintObject.cpp
+++ b/layout/printing/nsPrintObject.cpp
@@ -50,21 +50,23 @@
 //-- nsPrintObject Class Impl
 //---------------------------------------------------
 nsPrintObject::nsPrintObject() :
   mContent(nsnull), mFrameType(eFrame), mParent(nsnull),
   mHasBeenPrinted(PR_FALSE), mDontPrint(PR_TRUE), mPrintAsIs(PR_FALSE),
   mSharedPresShell(PR_FALSE), mInvisible(PR_FALSE), mDidCreateDocShell(PR_FALSE),
   mShrinkRatio(1.0), mZoomRatio(1.0)
 {
+  MOZ_COUNT_CTOR(nsPrintObject);
 }
 
 
 nsPrintObject::~nsPrintObject()
 {
+  MOZ_COUNT_DTOR(nsPrintObject);
   for (PRUint32 i=0;i<mKids.Length();i++) {
     nsPrintObject* po = mKids[i];
     delete po;
   }
 
   DestroyPresentation();
   if (mDidCreateDocShell && mDocShell) {
     nsCOMPtr<nsIBaseWindow> baseWin(do_QueryInterface(mDocShell));