Make overflow from text frames be visual overflow only, and not scrollable. (Bug 542595, patch 8) r=roc a2.0=blocking2.0:beta8

This commit is contained in:
L. David Baron 2010-10-06 21:25:45 -07:00
parent dd079acd74
commit 24d9099920
4 changed files with 30 additions and 23 deletions

View File

@ -2598,7 +2598,7 @@ nsLineLayout::RelativePositionFrames(PerSpanData* psd, nsOverflowAreas& aOverflo
if (pfd->GetFlag(PFD_ISTEXTFRAME)) {
if (pfd->GetFlag(PFD_RECOMPUTEOVERFLOW)) {
nsTextFrame* f = static_cast<nsTextFrame*>(frame);
r = f->RecomputeOverflowRect();
r = f->RecomputeOverflow();
}
frame->FinishAndStoreOverflow(r, frame->GetSize());
}

View File

@ -241,7 +241,7 @@ public:
// placeholders or inlines containing such).
struct TrimOutput {
// true if we trimmed some space or changed metrics in some other way.
// In this case, we should call RecomputeOverflowRect on this frame.
// In this case, we should call RecomputeOverflow on this frame.
PRPackedBool mChanged;
// true if the last character is not justifiable so should be subtracted
// from the count of justifiable characters in the frame, since the last
@ -257,7 +257,7 @@ public:
PRUint32 aSkippedStartOffset = 0,
PRUint32 aSkippedMaxLength = PR_UINT32_MAX);
nsRect RecomputeOverflowRect();
nsOverflowAreas RecomputeOverflow();
void AddInlineMinWidthForFlow(nsIRenderingContext *aRenderingContext,
nsIFrame::InlineMinWidthData *aData);
@ -400,7 +400,7 @@ protected:
void UnionTextDecorationOverflow(nsPresContext* aPresContext,
PropertyProvider& aProvider,
nsRect* aOverflowRect);
nsRect* aVisualOverflowRect);
void DrawText(gfxContext* aCtx,
const gfxPoint& aTextBaselinePt,

View File

@ -4104,11 +4104,12 @@ nsTextFrame::GetTextDecorations(nsPresContext* aPresContext)
void
nsTextFrame::UnionTextDecorationOverflow(nsPresContext* aPresContext,
PropertyProvider& aProvider,
nsRect* aOverflowRect)
nsRect* aVisualOverflowRect)
{
// Text-shadow overflows
nsRect shadowRect = nsLayoutUtils::GetTextShadowRectsUnion(*aOverflowRect, this);
aOverflowRect->UnionRect(*aOverflowRect, shadowRect);
nsRect shadowRect =
nsLayoutUtils::GetTextShadowRectsUnion(*aVisualOverflowRect, this);
aVisualOverflowRect->UnionRect(*aVisualOverflowRect, shadowRect);
if (IsFloatingFirstLetterChild()) {
// The underline/overline drawable area must be contained in the overflow
@ -4118,14 +4119,14 @@ nsTextFrame::UnionTextDecorationOverflow(nsPresContext* aPresContext,
fm->GetMaxAscent(fontAscent);
fm->GetMaxHeight(fontHeight);
nsRect fontRect(0, mAscent - fontAscent, GetSize().width, fontHeight);
aOverflowRect->UnionRect(*aOverflowRect, fontRect);
aVisualOverflowRect->UnionRect(*aVisualOverflowRect, fontRect);
}
// When this frame is not selected, the text-decoration area must be in
// frame bounds.
nsRect decorationRect;
if (!(GetStateBits() & NS_FRAME_SELECTED_CONTENT) ||
!CombineSelectionUnderlineRect(aPresContext, *aOverflowRect))
!CombineSelectionUnderlineRect(aPresContext, *aVisualOverflowRect))
return;
AddStateBits(TEXT_SELECTION_UNDERLINE_OVERFLOWED);
}
@ -6581,10 +6582,10 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
// Handle text that runs outside its normal bounds.
nsRect boundingBox = RoundOut(textMetrics.mBoundingBox) + nsPoint(0, mAscent);
aMetrics.mOverflowArea.UnionRect(boundingBox,
nsRect(0, 0, aMetrics.width, aMetrics.height));
aMetrics.SetOverflowAreasToDesiredBounds();
aMetrics.VisualOverflow().UnionRect(aMetrics.VisualOverflow(), boundingBox);
UnionTextDecorationOverflow(presContext, provider, &aMetrics.mOverflowArea);
UnionTextDecorationOverflow(presContext, provider, &aMetrics.VisualOverflow());
/////////////////////////////////////////////////////////////////////
// Clean up, update state
@ -6812,12 +6813,15 @@ nsTextFrame::TrimTrailingWhiteSpace(nsIRenderingContext* aRC)
return result;
}
nsRect
nsTextFrame::RecomputeOverflowRect()
nsOverflowAreas
nsTextFrame::RecomputeOverflow()
{
nsRect bounds(nsPoint(0, 0), GetSize());
nsOverflowAreas result(bounds, bounds);
gfxSkipCharsIterator iter = EnsureTextRun();
if (!mTextRun)
return nsRect(nsPoint(0,0), GetSize());
return result;
PropertyProvider provider(this, iter);
provider.InitializeForDisplay(PR_TRUE);
@ -6828,13 +6832,12 @@ nsTextFrame::RecomputeOverflowRect()
gfxFont::LOOSE_INK_EXTENTS, nsnull,
&provider);
nsRect boundingBox = RoundOut(textMetrics.mBoundingBox) + nsPoint(0, mAscent);
boundingBox.UnionRect(boundingBox,
nsRect(nsPoint(0,0), GetSize()));
nsRect &vis = result.VisualOverflow();
vis.UnionRect(vis, RoundOut(textMetrics.mBoundingBox) + nsPoint(0, mAscent));
UnionTextDecorationOverflow(PresContext(), provider, &boundingBox);
UnionTextDecorationOverflow(PresContext(), provider, &vis);
return boundingBox;
return result;
}
static PRUnichar TransformChar(const nsStyleText* aStyle, gfxTextRun* aTextRun,

View File

@ -956,11 +956,15 @@ nsTextBoxFrame::DoLayout(nsBoxLayoutState& aBoxLayoutState)
const nsStyleText* textStyle = GetStyleText();
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 textRect = CalcTextRect(*aBoxLayoutState.GetRenderingContext(), origin);
nsRect overflowRect(nsLayoutUtils::GetTextShadowRectsUnion(textRect, this));
overflowRect.UnionRect(overflowRect, nsRect(nsPoint(0, 0), GetSize()));
FinishAndStoreOverflow(&overflowRect, GetSize());
nsRect &vis = overflow.VisualOverflow();
vis.UnionRect(vis, nsLayoutUtils::GetTextShadowRectsUnion(textRect, this));
FinishAndStoreOverflow(overflow, GetSize());
}
return rv;
}