Bug 445081. Refactor code to use ComputeNormalizedHypotenuse ... relanding with a fix so that we don't lose precision and break SVG text mochitests. r=longsonr,sr=mats

This commit is contained in:
Robert O'Callahan 2008-07-15 20:46:54 +12:00
Родитель 9d14f2c566
Коммит b2bdb8ad76
4 изменённых файлов: 14 добавлений и 3 удалений

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

@ -1401,7 +1401,7 @@ nsSVGSVGElement::GetLength(PRUint8 aCtxType)
case nsSVGUtils::Y:
return h;
case nsSVGUtils::XY:
return (float)sqrt((w*w+h*h)/2.0);
return float(nsSVGUtils::ComputeNormalizedHypotenuse(w, h));
}
return 0;
}

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

@ -1230,7 +1230,7 @@ nsSVGGlyphFrame::EnsureTextRun(float *aDrawScale, float *aMetricsScale,
// diagonal vector (1,1) to the length of the untransformed diagonal
// (which is sqrt(2)).
gfxPoint p = m.Transform(gfxPoint(1, 1)) - m.Transform(gfxPoint(0, 0));
double contextScale = sqrt((p.x*p.x + p.y*p.y)/2);
double contextScale = nsSVGUtils::ComputeNormalizedHypotenuse(p.x, p.y);
nsCAutoString langGroup;
nsIAtom *langGroupAtom = presContext->GetLangGroup();

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

@ -944,6 +944,12 @@ nsSVGUtils::NotifyAncestorsOfFilterRegionChange(nsIFrame *aFrame)
}
}
double
nsSVGUtils::ComputeNormalizedHypotenuse(double aWidth, double aHeight)
{
return sqrt((aWidth*aWidth + aHeight*aHeight)/2);
}
float
nsSVGUtils::ObjectSpace(nsIDOMSVGRect *aRect, nsSVGLength2 *aLength)
{
@ -961,7 +967,7 @@ nsSVGUtils::ObjectSpace(nsIDOMSVGRect *aRect, nsSVGLength2 *aLength)
float width, height;
aRect->GetWidth(&width);
aRect->GetHeight(&height);
axis = sqrt(width * width + height * height)/sqrt(2.0f);
axis = float(ComputeNormalizedHypotenuse(width, height));
}
}

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

@ -283,6 +283,11 @@ public:
/* enum for specifying coordinate direction for ObjectSpace/UserSpace */
enum ctxDirection { X, Y, XY };
/**
* Computes sqrt((aWidth^2 + aHeight^2)/2);
*/
static double ComputeNormalizedHypotenuse(double aWidth, double aHeight);
/* Computes the input length in terms of object space coordinates.
Input: rect - bounding box
length - length to be converted