Bug 664434 - Make sure to Destroy the old document when setting a new print document, r=roc
--- 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));