mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 05:15:45 +00:00
Bug 519049 Wrong value broadcast when setting attribute twice while script blocker active r=smaug sr=bz
This commit is contained in:
parent
1f30264438
commit
54fdd39340
@ -1030,36 +1030,35 @@ nsXULDocument::AttributeChanged(nsIDocument* aDocument,
|
||||
= do_QueryReferent(bl->mListener);
|
||||
nsCOMPtr<nsIContent> l = do_QueryInterface(listenerEl);
|
||||
if (l) {
|
||||
PRBool possibleCycle = PR_FALSE;
|
||||
for (PRUint32 j = 0; j < mDelayedAttrChangeBroadcasts.Length(); ++j) {
|
||||
if (mDelayedAttrChangeBroadcasts[j].mListener == listenerEl &&
|
||||
mDelayedAttrChangeBroadcasts[j].mAttrName == aAttribute) {
|
||||
possibleCycle = PR_TRUE;
|
||||
break;
|
||||
nsAutoString currentValue;
|
||||
PRBool hasAttr = l->GetAttr(kNameSpaceID_None,
|
||||
aAttribute,
|
||||
currentValue);
|
||||
// We need to update listener only if we're
|
||||
// (1) removing an existing attribute,
|
||||
// (2) adding a new attribute or
|
||||
// (3) changing the value of an attribute.
|
||||
PRBool needsAttrChange =
|
||||
attrSet != hasAttr || !value.Equals(currentValue);
|
||||
nsDelayedBroadcastUpdate delayedUpdate(domele,
|
||||
listenerEl,
|
||||
aAttribute,
|
||||
value,
|
||||
attrSet,
|
||||
needsAttrChange);
|
||||
|
||||
PRUint32 index =
|
||||
mDelayedAttrChangeBroadcasts.IndexOf(delayedUpdate,
|
||||
0, nsDelayedBroadcastUpdate::Comparator());
|
||||
if (index != mDelayedAttrChangeBroadcasts.NoIndex) {
|
||||
if (mHandlingDelayedAttrChange) {
|
||||
NS_WARNING("Broadcasting loop!");
|
||||
continue;
|
||||
}
|
||||
mDelayedAttrChangeBroadcasts.RemoveElementAt(index);
|
||||
}
|
||||
|
||||
if (possibleCycle) {
|
||||
NS_WARNING("Broadcasting loop!");
|
||||
} else {
|
||||
nsAutoString currentValue;
|
||||
PRBool hasAttr = l->GetAttr(kNameSpaceID_None,
|
||||
aAttribute,
|
||||
currentValue);
|
||||
// We need to update listener only if we're
|
||||
// (1) removing an existing attribute,
|
||||
// (2) adding a new attribute or
|
||||
// (3) changing the value of an attribute.
|
||||
PRBool needsAttrChange =
|
||||
attrSet != hasAttr || !value.Equals(currentValue);
|
||||
nsDelayedBroadcastUpdate delayedUpdate(domele,
|
||||
listenerEl,
|
||||
aAttribute,
|
||||
value,
|
||||
attrSet,
|
||||
needsAttrChange);
|
||||
mDelayedAttrChangeBroadcasts.AppendElement(delayedUpdate);
|
||||
}
|
||||
mDelayedAttrChangeBroadcasts.AppendElement(delayedUpdate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -753,6 +753,13 @@ protected:
|
||||
nsCOMPtr<nsIAtom> mAttrName;
|
||||
PRPackedBool mSetAttr;
|
||||
PRPackedBool mNeedsAttrChange;
|
||||
|
||||
class Comparator {
|
||||
public:
|
||||
static PRBool Equals(const nsDelayedBroadcastUpdate& a, const nsDelayedBroadcastUpdate& b) {
|
||||
return a.mBroadcaster == b.mBroadcaster && a.mListener == b.mListener && a.mAttrName == b.mAttrName;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
nsTArray<nsDelayedBroadcastUpdate> mDelayedBroadcasters;
|
||||
|
Loading…
Reference in New Issue
Block a user