Bug 324857 - MathML all screwed up in Cairo builds: implement nsIRenderingContext::GetBoundingMetrics() p=steve.swanson@mackichan.com and karlt, r=pavlov a=blocking1.9+

This commit is contained in:
karlt+@karlt.net 2007-11-11 20:39:17 -08:00
Родитель 851b763a8a
Коммит 0d912a947b
4 изменённых файлов: 55 добавлений и 27 удалений

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

@ -99,12 +99,13 @@ public:
// caller will have to update them to twips before passing it
// back.
virtual nsresult GetBoundingMetrics(const char *aString, PRUint32 aLength,
nsThebesRenderingContext *aContext,
nsBoundingMetrics &aBoundingMetrics) = 0;
// aCachedOffset will be updated with a new offset.
virtual nsresult GetBoundingMetrics(const PRUnichar *aString,
PRUint32 aLength,
nsBoundingMetrics &aBoundingMetrics,
PRInt32 *aFontID) = 0;
nsThebesRenderingContext *aContext,
nsBoundingMetrics &aBoundingMetrics) = 0;
#endif /* MOZ_MATHML */
// Set the direction of the text rendering

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

@ -393,7 +393,6 @@ nsThebesFontMetrics::DrawString(const char *aString, PRUint32 aLength,
return NS_OK;
}
// aCachedOffset will be updated with a new offset.
nsresult
nsThebesFontMetrics::DrawString(const PRUnichar* aString, PRUint32 aLength,
nscoord aX, nscoord aY,
@ -419,25 +418,57 @@ nsThebesFontMetrics::DrawString(const PRUnichar* aString, PRUint32 aLength,
}
#ifdef MOZ_MATHML
// These two functions get the bounding metrics for this handle,
// updating the aBoundingMetrics in Points. This means that the
// caller will have to update them to twips before passing it
// back.
nsresult
nsThebesFontMetrics::GetBoundingMetrics(const char *aString, PRUint32 aLength,
nsBoundingMetrics &aBoundingMetrics)
static void
GetTextRunBoundingMetrics(gfxTextRun *aTextRun, PRUint32 aStart, PRUint32 aLength,
nsThebesRenderingContext *aContext,
nsBoundingMetrics &aBoundingMetrics)
{
return NS_ERROR_NOT_IMPLEMENTED;
StubPropertyProvider provider;
gfxTextRun::Metrics theMetrics =
aTextRun->MeasureText(aStart, aLength, PR_TRUE, aContext->Thebes(), &provider);
aBoundingMetrics.leftBearing = NSToCoordFloor(theMetrics.mBoundingBox.X());
aBoundingMetrics.rightBearing = NSToCoordCeil(theMetrics.mBoundingBox.XMost());
aBoundingMetrics.width = NSToCoordRound(theMetrics.mAdvanceWidth);
aBoundingMetrics.ascent = NSToCoordCeil(- theMetrics.mBoundingBox.Y());
aBoundingMetrics.descent = NSToCoordCeil(theMetrics.mBoundingBox.YMost());
}
// aCachedOffset will be updated with a new offset.
nsresult
nsThebesFontMetrics::GetBoundingMetrics(const PRUnichar *aString,
PRUint32 aLength,
nsBoundingMetrics &aBoundingMetrics,
PRInt32 *aFontID)
nsThebesFontMetrics::GetBoundingMetrics(const char *aString, PRUint32 aLength,
nsThebesRenderingContext *aContext,
nsBoundingMetrics &aBoundingMetrics)
{
return NS_ERROR_NOT_IMPLEMENTED;
if (aLength == 0) {
aBoundingMetrics.Clear();
return NS_OK;
}
AutoTextRun textRun(this, aContext, aString, aLength);
if (!textRun.get())
return NS_ERROR_FAILURE;
GetTextRunBoundingMetrics(textRun.get(), 0, aLength, aContext, aBoundingMetrics);
return NS_OK;
}
nsresult
nsThebesFontMetrics::GetBoundingMetrics(const PRUnichar *aString, PRUint32 aLength,
nsThebesRenderingContext *aContext,
nsBoundingMetrics &aBoundingMetrics)
{
if (aLength == 0) {
aBoundingMetrics.Clear();
return NS_OK;
}
AutoTextRun textRun(this, aContext, aString, aLength);
if (!textRun.get())
return NS_ERROR_FAILURE;
GetTextRunBoundingMetrics(textRun.get(), 0, aLength, aContext, aBoundingMetrics);
return NS_OK;
}
#endif /* MOZ_MATHML */

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

@ -85,7 +85,6 @@ public:
virtual nsresult GetWidth(const char* aString, PRUint32 aLength, nscoord& aWidth,
nsThebesRenderingContext *aContext);
// aCachedOffset will be updated with a new offset.
virtual nsresult GetWidth(const PRUnichar* aString, PRUint32 aLength,
nscoord& aWidth, PRInt32 *aFontID,
nsThebesRenderingContext *aContext);
@ -119,7 +118,6 @@ public:
nscoord aX, nscoord aY,
const nscoord* aSpacing,
nsThebesRenderingContext *aContext);
// aCachedOffset will be updated with a new offset.
virtual nsresult DrawString(const PRUnichar* aString, PRUint32 aLength,
nscoord aX, nscoord aY,
PRInt32 aFontID,
@ -128,16 +126,14 @@ public:
#ifdef MOZ_MATHML
// These two functions get the bounding metrics for this handle,
// updating the aBoundingMetrics in Points. This means that the
// caller will have to update them to twips before passing it
// back.
// updating the aBoundingMetrics in app units.
virtual nsresult GetBoundingMetrics(const char *aString, PRUint32 aLength,
nsThebesRenderingContext *aContext,
nsBoundingMetrics &aBoundingMetrics);
// aCachedOffset will be updated with a new offset.
virtual nsresult GetBoundingMetrics(const PRUnichar *aString,
PRUint32 aLength,
nsBoundingMetrics &aBoundingMetrics,
PRInt32 *aFontID);
nsThebesRenderingContext *aContext,
nsBoundingMetrics &aBoundingMetrics);
#endif /* MOZ_MATHML */
// Set the direction of the text rendering

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

@ -973,7 +973,7 @@ nsThebesRenderingContext::GetBoundingMetricsInternal(const char* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics)
{
return NS_ERROR_NOT_IMPLEMENTED;
return mFontMetrics->GetBoundingMetrics(aString, aLength, this, aBoundingMetrics);
}
NS_IMETHODIMP
@ -982,7 +982,7 @@ nsThebesRenderingContext::GetBoundingMetricsInternal(const PRUnichar* aString,
nsBoundingMetrics& aBoundingMetrics,
PRInt32* aFontID)
{
return NS_ERROR_NOT_IMPLEMENTED;
return mFontMetrics->GetBoundingMetrics(aString, aLength, this, aBoundingMetrics);
}
#endif // MOZ_MATHML