Bug 769902 - Avoid unnecessary precision issues in nsSVGUtils::ObjectSpace. r=longsonr.

This commit is contained in:
Jonathan Watt 2012-06-30 21:21:31 +01:00
parent 0ebf8c84cf
commit 3379f2249a

View File

@ -831,7 +831,7 @@ nsSVGUtils::ComputeNormalizedHypotenuse(double aWidth, double aHeight)
float
nsSVGUtils::ObjectSpace(const gfxRect &aRect, const nsSVGLength2 *aLength)
{
float fraction, axis;
float axis;
switch (aLength->GetCtxType()) {
case X:
@ -848,15 +848,11 @@ nsSVGUtils::ObjectSpace(const gfxRect &aRect, const nsSVGLength2 *aLength)
axis = 0.0f;
break;
}
if (aLength->IsPercentage()) {
fraction = aLength->GetAnimValInSpecifiedUnits() / 100;
} else {
fraction = aLength->GetAnimValue(static_cast<nsSVGSVGElement*>
(nsnull));
// Multiply first to avoid precision errors:
return axis * aLength->GetAnimValInSpecifiedUnits() / 100;
}
return fraction * axis;
return aLength->GetAnimValue(static_cast<nsSVGSVGElement*>(nsnull)) * axis;
}
float