Bug 1870222 - part 2: Make `HTMLEditor::OnEndHandlingTopLevelEditSubActionInternal` treat non-editable things as visible r=m_kato

When it cleans up unnecessary new empty inline ancestors, it should treat
non-editable elements in the inline containers as visible.

Depends on D196813

Differential Revision: https://phabricator.services.mozilla.com/D196814
This commit is contained in:
Masayuki Nakano 2023-12-25 12:54:06 +00:00
Родитель fa2b298f1a
Коммит 811e10d8a9
5 изменённых файлов: 52 добавлений и 3 удалений

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

@ -710,9 +710,7 @@ nsresult HTMLEditor::OnEndHandlingTopLevelEditSubActionInternal() {
if (!ancestor->IsHTMLElement() ||
!HTMLEditUtils::IsRemovableFromParentNode(*ancestor) ||
!HTMLEditUtils::IsEmptyInlineContainer(
*ancestor,
{EmptyCheckOption::TreatSingleBRElementAsVisible,
EmptyCheckOption::TreatNonEditableContentAsInvisible},
*ancestor, {EmptyCheckOption::TreatSingleBRElementAsVisible},
BlockInlineCheck::UseComputedDisplayStyle)) {
break;
}

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

@ -1100,3 +1100,6 @@
[[["delete",""\],["inserttext","g"\],["inserttext","h"\]\] "<div style=display:grid><span>abc</span><span><b>{def</b></span>}</div>" compare innerHTML]
expected:
if not early_beta_or_earlier: FAIL
[[["delete",""\],["inserttext","Y"\]\] "<b><span contenteditable=false>abc</span>X[\]</b><i>def</i>" compare innerHTML]
expected: FAIL

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

@ -3074,4 +3074,15 @@ var browserTests = [
"<div style=\"display:grid\"><span>abc</span><span><br></span></div>",
[true],
{}],
// Do not delete non-editable when deleting an editable character
["<b>X[]<span contenteditable=false>abc</span></b><i>def</i>",
[["delete",""]],
"<b><span contenteditable=\"false\">abc</span></b><i>def</i>",
[true],
{}],
["<b><span contenteditable=false>abc</span>X[]</b><i>def</i>",
[["delete",""]],
"<b><span contenteditable=\"false\">abc</span></b><i>def</i>",
[true],
{}],
]

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

@ -2954,4 +2954,15 @@ var browserTests = [
"<div style=\"display:grid\"><span>abc</span><span><br></span></div>",
[true],
{}],
// Do not delete non-editable when deleting an editable character
["<b>[]X<span contenteditable=false>abc</span></b><i>def</i>",
[["forwarddelete",""]],
"<b><span contenteditable=\"false\">abc</span></b><i>def</i>",
[true],
{}],
["<b><span contenteditable=false>abc</span>[]X</b><i>def</i>",
[["forwarddelete",""]],
"<b><span contenteditable=\"false\">abc</span></b><i>def</i>",
[true],
{}],
]

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

@ -3218,4 +3218,30 @@ var browserTests = [
"<div style=\"display:grid\"><span>abc</span><span><b>gh</b><br></span></div>"],
[true,true,true],
{}],
// Do not delete non-editable when deleting an editable character and preseve
// the style for new text.
["<b>X[]<span contenteditable=false>abc</span></b><i>def</i>",
[["delete",""],["inserttext","Y"]],
["<b>Y<span contenteditable=\"false\">abc</span></b><i>def</i>",
"<b>Y</b><b><span contenteditable=\"false\">abc</span></b><i>def</i>"],
[true,true],
{}],
["<b><span contenteditable=false>abc</span>X[]</b><i>def</i>",
[["delete",""],["inserttext","Y"]],
["<b><span contenteditable=\"false\">abc</span>Y</b><i>def</i>",
"<b><span contenteditable=\"false\">abc</span></b><b>Y</b><i>def</i>"],
[true,true],
{}],
["<b>[]X<span contenteditable=false>abc</span></b><i>def</i>",
[["forwarddelete",""],["inserttext","Y"]],
["<b>Y<span contenteditable=\"false\">abc</span></b><i>def</i>",
"<b>Y</b><b><span contenteditable=\"false\">abc</span></b><i>def</i>"],
[true,true],
{}],
["<b><span contenteditable=false>abc</span>[]X</b><i>def</i>",
[["forwarddelete",""],["inserttext","Y"]],
["<b><span contenteditable=\"false\">abc</span>Y</b><i>def</i>",
"<b><span contenteditable=\"false\">abc</span></b><b>Y</b><i>def</i>"],
[true,true],
{}],
]