Bug 1728566 - Make the `HTMLEditor::InsertParagraphSeparatorAsSubAction` callers compute the editing host no limited in the `<body>` r=m_kato

While handling an "insertParagraph" command, it's closed at least in the editing
host.  Therefore, it's file to use editing host outside `<body>` because it
won't make the tree messy outside the editing host.

Differential Revision: https://phabricator.services.mozilla.com/D213376
This commit is contained in:
Masayuki Nakano 2024-06-14 00:16:17 +00:00
Родитель 9e46b7e834
Коммит ae22ac0c53
2 изменённых файлов: 26 добавлений и 2 удалений

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

@ -1521,7 +1521,8 @@ NS_IMETHODIMP HTMLEditor::InsertLineBreak() {
return EditorBase::ToGenericNSResult(rv);
}
const RefPtr<Element> editingHost = ComputeEditingHost();
const RefPtr<Element> editingHost =
ComputeEditingHost(LimitInBodyElement::No);
if (!editingHost) {
return NS_SUCCESS_DOM_NO_OPERATION;
}
@ -1568,7 +1569,8 @@ nsresult HTMLEditor::InsertParagraphSeparatorAsAction(
return EditorBase::ToGenericNSResult(rv);
}
const RefPtr<Element> editingHost = ComputeEditingHost();
const RefPtr<Element> editingHost =
ComputeEditingHost(LimitInBodyElement::No);
if (!editingHost) {
return NS_SUCCESS_DOM_NO_OPERATION;
}

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

@ -0,0 +1,22 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script>
"use strict";
document.addEventListener("DOMContentLoaded", () => {
const dl = document.createElement("dl");
const dd = document.createElement("dd");
const p = document.createElement("p");
dd.appendChild(p);
dl.appendChild(dd);
document.documentElement.appendChild(dl);
dl.contentEditable = true;
getSelection().collapse(p, 0);
document.execCommand("insertParagraph");
}, {once: true});
</script>
</head>
<body></body>
</html>