Bug 1549283: add missing calls to `SerializeNodeEnd` r=hsivonen
authorMirko Brodesser <mbrodesser@mozilla.com>
Mon, 06 May 2019 13:49:53 +0000
changeset 531584 59306f187449c5f35614f7e86293dd53ec1f5422
parent 531583 3288c43195a26565edec3d59a8f8bce6018be592
child 531585 1f47ae47ceacd9bb1df12c3dd8987b93bd44f608
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershsivonen
bugs1549283
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1549283: add missing calls to `SerializeNodeEnd` r=hsivonen In order to have one call of `SerializeNodeEnd` for every `SerializeNodeStart` call. In the current state of the code, the absence of these calls doesn't cause bugs, but this can change anytime `SerializeNodeEnd` is changed. Moreover, it makes it simpler to reason about the code. Differential Revision: https://phabricator.services.mozilla.com/D29987
dom/base/nsDocumentEncoder.cpp
--- a/dom/base/nsDocumentEncoder.cpp
+++ b/dom/base/nsDocumentEncoder.cpp
@@ -537,19 +537,20 @@ nsresult nsDocumentEncoder::FlushText(ns
     aString.Truncate();
   }
 
   return rv;
 }
 
 static bool IsTextNode(nsINode* aNode) { return aNode && aNode->IsText(); }
 
-nsresult nsDocumentEncoder::SerializeRangeNodes(nsRange* aRange, nsINode* aNode,
+nsresult nsDocumentEncoder::SerializeRangeNodes(nsRange* const aRange,
+                                                nsINode* const aNode,
                                                 nsAString& aString,
-                                                int32_t aDepth) {
+                                                const int32_t aDepth) {
   nsCOMPtr<nsIContent> content = do_QueryInterface(aNode);
   NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);
 
   if (!IsVisibleNode(aNode)) return NS_OK;
 
   nsresult rv = NS_OK;
 
   // get start and end nodes for this recursion level
@@ -578,16 +579,18 @@ nsresult nsDocumentEncoder::SerializeRan
         int32_t startOffset = aRange->StartOffset();
         rv = SerializeNodeStart(aNode, startOffset, -1, aString);
         NS_ENSURE_SUCCESS(rv, rv);
       } else {
         int32_t endOffset = aRange->EndOffset();
         rv = SerializeNodeStart(aNode, 0, endOffset, aString);
         NS_ENSURE_SUCCESS(rv, rv);
       }
+      rv = SerializeNodeEnd(aNode, aString);
+      NS_ENSURE_SUCCESS(rv, rv);
     } else {
       if (aNode != mCommonParent) {
         if (IncludeInContext(aNode)) {
           // halt the incrementing of mStartDepth/mEndDepth.  This is
           // so paste client will include this node in paste.
           mHaltRangeHint = true;
         }
         if ((startNode == content) && !mHaltRangeHint) mStartDepth++;
@@ -754,16 +757,18 @@ nsresult nsDocumentEncoder::SerializeRan
       if (content && !content->GetPrimaryFrame()) {
         nsIContent* parent = content->GetParent();
         if (!parent || !IsVisibleNode(parent)) return NS_OK;
       }
     }
     rv = SerializeNodeStart(startContainer, startOffset, endOffset,
                             aOutputString);
     NS_ENSURE_SUCCESS(rv, rv);
+    rv = SerializeNodeEnd(startContainer, aOutputString);
+    NS_ENSURE_SUCCESS(rv, rv);
   } else {
     rv = SerializeRangeNodes(aRange, mCommonParent, aOutputString, 0);
     NS_ENSURE_SUCCESS(rv, rv);
   }
   rv = SerializeRangeContextEnd(aOutputString);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return rv;