Bug 1184842. Add aOldValue parameter to nsNodeUtils::AttributeChanged. r=peterv

This commit is contained in:
Robert O'Callahan 2015-07-21 16:13:53 +12:00
parent 4c4dbbd99b
commit 0d0c23582f
3 changed files with 15 additions and 4 deletions

View File

@ -2328,7 +2328,11 @@ Element::SetAttrAndNotify(int32_t aNamespaceID,
}
if (aNotify) {
nsNodeUtils::AttributeChanged(this, aNamespaceID, aName, aModType);
// Don't pass aOldValue to AttributeChanged since it may not be reliable.
// Callers only compute aOldValue under certain conditions which may not
// be triggered by all nsIMutationObservers.
nsNodeUtils::AttributeChanged(this, aNamespaceID, aName, aModType,
oldValue == &aParsedValue ? &aParsedValue : nullptr);
}
if (aFireMutation) {
@ -2540,8 +2544,10 @@ Element::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aName,
}
if (aNotify) {
// We can always pass oldValue here since there is no new value which could
// have corrupted it.
nsNodeUtils::AttributeChanged(this, aNameSpaceID, aName,
nsIDOMMutationEvent::REMOVAL);
nsIDOMMutationEvent::REMOVAL, &oldValue);
}
rv = AfterSetAttr(aNameSpaceID, aName, nullptr, aNotify);

View File

@ -135,7 +135,8 @@ void
nsNodeUtils::AttributeChanged(Element* aElement,
int32_t aNameSpaceID,
nsIAtom* aAttribute,
int32_t aModType)
int32_t aModType,
const nsAttrValue* aOldValue)
{
nsIDocument* doc = aElement->OwnerDoc();
IMPL_MUTATION_NOTIFICATION(AttributeChanged, aElement,

View File

@ -61,12 +61,16 @@ public:
* @param aNameSpaceID Namespace of changed attribute
* @param aAttribute Local-name of changed attribute
* @param aModType Type of change (add/change/removal)
* @param aOldValue If the old value was StoresOwnData() (or absent),
* that value, otherwise null
* @see nsIMutationObserver::AttributeChanged
*/
static void AttributeChanged(mozilla::dom::Element* aElement,
int32_t aNameSpaceID,
nsIAtom* aAttribute,
int32_t aModType);
int32_t aModType,
const nsAttrValue* aOldValue);
/**
* Send AttributeSetToCurrentValue notifications to nsIMutationObservers.
* @param aElement Element whose data changed