mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 761393 - Add a method to hash an nsStyleCoord. r=dbaron
This commit is contained in:
parent
8096d37d90
commit
ef774bffba
@ -11,6 +11,7 @@
|
||||
#include "prlog.h"
|
||||
#include "nsMathUtils.h"
|
||||
#include "nsStyleContext.h"
|
||||
#include "mozilla/HashFunctions.h"
|
||||
|
||||
nsStyleCoord::nsStyleCoord(nsStyleUnit aUnit)
|
||||
: mUnit(aUnit)
|
||||
@ -79,6 +80,39 @@ bool nsStyleCoord::operator==(const nsStyleCoord& aOther) const
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32_t nsStyleCoord::HashValue(uint32_t aHash = 0) const
|
||||
{
|
||||
aHash = mozilla::AddToHash(aHash, mUnit);
|
||||
|
||||
switch (mUnit) {
|
||||
case eStyleUnit_Null:
|
||||
case eStyleUnit_Normal:
|
||||
case eStyleUnit_Auto:
|
||||
case eStyleUnit_None:
|
||||
return mozilla::AddToHash(aHash, true);
|
||||
case eStyleUnit_Percent:
|
||||
case eStyleUnit_Factor:
|
||||
case eStyleUnit_Degree:
|
||||
case eStyleUnit_Grad:
|
||||
case eStyleUnit_Radian:
|
||||
case eStyleUnit_Turn:
|
||||
return mozilla::AddToHash(aHash, mValue.mFloat);
|
||||
case eStyleUnit_Coord:
|
||||
case eStyleUnit_Integer:
|
||||
case eStyleUnit_Enumerated:
|
||||
return mozilla::AddToHash(aHash, mValue.mInt);
|
||||
case eStyleUnit_Calc:
|
||||
Calc* calcValue = GetCalcValue();
|
||||
aHash = mozilla::AddToHash(aHash, calcValue->mLength);
|
||||
if (HasPercent()) {
|
||||
return mozilla::AddToHash(aHash, calcValue->mPercent);
|
||||
}
|
||||
return aHash;
|
||||
}
|
||||
NS_ABORT_IF_FALSE(false, "unexpected unit");
|
||||
return aHash;
|
||||
}
|
||||
|
||||
void nsStyleCoord::Reset()
|
||||
{
|
||||
mUnit = eStyleUnit_Null;
|
||||
|
@ -135,6 +135,7 @@ public:
|
||||
double GetAngleValueInRadians() const;
|
||||
Calc* GetCalcValue() const;
|
||||
void GetUnionValue(nsStyleUnion& aValue) const;
|
||||
uint32_t HashValue(uint32_t aHash) const;
|
||||
|
||||
void Reset(); // sets to null
|
||||
void SetCoordValue(nscoord aValue);
|
||||
|
Loading…
Reference in New Issue
Block a user