Bug 365414 overflowed decoration lines are not erased/painted r+sr=roc

This commit is contained in:
masayuki@d-toybox.com 2007-08-14 09:39:54 -07:00
parent 051a23c4b6
commit e2f6a778c9
3 changed files with 15 additions and 1 deletions

View File

@ -347,7 +347,9 @@ gfxFont::Measure(gfxTextRun *aTextRun,
metrics.mAdvanceWidth = floatAdvance;
const PRUint32 appUnitsPerDevUnit = aTextRun->GetAppUnitsPerDevUnit();
metrics.mAscent = fontMetrics.maxAscent*appUnitsPerDevUnit;
metrics.mDescent = fontMetrics.maxDescent*appUnitsPerDevUnit;
gfxFloat descentForUnderline =
NS_round(fontMetrics.underlineSize) + NS_round(metrics.mAscent - fontMetrics.underlineOffset) - metrics.mAscent;
metrics.mDescent = PR_MAX(fontMetrics.maxDescent, descentForUnderline)*appUnitsPerDevUnit;
metrics.mBoundingBox =
gfxRect(0, -metrics.mAscent, floatAdvance, metrics.mAscent + metrics.mDescent);
return metrics;

View File

@ -518,6 +518,9 @@ public:
float AppUnitsToPoints(nscoord aAppUnits) const
{ return (float)aAppUnits / mDeviceContext->AppUnitsPerInch() * 72.0f; }
nscoord RoundAppUnitsToNearestDevPixels(nscoord aAppUnits) const
{ return DevPixelsToAppUnits(AppUnitsToDevPixels(aAppUnits)); }
/**
* Get the language-specific transform type for the current document.
* This tells us whether we need to perform special language-dependent

View File

@ -559,6 +559,15 @@ nsInlineFrame::ReflowFrames(nsPresContext* aPresContext,
// affect our height.
fm->GetMaxAscent(aMetrics.ascent);
fm->GetHeight(aMetrics.height);
// Include the text-decoration lines to the height.
// Currently, only undeline is overflowable.
nscoord offset, size;
fm->GetUnderline(offset, size);
nscoord ascentAndUnderline =
aPresContext->RoundAppUnitsToNearestDevPixels(aMetrics.ascent - offset) +
aPresContext->RoundAppUnitsToNearestDevPixels(size);
if (ascentAndUnderline > aMetrics.height)
aMetrics.height = ascentAndUnderline;
} else {
NS_WARNING("Cannot get font metrics - defaulting sizes to 0");
aMetrics.ascent = aMetrics.height = 0;