Bug 1213859 part.4 ContentEventHandler should use NS_NewPreContentIterator rathr than NS_NewContentIterator at converting between DOM tree and flattened text r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Wed, 02 Dec 2015 13:20:00 +0900
changeset 309285 b7191f6c21ae13a810b89041da3adc4d5c153fc3
parent 309284 95efe6bad896355799aaaacea515f003c0c14f7e
child 309286 afae79e8f7d2cbd4a0cdd18d8309053d4d8c8173
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1213859
milestone45.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 1213859 part.4 ContentEventHandler should use NS_NewPreContentIterator rathr than NS_NewContentIterator at converting between DOM tree and flattened text r=smaug
dom/events/ContentEventHandler.cpp
--- a/dom/events/ContentEventHandler.cpp
+++ b/dom/events/ContentEventHandler.cpp
@@ -423,17 +423,17 @@ ContentEventHandler::GenerateFlatTextCon
   if (startNode == endNode && startNode->IsNodeOfType(nsINode::eTEXT)) {
     nsIContent* content = startNode->AsContent();
     AppendSubString(aString, content, aRange->StartOffset(),
                     aRange->EndOffset() - aRange->StartOffset());
     ConvertToNativeNewlines(aString);
     return NS_OK;
   }
 
-  nsCOMPtr<nsIContentIterator> iter = NS_NewContentIterator();
+  nsCOMPtr<nsIContentIterator> iter = NS_NewPreContentIterator();
   nsresult rv = iter->Init(aRange);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   for (; !iter->IsDone(); iter->Next()) {
     nsINode* node = iter->GetCurrentNode();
     if (NS_WARN_IF(!node)) {
       break;
@@ -583,17 +583,17 @@ ContentEventHandler::GenerateFlatFontRan
   nsINode* startNode = aRange->GetStartParent();
   nsINode* endNode = aRange->GetEndParent();
   if (NS_WARN_IF(!startNode) || NS_WARN_IF(!endNode)) {
     return NS_ERROR_FAILURE;
   }
 
   // baseOffset is the flattened offset of each content node.
   int32_t baseOffset = 0;
-  nsCOMPtr<nsIContentIterator> iter = NS_NewContentIterator();
+  nsCOMPtr<nsIContentIterator> iter = NS_NewPreContentIterator();
   nsresult rv = iter->Init(aRange);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   for (; !iter->IsDone(); iter->Next()) {
     nsINode* node = iter->GetCurrentNode();
     if (NS_WARN_IF(!node)) {
       break;
@@ -1465,17 +1465,17 @@ ContentEventHandler::GetFlatTextLengthIn
       "of its parent");
     MOZ_ASSERT(aStartPosition.mNode == aEndPosition.mNode,
       "At removing the node, start and end node should be same");
     MOZ_ASSERT(aStartPosition.mOffset == 0,
       "When the node is being removed, the start offset should be 0");
     MOZ_ASSERT(static_cast<uint32_t>(aEndPosition.mOffset) ==
                  aEndPosition.mNode->GetChildCount(),
       "When the node is being removed, the end offset should be child count");
-    iter = NS_NewContentIterator();
+    iter = NS_NewPreContentIterator();
     nsresult rv = iter->Init(aStartPosition.mNode);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
   } else {
     RefPtr<nsRange> prev = new nsRange(aRootContent);
     nsresult rv = aStartPosition.SetToRangeStart(prev);
     if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -1483,17 +1483,17 @@ ContentEventHandler::GetFlatTextLengthIn
     }
 
     if (aEndPosition.OffsetIsValid()) {
       // Offset is within node's length; set end of range to that offset
       rv = aEndPosition.SetToRangeEnd(prev);
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
-      iter = NS_NewContentIterator();
+      iter = NS_NewPreContentIterator();
       rv = iter->Init(prev);
       if (NS_WARN_IF(NS_FAILED(rv))) {
         return rv;
       }
     } else if (aEndPosition.mNode != aRootContent) {
       // Offset is past node's length; set end of range to end of node
       rv = aEndPosition.SetToRangeEndAfter(prev);
       if (NS_WARN_IF(NS_FAILED(rv))) {