summaryrefslogtreecommitdiffstats
path: root/dom/base/nsDocumentEncoder.cpp
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-08-28 14:39:17 +0200
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-08-28 14:39:17 +0200
commitb58a8779c02e8d4abdaae49e1fcc11efeb407bee (patch)
treedc251f391fe9657bc08341dc4cbcfd0ca431b636 /dom/base/nsDocumentEncoder.cpp
parent31def0da05280ab834c3585c37ec1b5cde29c89c (diff)
downloadUXP-b58a8779c02e8d4abdaae49e1fcc11efeb407bee.tar
UXP-b58a8779c02e8d4abdaae49e1fcc11efeb407bee.tar.gz
UXP-b58a8779c02e8d4abdaae49e1fcc11efeb407bee.tar.lz
UXP-b58a8779c02e8d4abdaae49e1fcc11efeb407bee.tar.xz
UXP-b58a8779c02e8d4abdaae49e1fcc11efeb407bee.zip
Issue #1221: Pass the original element into
nsXMLContentSerializer::CheckElementEnd so that we can properly determine whether it has children. This resolves #1221
Diffstat (limited to 'dom/base/nsDocumentEncoder.cpp')
-rw-r--r--dom/base/nsDocumentEncoder.cpp39
1 files changed, 32 insertions, 7 deletions
diff --git a/dom/base/nsDocumentEncoder.cpp b/dom/base/nsDocumentEncoder.cpp
index 84b128b15..34eb6ed38 100644
--- a/dom/base/nsDocumentEncoder.cpp
+++ b/dom/base/nsDocumentEncoder.cpp
@@ -82,7 +82,9 @@ protected:
nsAString& aStr,
bool aDontSerializeRoot,
uint32_t aMaxLength = 0);
- nsresult SerializeNodeEnd(nsINode* aNode, nsAString& aStr);
+ nsresult SerializeNodeEnd(nsINode* aOriginalNode,
+ nsAString& aStr,
+ nsINode* aFixupNode = nullptr);
// This serializes the content of aNode.
nsresult SerializeToStringIterative(nsINode* aNode,
nsAString& aStr);
@@ -405,14 +407,37 @@ nsDocumentEncoder::SerializeNodeStart(nsINode* aNode,
}
nsresult
-nsDocumentEncoder::SerializeNodeEnd(nsINode* aNode,
- nsAString& aStr)
+nsDocumentEncoder::SerializeNodeEnd(nsINode* aOriginalNode,
+ nsAString& aStr,
+ nsINode* aFixupNode)
{
- if (!IsVisibleNode(aNode))
+ if (!IsVisibleNode(aOriginalNode))
return NS_OK;
- if (aNode->IsElement()) {
- mSerializer->AppendElementEnd(aNode->AsElement(), aStr);
+ nsINode* node = nullptr;
+ nsCOMPtr<nsINode> fixedNodeKungfuDeathGrip;
+
+ // Caller didn't do fixup, so we'll do it ourselves
+ if (!aFixupNode) {
+ aFixupNode = aOriginalNode;
+ if (mNodeFixup) {
+ bool dummy;
+ nsCOMPtr<nsIDOMNode> domNodeIn = do_QueryInterface(aOriginalNode);
+ nsCOMPtr<nsIDOMNode> domNodeOut;
+ mNodeFixup->FixupNode(domNodeIn, &dummy, getter_AddRefs(domNodeOut));
+ fixedNodeKungfuDeathGrip = do_QueryInterface(domNodeOut);
+ node = fixedNodeKungfuDeathGrip;
+ }
+ }
+
+ // Fall back to original node if needed.
+ if (!node)
+ node = aOriginalNode;
+
+ if (node->IsElement()) {
+ mSerializer->AppendElementEnd(node->AsElement(),
+ aOriginalNode->AsElement(),
+ aStr);
}
return NS_OK;
}
@@ -481,7 +506,7 @@ nsDocumentEncoder::SerializeToStringRecursive(nsINode* aNode,
}
if (!aDontSerializeRoot) {
- rv = SerializeNodeEnd(maybeFixedNode, aStr);
+ rv = SerializeNodeEnd(aNode, aStr, maybeFixedNode);
NS_ENSURE_SUCCESS(rv, rv);
}