Backed out changeset febed94fa592 (bug 1408227) for asserting at editor/libeditor/EditorBase.cpp:2513 during execution of web-platform-test /editing/run/inserttext.html. r=backout on a CLOSED TREE
authorSebastian Hengst <archaeopteryx@coole-files.de>
Fri, 13 Oct 2017 19:48:22 +0200
changeset 386172 763378dbc0035a1cbe81270d16a088e9d3569ca6
parent 386171 a25dd5df93da4d5676bb51896bcd0301b9c169e9
child 386173 c1b376d294a0da6619eba58bcf752849ede533c4
push id32676
push userarchaeopteryx@coole-files.de
push dateFri, 13 Oct 2017 21:38:18 +0000
treeherdermozilla-central@a31334a65a1c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1408227
milestone58.0a1
backs outfebed94fa5926a5abebd4dcb7c3cd9595410ea73
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 febed94fa592 (bug 1408227) for asserting at editor/libeditor/EditorBase.cpp:2513 during execution of web-platform-test /editing/run/inserttext.html. r=backout on a CLOSED TREE
editor/libeditor/HTMLEditRules.cpp
editor/libeditor/HTMLEditor.cpp
editor/libeditor/TextEditor.cpp
editor/libeditor/TextEditor.h
editor/libeditor/WSRunObject.cpp
editor/libeditor/WSRunObject.h
--- a/editor/libeditor/HTMLEditRules.cpp
+++ b/editor/libeditor/HTMLEditRules.cpp
@@ -1339,17 +1339,16 @@ HTMLEditRules::WillInsertText(EditAction
       }
     }
   }
   // aAction == kInsertText
   else {
     // find where we are
     nsCOMPtr<nsINode> curNode = selNode;
     int32_t curOffset = selOffset;
-    nsCOMPtr<nsIContent> curChild = selChild;
 
     // is our text going to be PREformatted?
     // We remember this so that we know how to handle tabs.
     bool isPRE;
     NS_ENSURE_STATE(mHTMLEditor);
     rv = mHTMLEditor->IsPreformatted(GetAsDOMNode(selNode), &isPRE);
     NS_ENSURE_SUCCESS(rv, rv);
 
@@ -1395,23 +1394,23 @@ HTMLEditRules::WillInsertText(EditAction
 
           nsDependentSubstring subStr(tString, oldPos, subStrLen);
 
           // is it a return?
           if (subStr.Equals(newlineStr)) {
             NS_ENSURE_STATE(mHTMLEditor);
             nsCOMPtr<Element> br =
               mHTMLEditor->CreateBRImpl(address_of(curNode), &curOffset,
-                                        address_of(curChild), nsIEditor::eNone);
+                                        nsIEditor::eNone);
             NS_ENSURE_STATE(br);
             pos++;
           } else {
             NS_ENSURE_STATE(mHTMLEditor);
             rv = mHTMLEditor->InsertTextImpl(subStr, address_of(curNode),
-                                             address_of(curChild),
+                                             address_of(selChild),
                                              &curOffset, doc);
             NS_ENSURE_SUCCESS(rv, rv);
           }
         }
       } else {
         NS_NAMED_LITERAL_STRING(tabStr, "\t");
         NS_NAMED_LITERAL_STRING(spacesStr, "    ");
         char specialChars[] = {TAB, nsCRT::LF, 0};
@@ -1435,31 +1434,31 @@ HTMLEditRules::WillInsertText(EditAction
           nsDependentSubstring subStr(tString, oldPos, subStrLen);
           NS_ENSURE_STATE(mHTMLEditor);
           WSRunObject wsObj(mHTMLEditor, curNode, curOffset);
 
           // is it a tab?
           if (subStr.Equals(tabStr)) {
             rv =
               wsObj.InsertText(spacesStr, address_of(curNode),
-                               address_of(curChild), &curOffset, doc);
+                               address_of(selChild), &curOffset, doc);
             NS_ENSURE_SUCCESS(rv, rv);
             pos++;
           }
           // is it a return?
           else if (subStr.Equals(newlineStr)) {
             nsCOMPtr<Element> br = wsObj.InsertBreak(address_of(curNode),
                                                      &curOffset,
-                                                     nsIEditor::eNone,
-                                                     address_of(curChild));
+                                                     nsIEditor::eNone);
             NS_ENSURE_TRUE(br, NS_ERROR_FAILURE);
             pos++;
+            selChild = br->GetNextSibling();;
           } else {
             rv = wsObj.InsertText(subStr, address_of(curNode),
-                                  address_of(curChild), &curOffset, doc);
+                                  address_of(selChild), &curOffset, doc);
             NS_ENSURE_SUCCESS(rv, rv);
           }
         }
       }
     }
     aSelection->SetInterlinePosition(false);
     if (curNode) aSelection->Collapse(curNode, curOffset);
     // manually update the doc changed range so that AfterEdit will clean up
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -1028,30 +1028,30 @@ already_AddRefed<Element>
 HTMLEditor::CreateBR(nsINode* aNode,
                      int32_t aOffset,
                      EDirection aSelect)
 {
   nsCOMPtr<nsIDOMNode> parent = GetAsDOMNode(aNode);
   int32_t offset = aOffset;
   nsCOMPtr<nsIDOMNode> outBRNode;
   // We assume everything is fine if the br is not null, irrespective of retval
-  CreateBRImpl(address_of(parent), &offset, nullptr, address_of(outBRNode), aSelect);
+  CreateBRImpl(address_of(parent), &offset, address_of(outBRNode), aSelect);
   nsCOMPtr<Element> ret = do_QueryInterface(outBRNode);
   return ret.forget();
 }
 
 NS_IMETHODIMP
 HTMLEditor::CreateBR(nsIDOMNode* aNode,
                      int32_t aOffset,
                      nsCOMPtr<nsIDOMNode>* outBRNode,
                      EDirection aSelect)
 {
   nsCOMPtr<nsIDOMNode> parent = aNode;
   int32_t offset = aOffset;
-  return CreateBRImpl(address_of(parent), &offset, nullptr, outBRNode, aSelect);
+  return CreateBRImpl(address_of(parent), &offset, outBRNode, aSelect);
 }
 
 nsresult
 HTMLEditor::InsertBR(nsCOMPtr<nsIDOMNode>* outBRNode)
 {
   NS_ENSURE_TRUE(outBRNode, NS_ERROR_NULL_POINTER);
   *outBRNode = nullptr;
 
--- a/editor/libeditor/TextEditor.cpp
+++ b/editor/libeditor/TextEditor.cpp
@@ -412,43 +412,39 @@ TextEditor::TypedText(const nsAString& a
       // eTypedBR is only for HTML
       return NS_ERROR_FAILURE;
   }
 }
 
 already_AddRefed<Element>
 TextEditor::CreateBRImpl(nsCOMPtr<nsINode>* aInOutParent,
                          int32_t* aInOutOffset,
-                         nsCOMPtr<nsIContent>* aInOutChildAtOffset,
                          EDirection aSelect)
 {
   nsCOMPtr<nsIDOMNode> parent(GetAsDOMNode(*aInOutParent));
   nsCOMPtr<nsIDOMNode> br;
   // We ignore the retval, and assume it's fine if the br is non-null
-  CreateBRImpl(address_of(parent), aInOutOffset, aInOutChildAtOffset,
-               address_of(br), aSelect);
+  CreateBRImpl(address_of(parent), aInOutOffset, address_of(br), aSelect);
   *aInOutParent = do_QueryInterface(parent);
   nsCOMPtr<Element> ret(do_QueryInterface(br));
   return ret.forget();
 }
 
 nsresult
 TextEditor::CreateBRImpl(nsCOMPtr<nsIDOMNode>* aInOutParent,
                          int32_t* aInOutOffset,
-                         nsCOMPtr<nsIContent>* aInOutChildAtOffset,
                          nsCOMPtr<nsIDOMNode>* outBRNode,
                          EDirection aSelect)
 {
   NS_ENSURE_TRUE(aInOutParent && *aInOutParent && aInOutOffset && outBRNode, NS_ERROR_NULL_POINTER);
   *outBRNode = nullptr;
 
   // we need to insert a br.  unfortunately, we may have to split a text node to do it.
   nsCOMPtr<nsINode> node = do_QueryInterface(*aInOutParent);
   int32_t theOffset = *aInOutOffset;
-  const int32_t kInOffset = *aInOutOffset;
   RefPtr<Element> brNode;
   if (IsTextNode(node)) {
     int32_t offset;
     nsCOMPtr<nsINode> tmp = GetNodeLocation(node, &offset);
     NS_ENSURE_TRUE(tmp, NS_ERROR_FAILURE);
     if (!theOffset) {
       // we are already set to go
     } else if (theOffset == static_cast<int32_t>(node->Length())) {
@@ -472,21 +468,16 @@ TextEditor::CreateBRImpl(nsCOMPtr<nsIDOM
     *aInOutOffset = offset+1;
   } else {
     brNode = CreateNode(nsGkAtoms::br, node, theOffset);
     if (NS_WARN_IF(!brNode)) {
       return NS_ERROR_FAILURE;
     }
     (*aInOutOffset)++;
   }
-  for (int32_t i = 0; i < *aInOutOffset - kInOffset; ++i) {
-    if (aInOutChildAtOffset && *aInOutChildAtOffset) {
-      *aInOutChildAtOffset = (*aInOutChildAtOffset)->GetNextSibling();
-    }
-  }
 
   *outBRNode = GetAsDOMNode(brNode);
   if (*outBRNode && (aSelect != eNone)) {
     int32_t offset;
     nsCOMPtr<nsINode> parent = GetNodeLocation(brNode, &offset);
 
     RefPtr<Selection> selection = GetSelection();
     NS_ENSURE_STATE(selection);
@@ -507,17 +498,17 @@ TextEditor::CreateBRImpl(nsCOMPtr<nsIDOM
 NS_IMETHODIMP
 TextEditor::CreateBR(nsIDOMNode* aNode,
                      int32_t aOffset,
                      nsCOMPtr<nsIDOMNode>* outBRNode,
                      EDirection aSelect)
 {
   nsCOMPtr<nsIDOMNode> parent = aNode;
   int32_t offset = aOffset;
-  return CreateBRImpl(address_of(parent), &offset, nullptr, outBRNode, aSelect);
+  return CreateBRImpl(address_of(parent), &offset, outBRNode, aSelect);
 }
 
 nsresult
 TextEditor::ExtendSelectionForDelete(Selection* aSelection,
                                      nsIEditor::EDirection* aAction)
 {
   bool bCollapsed = aSelection->Collapsed();
 
--- a/editor/libeditor/TextEditor.h
+++ b/editor/libeditor/TextEditor.h
@@ -185,24 +185,21 @@ protected:
   already_AddRefed<nsIDocumentEncoder> GetAndInitDocEncoder(
                                          const nsAString& aFormatType,
                                          uint32_t aFlags,
                                          const nsACString& aCharset);
 
   NS_IMETHOD CreateBR(nsIDOMNode* aNode, int32_t aOffset,
                       nsCOMPtr<nsIDOMNode>* outBRNode,
                       EDirection aSelect = eNone);
-  already_AddRefed<Element>
-    CreateBRImpl(nsCOMPtr<nsINode>* aInOutParent,
-                 int32_t* aInOutOffset,
-                 nsCOMPtr<nsIContent>* aInOutChildAtOffset,
-                 EDirection aSelect);
+  already_AddRefed<Element> CreateBRImpl(nsCOMPtr<nsINode>* aInOutParent,
+                                         int32_t* aInOutOffset,
+                                         EDirection aSelect);
   nsresult CreateBRImpl(nsCOMPtr<nsIDOMNode>* aInOutParent,
                         int32_t* aInOutOffset,
-                        nsCOMPtr<nsIContent>* aInOutChildAtOffset,
                         nsCOMPtr<nsIDOMNode>* outBRNode,
                         EDirection aSelect);
 
   /**
    * Factored methods for handling insertion of data from transferables
    * (drag&drop or clipboard).
    */
   NS_IMETHOD PrepareTransferable(nsITransferable** transferable);
--- a/editor/libeditor/WSRunObject.cpp
+++ b/editor/libeditor/WSRunObject.cpp
@@ -164,18 +164,17 @@ WSRunObject::PrepareToSplitAcrossBlocks(
   WSRunObject wsObj(aHTMLEditor, *aSplitNode, *aSplitOffset);
 
   return wsObj.PrepareToSplitAcrossBlocksPriv();
 }
 
 already_AddRefed<Element>
 WSRunObject::InsertBreak(nsCOMPtr<nsINode>* aInOutParent,
                          int32_t* aInOutOffset,
-                         nsIEditor::EDirection aSelect,
-                         nsCOMPtr<nsIContent>* aInOutChildAtOffset)
+                         nsIEditor::EDirection aSelect)
 {
   // MOOSE: for now, we always assume non-PRE formatting.  Fix this later.
   // meanwhile, the pre case is handled in WillInsertText in
   // HTMLEditRules.cpp
   NS_ENSURE_TRUE(aInOutParent && aInOutOffset, nullptr);
 
   WSFragment *beforeRun, *afterRun;
   FindRun(*aInOutParent, *aInOutOffset, &beforeRun, false);
@@ -224,18 +223,17 @@ WSRunObject::InsertBreak(nsCOMPtr<nsINod
     } else if (beforeRun->mType == WSType::normalWS) {
       // Try to change an nbsp to a space, just to prevent nbsp proliferation
       nsresult rv = CheckTrailingNBSP(beforeRun, *aInOutParent, *aInOutOffset);
       NS_ENSURE_SUCCESS(rv, nullptr);
     }
   }
 
   // ready, aim, fire!
-  return mHTMLEditor->CreateBRImpl(aInOutParent, aInOutOffset,
-                                   aInOutChildAtOffset, aSelect);
+  return mHTMLEditor->CreateBRImpl(aInOutParent, aInOutOffset, aSelect);
 }
 
 nsresult
 WSRunObject::InsertText(const nsAString& aStringToInsert,
                         nsCOMPtr<nsINode>* aInOutParent,
                         nsCOMPtr<nsIContent>* aInOutChildAtOffset,
                         int32_t* aInOutOffset,
                         nsIDocument* aDoc)
--- a/editor/libeditor/WSRunObject.h
+++ b/editor/libeditor/WSRunObject.h
@@ -210,21 +210,19 @@ public:
   static nsresult PrepareToSplitAcrossBlocks(HTMLEditor* aHTMLEditor,
                                              nsCOMPtr<nsINode>* aSplitNode,
                                              int32_t* aSplitOffset);
 
   // InsertBreak inserts a br node at {aInOutParent,aInOutOffset}
   // and makes any needed adjustments to ws around that point.
   // example of fixup: normalws after {aInOutParent,aInOutOffset}
   //                   needs to begin with nbsp.
-  already_AddRefed<dom::Element>
-    InsertBreak(nsCOMPtr<nsINode>* aInOutParent,
-                int32_t* aInOutOffset,
-                nsIEditor::EDirection aSelect,
-                nsCOMPtr<nsIContent>* aInOutChildAtOffset = nullptr);
+  already_AddRefed<dom::Element> InsertBreak(nsCOMPtr<nsINode>* aInOutParent,
+                                             int32_t* aInOutOffset,
+                                             nsIEditor::EDirection aSelect);
 
   // InsertText inserts a string at {aInOutParent,aInOutOffset} and makes any
   // needed adjustments to ws around that point.  Example of fixup:
   // trailingws before {aInOutParent,aInOutOffset} needs to be removed.
   nsresult InsertText(const nsAString& aStringToInsert,
                       nsCOMPtr<nsINode>* aInOutNode,
                       nsCOMPtr<nsIContent>* aInOutChildAtOffset,
                       int32_t* aInOutOffset,