From 99967192206439e5bda18ca51bee3fc82b43fdd9 Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Thu, 25 Oct 2001 00:28:08 +0000 Subject: [PATCH] Make SetDocument() get a new nodeinfo if the old one does not match the new document. Bug 106393, r=peterv, sr=jst --- content/base/src/nsGenericElement.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/content/base/src/nsGenericElement.cpp b/content/base/src/nsGenericElement.cpp index a8d5c1e2e2a..73559e3536c 100644 --- a/content/base/src/nsGenericElement.cpp +++ b/content/base/src/nsGenericElement.cpp @@ -1640,6 +1640,33 @@ nsGenericElement::SetDocument(nsIDocument* aDocument, PRBool aDeep, } } + if (aDocument) { + // check the document on the nodeinfo to see whether we need a + // new nodeinfo + nsCOMPtr nodeinfoDoc; + mNodeInfo->GetDocument(*getter_AddRefs(nodeinfoDoc)); + if (aDocument != nodeinfoDoc) { + // get a new nodeinfo + nsCOMPtr name; + mNodeInfo->GetNameAtom(*getter_AddRefs(name)); + nsCOMPtr prefix; + mNodeInfo->GetPrefixAtom(*getter_AddRefs(prefix)); + PRInt32 nameSpaceID; + mNodeInfo->GetNamespaceID(nameSpaceID); + nsCOMPtr nodeInfoManager; + aDocument->GetNodeInfoManager(*getter_AddRefs(nodeInfoManager)); + if (nodeInfoManager) { + nsINodeInfo* newNodeInfo; + nodeInfoManager->GetNodeInfo(name, prefix, nameSpaceID, + newNodeInfo); + if (newNodeInfo) { + NS_RELEASE(mNodeInfo); + mNodeInfo = newNodeInfo; + } + } + } + } + mDocument = aDocument; }