зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1767386 - part 2: Make `HTMLEditor::RemoveInlinePropertyInternal` stop setting/removing style of an element if it's removed by `RemoveStyleInside` r=m_kato
`CSSEditUtils` will refer the composed document of the element to compute the style of it. However, it'll fail if `RemoveStyleInside` has already removed the element from the DOM tree. Therefore, `RemoveInlinePropertyInternal` should stop handling the element immediately after calling `RemoveStyleInside` if the element is removed. Depends on D145303 Differential Revision: https://phabricator.services.mozilla.com/D145304
This commit is contained in:
Родитель
ba7aebf080
Коммит
5e6b541ce8
|
@ -4075,6 +4075,8 @@ class HTMLEditor final : public EditorBase,
|
|||
* RemoveStyleInside() removes elements which represent aProperty/aAttribute
|
||||
* and removes CSS style. This handles aElement and all its descendants
|
||||
* (including leaf text nodes) recursively.
|
||||
* TODO: Rename this to explain that this maybe remove aElement from the DOM
|
||||
* tree.
|
||||
*
|
||||
* @param aSpecifiedStyle Whether the class and style attributes should
|
||||
* be preserved or discareded.
|
||||
|
|
|
@ -2156,6 +2156,11 @@ nsresult HTMLEditor::RemoveInlinePropertyInternal(
|
|||
NS_WARNING("HTMLEditor::RemoveStyleInside() failed");
|
||||
return rv;
|
||||
}
|
||||
// If the element was removed from the DOM tree by
|
||||
// RemoveStyleInside, we need nothing to do for it anymore.
|
||||
if (!content->GetParentNode()) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Result<bool, nsresult> isRemovableParentStyleOrError =
|
||||
|
@ -2222,6 +2227,8 @@ nsresult HTMLEditor::RemoveInlinePropertyInternal(
|
|||
// they still have the style.
|
||||
AutoTArray<OwningNonNull<Text>, 32> leafTextNodes;
|
||||
for (OwningNonNull<nsIContent>& content : arrayOfContents) {
|
||||
// XXX Should we ignore content which has already removed from the
|
||||
// DOM tree by the previous for-loop?
|
||||
if (content->IsElement()) {
|
||||
CollectEditableLeafTextNodes(*content->AsElement(),
|
||||
leafTextNodes);
|
||||
|
|
Загрузка…
Ссылка в новой задаче