Bug 1616539 - Make `TextEditor::OnDrop()` compare newly focused element with active editing host r=m_kato

Currently, it checks whether proper element gets focus as expected with
`nsFocusManager::GetFocusedElement()`, but it returns globally focused element.
I.e., it may return different document's element or `nullptr` if application
itself is inactive.

The purpose of the focus check is, `HTMLEditor` can modify contents only in
active editing host.  Therefore, comparing with
`HTMLEditor::GetActiveEditingHost()` is better and simpler for here.

Differential Revision: https://phabricator.services.mozilla.com/D63581

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Masayuki Nakano 2020-02-25 01:28:01 +00:00
Родитель 5437a922a7
Коммит 5f656bfdd1
1 изменённых файлов: 9 добавлений и 9 удалений

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

@ -402,16 +402,16 @@ nsresult TextEditor::OnDrop(DragEvent* aDropEvent) {
} }
droppedAt = rangeAtDropPoint->StartRef(); droppedAt = rangeAtDropPoint->StartRef();
MOZ_ASSERT(droppedAt.IsSetAndValid()); MOZ_ASSERT(droppedAt.IsSetAndValid());
}
// If focus is changed to different element and we're handling drop in // If focus is changed to different element and we're handling drop in
// contenteditable, we cannot handle it without focus. So, we should give // contenteditable, we cannot handle it without focus. So, we should give
// it up. // it up.
if (NS_WARN_IF(newFocusedElement != if (AsHTMLEditor() && !AsHTMLEditor()->IsInDesignMode() &&
nsFocusManager::GetFocusManager()->GetFocusedElement() && NS_WARN_IF(newFocusedElement !=
AsHTMLEditor() && !AsHTMLEditor()->IsInDesignMode())) { AsHTMLEditor()->GetActiveEditingHost())) {
editActionData.Abort(); editActionData.Abort();
return NS_OK; return NS_OK;
}
} }
if (!AsHTMLEditor()) { if (!AsHTMLEditor()) {