Bug 534526 part 2. Move AttributeWillChange out of SetAttrAndNotify, and in particular to before ParseAttribute, since some ParseAttribute implementations actually change the attribute value. Also move it to before we've changed the CSSDeclaration for inline style changes. r=sicking,longsonr,dbaron

This commit is contained in:
Boris Zbarsky
2010-02-23 23:37:47 -05:00
parent 615929fc40
commit 639ac4e9e8
7 changed files with 110 additions and 40 deletions

View File

@@ -4345,16 +4345,24 @@ nsGenericElement::SetAttr(PRInt32 aNamespaceID, nsIAtom* aName,
}
}
nsresult rv = BeforeSetAttr(aNamespaceID, aName, &aValue, aNotify);
NS_ENSURE_SUCCESS(rv, rv);
PRUint8 modType = modification ?
static_cast<PRUint8>(nsIDOMMutationEvent::MODIFICATION) :
static_cast<PRUint8>(nsIDOMMutationEvent::ADDITION);
if (aNotify) {
nsNodeUtils::AttributeWillChange(this, aNamespaceID, aName, modType);
}
nsAttrValue attrValue;
if (!ParseAttribute(aNamespaceID, aName, aValue, attrValue)) {
attrValue.SetTo(aValue);
}
return SetAttrAndNotify(aNamespaceID, aName, aPrefix, oldValue,
attrValue, modification, hasListeners, aNotify,
attrValue, modType, hasListeners, aNotify,
&aValue);
}
@@ -4364,15 +4372,12 @@ nsGenericElement::SetAttrAndNotify(PRInt32 aNamespaceID,
nsIAtom* aPrefix,
const nsAString& aOldValue,
nsAttrValue& aParsedValue,
PRBool aModification,
PRUint8 aModType,
PRBool aFireMutation,
PRBool aNotify,
const nsAString* aValueForAfterSetAttr)
{
nsresult rv;
PRUint8 modType = aModification ?
static_cast<PRUint8>(nsIDOMMutationEvent::MODIFICATION) :
static_cast<PRUint8>(nsIDOMMutationEvent::ADDITION);
nsIDocument* document = GetCurrentDoc();
mozAutoDocUpdate updateBatch(document, UPDATE_CONTENT_MODEL, aNotify);
@@ -4382,8 +4387,6 @@ nsGenericElement::SetAttrAndNotify(PRInt32 aNamespaceID,
PRUint32 stateMask;
if (aNotify) {
stateMask = PRUint32(IntrinsicState());
nsNodeUtils::AttributeWillChange(this, aNamespaceID, aName, modType);
}
if (aNamespaceID == kNameSpaceID_None) {
@@ -4421,7 +4424,7 @@ nsGenericElement::SetAttrAndNotify(PRInt32 aNamespaceID,
MOZ_AUTO_DOC_UPDATE(document, UPDATE_CONTENT_STATE, aNotify);
document->ContentStatesChanged(this, nsnull, stateMask);
}
nsNodeUtils::AttributeChanged(this, aNamespaceID, aName, modType);
nsNodeUtils::AttributeChanged(this, aNamespaceID, aName, aModType);
}
if (aNamespaceID == kNameSpaceID_XMLEvents &&
@@ -4455,7 +4458,7 @@ nsGenericElement::SetAttrAndNotify(PRInt32 aNamespaceID,
if (!aOldValue.IsEmpty()) {
mutation.mPrevAttrValue = do_GetAtom(aOldValue);
}
mutation.mAttrChange = modType;
mutation.mAttrChange = aModType;
mozAutoSubtreeModified subtree(GetOwnerDoc(), this);
nsEventDispatcher::Dispatch(this, nsnull, &mutation);