Fix for bug 297067 (First tag is not transformed). r=Pike, sr=jst.

This commit is contained in:
peterv%propagandism.org 2005-09-14 08:48:54 +00:00
parent 53d768e870
commit c5e408a7cd

View File

@ -488,14 +488,36 @@ void txMozillaXMLOutput::closePrevious(PRInt8 aAction)
NS_ASSERTION(NS_SUCCEEDED(rv), "Can't create wrapper element"); NS_ASSERTION(NS_SUCCEEDED(rv), "Can't create wrapper element");
nsCOMPtr<nsIDOMNode> child, resultNode; nsCOMPtr<nsIDOMNode> child, resultNode;
PRUint32 i, childCount = document->GetChildCount(); PRUint32 i, j, childCount = document->GetChildCount();
for (i = 0; i < childCount; ++i) { for (i = 0, j = 0; i < childCount; ++i) {
nsCOMPtr<nsIContent> childContent = document->GetChildAt(0); nsCOMPtr<nsIContent> childContent = document->GetChildAt(j);
if (childContent == mRootContent) { if (childContent == mRootContent) {
document->SetRootContent(nsnull); document->SetRootContent(nsnull);
} }
child = do_QueryInterface(childContent); child = do_QueryInterface(childContent);
wrapper->AppendChild(child, getter_AddRefs(resultNode)); PRUint16 nodeType;
child->GetNodeType(&nodeType);
switch (nodeType) {
case nsIDOMNode::ELEMENT_NODE:
case nsIDOMNode::TEXT_NODE:
case nsIDOMNode::CDATA_SECTION_NODE:
case nsIDOMNode::ENTITY_REFERENCE_NODE:
case nsIDOMNode::PROCESSING_INSTRUCTION_NODE:
case nsIDOMNode::COMMENT_NODE:
case nsIDOMNode::DOCUMENT_FRAGMENT_NODE:
{
rv = wrapper->AppendChild(child,
getter_AddRefs(resultNode));
if (NS_FAILED(rv)) {
// XXX Need to notify about this!
++j;
}
}
default:
{
++j;
}
}
} }
mParentNode = wrapper; mParentNode = wrapper;