Make nsStyleCoord::operator== check deep equality of calc() expressions rather than just doing pointer comparison. (Bug 585715) r=bzbarsky a2.0=blocking+

This commit is contained in:
L. David Baron 2010-08-31 12:05:12 -04:00
Родитель 37d18ea6ad
Коммит 8e4c118d9d
1 изменённых файлов: 29 добавлений и 7 удалений

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

@ -102,14 +102,36 @@ nsStyleCoord& nsStyleCoord::operator=(const nsStyleCoord& aCopy)
PRBool nsStyleCoord::operator==(const nsStyleCoord& aOther) const
{
if (mUnit == aOther.mUnit) {
if ((eStyleUnit_Percent <= mUnit) && (mUnit < eStyleUnit_Coord)) {
return PRBool(mValue.mFloat == aOther.mValue.mFloat);
}
else {
return PRBool(mValue.mInt == aOther.mValue.mInt);
if (mUnit != aOther.mUnit) {
return PR_FALSE;
}
switch (mUnit) {
case eStyleUnit_Null:
case eStyleUnit_Normal:
case eStyleUnit_Auto:
case eStyleUnit_None:
return PR_TRUE;
case eStyleUnit_Percent:
case eStyleUnit_Factor:
case eStyleUnit_Degree:
case eStyleUnit_Grad:
case eStyleUnit_Radian:
return mValue.mFloat == aOther.mValue.mFloat;
case eStyleUnit_Coord:
case eStyleUnit_Integer:
case eStyleUnit_Enumerated:
return mValue.mInt == aOther.mValue.mInt;
case eStyleUnit_Calc:
case eStyleUnit_Calc_Plus:
case eStyleUnit_Calc_Minus:
case eStyleUnit_Calc_Times_L:
case eStyleUnit_Calc_Times_R:
case eStyleUnit_Calc_Divided:
case eStyleUnit_Calc_Minimum:
case eStyleUnit_Calc_Maximum:
return *this->GetArrayValue() == *aOther.GetArrayValue();
}
NS_ABORT_IF_FALSE(PR_FALSE, "unexpected unit");
return PR_FALSE;
}