Bug 656197 part 4. Move calls to AfterSetAttr to before UpdateState when manipulating attributes. r=smaug

In particular, this lets us remove UpdateState() calls from AfterSetAttr.  That
change is next.

MozReview-Commit-ID: CFeft0E9o8m
This commit is contained in:
Boris Zbarsky 2017-03-16 14:50:42 -04:00
Родитель 67e823d90a
Коммит 55cdc32c73
1 изменённых файлов: 7 добавлений и 7 удалений

Просмотреть файл

@ -2466,8 +2466,6 @@ Element::SetAttrAndNotify(int32_t aNamespaceID,
}
}
UpdateState(aNotify);
nsIDocument* ownerDoc = OwnerDoc();
if (ownerDoc && GetCustomElementData()) {
nsCOMPtr<nsIAtom> oldValueAtom = oldValue->GetAsAtom();
@ -2493,6 +2491,8 @@ Element::SetAttrAndNotify(int32_t aNamespaceID,
}
}
UpdateState(aNotify);
if (aNotify) {
// Don't pass aOldValue to AttributeChanged since it may not be reliable.
// Callers only compute aOldValue under certain conditions which may not
@ -2704,8 +2704,6 @@ Element::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aName,
}
}
UpdateState(aNotify);
nsIDocument* ownerDoc = OwnerDoc();
if (ownerDoc && GetCustomElementData()) {
nsCOMPtr<nsIAtom> oldValueAtom = oldValue.GetAsAtom();
@ -2719,6 +2717,11 @@ Element::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aName,
ownerDoc, nsIDocument::eAttributeChanged, this, &args);
}
rv = AfterSetAttr(aNameSpaceID, aName, nullptr, aNotify);
NS_ENSURE_SUCCESS(rv, rv);
UpdateState(aNotify);
if (aNotify) {
// We can always pass oldValue here since there is no new value which could
// have corrupted it.
@ -2726,9 +2729,6 @@ Element::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aName,
nsIDOMMutationEvent::REMOVAL, &oldValue);
}
rv = AfterSetAttr(aNameSpaceID, aName, nullptr, aNotify);
NS_ENSURE_SUCCESS(rv, rv);
if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::dir) {
OnSetDirAttr(this, nullptr, hadValidDir, hadDirAuto, aNotify);
}