зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1916081 - Make `HTMLEditor::FocusedElementOrDocumentBecomesNotEditable` stop using `aHTMLEditor` at adjusting IME state r=m_kato
`aHTMLEditor` may be `nullptr` and there may have been an `HTMLEditor` before it's called. Therefore, it may need to adjust IME state even if `aHTMLEditor` is `nullptr`. So, it should adjust IME state from `aDocument` which should be same as `aHTMLEditor->GetDocument()` if `aHTMLEditor` is not `nullptr`. Note that if `IMEStateManager` thinks another `nsPresContext` has focus, it does not touch IME state. Therefore, it's safe to skip checking the focus state of the `Document`. Differential Revision: https://phabricator.services.mozilla.com/D220772
This commit is contained in:
Родитель
c13abd36f2
Коммит
df7aad424e
|
@ -863,16 +863,14 @@ nsresult HTMLEditor::FocusedElementOrDocumentBecomesNotEditable(
|
||||||
// the editing state change. Note that if the window of the HTMLEditor has
|
// the editing state change. Note that if the window of the HTMLEditor has
|
||||||
// already lost focus, we don't need to do that and we should not touch the
|
// already lost focus, we don't need to do that and we should not touch the
|
||||||
// other windows.
|
// other windows.
|
||||||
if (aHTMLEditor->OurWindowHasFocus()) {
|
if (const RefPtr<nsPresContext> presContext = aDocument.GetPresContext()) {
|
||||||
if (RefPtr<nsPresContext> presContext = aHTMLEditor->GetPresContext()) {
|
const RefPtr<Element> focusedElementInDocument =
|
||||||
RefPtr<Element> focusedElement =
|
Element::FromNodeOrNull(aDocument.GetUnretargetedFocusedContent());
|
||||||
nsFocusManager::GetFocusedElementStatic();
|
MOZ_ASSERT_IF(focusedElementInDocument,
|
||||||
MOZ_ASSERT_IF(focusedElement,
|
focusedElementInDocument->GetPresContext(
|
||||||
focusedElement->GetPresContext(
|
Element::PresContextFor::eForComposedDoc));
|
||||||
Element::PresContextFor::eForComposedDoc));
|
IMEStateManager::MaybeOnEditableStateDisabled(*presContext,
|
||||||
IMEStateManager::MaybeOnEditableStateDisabled(*presContext,
|
focusedElementInDocument);
|
||||||
focusedElement);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче