Bug 1748018 - Make `HTMLEditUtils::GetFirstListItemElement` scan only within the given list element r=m_kato

It calls `nsINode::GetNextNode()` to scan first descendant list item in the
list without specifying the root node to scan within.  Therefore, it may return
following list item element of the given list element if the list element does
not have children.

Differential Revision: https://phabricator.services.mozilla.com/D135110
This commit is contained in:
Masayuki Nakano 2022-01-06 04:04:49 +00:00
Родитель 88b259fb02
Коммит 0edb1a99b9
2 изменённых файлов: 14 добавлений и 1 удалений

Просмотреть файл

@ -1341,7 +1341,7 @@ class HTMLEditUtils final {
MOZ_ASSERT(HTMLEditUtils::IsAnyListElement(&aListElement));
for (nsIContent* maybeFirstListItem = aListElement.GetFirstChild();
maybeFirstListItem;
maybeFirstListItem = maybeFirstListItem->GetNextNode()) {
maybeFirstListItem = maybeFirstListItem->GetNextNode(&aListElement)) {
if (HTMLEditUtils::IsListItem(maybeFirstListItem)) {
return maybeFirstListItem->AsElement();
}

Просмотреть файл

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html id="a">
<meta charset="utf-8">
<script id="b">
window.onload = () => {
c.appendChild(document.head)
a.appendChild(d)
document.execCommand("selectAll")
document.execCommand("delete")
}
</script>
<dl id="c" contenteditable="true">
<dt id="d">