Backed out changeset 19fee71d7e27 (bug 1408125)
authorSebastian Hengst <archaeopteryx@coole-files.de>
Sat, 14 Oct 2017 00:05:10 +0200
changeset 386258 f5034aeb64077a10abfabc0d58d046b2e6cee5c7
parent 386257 95dff4968a191f64341700d28fa954d898cd8367
child 386259 1f8ee2e6f0658e2ab760a5a7618ac0fa2298760d
push id53313
push userarchaeopteryx@coole-files.de
push dateSat, 14 Oct 2017 10:39:31 +0000
treeherderautoland@169bde8f9f3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1408125
milestone58.0a1
backs out19fee71d7e277ee56f7674ca7d40bea8eb5d7945
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
Backed out changeset 19fee71d7e27 (bug 1408125)
editor/libeditor/EditorBase.cpp
editor/libeditor/HTMLEditor.cpp
editor/libeditor/HTMLEditorDataTransfer.cpp
editor/libeditor/HTMLTableEditor.cpp
editor/libeditor/TextEditRules.cpp
--- a/editor/libeditor/EditorBase.cpp
+++ b/editor/libeditor/EditorBase.cpp
@@ -1696,23 +1696,23 @@ EditorBase::ReplaceContainer(Element* aO
   {
     AutoTransactionsConserveSelection conserveSelection(this);
     while (aOldContainer->HasChildren()) {
       nsCOMPtr<nsIContent> child = aOldContainer->GetFirstChild();
 
       nsresult rv = DeleteNode(child);
       NS_ENSURE_SUCCESS(rv, nullptr);
 
-      rv = InsertNode(*child, *ret, -1, nullptr);
+      rv = InsertNode(*child, *ret, -1);
       NS_ENSURE_SUCCESS(rv, nullptr);
     }
   }
 
   // insert new container into tree
-  nsresult rv = InsertNode(*ret, *parent, offset, aOldContainer);
+  nsresult rv = InsertNode(*ret, *parent, offset);
   NS_ENSURE_SUCCESS(rv, nullptr);
 
   // delete old container
   rv = DeleteNode(aOldContainer);
   NS_ENSURE_SUCCESS(rv, nullptr);
 
   return ret.forget();
 }
@@ -1733,27 +1733,23 @@ EditorBase::RemoveContainer(nsIContent* 
 
   // Loop through the children of inNode and promote them into inNode's parent
   uint32_t nodeOrigLen = aNode->GetChildCount();
 
   // notify our internal selection state listener
   AutoRemoveContainerSelNotify selNotify(mRangeUpdater, aNode, parent,
                                          offset, nodeOrigLen);
 
-  nsIContent* childAtOffset = aNode;
-
   while (aNode->HasChildren()) {
     nsCOMPtr<nsIContent> child = aNode->GetLastChild();
     nsresult rv = DeleteNode(child);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    rv = InsertNode(*child, *parent, offset, childAtOffset);
+    rv = InsertNode(*child, *parent, offset);
     NS_ENSURE_SUCCESS(rv, rv);
-
-    childAtOffset = childAtOffset->GetPreviousSibling();
   }
 
   return DeleteNode(aNode);
 }
 
 /**
  * InsertContainerAbove() inserts a new parent for inNode, which is contructed
  * to be of type aNodeType.  outNode becomes a child of inNode's earlier
@@ -1782,30 +1778,27 @@ EditorBase::InsertContainerAbove(nsICont
       newContent->SetAttr(kNameSpaceID_None, aAttribute, *aValue, true);
     NS_ENSURE_SUCCESS(rv, nullptr);
   }
 
   // Notify our internal selection state listener
   AutoInsertContainerSelNotify selNotify(mRangeUpdater);
 
   // Put inNode in new parent, outNode
-  nsIContent* nextSibling = aNode->GetNextSibling();
   nsresult rv = DeleteNode(aNode);
   NS_ENSURE_SUCCESS(rv, nullptr);
 
   {
     AutoTransactionsConserveSelection conserveSelection(this);
-    rv = InsertNode(*aNode, *newContent, 0, nullptr);
+    rv = InsertNode(*aNode, *newContent, 0);
     NS_ENSURE_SUCCESS(rv, nullptr);
   }
 
   // Put new parent in doc
-  // Since we have deleted aNode above, now its next sibling is the child at
-  // our offset.
-  rv = InsertNode(*newContent, *parent, offset, nextSibling);
+  rv = InsertNode(*newContent, *parent, offset);
   NS_ENSURE_SUCCESS(rv, nullptr);
 
   return newContent.forget();
 }
 
 /**
  * MoveNode() moves aNode to {aParent,aOffset}.
  */
