Make SetDocument() get a new nodeinfo if the old one does not match the

new document.  Bug 106393, r=peterv, sr=jst
This commit is contained in:
bzbarsky%mit.edu 2001-10-25 00:28:08 +00:00
Родитель d28c4dced3
Коммит 9996719220
1 изменённых файлов: 27 добавлений и 0 удалений

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

@ -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<nsIDocument> nodeinfoDoc;
mNodeInfo->GetDocument(*getter_AddRefs(nodeinfoDoc));
if (aDocument != nodeinfoDoc) {
// get a new nodeinfo
nsCOMPtr<nsIAtom> name;
mNodeInfo->GetNameAtom(*getter_AddRefs(name));
nsCOMPtr<nsIAtom> prefix;
mNodeInfo->GetPrefixAtom(*getter_AddRefs(prefix));
PRInt32 nameSpaceID;
mNodeInfo->GetNamespaceID(nameSpaceID);
nsCOMPtr<nsINodeInfoManager> 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; mDocument = aDocument;
} }