From 8acc9c253b19126fd220e9cc9150fe5511d2c1a2 Mon Sep 17 00:00:00 2001 From: Olli Pettay Date: Sat, 11 Feb 2012 13:03:54 +0200 Subject: [PATCH] Bug 701423 - Log the id and classes of an element in cycle collector dumps, f=mccr8,r=sicking --- content/base/src/nsGenericElement.cpp | 29 +++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/content/base/src/nsGenericElement.cpp b/content/base/src/nsGenericElement.cpp index bc641648b143..fc59325ab7ef 100644 --- a/content/base/src/nsGenericElement.cpp +++ b/content/base/src/nsGenericElement.cpp @@ -4796,14 +4796,31 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsGenericElement) tmp->OwnerDoc()->GetDocumentURI()->GetSpec(uri); } - if (nsid < ArrayLength(kNSURIs)) { - PR_snprintf(name, sizeof(name), "nsGenericElement%s %s %s", kNSURIs[nsid], - localName.get(), uri.get()); + nsAutoString id; + nsIAtom* idAtom = tmp->GetID(); + if (idAtom) { + id.AppendLiteral(" id='"); + id.Append(nsDependentAtomString(idAtom)); + id.AppendLiteral("'"); } - else { - PR_snprintf(name, sizeof(name), "nsGenericElement %s %s", - localName.get(), uri.get()); + + nsAutoString classes; + const nsAttrValue* classAttrValue = tmp->GetClasses(); + if (classAttrValue) { + classes.AppendLiteral(" class='"); + nsAutoString classString; + classAttrValue->ToString(classString); + classes.Append(classString); + classes.AppendLiteral("'"); } + + const char* nsuri = nsid < ArrayLength(kNSURIs) ? kNSURIs[nsid] : ""; + PR_snprintf(name, sizeof(name), "nsGenericElement%s %s%s%s %s", + nsuri, + localName.get(), + NS_ConvertUTF16toUTF8(id).get(), + NS_ConvertUTF16toUTF8(classes).get(), + uri.get()); cb.DescribeRefCountedNode(tmp->mRefCnt.get(), sizeof(nsGenericElement), name); }