зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1803044 - part 5: Make `HTMLEditor::RemoveStyleInside` check whether aElement is editable first r=m_kato
Depends on D163999 Differential Revision: https://phabricator.services.mozilla.com/D164000
This commit is contained in:
Родитель
54dbcd7cc4
Коммит
13c3a0c6ec
|
@ -1602,18 +1602,19 @@ Result<EditorDOMPoint, nsresult> HTMLEditor::RemoveStyleInside(
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: It seems that if aElement is not editable, we should insert new
|
||||
// container to remove the style if possible.
|
||||
if (!EditorUtils::IsEditableContent(aElement, EditorType::HTML)) {
|
||||
return pointToPutCaret;
|
||||
}
|
||||
|
||||
// Next, remove the element or its attribute.
|
||||
auto ShouldRemoveHTMLStyle = [&]() {
|
||||
if (!aStyleToRemove.IsStyleToClearAllInlineStyles()) {
|
||||
return aStyleToRemove.IsRepresentedBy(aElement);
|
||||
}
|
||||
// XXX Why do we check if aElement is editable only when we're removing all
|
||||
// styles?
|
||||
if (EditorUtils::IsEditableContent(aElement, EditorType::HTML)) {
|
||||
// or removing all styles and the element is a presentation element.
|
||||
return HTMLEditUtils::IsRemovableInlineStyleElement(aElement);
|
||||
}
|
||||
return false;
|
||||
// or removing all styles and the element is a presentation element.
|
||||
return HTMLEditUtils::IsRemovableInlineStyleElement(aElement);
|
||||
};
|
||||
|
||||
if (ShouldRemoveHTMLStyle()) {
|
||||
|
|
|
@ -1024,5 +1024,18 @@ var browserTests = [
|
|||
[["stylewithcss","false"],["bold",""]],
|
||||
"<span style=\"font-weight:100\">fo<b>[o</b></span><span style=\"font-weight:200\"><b>b]</b>ar</span>",
|
||||
[true,true],
|
||||
{"stylewithcss":[false,true,"",false,false,""],"bold":[false,false,"",false,true,""]}]
|
||||
{"stylewithcss":[false,true,"",false,false,""],"bold":[false,false,"",false,true,""]}],
|
||||
|
||||
// Don't delete non-editable node.
|
||||
["abc<b>[d<span contenteditable=\"false\"><b>e</b></span>f]</b>ghi",
|
||||
[["stylewithcss","false"],["bold",""]],
|
||||
"abcd<span contenteditable=\"false\"><b>e</b></span>fghi",
|
||||
[true,true],
|
||||
{}],
|
||||
// but delete editable node in non-editable node.
|
||||
["abc<b>[d<span contenteditable=\"false\"><span contenteditable><b>e</b></span></span>f]</b>ghi",
|
||||
[["stylewithcss","false"],["bold",""]],
|
||||
"abcd<span contenteditable=\"false\"><span contenteditable=\"\">e</span></span>fghi",
|
||||
[true,true],
|
||||
{}],
|
||||
]
|
||||
|
|
Загрузка…
Ссылка в новой задаче