Bug 932102 - Fix rooting hazard in nsStyleUtil::AppendAngleValue r=dbaron

This commit is contained in:
Jon Coppeard 2013-11-21 01:00:57 +00:00
parent 8ba03743e8
commit 5d2c44915e
3 changed files with 14 additions and 14 deletions

View File

@ -89,7 +89,7 @@ nsROCSSPrimitiveValue::GetCssText(nsAString& aCssText)
case CSS_PX :
{
float val = nsPresContext::AppUnitsToFloatCSSPixels(mValue.mAppUnits);
tmpStr.AppendFloat(val);
nsStyleUtil::AppendCSSNumber(val, tmpStr);
tmpStr.AppendLiteral("px");
break;
}
@ -133,36 +133,36 @@ nsROCSSPrimitiveValue::GetCssText(nsAString& aCssText)
}
case CSS_PERCENTAGE :
{
tmpStr.AppendFloat(mValue.mFloat * 100);
nsStyleUtil::AppendCSSNumber(mValue.mFloat * 100, tmpStr);
tmpStr.Append(PRUnichar('%'));
break;
}
case CSS_NUMBER :
{
tmpStr.AppendFloat(mValue.mFloat);
nsStyleUtil::AppendCSSNumber(mValue.mFloat, tmpStr);
break;
}
case CSS_DEG :
{
tmpStr.AppendFloat(mValue.mFloat);
nsStyleUtil::AppendCSSNumber(mValue.mFloat, tmpStr);
tmpStr.AppendLiteral("deg");
break;
}
case CSS_GRAD :
{
tmpStr.AppendFloat(mValue.mFloat);
nsStyleUtil::AppendCSSNumber(mValue.mFloat, tmpStr);
tmpStr.AppendLiteral("grad");
break;
}
case CSS_RAD :
{
tmpStr.AppendFloat(mValue.mFloat);
nsStyleUtil::AppendCSSNumber(mValue.mFloat, tmpStr);
tmpStr.AppendLiteral("rad");
break;
}
case CSS_TURN :
{
tmpStr.AppendFloat(mValue.mFloat);
nsStyleUtil::AppendCSSNumber(mValue.mFloat, tmpStr);
tmpStr.AppendLiteral("turn");
break;
}
@ -250,7 +250,7 @@ nsROCSSPrimitiveValue::GetCssText(nsAString& aCssText)
}
case CSS_S :
{
tmpStr.AppendFloat(mValue.mFloat);
nsStyleUtil::AppendCSSNumber(mValue.mFloat, tmpStr);
tmpStr.AppendLiteral("s");
break;
}

View File

@ -163,13 +163,8 @@ nsStyleUtil::AppendAngleValue(const nsStyleCoord& aAngle, nsAString& aResult)
{
MOZ_ASSERT(aAngle.IsAngleValue(), "Should have angle value");
nsROCSSPrimitiveValue tmpVal;
nsAutoString tokenString;
// Append number.
tmpVal.SetNumber(aAngle.GetAngleValue());
tmpVal.GetCssText(tokenString);
aResult.Append(tokenString);
AppendCSSNumber(aAngle.GetAngleValue(), aResult);
// Append unit.
switch (aAngle.GetUnit()) {

View File

@ -57,6 +57,11 @@ public:
static void AppendFontFeatureSettings(const nsCSSValue& src,
nsAString& aResult);
static void AppendCSSNumber(float aNumber, nsAString& aResult)
{
aResult.AppendFloat(aNumber);
}
// convert bitmask value to keyword name for a functional alternate
static void GetFunctionalAlternatesName(int32_t aFeature,
nsAString& aFeatureName);