From a5600aeaf2f12f418801f238a4418d4d355210c7 Mon Sep 17 00:00:00 2001 From: "Olli.Pettay@helsinki.fi" Date: Wed, 19 Mar 2008 12:44:08 -0700 Subject: [PATCH] Bug 421366, [@ nsContentUtils::IsEventAttributeName] r+sr=peterv --- content/html/document/src/nsHTMLDocument.cpp | 5 ++++- content/xbl/src/nsXBLBinding.cpp | 4 +++- content/xbl/src/nsXBLPrototypeBinding.cpp | 4 +++- content/xul/templates/src/nsXULContentBuilder.cpp | 4 +++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp index a82b7891cc6..7778a9d77ac 100644 --- a/content/html/document/src/nsHTMLDocument.cpp +++ b/content/html/document/src/nsHTMLDocument.cpp @@ -2224,7 +2224,10 @@ nsHTMLDocument::OpenCommon(const nsACString& aContentType, PRBool aReplace) // Remove all attributes from the root element while (count-- > 0) { const nsAttrName* name = root->GetAttrNameAt(count); - root->UnsetAttr(name->NamespaceID(), name->LocalName(), PR_FALSE); + // Hold a strong reference here so that the atom doesn't go away during + // UnsetAttr. + nsCOMPtr localName = name->LocalName(); + root->UnsetAttr(name->NamespaceID(), localName, PR_FALSE); } // Remove the root from the childlist diff --git a/content/xbl/src/nsXBLBinding.cpp b/content/xbl/src/nsXBLBinding.cpp index c8d28b92df3..5bd699b15a7 100644 --- a/content/xbl/src/nsXBLBinding.cpp +++ b/content/xbl/src/nsXBLBinding.cpp @@ -770,7 +770,9 @@ nsXBLBinding::GenerateAnonymousContent() const nsAttrName* attrName; for (PRUint32 i = 0; (attrName = content->GetAttrNameAt(i)); ++i) { PRInt32 namespaceID = attrName->NamespaceID(); - nsIAtom* name = attrName->LocalName(); + // Hold a strong reference here so that the atom doesn't go away during + // UnsetAttr. + nsCOMPtr name = attrName->LocalName(); if (name != nsGkAtoms::includes) { if (!nsContentUtils::HasNonEmptyAttr(mBoundElement, namespaceID, name)) { diff --git a/content/xbl/src/nsXBLPrototypeBinding.cpp b/content/xbl/src/nsXBLPrototypeBinding.cpp index 672fd5b100b..5d19d29fcc9 100644 --- a/content/xbl/src/nsXBLPrototypeBinding.cpp +++ b/content/xbl/src/nsXBLPrototypeBinding.cpp @@ -570,7 +570,9 @@ nsXBLPrototypeBinding::AttributeChanged(nsIAtom* aAttribute, element); if (realElement) { - nsIAtom* dstAttr = xblAttr->GetDstAttribute(); + // Hold a strong reference here so that the atom doesn't go away during + // UnsetAttr. + nsCOMPtr dstAttr = xblAttr->GetDstAttribute(); PRInt32 dstNs = xblAttr->GetDstNameSpace(); if (aRemoveFlag) diff --git a/content/xul/templates/src/nsXULContentBuilder.cpp b/content/xul/templates/src/nsXULContentBuilder.cpp index 15b4f52d351..bc6afeba299 100644 --- a/content/xul/templates/src/nsXULContentBuilder.cpp +++ b/content/xul/templates/src/nsXULContentBuilder.cpp @@ -898,7 +898,9 @@ nsXULContentBuilder::CopyAttributesToElement(nsIContent* aTemplateNode, for (PRUint32 attr = 0; attr < numAttribs; attr++) { const nsAttrName* name = aTemplateNode->GetAttrNameAt(attr); PRInt32 attribNameSpaceID = name->NamespaceID(); - nsIAtom* attribName = name->LocalName(); + // Hold a strong reference here so that the atom doesn't go away + // during UnsetAttr. + nsCOMPtr attribName = name->LocalName(); // XXXndeakin ignore namespaces until bug 321182 is fixed if (attribName != nsGkAtoms::id && attribName != nsGkAtoms::uri) {