fix(dom/html/nsGenericHTMLElement): Clear focused when the active element is disabled
draft
fix(dom/html/nsGenericHTMLElement): Clear focused when the active element is disabled
Fixes there failing Web Platform Tests:
- https://github.com/w3c/web-platform-tests/blob/009111410a1099e85d4027a679985975757ceb4d/html/editing/focus/processing-model/focus-fixup-rule-one-no-dialogs.html#L24
- https://github.com/w3c/web-platform-tests/blob/009111410a1099e85d4027a679985975757ceb4d/html/editing/focus/processing-model/focus-fixup-rule-one-no-dialogs.html#L62
- https://github.com/w3c/web-platform-tests/blob/009111410a1099e85d4027a679985975757ceb4d/html/editing/focus/processing-model/focus-fixup-rule-one-no-dialogs.html#L74
--- a/dom/html/nsGenericHTMLElement.cpp
+++ b/dom/html/nsGenericHTMLElement.cpp
@@ -2428,16 +2428,24 @@ void nsGenericHTMLFormElement::UpdateDis
} else {
disabledStates |= NS_EVENT_STATE_ENABLED;
}
EventStates oldDisabledStates = State() & DISABLED_STATES;
EventStates changedStates = disabledStates ^ oldDisabledStates;
if (!changedStates.IsEmpty()) {
+ if (aNotify) {
+ nsFocusManager *fm = nsFocusManager::GetFocusManager();
+
+ if (fm && fm->IsFocused(this)) {
+ fm->ClearFocus(OwnerDoc()->GetWindow());
+ }
+ }
+
ToggleStates(changedStates, aNotify);
}
}
void
nsGenericHTMLFormElement::UpdateRequiredState(bool aIsRequired, bool aNotify)
{
#ifdef DEBUG