mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 984761 - Add AttributeMap::EnumerateRead. r=roc
This commit is contained in:
parent
12b3f841f0
commit
be5c6e3640
@ -1603,6 +1603,8 @@ struct FilterAttribute {
|
||||
return !(*this == aOther);
|
||||
}
|
||||
|
||||
AttributeType Type() const { return mType; }
|
||||
|
||||
#define MAKE_CONSTRUCTOR_AND_ACCESSOR_BASIC(type, typeLabel) \
|
||||
FilterAttribute(type aValue) \
|
||||
: mType(AttributeType::e##typeLabel), m##typeLabel(aValue) \
|
||||
@ -1839,6 +1841,34 @@ AttributeMap::operator==(const AttributeMap& aOther) const
|
||||
return matchingMap.matches;
|
||||
}
|
||||
|
||||
namespace {
|
||||
struct HandlerWithUserData
|
||||
{
|
||||
AttributeMap::AttributeHandleCallback handler;
|
||||
void* userData;
|
||||
};
|
||||
}
|
||||
|
||||
static PLDHashOperator
|
||||
PassAttributeToHandleCallback(const uint32_t& aAttributeName,
|
||||
Attribute* aAttribute,
|
||||
void* aHandlerWithUserData)
|
||||
{
|
||||
HandlerWithUserData* handlerWithUserData =
|
||||
static_cast<HandlerWithUserData*>(aHandlerWithUserData);
|
||||
return handlerWithUserData->handler(AttributeName(aAttributeName),
|
||||
aAttribute->Type(),
|
||||
handlerWithUserData->userData) ?
|
||||
PL_DHASH_NEXT : PL_DHASH_STOP;
|
||||
}
|
||||
|
||||
void
|
||||
AttributeMap::EnumerateRead(AttributeMap::AttributeHandleCallback aCallback, void* aUserData) const
|
||||
{
|
||||
HandlerWithUserData handlerWithUserData = { aCallback, aUserData };
|
||||
mMap.EnumerateRead(PassAttributeToHandleCallback, &handlerWithUserData);
|
||||
}
|
||||
|
||||
#define MAKE_ATTRIBUTE_HANDLERS_BASIC(type, typeLabel, defaultValue) \
|
||||
type \
|
||||
AttributeMap::Get##typeLabel(AttributeName aName) const { \
|
||||
|
@ -206,6 +206,9 @@ public:
|
||||
AttributeMap GetAttributeMap(AttributeName aName) const;
|
||||
const nsTArray<float>& GetFloats(AttributeName aName) const;
|
||||
|
||||
typedef bool (*AttributeHandleCallback)(AttributeName aName, AttributeType aType, void* aUserData);
|
||||
void EnumerateRead(AttributeHandleCallback aCallback, void* aUserData) const;
|
||||
|
||||
private:
|
||||
mutable nsClassHashtable<nsUint32HashKey, FilterAttribute> mMap;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user