зеркало из https://github.com/mozilla/pjs.git
Bug 746421 - Make nsTextBoxFrames overflow area include the LOOSE_INK_EXTENTS of the text. r=jfkthame
This commit is contained in:
Родитель
f0cac247dc
Коммит
3d94253d33
|
@ -365,20 +365,20 @@ nsFontMetrics::DrawString(const PRUnichar* aString, PRUint32 aLength,
|
|||
&provider, nsnull, nsnull);
|
||||
}
|
||||
|
||||
nsBoundingMetrics
|
||||
nsFontMetrics::GetBoundingMetrics(const PRUnichar *aString, PRUint32 aLength,
|
||||
nsRenderingContext *aContext)
|
||||
static nsBoundingMetrics
|
||||
GetTextBoundingMetrics(nsFontMetrics* aMetrics, const PRUnichar *aString, PRUint32 aLength,
|
||||
nsRenderingContext *aContext, gfxFont::BoundingBoxType aType)
|
||||
{
|
||||
if (aLength == 0)
|
||||
return nsBoundingMetrics();
|
||||
|
||||
StubPropertyProvider provider;
|
||||
AutoTextRun textRun(this, aContext, aString, aLength);
|
||||
AutoTextRun textRun(aMetrics, aContext, aString, aLength);
|
||||
nsBoundingMetrics m;
|
||||
if (textRun.get()) {
|
||||
gfxTextRun::Metrics theMetrics =
|
||||
textRun->MeasureText(0, aLength,
|
||||
gfxFont::TIGHT_HINTED_OUTLINE_EXTENTS,
|
||||
aType,
|
||||
aContext->ThebesContext(), &provider);
|
||||
|
||||
m.leftBearing = NSToCoordFloor( theMetrics.mBoundingBox.X());
|
||||
|
@ -389,3 +389,19 @@ nsFontMetrics::GetBoundingMetrics(const PRUnichar *aString, PRUint32 aLength,
|
|||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
nsBoundingMetrics
|
||||
nsFontMetrics::GetBoundingMetrics(const PRUnichar *aString, PRUint32 aLength,
|
||||
nsRenderingContext *aContext)
|
||||
{
|
||||
return GetTextBoundingMetrics(this, aString, aLength, aContext, gfxFont::TIGHT_HINTED_OUTLINE_EXTENTS);
|
||||
|
||||
}
|
||||
|
||||
nsBoundingMetrics
|
||||
nsFontMetrics::GetInkBoundsForVisualOverflow(const PRUnichar *aString, PRUint32 aLength,
|
||||
nsRenderingContext *aContext)
|
||||
{
|
||||
return GetTextBoundingMetrics(this, aString, aLength, aContext, gfxFont::LOOSE_INK_EXTENTS);
|
||||
}
|
||||
|
||||
|
|
|
@ -221,6 +221,12 @@ public:
|
|||
PRUint32 aLength,
|
||||
nsRenderingContext *aContext);
|
||||
|
||||
// Returns the LOOSE_INK_EXTENTS bounds of the text for determing the
|
||||
// overflow area of the string.
|
||||
nsBoundingMetrics GetInkBoundsForVisualOverflow(const PRUnichar *aString,
|
||||
PRUint32 aLength,
|
||||
nsRenderingContext *aContext);
|
||||
|
||||
void SetTextRunRTL(bool aIsRTL) { mTextRunRTL = aIsRTL; }
|
||||
bool GetTextRunRTL() { return mTextRunRTL; }
|
||||
|
||||
|
|
|
@ -930,16 +930,32 @@ nsTextBoxFrame::DoLayout(nsBoxLayoutState& aBoxLayoutState)
|
|||
CalcDrawRect(*aBoxLayoutState.GetRenderingContext());
|
||||
|
||||
const nsStyleText* textStyle = GetStyleText();
|
||||
|
||||
nsRect bounds(nsPoint(0, 0), GetSize());
|
||||
nsRect textRect = mTextDrawRect;
|
||||
|
||||
nsRefPtr<nsFontMetrics> fontMet;
|
||||
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet));
|
||||
nsBoundingMetrics metrics =
|
||||
fontMet->GetInkBoundsForVisualOverflow(mTitle.get(), mTitle.Length(),
|
||||
aBoxLayoutState.GetRenderingContext());
|
||||
|
||||
textRect.x -= metrics.leftBearing;
|
||||
textRect.width = metrics.width;
|
||||
// In DrawText() we always draw with the baseline at MaxAscent() (relative to mTextDrawRect),
|
||||
textRect.y += fontMet->MaxAscent() - metrics.ascent;
|
||||
textRect.height = metrics.ascent + metrics.descent;
|
||||
|
||||
bounds.UnionRect(bounds, textRect);
|
||||
nsOverflowAreas overflow(bounds, bounds);
|
||||
|
||||
if (textStyle->mTextShadow) {
|
||||
nsRect bounds(nsPoint(0, 0), GetSize());
|
||||
nsOverflowAreas overflow(bounds, bounds);
|
||||
// Our scrollable overflow is our bounds; our visual overflow may
|
||||
// extend beyond that.
|
||||
nsPoint origin(0,0);
|
||||
nsRect &vis = overflow.VisualOverflow();
|
||||
vis.UnionRect(vis, nsLayoutUtils::GetTextShadowRectsUnion(mTextDrawRect, this));
|
||||
FinishAndStoreOverflow(overflow, GetSize());
|
||||
}
|
||||
FinishAndStoreOverflow(overflow, GetSize());
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -947,8 +963,7 @@ nsTextBoxFrame::DoLayout(nsBoxLayoutState& aBoxLayoutState)
|
|||
nsRect
|
||||
nsTextBoxFrame::GetComponentAlphaBounds()
|
||||
{
|
||||
return nsLayoutUtils::GetTextShadowRectsUnion(mTextDrawRect, this,
|
||||
nsLayoutUtils::EXCLUDE_BLUR_SHADOWS);
|
||||
return GetVisualOverflowRectRelativeToSelf();
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
Загрузка…
Ссылка в новой задаче