Bug 702477 - Change the names of nsSVGPathElement::GetScale and nsSVGTextPathFrame::GetPathScale, and add documenting comments. r=longsonr.

This commit is contained in:
Jonathan Watt 2011-11-15 13:11:43 +00:00
Родитель ce3d0d1eb3
Коммит 3871c9a943
6 изменённых файлов: 29 добавлений и 10 удалений

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

@ -427,7 +427,7 @@ nsSVGPathElement::ConstructPath(gfxContext *aCtx)
}
gfxFloat
nsSVGPathElement::GetScale()
nsSVGPathElement::GetPathLengthScale()
{
if (mPathLength.IsExplicitlySet()) {

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

@ -98,7 +98,12 @@ public:
return nsGkAtoms::d;
}
gfxFloat GetScale();
/**
* Gets the ratio of the actual path length to the content author's estimated
* length (as provided by the <path> element's 'pathLength' attribute). This
* is used to scale stroke dashing, and to scale offsets along a textPath.
*/
gfxFloat GetPathLengthScale();
protected:

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

@ -120,7 +120,8 @@ nsSVGGeometryFrame::GetStrokeDashArray(gfxFloat **aDashes, PRUint32 *aCount)
gfxFloat pathScale = 1.0;
if (mContent->Tag() == nsGkAtoms::path) {
pathScale = static_cast<nsSVGPathElement*>(mContent)->GetScale();
pathScale =
static_cast<nsSVGPathElement*>(mContent)->GetPathLengthScale();
if (pathScale <= 0) {
return NS_OK;
}

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

@ -751,7 +751,7 @@ nsSVGGlyphFrame::GetCharacterPositions(nsTArray<CharacterPosition>* aCharacterPo
if (!aCharacterPositions->SetLength(strLength))
return false;
gfxFloat pathScale = textPath->GetPathScale();
gfxFloat pathScale = textPath->GetOffsetScale();
CharacterPosition *cp = aCharacterPositions->Elements();
@ -877,7 +877,7 @@ nsSVGGlyphFrame::GetSubStringAdvance(PRUint32 aCharnum,
gfxFloat pathScale = 1.0;
nsSVGTextPathFrame *textPath = FindTextPathParent();
if (textPath)
pathScale = textPath->GetPathScale();
pathScale = textPath->GetOffsetScale();
if (dxcount > aFragmentChars)
dxcount = aFragmentChars;
for (PRUint32 i = aCharnum; i < dxcount; i++) {
@ -1101,7 +1101,7 @@ nsSVGGlyphFrame::SetGlyphPosition(gfxPoint *aPosition, bool aForceGlobalTransfor
gfxFloat pathScale = 1.0;
if (textPath)
pathScale = textPath->GetPathScale();
pathScale = textPath->GetOffsetScale();
nsTArray<float> dxList, dyList;
GetEffectiveDxDy(strLength, dxList, dyList);

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

@ -166,17 +166,18 @@ nsSVGTextPathFrame::GetStartOffset()
nsRefPtr<gfxFlattenedPath> data = GetFlattenedPath();
return data ? (val * data->GetLength() / 100.0) : 0.0;
}
return val * GetPathScale();
return val * GetOffsetScale();
}
gfxFloat
nsSVGTextPathFrame::GetPathScale()
nsSVGTextPathFrame::GetOffsetScale()
{
nsIFrame *pathFrame = GetPathFrame();
if (!pathFrame)
return 1.0;
return static_cast<nsSVGPathElement*>(pathFrame->GetContent())->GetScale();
return static_cast<nsSVGPathElement*>(pathFrame->GetContent())->
GetPathLengthScale();
}
//----------------------------------------------------------------------

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

@ -84,8 +84,20 @@ public:
already_AddRefed<gfxFlattenedPath> GetFlattenedPath();
nsIFrame *GetPathFrame();
/**
* Gets the scale by which offsets along this textPath must be scaled. This
* scaling is due to the user provided 'pathLength' attribute on the <path>
* element, which is a user provided estimate of the path length.
*/
gfxFloat GetOffsetScale();
/**
* Gets the offset from the start of the path at which the first character
* should be positioned. The value returned already takes GetOffsetScale
* into account.
*/
gfxFloat GetStartOffset();
gfxFloat GetPathScale();
protected:
virtual void GetXY(SVGUserUnitList *aX, SVGUserUnitList *aY);