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

--HG--
extra : commitid : KqRNGrLrGkl
extra : rebase_source : 232a10b649b7c580a0ad3afa0a11a09cdb8b907d
This commit is contained in:
Robert O'Callahan 2015-07-21 16:13:53 +12:00
Родитель 27590d7e61
Коммит 4339caede4
3 изменённых файлов: 15 добавлений и 4 удалений

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

@ -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);

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

@ -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,

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

@ -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