fix(dom/html/nsGenericHTMLElement): Clear focused when the active element is disabled draft
authorSorin Davidoi <sorin.davidoi@gmail.com>
Sat, 10 Feb 2018 14:00:13 +0100
changeset 753524 f84c7a94ab47dd1aa61949981a1bb964ddb325b9
parent 753523 a78881eaedd4244c8ecce946abcb8569c21d3166
child 753525 dcb46b7aec0e411ede741bc0c619d581b1c3a0ca
push id98577
push userbmo:sorin.davidoi@gmail.com
push dateSat, 10 Feb 2018 13:40:06 +0000
milestone60.0a1
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
dom/html/nsGenericHTMLElement.cpp
--- 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