refactor(dom/base/Element): Use Blur() when the element is hidden
MozReview-Commit-ID: H9mte80NvBy
--- 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)