@@ -2549,17 +2542,17 @@ EditorBase::InsertTextImpl(const nsAStri
 
   if (ShouldHandleIMEComposition()) {
     CheckedInt<int32_t> newOffset;
     if (!node->IsNodeOfType(nsINode::eTEXT)) {
       // create a text node
       RefPtr<nsTextNode> newNode =
         EditorBase::CreateTextNode(*aDoc, EmptyString());
       // then we insert it into the dom tree
-      nsresult rv = InsertNode(*newNode, *node, offset, child);
+      nsresult rv = InsertNode(*newNode, *node, offset);
       NS_ENSURE_SUCCESS(rv, rv);
       node = newNode;
       offset = 0;
       newOffset = lengthToInsert;
     } else {
       newOffset = lengthToInsert + offset;
       NS_ENSURE_TRUE(newOffset.isValid(), NS_ERROR_FAILURE);
     }
@@ -2577,17 +2570,17 @@ EditorBase::InsertTextImpl(const nsAStri
       NS_ENSURE_SUCCESS(rv, rv);
       offset = newOffset.value();
     } else {
       // we are inserting text into a non-text node.  first we have to create a
       // textnode (this also populates it with the text)
       RefPtr<nsTextNode> newNode =
         EditorBase::CreateTextNode(*aDoc, aStringToInsert);
       // then we insert it into the dom tree
-      nsresult rv = InsertNode(*newNode, *node, offset, child);
+      nsresult rv = InsertNode(*newNode, *node, offset);
       NS_ENSURE_SUCCESS(rv, rv);
       node = newNode;
       offset = lengthToInsert.value();
     }
   }
 
   *aInOutNode = node;
   *aInOutOffset = offset;
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -1180,17 +1180,17 @@ HTMLEditor::ReplaceHeadContentsWithHTML(
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   // Now insert the new nodes
   int32_t offsetOfNewNode = 0;
 
   // Loop over the contents of the fragment and move into the document
   while (nsCOMPtr<nsIContent> child = docfrag->GetFirstChild()) {
-    nsresult rv = InsertNode(*child, *headNode, offsetOfNewNode++, nullptr);
+    nsresult rv = InsertNode(*child, *headNode, offsetOfNewNode++);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HTMLEditor::RebuildDocumentFromSource(const nsAString& aSourceString)
@@ -1623,25 +1623,19 @@ HTMLEditor::InsertNodeAtPoint(nsIDOMNode
     NS_ENSURE_STATE(offset != -1);
     *ioParent = GetAsDOMNode(parent);
     *ioOffset = offset;
     if (ioChildAtOffset) {
       *ioChildAtOffset = GetAsDOMNode(child);
     }
   }
   // Now we can insert the new node
-  nsCOMPtr<nsIContent> child;
-  if (ioChildAtOffset) {
-    child = do_QueryInterface(*ioChildAtOffset);
-  }
-  nsresult rv = InsertNode(*node, *parent, *ioOffset, child);
+  nsresult rv = InsertNode(*node, *parent, *ioOffset);
   if (isDocumentFragment) {
     *ioChildAtOffset = do_QueryInterface(parent->GetChildAt(*ioOffset));
-  } else if (ioChildAtOffset) {
-    *ioChildAtOffset = GetAsDOMNode(child);
   }
   return rv;
 }
 
 NS_IMETHODIMP
 HTMLEditor::SelectElement(nsIDOMElement* aElement)
 {
   nsCOMPtr<Element> element = do_QueryInterface(aElement);
--- a/editor/libeditor/HTMLEditorDataTransfer.cpp
+++ b/editor/libeditor/HTMLEditorDataTransfer.cpp
@@ -129,29 +129,24 @@ HTMLEditor::LoadHTML(const nsAString& aI
     // create fragment for pasted html
     nsCOMPtr<nsIDOMDocumentFragment> docfrag;
     rv = range->CreateContextualFragment(aInputString, getter_AddRefs(docfrag));
     NS_ENSURE_SUCCESS(rv, rv);
     // put the fragment into the document
     nsCOMPtr<nsINode> parent = range->GetStartContainer();
     NS_ENSURE_TRUE(parent, NS_ERROR_NULL_POINTER);
     uint32_t childOffset = range->StartOffset();
-    nsCOMPtr<nsIContent> child = range->GetChildAtStartOffset();
 
     nsCOMPtr<nsIDOMNode> nodeToInsert;
     docfrag->GetFirstChild(getter_AddRefs(nodeToInsert));
     while (nodeToInsert) {
       rv = InsertNode(nodeToInsert, GetAsDOMNode(parent),
-                      static_cast<int32_t>(childOffset), child);
+                      static_cast<int32_t>(childOffset++));
       NS_ENSURE_SUCCESS(rv, rv);
-      childOffset++;
       docfrag->GetFirstChild(getter_AddRefs(nodeToInsert));
-      if (child) {
-        child = child->GetNextSibling();
-      }
     }
   }
 
   return rules->DidDoAction(selection, &ruleInfo, rv);
 }
 
 NS_IMETHODIMP
 HTMLEditor::InsertHTML(const nsAString& aInString)
--- a/editor/libeditor/HTMLTableEditor.cpp
+++ b/editor/libeditor/HTMLTableEditor.cpp
@@ -99,17 +99,16 @@ HTMLEditor::InsertCell(nsIDOMElement* aC
   }
 
   // And the parent and offsets needed to do an insert
   nsCOMPtr<nsIDOMNode> cellParent;
   nsresult rv = aCell->GetParentNode(getter_AddRefs(cellParent));
   NS_ENSURE_SUCCESS(rv, rv);
   NS_ENSURE_TRUE(cellParent, NS_ERROR_NULL_POINTER);
 
-  nsCOMPtr<nsIContent> child = do_QueryInterface(aCell);
   int32_t cellOffset = GetChildOffset(aCell, cellParent);
 
   nsCOMPtr<nsIDOMElement> newCell;
   rv = CreateElementWithDefaults(aIsHeader ? NS_LITERAL_STRING("th") :
                                              NS_LITERAL_STRING("tb"),
                                  getter_AddRefs(newCell));
   if (NS_FAILED(rv)) {
     return rv;
@@ -133,24 +132,21 @@ HTMLEditor::InsertCell(nsIDOMElement* aC
   if (aColSpan > 1) {
     // Note: Do NOT use editor transaction for this
     nsAutoString newColSpan;
     newColSpan.AppendInt(aColSpan, 10);
     newCell->SetAttribute(NS_LITERAL_STRING("colspan"), newColSpan);
   }
   if (aAfter) {
     cellOffset++;
-    if (child) {
-      child = child->GetNextSibling();
-    }
   }
 
   //Don't let Rules System change the selection
   AutoTransactionsConserveSelection dontChangeSelection(this);
-  return InsertNode(newCell, cellParent, cellOffset, child);
+  return InsertNode(newCell, cellParent, cellOffset);
 }
 
 NS_IMETHODIMP
 HTMLEditor::SetColSpan(nsIDOMElement* aCell,
                        int32_t aColSpan)
 {
   NS_ENSURE_TRUE(aCell, NS_ERROR_NULL_POINTER);
   nsAutoString newSpan;
@@ -179,17 +175,16 @@ HTMLEditor::InsertTableCell(int32_t aNum
   nsresult rv = GetCellContext(nullptr,
                                getter_AddRefs(table),
                                getter_AddRefs(curCell),
                                getter_AddRefs(cellParent), &cellOffset,
                                &startRowIndex, &startColIndex);
   NS_ENSURE_SUCCESS(rv, rv);
   // Don't fail if no cell found
   NS_ENSURE_TRUE(curCell, NS_SUCCESS_EDITOR_ELEMENT_NOT_FOUND);
-  nsCOMPtr<nsIContent> child = do_QueryInterface(curCell);
 
   // Get more data for current cell in row we are inserting at (we need COLSPAN)
   int32_t curStartRowIndex, curStartColIndex, rowSpan, colSpan, actualRowSpan, actualColSpan;
   bool    isSelected;
   rv = GetCellDataAt(table, startRowIndex, startColIndex,
                      getter_AddRefs(curCell),
                      &curStartRowIndex, &curStartColIndex, &rowSpan, &colSpan,
                      &actualRowSpan, &actualColSpan, &isSelected);
@@ -205,21 +200,18 @@ HTMLEditor::InsertTableCell(int32_t aNum
 
   for (int32_t i = 0; i < aNumber; i++) {
     nsCOMPtr<nsIDOMElement> newCell;
     rv = CreateElementWithDefaults(NS_LITERAL_STRING("td"),
                                    getter_AddRefs(newCell));
     if (NS_SUCCEEDED(rv) && newCell) {
       if (aAfter) {
         cellOffset++;
-        if (child) {
-          child = child->GetNextSibling();
-        }
       }
-      rv = InsertNode(newCell, cellParent, cellOffset, child);
+      rv = InsertNode(newCell, cellParent, cellOffset);
       if (NS_FAILED(rv)) {
         break;
       }
     }
   }
   // XXX This is perhaps the result of the last call of InsertNode() or
   //     CreateElementWithDefaults().
   return rv;
@@ -662,22 +654,20 @@ HTMLEditor::InsertTableRow(int32_t aNumb
     nsCOMPtr<Element> parentRow =
       GetElementOrParentByTagName(trStr, cellNodeForRowParent);
     NS_ENSURE_TRUE(parentRow, NS_ERROR_NULL_POINTER);
 
     // The row parent and offset where we will insert new row
     nsCOMPtr<nsINode> parentOfRow = parentRow->GetParentNode();
     NS_ENSURE_TRUE(parentOfRow, NS_ERROR_NULL_POINTER);
     int32_t newRowOffset = parentOfRow->IndexOf(parentRow);
-    nsIContent* child = parentRow;
 
     // Adjust for when adding past the end
     if (aAfter && startRowIndex >= rowCount) {
       newRowOffset++;
-      child = child->GetNextSibling();
     }
 
     for (int32_t row = 0; row < aNumber; row++) {
       // Create a new row
       nsCOMPtr<Element> newRow = CreateElementWithDefaults(trStr);
       NS_ENSURE_TRUE(newRow, NS_ERROR_FAILURE);
 
       for (int32_t i = 0; i < cellsInRow; i++) {
@@ -691,17 +681,17 @@ HTMLEditor::InsertTableRow(int32_t aNumb
         newRow->AppendChild(*newCell, result);
         if (NS_WARN_IF(result.Failed())) {
           return result.StealNSResult();
         }
       }
 
       // Use transaction system to insert the entire row+cells
       // (Note that rows are inserted at same childoffset each time)
-      rv = InsertNode(*newRow, *parentOfRow, newRowOffset, child);
+      rv = InsertNode(*newRow, *parentOfRow, newRowOffset);
       NS_ENSURE_SUCCESS(rv, rv);
     }
   }
 
   // SetSelectionAfterTableEdit from AutoSelectionSetterAfterTableEdit will
   // access frame selection, so we need reframe.
   // Because GetCellAt depends on frame.
   nsCOMPtr<nsIPresShell> ps = GetPresShell();
@@ -2336,18 +2326,17 @@ HTMLEditor::MergeCells(nsCOMPtr<nsIDOMEl
     }
 
     // Move the contents
     while (cellToMerge->HasChildren()) {
       nsCOMPtr<nsIDOMNode> cellChild = cellToMerge->GetLastChild()->AsDOMNode();
       nsresult rv = DeleteNode(cellChild);
       NS_ENSURE_SUCCESS(rv, rv);
 
-      rv = InsertNode(cellChild, aTargetCell, insertIndex,
-                      targetCell->GetLastChild());
+      rv = InsertNode(cellChild, aTargetCell, insertIndex);
       NS_ENSURE_SUCCESS(rv, rv);
     }
   }
 
   // Delete cells whose contents were moved
   if (aDeleteCellToMerge) {
     return DeleteNode(aCellToMerge);
   }
--- a/editor/libeditor/TextEditRules.cpp
+++ b/editor/libeditor/TextEditRules.cpp
@@ -855,18 +855,17 @@ TextEditRules::WillSetText(Selection& aS
     RefPtr<nsIDocument> doc = textEditor->GetDocument();
     if (NS_WARN_IF(!doc)) {
       return NS_OK;
     }
     RefPtr<nsTextNode> newNode = EditorBase::CreateTextNode(*doc, tString);
     if (NS_WARN_IF(!newNode)) {
       return NS_OK;
     }
-    nsresult rv = textEditor->InsertNode(*newNode, *rootElement, 0,
-                                         rootElement->GetFirstChild());
+    nsresult rv = textEditor->InsertNode(*newNode, *rootElement, 0);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return rv;
     }
     *aHandled = true;
 
     ASSERT_PASSWORD_LENGTHS_EQUAL();
 
     return NS_OK;
@@ -1431,18 +1430,17 @@ TextEditRules::CreateBogusNodeIfNeeded(S
   // set mBogusNode to be the newly created <br>
   mBogusNode = newContent;
 
   // Give it a special attribute.
   newContent->SetAttr(kNameSpaceID_None, kMOZEditorBogusNodeAttrAtom,
                       kMOZEditorBogusNodeValue, false);
 
   // Put the node in the document.
-  nsresult rv = mTextEditor->InsertNode(*mBogusNode, *body, 0,
-                                        body->GetFirstChild());
+  nsresult rv = mTextEditor->InsertNode(*mBogusNode, *body, 0);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Set selection.
   aSelection->Collapse(body, 0);
   return NS_OK;
 }