diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-09-06 10:31:35 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-09-06 10:31:35 +0200 |
commit | 0f7f961e8894c8408b7fa21bbeba7ac503d372eb (patch) | |
tree | 033c37b3e8ca856d8b35d2408afa5269f0237078 /dom/base/nsDocumentEncoder.cpp | |
parent | dba27e6f639954060b9353c6d8f594eab0e06a99 (diff) | |
parent | 6db06749e2037029adc96660aafa5339ed609e60 (diff) | |
download | UXP-0f7f961e8894c8408b7fa21bbeba7ac503d372eb.tar UXP-0f7f961e8894c8408b7fa21bbeba7ac503d372eb.tar.gz UXP-0f7f961e8894c8408b7fa21bbeba7ac503d372eb.tar.lz UXP-0f7f961e8894c8408b7fa21bbeba7ac503d372eb.tar.xz UXP-0f7f961e8894c8408b7fa21bbeba7ac503d372eb.zip |
Merge branch 'master' into Basilisk-releasev2019.09.12
Diffstat (limited to 'dom/base/nsDocumentEncoder.cpp')
-rw-r--r-- | dom/base/nsDocumentEncoder.cpp | 39 |
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); } |