forked from mirrors/gecko-dev
Bug 1941002 - Clone source. r=smaug a=pascalc
Differential Revision: https://phabricator.services.mozilla.com/D235577
This commit is contained in:
parent
b4bc1a7836
commit
c876e3e97c
4 changed files with 26 additions and 9 deletions
|
|
@ -80,7 +80,7 @@ nsresult nsXMLPrettyPrinter::PrettyPrint(Document* aDocument,
|
|||
}
|
||||
|
||||
RefPtr<DocumentFragment> resultFragment =
|
||||
transformer->TransformToFragment(*aDocument, *aDocument, err);
|
||||
transformer->TransformToFragment(*aDocument, false, *aDocument, err);
|
||||
if (NS_WARN_IF(err.Failed())) {
|
||||
return err.StealNSResult();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -479,7 +479,7 @@ static nsresult handleNode(nsINode* aNode, txStylesheetCompiler* aCompiler) {
|
|||
// explicitly destroy the attrs here since we no longer need it
|
||||
atts = nullptr;
|
||||
|
||||
for (nsIContent* child = element->GetFirstChild(); child;
|
||||
for (nsCOMPtr<nsIContent> child = element->GetFirstChild(); child;
|
||||
child = child->GetNextSibling()) {
|
||||
rv = handleNode(child, aCompiler);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
|
@ -493,7 +493,7 @@ static nsresult handleNode(nsINode* aNode, txStylesheetCompiler* aCompiler) {
|
|||
rv = aCompiler->characters(chars);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
} else if (aNode->IsDocument()) {
|
||||
for (nsIContent* child = aNode->GetFirstChild(); child;
|
||||
for (nsCOMPtr<nsIContent> child = aNode->GetFirstChild(); child;
|
||||
child = child->GetNextSibling()) {
|
||||
rv = handleNode(child, aCompiler);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
|
|
|||
|
|
@ -553,7 +553,10 @@ already_AddRefed<Document> txMozillaXSLTProcessor::TransformToDocument(
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
mSource = &aSource;
|
||||
mSource = aSource.CloneNode(true, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsCOMPtr<Document> doc;
|
||||
rv = TransformToDoc(getter_AddRefs(doc), true);
|
||||
|
|
@ -721,7 +724,7 @@ nsresult txMozillaXSLTProcessor::TransformToDoc(Document** aResult,
|
|||
}
|
||||
|
||||
already_AddRefed<DocumentFragment> txMozillaXSLTProcessor::TransformToFragment(
|
||||
nsINode& aSource, Document& aOutput, ErrorResult& aRv) {
|
||||
nsINode& aSource, bool aCloneSource, Document& aOutput, ErrorResult& aRv) {
|
||||
if (NS_WARN_IF(NS_FAILED(mCompileResult))) {
|
||||
aRv.Throw(mCompileResult);
|
||||
return nullptr;
|
||||
|
|
@ -741,8 +744,17 @@ already_AddRefed<DocumentFragment> txMozillaXSLTProcessor::TransformToFragment(
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
UniquePtr<txXPathNode> sourceNode(
|
||||
txXPathNativeNode::createXPathNode(&aSource));
|
||||
nsCOMPtr<nsINode> source;
|
||||
if (aCloneSource) {
|
||||
source = aSource.CloneNode(true, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return nullptr;
|
||||
}
|
||||
} else {
|
||||
source = &aSource;
|
||||
}
|
||||
|
||||
UniquePtr<txXPathNode> sourceNode(txXPathNativeNode::createXPathNode(source));
|
||||
if (!sourceNode) {
|
||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return nullptr;
|
||||
|
|
@ -1049,7 +1061,7 @@ nsresult txMozillaXSLTProcessor::ensureStylesheet() {
|
|||
|
||||
NS_ENSURE_TRUE(mStylesheetDocument, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
nsINode* style = mEmbeddedStylesheetRoot;
|
||||
nsCOMPtr<nsINode> style = mEmbeddedStylesheetRoot;
|
||||
if (!style) {
|
||||
style = mStylesheetDocument;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,12 @@ class txMozillaXSLTProcessor final : public nsIDocumentTransformer,
|
|||
|
||||
void ImportStylesheet(nsINode& stylesheet, mozilla::ErrorResult& aRv);
|
||||
already_AddRefed<mozilla::dom::DocumentFragment> TransformToFragment(
|
||||
nsINode& source, mozilla::dom::Document& docVal,
|
||||
nsINode& aSource, mozilla::dom::Document& aDocument,
|
||||
mozilla::ErrorResult& aRv) {
|
||||
return TransformToFragment(aSource, true, aDocument, aRv);
|
||||
}
|
||||
already_AddRefed<mozilla::dom::DocumentFragment> TransformToFragment(
|
||||
nsINode& aSource, bool aCloneSource, mozilla::dom::Document& aOutput,
|
||||
mozilla::ErrorResult& aRv);
|
||||
already_AddRefed<mozilla::dom::Document> TransformToDocument(
|
||||
nsINode& source, mozilla::ErrorResult& aRv);
|
||||
|
|
|
|||
Loading…
Reference in a new issue