зеркало из https://github.com/mozilla/pjs.git
Fix for bug 155915 (txMozillaXMLOutput drops previous documentElement on creating transformiix wrapper). r=Pike, sr=jst.
This commit is contained in:
Родитель
49b8c035be
Коммит
69f4376dfb
|
@ -42,6 +42,7 @@
|
||||||
#include "nsIDOMComment.h"
|
#include "nsIDOMComment.h"
|
||||||
#include "nsIDOMDocumentType.h"
|
#include "nsIDOMDocumentType.h"
|
||||||
#include "nsIDOMDOMImplementation.h"
|
#include "nsIDOMDOMImplementation.h"
|
||||||
|
#include "nsIDOMNodeList.h"
|
||||||
#include "nsIDOMProcessingInstruction.h"
|
#include "nsIDOMProcessingInstruction.h"
|
||||||
#include "nsIDOMText.h"
|
#include "nsIDOMText.h"
|
||||||
#include "nsIDOMHTMLTableSectionElem.h"
|
#include "nsIDOMHTMLTableSectionElem.h"
|
||||||
|
@ -386,7 +387,19 @@ void txMozillaXMLOutput::closePrevious(PRInt8 aAction)
|
||||||
getter_AddRefs(wrapper));
|
getter_AddRefs(wrapper));
|
||||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Can't create wrapper element");
|
NS_ASSERTION(NS_SUCCEEDED(rv), "Can't create wrapper element");
|
||||||
|
|
||||||
wrapChildren(mParentNode, wrapper);
|
nsCOMPtr<nsIContent> childContent;
|
||||||
|
nsCOMPtr<nsIDOMNode> child, resultNode;
|
||||||
|
PRInt32 childCount, i;
|
||||||
|
document->GetChildCount(childCount);
|
||||||
|
for (i = 0; i < childCount; ++i) {
|
||||||
|
document->ChildAt(0, *getter_AddRefs(childContent));
|
||||||
|
if (childContent == mRootContent) {
|
||||||
|
document->SetRootContent(nsnull);
|
||||||
|
}
|
||||||
|
child = do_QueryInterface(childContent);
|
||||||
|
wrapper->AppendChild(child, getter_AddRefs(resultNode));
|
||||||
|
}
|
||||||
|
|
||||||
mParentNode = wrapper;
|
mParentNode = wrapper;
|
||||||
mRootContent = do_QueryInterface(wrapper);
|
mRootContent = do_QueryInterface(wrapper);
|
||||||
mRootContent->SetDocument(document, PR_FALSE, PR_TRUE);
|
mRootContent->SetDocument(document, PR_FALSE, PR_TRUE);
|
||||||
|
@ -398,7 +411,7 @@ void txMozillaXMLOutput::closePrevious(PRInt8 aAction)
|
||||||
mNonAddedNode = mCurrentNode;
|
mNonAddedNode = mCurrentNode;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (document && !mRootContent) {
|
if (document && currentElement && !mRootContent) {
|
||||||
mRootContent = do_QueryInterface(mCurrentNode);
|
mRootContent = do_QueryInterface(mCurrentNode);
|
||||||
mRootContent->SetDocument(document, PR_FALSE, PR_TRUE);
|
mRootContent->SetDocument(document, PR_FALSE, PR_TRUE);
|
||||||
document->SetRootContent(mRootContent);
|
document->SetRootContent(mRootContent);
|
||||||
|
@ -573,26 +586,20 @@ void txMozillaXMLOutput::processHTTPEquiv(nsIAtom* aHeader, const nsAString& aVa
|
||||||
void txMozillaXMLOutput::wrapChildren(nsIDOMNode* aCurrentNode,
|
void txMozillaXMLOutput::wrapChildren(nsIDOMNode* aCurrentNode,
|
||||||
nsIDOMElement* aWrapper)
|
nsIDOMElement* aWrapper)
|
||||||
{
|
{
|
||||||
nsresult rv;
|
nsCOMPtr<nsIDOMNodeList> children;
|
||||||
nsCOMPtr<nsIContent> currentContent;
|
nsresult rv = aCurrentNode->GetChildNodes(getter_AddRefs(children));
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
currentContent = do_QueryInterface(mCurrentNode, &rv);
|
NS_ASSERTION(0, "Can't get children!");
|
||||||
|
|
||||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Can't QI to nsIContent");
|
|
||||||
if (!currentContent)
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
PRInt32 count, i = 0;
|
|
||||||
nsCOMPtr<nsIDOMNode> child, resultNode;
|
nsCOMPtr<nsIDOMNode> child, resultNode;
|
||||||
nsCOMPtr<nsIContent> childContent;
|
PRUint32 count, i;
|
||||||
|
children->GetLength(&count);
|
||||||
currentContent->ChildCount(count);
|
for (i = 0; i < count; ++i) {
|
||||||
for (i = 0; i < count; i++) {
|
rv = children->Item(0, getter_AddRefs(child));
|
||||||
rv = currentContent->ChildAt(0, *getter_AddRefs(childContent));
|
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
child = do_QueryInterface(childContent);
|
aWrapper->AppendChild(child, getter_AddRefs(resultNode));
|
||||||
aCurrentNode->RemoveChild(child, getter_AddRefs(resultNode));
|
|
||||||
aWrapper->AppendChild(resultNode, getter_AddRefs(child));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче