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
--- 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