Bug 519049 Wrong value broadcast when setting attribute twice while script blocker active r=smaug sr=bz

This commit is contained in:
Neil Rashbrook 2009-10-13 11:11:17 +01:00
Родитель 1f30264438
Коммит 54fdd39340
2 изменённых файлов: 33 добавлений и 27 удалений

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

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