зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1413181 - part 7: EditorBase::SplitNodeDeep() should stop splitting orphan node if it meets an orphan node before meeting the most ancestor node to be split r=m_kato
This doesn't change any meaning of the loop. It is a bug if the loop meets orphan node before meeting the most ancestor node to be split which is given as aNode. So, we can check it before trying to split it. MozReview-Commit-ID: 1TD7WHCoZh1 --HG-- extra : rebase_source : 17b8d7b3db458e29fb52be5cedb900560e1b70a4
This commit is contained in:
Родитель
bf54c638b2
Коммит
d8cfeab3e4
|
@ -4072,6 +4072,13 @@ EditorBase::SplitNodeDeep(nsIContent& aNode,
|
|||
nsCOMPtr<nsIContent> leftNode, rightNode;
|
||||
OwningNonNull<nsIContent> nodeToSplit = aSplitPointParent;
|
||||
while (true) {
|
||||
// If we meet an orphan node before meeting aNode, we need to stop
|
||||
// splitting. This is a bug of the caller.
|
||||
nsCOMPtr<nsIContent> parent = nodeToSplit->GetParent();
|
||||
if (NS_WARN_IF(nodeToSplit != &aNode && !parent)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// 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
|
||||
|
@ -4099,15 +4106,12 @@ EditorBase::SplitNodeDeep(nsIContent& aNode,
|
|||
leftNode = newLeftNode;
|
||||
}
|
||||
|
||||
NS_ENSURE_TRUE(nodeToSplit->GetParent(), -1);
|
||||
OwningNonNull<nsIContent> parentNode = *nodeToSplit->GetParent();
|
||||
|
||||
if (!didSplit && offset) {
|
||||
// Must be "end of text node" case, we didn't split it, just move past it
|
||||
offset = parentNode->IndexOf(nodeToSplit) + 1;
|
||||
offset = parent->IndexOf(nodeToSplit) + 1;
|
||||
leftNode = nodeToSplit;
|
||||
} else {
|
||||
offset = parentNode->IndexOf(nodeToSplit);
|
||||
offset = parent->IndexOf(nodeToSplit);
|
||||
rightNode = nodeToSplit;
|
||||
}
|
||||
|
||||
|
@ -4116,7 +4120,7 @@ EditorBase::SplitNodeDeep(nsIContent& aNode,
|
|||
break;
|
||||
}
|
||||
|
||||
nodeToSplit = parentNode;
|
||||
nodeToSplit = *parent;
|
||||
}
|
||||
|
||||
if (aOutLeftNode) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче