Bug 818626 - More debugging for crashes at the end of printing. r=roc

This commit is contained in:
Cameron McCormack 2013-01-07 14:29:47 +11:00
Родитель 525f2b3c10
Коммит 03e4e10349
3 изменённых файлов: 83 добавлений и 0 удалений

Просмотреть файл

@ -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<uint64_t>(reinterpret_cast<uintptr_t>(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) {

Просмотреть файл

@ -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();
}

Просмотреть файл

@ -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();