mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-26 23:23:33 +00:00
Fixing bug 47733. Making document.implementation.createDocument() set up the root element in the document correctly so that it's parent and owner document is the document that it's in. r=heikki@netscape.com, sr=rpotts@netscape.com
This commit is contained in:
parent
07415aa237
commit
88fbf3f6f2
@ -131,29 +131,35 @@ NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
|
||||
if (doc == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> kungFuDeathGrip(doc);
|
||||
|
||||
rv = doc->Reset(nsnull, nsnull);
|
||||
if (NS_FAILED(rv)) {
|
||||
delete doc;
|
||||
return rv;
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
doc->SetDocumentURL(aBaseURI);
|
||||
|
||||
if (aDoctype) {
|
||||
nsCOMPtr<nsIDOMNode> tmpNode;
|
||||
doc->AppendChild(aDoctype, getter_AddRefs(tmpNode));
|
||||
rv = doc->AppendChild(aDoctype, getter_AddRefs(tmpNode));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
if (aQualifiedName.Length() > 0) {
|
||||
nsCOMPtr<nsIDOMElement> root;
|
||||
rv = doc->CreateElementNS(aNamespaceURI, aQualifiedName, getter_AddRefs(root));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(root);
|
||||
doc->SetRootContent(content);
|
||||
}
|
||||
rv = doc->CreateElementNS(aNamespaceURI, aQualifiedName,
|
||||
getter_AddRefs(root));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> tmpNode;
|
||||
|
||||
rv = doc->AppendChild(root, getter_AddRefs(tmpNode));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
return doc->QueryInterface(NS_GET_IID(nsIDOMDocument), (void**) aInstancePtrResult);
|
||||
*aInstancePtrResult = doc;
|
||||
NS_ADDREF(*aInstancePtrResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -131,29 +131,35 @@ NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
|
||||
if (doc == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> kungFuDeathGrip(doc);
|
||||
|
||||
rv = doc->Reset(nsnull, nsnull);
|
||||
if (NS_FAILED(rv)) {
|
||||
delete doc;
|
||||
return rv;
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
doc->SetDocumentURL(aBaseURI);
|
||||
|
||||
if (aDoctype) {
|
||||
nsCOMPtr<nsIDOMNode> tmpNode;
|
||||
doc->AppendChild(aDoctype, getter_AddRefs(tmpNode));
|
||||
rv = doc->AppendChild(aDoctype, getter_AddRefs(tmpNode));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
if (aQualifiedName.Length() > 0) {
|
||||
nsCOMPtr<nsIDOMElement> root;
|
||||
rv = doc->CreateElementNS(aNamespaceURI, aQualifiedName, getter_AddRefs(root));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(root);
|
||||
doc->SetRootContent(content);
|
||||
}
|
||||
rv = doc->CreateElementNS(aNamespaceURI, aQualifiedName,
|
||||
getter_AddRefs(root));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDOMNode> tmpNode;
|
||||
|
||||
rv = doc->AppendChild(root, getter_AddRefs(tmpNode));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
return doc->QueryInterface(NS_GET_IID(nsIDOMDocument), (void**) aInstancePtrResult);
|
||||
*aInstancePtrResult = doc;
|
||||
NS_ADDREF(*aInstancePtrResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user