diff --git a/layout/printing/nsPrintData.cpp b/layout/printing/nsPrintData.cpp index 9319ac643fd4..63e2bb1567a9 100644 --- a/layout/printing/nsPrintData.cpp +++ b/layout/printing/nsPrintData.cpp @@ -116,6 +116,66 @@ AssertPresShellsAndContextsSane(nsPrintObject* aPO, } } +#ifdef MOZ_CRASHREPORTER +static void +AppendBoolean(nsCString& aString, bool aValue) +{ + if (aValue) { + aString.AppendLiteral("true"); + } else { + aString.AppendLiteral("false"); + } +} + +static void +NotePrintObjectTree(nsPrintObject* aPO, int32_t aDepth) +{ + nsCString note; + for (int32_t i = 0; i < aDepth; i++) { + note.AppendLiteral(" "); + } + note.AppendInt(static_cast(reinterpret_cast(aPO)), 16); + note.AppendLiteral(" = { mFrameType = "); + note.AppendInt(aPO->mFrameType); + note.AppendLiteral(", mHasBeenPrinted = "); + AppendBoolean(note, aPO->mHasBeenPrinted); + note.AppendLiteral(", mDontPrint = "); + AppendBoolean(note, aPO->mDontPrint); + note.AppendLiteral(", mPrintAsIs = "); + AppendBoolean(note, aPO->mPrintAsIs); + note.AppendLiteral(", mInvisible = "); + AppendBoolean(note, aPO->mInvisible); + note.AppendLiteral(", mPrintPreview = "); + AppendBoolean(note, aPO->mPrintPreview); + note.AppendLiteral(", mDidCreateDocShell = "); + AppendBoolean(note, aPO->mDidCreateDocShell); + note.AppendLiteral(", mShrinkRatio = "); + note.AppendFloat(aPO->mShrinkRatio); + note.AppendLiteral(", mZoomRatio = "); + note.AppendFloat(aPO->mZoomRatio); + note.AppendLiteral(", mContent = "); + if (aPO->mContent) { + nsString tag; + aPO->mContent->Tag()->ToString(tag); + LossyAppendUTF16toASCII(tag, note); + } else { + note.AppendLiteral("null"); + } + note.AppendLiteral(" }\n"); + CrashReporter::AppendAppNotesToCrashReport(note); + for (uint32_t i = 0; i < aPO->mKids.Length(); i++) { + NotePrintObjectTree(aPO->mKids[i], aDepth + 1); + } +} + +static void +NotePrintObjectTree(nsPrintObject* aPO) +{ + CrashReporter::AppendAppNotesToCrashReport(NS_LITERAL_CSTRING("Print object tree:\n")); + NotePrintObjectTree(aPO, 1); +} +#endif + #undef ASSERT_AND_NOTE static void @@ -160,6 +220,9 @@ nsPrintData::~nsPrintData() } AssertPresShellsAndContextsSane(mPrintObject); +#ifdef MOZ_CRASHREPORTER + NotePrintObjectTree(mPrintObject); +#endif delete mPrintObject; if (mBrandName) { diff --git a/layout/printing/nsPrintEngine.cpp b/layout/printing/nsPrintEngine.cpp index 2224765fddce..02f7bbb10932 100644 --- a/layout/printing/nsPrintEngine.cpp +++ b/layout/printing/nsPrintEngine.cpp @@ -124,6 +124,10 @@ static const char kPrintingPromptService[] = "@mozilla.org/embedcomp/printingpro #include "mozilla/dom/Element.h" #include "nsContentList.h" +#ifdef MOZ_CRASHREPORTER +#include "nsExceptionHandler.h" +#endif + using namespace mozilla; using namespace mozilla::dom; @@ -1530,6 +1534,9 @@ nsresult nsPrintEngine::CleanupOnFailure(nsresult aResult, bool aIsPrinting) ShowPrintErrorDialog(aResult, aIsPrinting); } +#ifdef MOZ_CRASHREPORTER + CrashReporter::AppendAppNotesToCrashReport(NS_LITERAL_CSTRING("Unsuccessful print.\n")); +#endif FirePrintCompletionEvent(); return aResult; @@ -3170,6 +3177,9 @@ nsPrintEngine::DonePrintingPages(nsPrintObject* aPO, nsresult aResult) } if (NS_SUCCEEDED(aResult)) { +#ifdef MOZ_CRASHREPORTER + CrashReporter::AppendAppNotesToCrashReport(NS_LITERAL_CSTRING("Successful print.\n")); +#endif FirePrintCompletionEvent(); } diff --git a/layout/printing/nsPrintObject.cpp b/layout/printing/nsPrintObject.cpp index af28c1b82a47..e21c83bef862 100644 --- a/layout/printing/nsPrintObject.cpp +++ b/layout/printing/nsPrintObject.cpp @@ -14,6 +14,10 @@ #include "nsIDocShellTreeItem.h" #include "nsIBaseWindow.h" +#ifdef MOZ_CRASHREPORTER +#include "nsExceptionHandler.h" +#endif + //--------------------------------------------------- //-- nsPrintObject Class Impl //--------------------------------------------------- @@ -101,6 +105,12 @@ void nsPrintObject::DestroyPresentation() { if (mPresShell) { +#ifdef MOZ_CRASHREPORTER + if (mPresShell->GetPresContext() && !mPresShell->GetPresContext()->GetPresShell()) { + NS_ASSERTION(false, "about to destroy print object's PresShell when its pres context no longer has it"); + CrashReporter::AppendAppNotesToCrashReport(NS_LITERAL_CSTRING("about to destroy print object's PresShell when its pres context no longer has it\n")); + } +#endif mPresShell->EndObservingDocument(); nsAutoScriptBlocker scriptBlocker; mPresShell->Destroy();