refactor(dom/base/Element): Use Blur() when the tabIndex is removed
MozReview-Commit-ID: 5F9cnPtmuHm
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -2994,16 +2994,17 @@ Element::UnsetAttr(int32_t aNameSpaceID,
mozAutoDocUpdate updateBatch(document, UPDATE_CONTENT_MODEL, aNotify);
if (aNotify) {
nsNodeUtils::AttributeWillChange(this, aNameSpaceID, aName,
MutationEventBinding::REMOVAL,
nullptr);
}
+ mozilla::ErrorResult errResult;
nsresult rv = BeforeSetAttr(aNameSpaceID, aName, nullptr, aNotify);
NS_ENSURE_SUCCESS(rv, rv);
bool hasMutationListeners = aNotify &&
nsContentUtils::HasMutationListeners(this,
NS_EVENT_BITS_MUTATION_ATTRMODIFIED,
this);
@@ -3037,21 +3038,17 @@ Element::UnsetAttr(int32_t aNameSpaceID,
nsAttrValue oldValue;
rv = mAttrsAndChildren.RemoveAttrAt(index, oldValue);
NS_ENSURE_SUCCESS(rv, rv);
PostIdMaybeChange(aNameSpaceID, aName, nullptr);
if (aName == nsGkAtoms::tabindex) {
- nsFocusManager *fm = nsFocusManager::GetFocusManager();
-
- if (fm && fm->IsFocused(this)) {
- fm->ClearFocus(OwnerDoc()->GetWindow());
- }
+ this->Blur(errResult);
}
if (document || HasFlag(NODE_FORCE_XBL_BINDINGS)) {
RefPtr<nsXBLBinding> binding = GetXBLBinding();
if (binding) {
binding->AttributeChanged(aName, aNameSpaceID, true, aNotify);
}
}
@@ -3104,17 +3101,17 @@ Element::UnsetAttr(int32_t aNameSpaceID,
if (!value.IsEmpty())
mutation.mPrevAttrValue = NS_Atomize(value);
mutation.mAttrChange = MutationEventBinding::REMOVAL;
mozAutoSubtreeModified subtree(OwnerDoc(), this);
(new AsyncEventDispatcher(this, mutation))->RunDOMEventWhenSafe();
}
- return NS_OK;
+ return errResult.StealNSResult();
}
void
Element::DescribeAttribute(uint32_t index, nsAString& aOutDescription) const
{
// name
mAttrsAndChildren.AttrNameAt(index)->GetQualifiedName(aOutDescription);