Bug 1726064 - part 9: Make `TextServicesDocument::HasSameBlockNodeParent()` use `HTMLEditUtils::GetAncestorElement()` r=m_kato

For keeping current behavior, the options should be set to
`HTMLEditUtils::ClosestEditableBlockElement`, but it may cause returning
`nullptr` if the text node is in an inline editing host, and also cause
returning true from the method even when the text nodes are in different
inline editing hosts.  Therefore, this patch uses
`HTMLEditUtils::ClosestEditableBlockElementOrInlineEditingHost` instead.

Differential Revision: https://phabricator.services.mozilla.com/D122947
This commit is contained in:
Masayuki Nakano 2021-08-20 11:12:08 +00:00
Родитель 367ad55539
Коммит 593b780331
1 изменённых файлов: 16 добавлений и 11 удалений

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

@ -1618,19 +1618,24 @@ void TextServicesDocument::ClearDidSkip(
// static
bool TextServicesDocument::HasSameBlockNodeParent(Text& aTextNode1,
Text& aTextNode2) {
nsIContent* container1 = aTextNode1.GetParent();
nsIContent* container2 = aTextNode2.GetParent();
if (container1 == container2) {
// XXX How about the case that both text nodes are orphan nodes?
if (aTextNode1.GetParent() == aTextNode2.GetParent()) {
return true;
}
Element* parentBlockElement1 =
container1 ? HTMLEditUtils::GetInclusiveAncestorBlockElement(*container1)
: nullptr;
Element* parentBlockElement2 =
container2 ? HTMLEditUtils::GetInclusiveAncestorBlockElement(*container2)
: nullptr;
return parentBlockElement1 == parentBlockElement2;
// I think that spellcheck should be available only in editable nodes.
// So, we also need to check whether they are in same editing host.
const Element* editableBlockElementOrInlineEditingHost1 =
HTMLEditUtils::GetAncestorElement(
aTextNode1,
HTMLEditUtils::ClosestEditableBlockElementOrInlineEditingHost);
const Element* editableBlockElementOrInlineEditingHost2 =
HTMLEditUtils::GetAncestorElement(
aTextNode2,
HTMLEditUtils::ClosestEditableBlockElementOrInlineEditingHost);
return editableBlockElementOrInlineEditingHost1 &&
editableBlockElementOrInlineEditingHost1 ==
editableBlockElementOrInlineEditingHost2;
}
Result<EditorRawDOMRangeInTexts, nsresult>