refactor(dom/base/Element): Use Blur() when the element is hidden draft
authorSorin Davidoi <sorin.davidoi@gmail.com>
Sat, 10 Feb 2018 15:29:58 +0100
changeset 753527 97014921a26abe9f60d39289f16a3af7249305ab
parent 753526 fb9094180e32a9587b8e5b426f634e5ae36e560f
child 753528 bf1c5bb5293086190131c5c72b00d110e2670201
push id98578
push userbmo:sorin.davidoi@gmail.com
push dateSat, 10 Feb 2018 14:31:15 +0000
milestone60.0a1
refactor(dom/base/Element): Use Blur() when the element is hidden MozReview-Commit-ID: H9mte80NvBy
dom/base/Element.cpp
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -2671,16 +2671,17 @@ Element::SetAttrAndNotify(int32_t aNames
                           uint8_t aModType,
                           bool aFireMutation,
                           bool aNotify,
                           bool aCallAfterSetAttr,
                           nsIDocument* aComposedDocument,
                           const mozAutoDocUpdate&)
 {
   nsresult rv;
+  mozilla::ErrorResult errResult;
   nsMutationGuard::DidMutate();
 
   // Copy aParsedValue for later use since it will be lost when we call
   // SetAndSwapMappedAttr below
   nsAttrValue valueForAfterSetAttr;
   if (aCallAfterSetAttr || GetCustomElementData()) {
     valueForAfterSetAttr.SetTo(aParsedValue);
   }
@@ -2725,21 +2726,17 @@ Element::SetAttrAndNotify(int32_t aNames
     }
   } else {
     // No need to conditionally assign null here. If there was no previously
     // set value for the attribute, aOldValue will already be null.
     oldValue = aOldValue;
   }
 
   if (aName == nsGkAtoms::hidden && HasAttr(kNameSpaceID_None, nsGkAtoms::hidden)) {
-    nsFocusManager *fm = nsFocusManager::GetFocusManager();
-
-    if (fm && fm->IsFocused(this)) {
-      fm->ClearFocus(OwnerDoc()->GetWindow());
-    }
+    this->Blur(errResult);
   }
 
   if (aComposedDocument || HasFlag(NODE_FORCE_XBL_BINDINGS)) {
     RefPtr<nsXBLBinding> binding = GetXBLBinding();
     if (binding) {
       binding->AttributeChanged(aName, aNamespaceID, false, aNotify);
     }
   }
@@ -2814,17 +2811,17 @@ Element::SetAttrAndNotify(int32_t aNames
       mutation.mPrevAttrValue = oldValue->GetAsAtom();
     }
     mutation.mAttrChange = aModType;
 
     mozAutoSubtreeModified subtree(OwnerDoc(), this);
     (new AsyncEventDispatcher(this, mutation))->RunDOMEventWhenSafe();
   }
 
-  return NS_OK;
+  return errResult.StealNSResult();
 }
 
 bool
 Element::ParseAttribute(int32_t aNamespaceID,
                         nsAtom* aAttribute,
                         const nsAString& aValue,
                         nsIPrincipal* aMaybeScriptedPrincipal,
                         nsAttrValue& aResult)