Bug 223764: Inlines inside inlines that draw text-decorations shouldn't alter the baseline. (r=dbaron)

We add a baseline field to nsInlineFrame and modify
nsLineLayout::BeginSpan to take a pointer to a baseline to update. This
also means that nsFirstLetterFrame no longer needs to update its own
baseline, and instead should just pass its own field along.
This commit is contained in:
Vitor Menezes 2011-08-03 11:30:58 -07:00
parent 4dbadf264d
commit 1baff11dba
10 changed files with 57 additions and 14 deletions

View File

@ -226,6 +226,10 @@ nsFirstLetterFrame::Reflow(nsPresContext* aPresContext,
ll.EndLineReflow();
ll.SetInFirstLetter(PR_FALSE);
// In the floating first-letter case, we need to set this ourselves;
// nsLineLayout::BeginSpan will set it in the other case
mBaseline = aMetrics.ascent;
}
else {
// Pretend we are a span and reflow the child frame
@ -234,7 +238,7 @@ nsFirstLetterFrame::Reflow(nsPresContext* aPresContext,
ll->SetInFirstLetter(
mStyleContext->GetPseudo() == nsCSSPseudoElements::firstLetter);
ll->BeginSpan(this, &aReflowState, bp.left, availSize.width);
ll->BeginSpan(this, &aReflowState, bp.left, availSize.width, &mBaseline);
ll->ReflowFrame(kid, aReflowStatus, &aMetrics, pushedFrame);
ll->EndSpan(this);
ll->SetInFirstLetter(PR_FALSE);
@ -248,7 +252,6 @@ nsFirstLetterFrame::Reflow(nsPresContext* aPresContext,
aMetrics.width += lr;
aMetrics.height += tb;
aMetrics.ascent += bp.top;
mBaseline = aMetrics.ascent;
// Ensure that the overflow rect contains the child textframe's overflow rect.
// Note that if this is floating, the overline/underline drawable area is in

View File

@ -474,7 +474,8 @@ nsInlineFrame::ReflowFrames(nsPresContext* aPresContext,
availableWidth -= leftEdge;
availableWidth -= ltr ? aReflowState.mComputedBorderPadding.right
: aReflowState.mComputedBorderPadding.left;
lineLayout->BeginSpan(this, &aReflowState, leftEdge, leftEdge + availableWidth);
lineLayout->BeginSpan(this, &aReflowState, leftEdge,
leftEdge + availableWidth, &mBaseline);
// First reflow our current children
nsIFrame* frame = mFrames.FirstChild();
@ -913,13 +914,7 @@ nsInlineFrame::GetSkipSides() const
nscoord
nsInlineFrame::GetBaseline() const
{
nscoord ascent = 0;
nsRefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm));
if (fm) {
ascent = fm->MaxAscent();
}
return NS_MIN(mRect.height, ascent + GetUsedBorderAndPadding().top);
return mBaseline;
}
#ifdef ACCESSIBILITY

View File

@ -194,6 +194,8 @@ protected:
nsIFrame* aFromChild,
nsIFrame* aPrevSibling,
InlineReflowState& aState);
nscoord mBaseline;
};
//----------------------------------------------------------------------

View File

@ -402,7 +402,8 @@ nsresult
nsLineLayout::BeginSpan(nsIFrame* aFrame,
const nsHTMLReflowState* aSpanReflowState,
nscoord aLeftEdge,
nscoord aRightEdge)
nscoord aRightEdge,
nscoord* aBaseline)
{
NS_ASSERTION(aRightEdge != NS_UNCONSTRAINEDSIZE,
"should no longer be using unconstrained sizes");
@ -427,6 +428,7 @@ nsLineLayout::BeginSpan(nsIFrame* aFrame,
psd->mLeftEdge = aLeftEdge;
psd->mX = aLeftEdge;
psd->mRightEdge = aRightEdge;
psd->mBaseline = aBaseline;
psd->mNoWrap =
!aSpanReflowState->frame->GetStyleText()->WhiteSpaceCanWrap();
@ -1763,7 +1765,7 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd)
// This is the distance from the top edge of the parents visual
// box to the baseline. The span already computed this for us,
// so just use it.
baselineY = spanFramePFD->mAscent;
*psd->mBaseline = baselineY = spanFramePFD->mAscent;
#ifdef NOISY_VERTICAL_ALIGN
@ -2140,6 +2142,7 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd)
spanFramePFD->mAscent -= minY; // move the baseline up
spanFramePFD->mBounds.height -= minY; // move the bottom up
psd->mTopLeading += minY;
*psd->mBaseline -= minY;
pfd = psd->mFirstFrame;
while (nsnull != pfd) {

View File

@ -103,7 +103,8 @@ public:
nsresult BeginSpan(nsIFrame* aFrame,
const nsHTMLReflowState* aSpanReflowState,
nscoord aLeftEdge,
nscoord aRightEdge);
nscoord aRightEdge,
nscoord* aBaseline);
// Returns the width of the span
nscoord EndSpan(nsIFrame* aFrame);
@ -506,6 +507,7 @@ protected:
nscoord mTopLeading, mBottomLeading;
nscoord mLogicalHeight;
nscoord mMinY, mMaxY;
nscoord* mBaseline;
void AppendFrame(PerFrameData* pfd) {
if (nsnull == mLastFrame) {

View File

@ -0,0 +1,10 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<title>test for bug 223764 (Almost-standards)</title>
<body>
<p style="overflow: hidden; padding-bottom: 20px;">
<span style="font-size: 100px;"><span style="font-size: 20px">hello</span></span>
</p>
</body>
</html>

View File

@ -0,0 +1,10 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<title>test for bug 223764 (Almost-standards)</title>
<body>
<p style="overflow: hidden; padding-bottom: 20px;">
<span style="font-size: 100px; text-decoration:underline"><span style="font-size: 20px">hello</span></span>
</p>
</body>
</html>

View File

@ -0,0 +1,8 @@
<html>
<title>test for bug 223764 (Quirks)</title>
<body>
<p style="overflow: hidden; padding-bottom: 20px;">
<span style="font-size: 100px;"><span style="font-size: 20px">hello</span></span>
</p>
</body>
</html>

View File

@ -0,0 +1,8 @@
<html>
<title>test for bug 223764 (Quirks)</title>
<body>
<p style="overflow: hidden; padding-bottom: 20px;">
<span style="font-size: 100px; text-decoration:underline"><span style="font-size: 20px">hello</span></span>
</p>
</body>
</html>

View File

@ -93,4 +93,6 @@ fails-if(Android) == underline-block-propagation-2-standards.html underline-bloc
== decoration-color-override-quirks.html decoration-color-override-quirks-ref.html
== decoration-color-override-standards.html decoration-color-override-standards-ref.html
!= decoration-color-override-standards-ref.html decoration-color-override-quirks-ref.html
== decoration-css21-block.html decoration-css21-block-ref.html # bug 403524
== decoration-css21-block.html decoration-css21-block-ref.html
!= inline-baseline-almost-standards.html inline-baseline-almost-standards-ref.html
!= inline-baseline-quirks.html inline-baseline-quirks-ref.html