Bug 718297 - Add EnumerateAll to nsPropertyTable, r=jst

This commit is contained in:
Olli Pettay 2012-01-15 21:02:06 +02:00
parent 312c985951
commit 233390c4b7
2 changed files with 34 additions and 0 deletions

View File

@ -161,6 +161,33 @@ nsPropertyTable::Enumerate(nsPropertyOwner aObject,
}
}
struct PropertyEnumeratorData
{
nsIAtom* mName;
NSPropertyFunc mCallBack;
void* mData;
};
static PLDHashOperator
PropertyEnumerator(PLDHashTable* aTable, PLDHashEntryHdr* aHdr,
PRUint32 aNumber, void* aArg)
{
PropertyListMapEntry* entry = static_cast<PropertyListMapEntry*>(aHdr);
PropertyEnumeratorData* data = static_cast<PropertyEnumeratorData*>(aArg);
data->mCallBack(const_cast<void*>(entry->key), data->mName, entry->value,
data->mData);
return PL_DHASH_NEXT;
}
void
nsPropertyTable::EnumerateAll(NSPropertyFunc aCallBack, void* aData)
{
for (PropertyList* prop = mPropertyList; prop; prop = prop->mNext) {
PropertyEnumeratorData data = { prop->mName, aCallBack, aData };
PL_DHashTableEnumerate(&prop->mObjectValueMap, PropertyEnumerator, &data);
}
}
void*
nsPropertyTable::GetPropertyInternal(nsPropertyOwner aObject,
nsIAtom *aPropertyName,

View File

@ -181,6 +181,13 @@ class nsPropertyTable
NS_HIDDEN_(void) Enumerate(nsPropertyOwner aObject,
NSPropertyFunc aCallback, void *aData);
/**
* Enumerate all the properties.
* For every property |aCallback| will be called with arguments the owner,
* the property name, the property value and |aData|.
*/
NS_HIDDEN_(void) EnumerateAll(NSPropertyFunc aCallback, void *aData);
/**
* Deletes all of the properties for all objects in the property
* table, calling the destructor function for each property.