Bug 174055, part 5: prune unused and unimplemented methods.

This commit is contained in:
Zack Weinberg 2011-04-07 20:07:27 -07:00
Родитель b6b73ad75a
Коммит 5731d401c8
16 изменённых файлов: 70 добавлений и 216 удалений

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

@ -2494,7 +2494,7 @@ GetScrollableLineHeight(nsIFrame* aTargetFrame)
NS_ASSERTION(fm, "FontMetrics is null!");
nscoord lineHeight = 0;
if (fm)
fm->GetHeight(lineHeight);
fm->GetMaxHeight(lineHeight);
return lineHeight;
}

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

@ -85,7 +85,6 @@ nsFontMetrics::~nsFontMetrics()
if (mDeviceContext)
mDeviceContext->FontMetricsDeleted(this);
delete mFontStyle;
//delete mFontGroup;
}
nsresult
@ -173,7 +172,7 @@ nsFontMetrics::GetUnderline(nscoord& aOffset, nscoord& aSize)
return NS_OK;
}
// GetHeight/GetMaxAscent/GetMaxDescent/GetMaxHeight must contain the
// GetMaxAscent/GetMaxDescent/GetMaxHeight must contain the
// text-decoration lines drawable area. See bug 421353.
// BE CAREFUL for rounding each values. The logic MUST be same as
// nsCSSRendering::GetTextDecorationRectInternal's.
@ -192,14 +191,6 @@ static gfxFloat ComputeMaxAscent(const gfxFont::Metrics& aMetrics)
return NS_floor(aMetrics.maxAscent + 0.5);
}
nsresult
nsFontMetrics::GetHeight(nscoord &aHeight)
{
aHeight = CEIL_TO_TWIPS(ComputeMaxAscent(GetMetrics())) +
CEIL_TO_TWIPS(ComputeMaxDescent(GetMetrics(), mFontGroup));
return NS_OK;
}
nsresult
nsFontMetrics::GetInternalLeading(nscoord &aLeading)
{
@ -272,12 +263,6 @@ nsFontMetrics::GetLanguage(nsIAtom** aLanguage)
return NS_OK;
}
nsresult
nsFontMetrics::GetFontHandle(nsFontHandle &aHandle)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
nsFontMetrics::GetAveCharWidth(nscoord& aAveCharWidth)
{
@ -365,43 +350,6 @@ nsFontMetrics::GetWidth(const PRUnichar* aString, PRUint32 aLength,
return NS_OK;
}
// Get the text dimensions for this string
nsresult
nsFontMetrics::GetTextDimensions(const PRUnichar* aString,
PRUint32 aLength,
nsTextDimensions& aDimensions,
PRInt32* aFontID)
{
return NS_OK;
}
nsresult
nsFontMetrics::GetTextDimensions(const char* aString,
PRInt32 aLength,
PRInt32 aAvailWidth,
PRInt32* aBreaks,
PRInt32 aNumBreaks,
nsTextDimensions& aDimensions,
PRInt32& aNumCharsFit,
nsTextDimensions& aLastWordDimensions,
PRInt32* aFontID)
{
return NS_OK;
}
nsresult
nsFontMetrics::GetTextDimensions(const PRUnichar* aString,
PRInt32 aLength,
PRInt32 aAvailWidth,
PRInt32* aBreaks,
PRInt32 aNumBreaks,
nsTextDimensions& aDimensions,
PRInt32& aNumCharsFit,
nsTextDimensions& aLastWordDimensions,
PRInt32* aFontID)
{
return NS_OK;
}
// Draw a string using this font handle on the surface passed in.
nsresult
nsFontMetrics::DrawString(const char *aString, PRUint32 aLength,
@ -449,47 +397,6 @@ nsFontMetrics::DrawString(const PRUnichar* aString, PRUint32 aLength,
}
#ifdef MOZ_MATHML
static void
GetTextRunBoundingMetrics(gfxTextRun *aTextRun,
PRUint32 aStart, PRUint32 aLength,
nsRenderingContext *aContext,
nsBoundingMetrics &aBoundingMetrics)
{
StubPropertyProvider provider;
gfxTextRun::Metrics theMetrics =
aTextRun->MeasureText(aStart, aLength,
gfxFont::TIGHT_HINTED_OUTLINE_EXTENTS,
aContext->ThebesContext(), &provider);
// note that TIGHT_HINTED_OUTLINE_EXTENTS can be expensive (on Windows)
// but this is only used for MathML positioning so it's not critical
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());
}
nsresult
nsFontMetrics::GetBoundingMetrics(const char *aString, PRUint32 aLength,
nsRenderingContext *aContext,
nsBoundingMetrics &aBoundingMetrics)
{
if (aLength == 0) {
aBoundingMetrics = nsBoundingMetrics();
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
nsFontMetrics::GetBoundingMetrics(const PRUnichar *aString, PRUint32 aLength,
nsRenderingContext *aContext,
@ -504,30 +411,21 @@ nsFontMetrics::GetBoundingMetrics(const PRUnichar *aString, PRUint32 aLength,
if (!textRun.get())
return NS_ERROR_FAILURE;
GetTextRunBoundingMetrics(textRun.get(), 0, aLength, aContext,
aBoundingMetrics);
// note that TIGHT_HINTED_OUTLINE_EXTENTS can be expensive (on Windows)
// but this is only used for MathML positioning so it's not critical
StubPropertyProvider provider;
gfxTextRun::Metrics theMetrics =
textRun->MeasureText(0, aLength,
gfxFont::TIGHT_HINTED_OUTLINE_EXTENTS,
aContext->ThebesContext(), &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());
return NS_OK;
}
#endif /* MOZ_MATHML */
// Set the direction of the text rendering
nsresult
nsFontMetrics::SetRightToLeftText(PRBool aIsRTL)
{
mIsRightToLeft = aIsRTL;
return NS_OK;
}
// Set the direction of the text rendering
PRBool
nsFontMetrics::GetRightToLeftText()
{
return mIsRightToLeft;
}
gfxUserFontSet*
nsFontMetrics::GetUserFontSet()
{
return mFontGroup->GetUserFontSet();
}

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

@ -53,12 +53,6 @@ class nsRenderingContext;
class nsString;
class nsThebesDeviceContext;
struct nsBoundingMetrics;
struct nsTextDimensions;
/**
* A native font handle
*/
typedef void* nsFontHandle;
/**
* Font metrics
@ -95,107 +89,115 @@ public:
nsresult Init(const nsFont& aFont, nsIAtom* aLanguage,
nsIDeviceContext *aContext,
gfxUserFontSet *aUserFontSet = nsnull);
/**
* Destroy this font metrics. This breaks the association between
* the font metrics and the device context.
*/
nsresult Destroy();
/**
* Return the font's xheight property, scaled into app-units.
* Return the font's x-height.
*/
nsresult GetXHeight(nscoord& aResult);
/**
* Return the font's superscript offset (the distance from the
* baseline to where a superscript's baseline should be placed).
* The value returned will be positive.
*/
nsresult GetSuperscriptOffset(nscoord& aResult);
/**
* Return the font's subscript offset (the distance from the
* baseline to where a subscript's baseline should be placed). The
* value returned will be a positive value.
* baseline to where a subscript's baseline should be placed).
* The value returned will be positive.
*/
nsresult GetSubscriptOffset(nscoord& aResult);
/**
* Return the font's strikeout offset (the distance from the
* baseline to where a strikeout should be placed) and size.
* Positive values are above the baseline, negative below.
*/
nsresult GetStrikeout(nscoord& aOffset, nscoord& aSize);
/**
* Return the font's underline offset (the distance from the
* baseline to where a underline should be placed) and size.
* Positive values are above the baseline, negative below.
*/
nsresult GetUnderline(nscoord& aOffset, nscoord& aSize);
/**
* Returns the height (in app units) of the font. This is ascent plus descent
* plus any internal leading
*
* This method will be removed once the callers have been moved over to the
* new GetEmHeight (and possibly GetMaxHeight).
*/
nsresult GetHeight(nscoord &aHeight);
/**
* Returns the amount of internal leading (in app units) for the font. This
* is computed as the "height - (ascent + descent)"
* Returns the amount of internal leading for the font.
* This is normally the difference between the max ascent
* and the em ascent.
*/
nsresult GetInternalLeading(nscoord &aLeading);
/**
* Returns the amount of external leading (in app units) as
* suggested by font vendor. This value is suggested by font vendor
* to add to normal line-height beside font height.
* Returns the amount of external leading for the font.
* em ascent(?) plus external leading is the font designer's
* recommended line-height for this font.
*/
nsresult GetExternalLeading(nscoord &aLeading);
/**
* Returns the height (in app units) of the Western font's em square. This is
* em ascent plus em descent.
* Returns the height of the em square.
* This is em ascent plus em descent.
*/
nsresult GetEmHeight(nscoord &aHeight);
/**
* Returns, in app units, the ascent part of the Western font's em square.
* Returns the ascent part of the em square.
*/
nsresult GetEmAscent(nscoord &aAscent);
/**
* Returns, in app units, the descent part of the Western font's em square.
* Returns the descent part of the em square.
*/
nsresult GetEmDescent(nscoord &aDescent);
/**
* Returns the height (in app units) of the Western font's bounding box.
* Returns the height of the bounding box.
* This is max ascent plus max descent.
*/
nsresult GetMaxHeight(nscoord &aHeight);
/**
* Returns, in app units, the maximum distance characters in this font extend
* Returns the maximum distance characters in this font extend
* above the base line.
*/
nsresult GetMaxAscent(nscoord &aAscent);
/**
* Returns, in app units, the maximum distance characters in this font extend
* Returns the maximum distance characters in this font extend
* below the base line.
*/
nsresult GetMaxDescent(nscoord &aDescent);
/**
* Returns, in app units, the maximum character advance for the font
* Returns the maximum character advance for the font.
*/
nsresult GetMaxAdvance(nscoord &aAdvance);
/**
* Returns the font associated with these metrics. The return value
* is only defined after Init() has been called.
*/
const nsFont &Font() { return mFont; }
/**
* Returns the language associated with these metrics
*/
nsresult GetLanguage(nsIAtom** aLanguage);
/**
* Returns the font handle associated with these metrics
*/
nsresult GetFontHandle(nsFontHandle &aHandle);
/**
* Returns the average character width
*/
nsresult GetAveCharWidth(nscoord& aAveCharWidth);
/**
* Returns the often needed width of the space character
*/
@ -212,55 +214,17 @@ public:
nscoord& aWidth, PRInt32 *aFontID,
nsRenderingContext *aContext);
// Get the text dimensions for this string
nsresult GetTextDimensions(const PRUnichar* aString,
PRUint32 aLength,
nsTextDimensions& aDimensions,
PRInt32* aFontID);
nsresult GetTextDimensions(const char* aString,
PRInt32 aLength,
PRInt32 aAvailWidth,
PRInt32* aBreaks,
PRInt32 aNumBreaks,
nsTextDimensions& aDimensions,
PRInt32& aNumCharsFit,
nsTextDimensions& aLastWordDimensions,
PRInt32* aFontID);
nsresult GetTextDimensions(const PRUnichar* aString,
PRInt32 aLength,
PRInt32 aAvailWidth,
PRInt32* aBreaks,
PRInt32 aNumBreaks,
nsTextDimensions& aDimensions,
PRInt32& aNumCharsFit,
nsTextDimensions& aLastWordDimensions,
PRInt32* aFontID);
// Draw a string using this font handle on the surface passed in.
nsresult DrawString(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
const nscoord* aSpacing,
nsRenderingContext *aContext);
nsresult DrawString(const PRUnichar* aString, PRUint32 aLength,
nscoord aX, nscoord aY,
PRInt32 aFontID,
const nscoord* aSpacing,
nsRenderingContext *aContext)
{
NS_ASSERTION(!aSpacing, "Spacing not supported here");
return DrawString(aString, aLength, aX, aY, aContext, aContext);
}
nsresult DrawString(const PRUnichar* aString, PRUint32 aLength,
nscoord aX, nscoord aY,
nsRenderingContext *aContext,
nsRenderingContext *aTextRunConstructionContext);
#ifdef MOZ_MATHML
// These two functions get the bounding metrics for this handle,
// updating the aBoundingMetrics in app units.
nsresult GetBoundingMetrics(const char *aString, PRUint32 aLength,
nsRenderingContext *aContext,
nsBoundingMetrics &aBoundingMetrics);
nsresult GetBoundingMetrics(const PRUnichar *aString,
PRUint32 aLength,
nsRenderingContext *aContext,
@ -268,17 +232,14 @@ public:
#endif /* MOZ_MATHML */
// Set the direction of the text rendering
nsresult SetRightToLeftText(PRBool aIsRTL);
PRBool GetRightToLeftText();
void SetRightToLeftText(PRBool aIsRTL) { mIsRightToLeft = aIsRTL; }
PRBool GetRightToLeftText() { return mIsRightToLeft; }
void SetTextRunRTL(PRBool aIsRTL) { mTextRunRTL = aIsRTL; }
PRBool GetRightToLeftTextRunMode() { return mTextRunRTL; }
gfxFontGroup* GetThebesFontGroup() { return mFontGroup; }
gfxUserFontSet* GetUserFontSet();
PRBool GetRightToLeftTextRunMode() {
return mTextRunRTL;
}
gfxUserFontSet* GetUserFontSet() { return mFontGroup->GetUserFontSet(); }
PRInt32 AppUnitsPerDevPixel() { return mP2A; }

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

@ -2847,7 +2847,7 @@ nsLayoutUtils::GetCenteredFontBaseline(nsFontMetrics* aFontMetrics,
{
nscoord fontAscent, fontHeight;
aFontMetrics->GetMaxAscent(fontAscent);
aFontMetrics->GetHeight(fontHeight);
aFontMetrics->GetMaxHeight(fontHeight);
nscoord leading = aLineHeight - fontHeight;
return fontAscent + leading/2;

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

@ -8813,7 +8813,7 @@ void ReflowCountMgr::PaintCount(const char* aName,
nscoord width, height;
aRenderingContext->SetTextRunRTL(PR_FALSE);
aRenderingContext->GetWidth((char*)buf, width);
fm->GetHeight(height);
fm->GetMaxHeight(height);
fm->GetMaxAscent(y);
PRUint32 color;

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

@ -1882,7 +1882,7 @@ nsListControlFrame::CalcFallbackRowHeight()
nsRefPtr<nsFontMetrics> fontMet;
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet));
if (fontMet) {
fontMet->GetHeight(rowHeight);
fontMet->GetMaxHeight(rowHeight);
}
return rowHeight;

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

@ -1422,7 +1422,7 @@ nsBulletFrame::GetDesiredSize(nsPresContext* aCX,
case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_TI_ER:
case NS_STYLE_LIST_STYLE_MOZ_ETHIOPIC_HALEHAME_TI_ET:
GetListItemText(*myList, text);
fm->GetHeight(aMetrics.height);
fm->GetMaxHeight(aMetrics.height);
aRenderingContext->SetFont(fm);
aMetrics.width = nsLayoutUtils::GetStringWidth(this, aRenderingContext, text.get(), text.Length());
aMetrics.width += mPadding.right;

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

@ -2206,7 +2206,7 @@ nsGfxScrollFrameInner::GetLineScrollAmount() const
NS_ASSERTION(fm, "FontMetrics is null, assuming fontHeight == 1 appunit");
nscoord fontHeight = 1;
if (fm) {
fm->GetHeight(fontHeight);
fm->GetMaxHeight(fontHeight);
}
return nsSize(fontHeight, fontHeight);

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

@ -979,7 +979,7 @@ nsImageFrame::DisplayAltText(nsPresContext* aPresContext,
nscoord maxAscent, maxDescent, height;
fm->GetMaxAscent(maxAscent);
fm->GetMaxDescent(maxDescent);
fm->GetHeight(height);
fm->GetMaxHeight(height);
// XXX It would be nice if there was a way to have the font metrics tell
// use where to break the text given a maximum width. At a minimum we need
@ -1124,7 +1124,6 @@ nsImageFrame::DisplayAltFeedback(nsRenderingContext& aRenderingContext,
// if we could not draw the icon, flag that we're waiting for it and
// just draw some graffiti in the mean time
if (!iconUsed) {
nscolor oldColor;
nscoord iconXPos = (vis->mDirection == NS_STYLE_DIRECTION_RTL) ?
inner.XMost() - size : inner.x;
nscoord twoPX = nsPresContext::CSSPixelsToAppUnits(2);

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

@ -657,7 +657,7 @@ nsInlineFrame::ReflowFrames(nsPresContext* aPresContext,
// and bottom border and padding. The height of children do not
// affect our height.
fm->GetMaxAscent(aMetrics.ascent);
fm->GetHeight(aMetrics.height);
fm->GetMaxHeight(aMetrics.height);
} else {
NS_WARNING("Cannot get font metrics - defaulting sizes to 0");
aMetrics.ascent = aMetrics.height = 0;

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

@ -520,7 +520,7 @@ nsPageFrame::PaintHeaderFooter(nsRenderingContext& aRenderingContext,
nscoord ascent = 0;
nscoord visibleHeight = 0;
if (fontMet) {
fontMet->GetHeight(visibleHeight);
fontMet->GetMaxHeight(visibleHeight);
fontMet->GetMaxAscent(ascent);
}

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

@ -2144,7 +2144,6 @@ nsMathMLChar::PaintVertically(nsPresContext* aPresContext,
nsGlyphTable* aGlyphTable,
nsRect& aRect)
{
nsresult rv = NS_OK;
// Get the device pixel size in the vertical direction.
// (This makes no effort to optimize for non-translation transformations.)
nscoord oneDevPixel = aPresContext->AppUnitsPerDevPixel();
@ -2373,7 +2372,6 @@ nsMathMLChar::PaintHorizontally(nsPresContext* aPresContext,
nsGlyphTable* aGlyphTable,
nsRect& aRect)
{
nsresult rv = NS_OK;
// Get the device pixel size in the horizontal direction.
// (This makes no effort to optimize for non-translation transformations.)
nscoord oneDevPixel = aPresContext->AppUnitsPerDevPixel();

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

@ -85,8 +85,6 @@ nsresult
nsMathMLContainerFrame::ReflowError(nsRenderingContext& aRenderingContext,
nsHTMLReflowMetrics& aDesiredSize)
{
nsresult rv;
// clear all other flags and record that there is an error with this frame
mEmbellishData.flags = 0;
mPresentationData.flags = NS_MATHML_ERROR;

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

@ -227,7 +227,7 @@ nsListBoxBodyFrame::Init(nsIContent* aContent,
}
nsRefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm));
fm->GetHeight(mRowHeight);
fm->GetMaxHeight(mRowHeight);
return rv;
}

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

@ -1001,7 +1001,7 @@ nsTextBoxFrame::GetTextSize(nsPresContext* aPresContext, nsRenderingContext& aRe
{
nsRefPtr<nsFontMetrics> fontMet;
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet));
fontMet->GetHeight(aSize.height);
fontMet->GetMaxHeight(aSize.height);
aRenderingContext.SetFont(fontMet);
aSize.width =
nsLayoutUtils::GetStringWidth(this, &aRenderingContext, aString.get(), aString.Length());

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

@ -1265,7 +1265,7 @@ nsTreeBodyFrame::GetCoordsForCellItem(PRInt32 aRow, nsITreeColumn* aCol, const n
nsLayoutUtils::GetFontMetricsForStyleContext(textContext,
getter_AddRefs(fm));
nscoord height;
fm->GetHeight(height);
fm->GetMaxHeight(height);
nsMargin textMargin;
textContext->GetStyleMargin()->GetMargin(textMargin);
@ -3573,7 +3573,7 @@ nsTreeBodyFrame::PaintText(PRInt32 aRowIndex,
getter_AddRefs(fontMet));
nscoord height, baseline;
fontMet->GetHeight(height);
fontMet->GetMaxHeight(height);
fontMet->GetMaxAscent(baseline);
// Center the text. XXX Obey vertical-align style prop?