Bug 1423767 - Splitting node might be orphan. r=masayuki
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Wed, 16 May 2018 16:54:20 +0900
changeset 475298 d25e01a0ac0963b8c7b7dfa22fbc1912828417ba
parent 475297 26af09fb8be9e644be92f4dea6b94440804c13a8
child 475299 e5ecf6627dfd203a2d6e3f764811fb132fe2126a
push id1757
push userffxbld-merge
push dateFri, 24 Aug 2018 17:02:43 +0000
treeherdermozilla-release@736023aebdb1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1423767
milestone62.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 1423767 - Splitting node might be orphan. r=masayuki SplitNodeDeepWithTransaction will split nodes until better point. But this test case becomes that node is orphan into loop. So I would like to add more check whether parent is nothing. MozReview-Commit-ID: EroSV4uVBVL
editor/libeditor/EditorBase.cpp
editor/libeditor/crashtests/1423767.html
editor/libeditor/crashtests/crashtests.list
--- a/editor/libeditor/EditorBase.cpp
+++ b/editor/libeditor/EditorBase.cpp
@@ -4004,31 +4004,30 @@ EditorBase::SplitNodeDeepWithTransaction
 
   if (NS_WARN_IF(!aStartOfDeepestRightNode.IsSet())) {
     return SplitNodeResult(NS_ERROR_INVALID_ARG);
   }
 
   nsCOMPtr<nsIContent> newLeftNodeOfMostAncestor;
   EditorDOMPoint atStartOfRightNode(aStartOfDeepestRightNode);
   while (true) {
+    // Need to insert rules code call here to do things like not split a list
+    // if you are after the last <li> or before the first, etc.  For now we
+    // just have some smarts about unneccessarily splitting text nodes, which
+    // should be universal enough to put straight in this EditorBase routine.
+    if (NS_WARN_IF(!atStartOfRightNode.GetContainerAsContent())) {
+      return SplitNodeResult(NS_ERROR_FAILURE);
+    }
     // If we meet an orphan node before meeting aMostAncestorToSplit, we need
     // to stop splitting.  This is a bug of the caller.
     if (NS_WARN_IF(atStartOfRightNode.GetContainer() != &aMostAncestorToSplit &&
                    !atStartOfRightNode.GetContainer()->GetParent())) {
       return SplitNodeResult(NS_ERROR_FAILURE);
     }
 
-    // Need to insert rules code call here to do things like not split a list
-    // if you are after the last <li> or before the first, etc.  For now we
-    // just have some smarts about unneccessarily splitting text nodes, which
-    // should be universal enough to put straight in this EditorBase routine.
-
-    if (NS_WARN_IF(!atStartOfRightNode.GetContainerAsContent())) {
-      return SplitNodeResult(NS_ERROR_FAILURE);
-    }
     nsIContent* currentRightNode = atStartOfRightNode.GetContainerAsContent();
 
     // If the split point is middle of the node or the node is not a text node
     // and we're allowed to create empty element node, split it.
     if ((aSplitAtEdges == SplitAtEdges::eAllowToCreateEmptyContainer &&
          !atStartOfRightNode.GetContainerAsText()) ||
         (!atStartOfRightNode.IsStartOfContainer() &&
          !atStartOfRightNode.IsEndOfContainer())) {
new file mode 100644
--- /dev/null
+++ b/editor/libeditor/crashtests/1423767.html
@@ -0,0 +1,13 @@
+<script>
+function go() {
+  document.getElementById("label1").addEventListener("DOMNodeRemoved", () => {
+    document.getElementById("a1").innerText = "";
+  });
+  document.execCommand("indent", false);
+}
+</script>
+<body onload=go()>
+<li contenteditable="">
+<a id="a1">
+<label id="label1"></br>
+<!---
--- a/editor/libeditor/crashtests/crashtests.list
+++ b/editor/libeditor/crashtests/crashtests.list
@@ -91,13 +91,14 @@ load 1393171.html
 needs-focus load 1402196.html
 load 1402469.html
 load 1402526.html
 load 1402904.html
 load 1405747.html
 load 1408170.html
 load 1414581.html
 load 1415231.html
+load 1423767.html
 needs-focus load 1424450.html
 load 1425091.html
 load 1443664.html
 skip-if(Android) needs-focus load 1444630.html
 load 1446451.html