fix(dom/html/nsGenericHTMLElement): Clear focus when a contentEditable is disabled on the active element
draft
fix(dom/html/nsGenericHTMLElement): Clear focus when a contentEditable is disabled on the active element
Fixes a failing Web Platform Test (https://github.com/w3c/web-platform-tests/blob/009111410a1099e85d4027a679985975757ceb4d/html/editing/focus/processing-model/focus-fixup-rule-one-no-dialogs.html#L99).
--- a/dom/html/nsGenericHTMLElement.cpp
+++ b/dom/html/nsGenericHTMLElement.cpp
@@ -2797,16 +2797,22 @@ nsGenericHTMLElement::ChangeEditableStat
nsIContent* parent = GetParent();
while (parent) {
parent->ChangeEditableDescendantCount(aChange);
parent = parent->GetParent();
}
}
+ nsFocusManager *fm = nsFocusManager::GetFocusManager();
+
+ if (fm && fm->IsFocused(this)) {
+ fm->ClearFocus(OwnerDoc()->GetWindow());
+ }
+
if (document->HasFlag(NODE_IS_EDITABLE)) {
document = nullptr;
}
// MakeContentDescendantsEditable is going to call ContentStateChanged for
// this element and all descendants if editable state has changed.
// We might as well wrap it all in one script blocker.
nsAutoScriptBlocker scriptBlocker;