mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 984761 - Add AttributeMap::operator==. r=roc
This commit is contained in:
parent
55cc3adae6
commit
46966112cf
@ -1783,6 +1783,41 @@ AttributeMap::operator=(const AttributeMap& aOther)
|
||||
return *this;
|
||||
}
|
||||
|
||||
namespace {
|
||||
struct MatchingMap {
|
||||
typedef nsClassHashtable<nsUint32HashKey, Attribute> Map;
|
||||
const Map& map;
|
||||
bool matches;
|
||||
};
|
||||
}
|
||||
|
||||
static PLDHashOperator
|
||||
CheckAttributeEquality(const uint32_t& aAttributeName,
|
||||
Attribute* aAttribute,
|
||||
void* aMatchingMap)
|
||||
{
|
||||
MatchingMap& matchingMap = *static_cast<MatchingMap*>(aMatchingMap);
|
||||
Attribute* matchingAttribute = matchingMap.map.Get(aAttributeName);
|
||||
if (!matchingAttribute ||
|
||||
*matchingAttribute != *aAttribute) {
|
||||
matchingMap.matches = false;
|
||||
return PL_DHASH_STOP;
|
||||
}
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
bool
|
||||
AttributeMap::operator==(const AttributeMap& aOther) const
|
||||
{
|
||||
if (mMap.Count() != aOther.mMap.Count()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
MatchingMap matchingMap = { mMap, true };
|
||||
aOther.mMap.EnumerateRead(CheckAttributeEquality, &matchingMap);
|
||||
return matchingMap.matches;
|
||||
}
|
||||
|
||||
#define MAKE_ATTRIBUTE_HANDLERS_BASIC(type, typeLabel, defaultValue) \
|
||||
type \
|
||||
AttributeMap::Get##typeLabel(AttributeName aName) const { \
|
||||
|
@ -173,6 +173,11 @@ public:
|
||||
AttributeMap();
|
||||
AttributeMap(const AttributeMap& aOther);
|
||||
AttributeMap& operator=(const AttributeMap& aOther);
|
||||
bool operator==(const AttributeMap& aOther) const;
|
||||
bool operator!=(const AttributeMap& aOther) const
|
||||
{
|
||||
return !(*this == aOther);
|
||||
}
|
||||
~AttributeMap();
|
||||
|
||||
void Set(AttributeName aName, bool aValue);
|
||||
|
Loading…
Reference in New Issue
Block a user