зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1870222 - part 5: Make `HTMLEditor::ClearStyleAt` treat non-editable content as visible r=m_kato
Pasting and inserting HTML clears current style to respect the new style. Therefore, the old ancestors shouldn't be removed when they have only non-editable content. Unfortunately, I have no idea how to test all of the paths which are changed by this patch. However, I believe the method should always treat non-editable content as visible. Differential Revision: https://phabricator.services.mozilla.com/D196817
This commit is contained in:
Родитель
3a1fc63ab7
Коммит
bc25bfb070
|
@ -2347,8 +2347,7 @@ Result<EditorDOMPoint, nsresult> HTMLEditor::ClearStyleAt(
|
|||
*unwrappedSplitNodeResult.GetPreviousContent(),
|
||||
{EmptyCheckOption::TreatSingleBRElementAsVisible,
|
||||
EmptyCheckOption::TreatListItemAsVisible,
|
||||
EmptyCheckOption::TreatTableCellAsVisible,
|
||||
EmptyCheckOption::TreatNonEditableContentAsInvisible})) {
|
||||
EmptyCheckOption::TreatTableCellAsVisible})) {
|
||||
AutoTrackDOMPoint trackPointToPutCaret(RangeUpdaterRef(), &pointToPutCaret);
|
||||
// Delete previous node if it's empty.
|
||||
// MOZ_KnownLive(unwrappedSplitNodeResult.GetPreviousContent()):
|
||||
|
@ -2430,8 +2429,7 @@ Result<EditorDOMPoint, nsresult> HTMLEditor::ClearStyleAt(
|
|||
if (HTMLEditUtils::IsEmptyNode(
|
||||
*unwrappedSplitResultAtStartOfNextNode.GetNextContent(),
|
||||
{EmptyCheckOption::TreatListItemAsVisible,
|
||||
EmptyCheckOption::TreatTableCellAsVisible,
|
||||
EmptyCheckOption::TreatNonEditableContentAsInvisible},
|
||||
EmptyCheckOption::TreatTableCellAsVisible},
|
||||
&seenBR)) {
|
||||
if (seenBR && !brElement) {
|
||||
brElement = HTMLEditUtils::GetFirstBRElement(
|
||||
|
@ -2530,8 +2528,7 @@ Result<EditorDOMPoint, nsresult> HTMLEditor::ClearStyleAt(
|
|||
*unwrappedSplitResultAtStartOfNextNode.GetNextContent(),
|
||||
{EmptyCheckOption::TreatSingleBRElementAsVisible,
|
||||
EmptyCheckOption::TreatListItemAsVisible,
|
||||
EmptyCheckOption::TreatTableCellAsVisible,
|
||||
EmptyCheckOption::TreatNonEditableContentAsInvisible})) {
|
||||
EmptyCheckOption::TreatTableCellAsVisible})) {
|
||||
// MOZ_KnownLive because the result is grabbed by
|
||||
// unwrappedSplitResultAtStartOfNextNode.
|
||||
nsresult rv = DeleteNodeWithTransaction(MOZ_KnownLive(
|
||||
|
@ -2550,16 +2547,14 @@ Result<EditorDOMPoint, nsresult> HTMLEditor::ClearStyleAt(
|
|||
else if (HTMLEditUtils::IsEmptyNode(
|
||||
*unwrappedSplitResultAtStartOfNextNode.GetNextContent(),
|
||||
{EmptyCheckOption::TreatListItemAsVisible,
|
||||
EmptyCheckOption::TreatTableCellAsVisible,
|
||||
EmptyCheckOption::TreatNonEditableContentAsInvisible})) {
|
||||
EmptyCheckOption::TreatTableCellAsVisible})) {
|
||||
AutoTArray<OwningNonNull<nsIContent>, 4> emptyInlineContainerElements;
|
||||
HTMLEditUtils::CollectEmptyInlineContainerDescendants(
|
||||
*unwrappedSplitResultAtStartOfNextNode.GetNextContentAs<Element>(),
|
||||
emptyInlineContainerElements,
|
||||
{EmptyCheckOption::TreatSingleBRElementAsVisible,
|
||||
EmptyCheckOption::TreatListItemAsVisible,
|
||||
EmptyCheckOption::TreatTableCellAsVisible,
|
||||
EmptyCheckOption::TreatNonEditableContentAsInvisible},
|
||||
EmptyCheckOption::TreatTableCellAsVisible},
|
||||
BlockInlineCheck::UseComputedDisplayOutsideStyle);
|
||||
for (const OwningNonNull<nsIContent>& emptyInlineContainerElement :
|
||||
emptyInlineContainerElements) {
|
||||
|
|
|
@ -590,4 +590,17 @@ var browserTests = [
|
|||
"<div class=\"d1\"></div><div class=\"d2\"><span class=\"s1\">some text</span><a href=\"foo.html\"></a></div>",
|
||||
[true],
|
||||
{"inserthtml":[false,false,"",false,false,""]}],
|
||||
|
||||
// Do not delete non-editable when clearing the original style
|
||||
["<p><b>[X]<span contenteditable=false>abc</span></b><i>def</i></p>",
|
||||
[["inserthtml","<i>Z</i>"]],
|
||||
"<p><i>Z</i><b><span contenteditable=\"false\">abc</span></b><i>def</i></p>",
|
||||
[true],
|
||||
{}],
|
||||
["<p><b><span contenteditable=false>abc</span>[Y]</b><i>def</i></p>",
|
||||
[["inserthtml","<i>Z</i>"]],
|
||||
["<p><b><span contenteditable=\"false\">abc</span></b><i>Z</i><i>def</i></p>",
|
||||
"<p><b><span contenteditable=\"false\">abc</span></b><i>Zdef</i></p>"],
|
||||
[true],
|
||||
{}],
|
||||
]
|
||||
|
|
Загрузка…
Ссылка в новой задаче