зеркало из 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:
Родитель
7339cd7dbf
Коммит
3f1398db93
|
@ -863,16 +863,14 @@ nsresult HTMLEditor::FocusedElementOrDocumentBecomesNotEditable(
|
|||
// 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
|
||||
// other windows.
|
||||
if (aHTMLEditor->OurWindowHasFocus()) {
|
||||
if (RefPtr<nsPresContext> presContext = aHTMLEditor->GetPresContext()) {
|
||||
RefPtr<Element> focusedElement =
|
||||
nsFocusManager::GetFocusedElementStatic();
|
||||
MOZ_ASSERT_IF(focusedElement,
|
||||
focusedElement->GetPresContext(
|
||||
Element::PresContextFor::eForComposedDoc));
|
||||
IMEStateManager::MaybeOnEditableStateDisabled(*presContext,
|
||||
focusedElement);
|
||||
}
|
||||
if (const RefPtr<nsPresContext> presContext = aDocument.GetPresContext()) {
|
||||
const RefPtr<Element> focusedElementInDocument =
|
||||
Element::FromNodeOrNull(aDocument.GetUnretargetedFocusedContent());
|
||||
MOZ_ASSERT_IF(focusedElementInDocument,
|
||||
focusedElementInDocument->GetPresContext(
|
||||
Element::PresContextFor::eForComposedDoc));
|
||||
IMEStateManager::MaybeOnEditableStateDisabled(*presContext,
|
||||
focusedElementInDocument);
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
[replace_documentElement_children_after_window_closed.html]
|
||||
disabled:
|
||||
if verify: crash in verify mode
|
|
@ -0,0 +1,34 @@
|
|||
<!doctype html>
|
||||
<html class="reftest-wait">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<script>
|
||||
let waitForWindowClose;
|
||||
addEventListener("load", () => {
|
||||
try {
|
||||
document.documentElement.setHTML("", {});
|
||||
} catch (e) {}
|
||||
Promise.all([waitForWindowClose]).then(
|
||||
() => document.documentElement.removeAttribute("class")
|
||||
);
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<header contenteditable="true">
|
||||
<script>
|
||||
(() => {
|
||||
document.querySelector("header[contenteditable]").focus();
|
||||
const db = indexedDB.open("DB_FOO", 1);
|
||||
waitForWindowClose = new Promise(resolve => {
|
||||
db.onsuccess = () => {
|
||||
window.close();
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
<iframe src=">"></iframe>
|
||||
</header>
|
||||
</body>
|
||||
</html>
|
Загрузка…
Ссылка в новой задаче