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

--HG--
extra : rebase_source : f594bdf7cd9efac7d10e6e05a8f87dadfc761295
This commit is contained in:
Makoto Kato 2018-05-16 16:54:20 +09:00
parent fdb1c18e80
commit bf208eff66
3 changed files with 21 additions and 8 deletions

View File

@ -4009,6 +4009,13 @@ EditorBase::SplitNodeDeepWithTransaction(
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 &&
@ -4016,14 +4023,6 @@ EditorBase::SplitNodeDeepWithTransaction(
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

View File

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

View File

@ -96,6 +96,7 @@ 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