зеркало из https://github.com/mozilla/gecko-dev.git
Bug 333659. Relanding nsLineLayout API changes for new text code. r+sr=dbaron
This commit is contained in:
Родитель
d114701e8d
Коммит
7790a961e0
|
@ -3101,7 +3101,7 @@ nsBlockFrame::ReflowInlineFrames(nsBlockReflowState& aState,
|
|||
// no longer makes sense. Now we always allocate on the stack
|
||||
nsLineLayout lineLayout(aState.mPresContext,
|
||||
aState.mReflowState.mSpaceManager,
|
||||
&aState.mReflowState);
|
||||
&aState.mReflowState, &aLine);
|
||||
lineLayout.Init(&aState, aState.mMinLineHeight, aState.mLineNumber);
|
||||
if (forceBreakInContent) {
|
||||
lineLayout.ForceBreakAtPosition(forceBreakInContent, forceBreakOffset);
|
||||
|
@ -3827,7 +3827,7 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState,
|
|||
aLineLayout.AddBulletFrame(mBullet, metrics);
|
||||
addedBullet = PR_TRUE;
|
||||
}
|
||||
aLineLayout.VerticalAlignLine(aLine);
|
||||
aLineLayout.VerticalAlignLine();
|
||||
// Our ascent is the ascent of our first line (but if this line is all
|
||||
// whitespace we'll correct things in |ReflowBlockFrame|).
|
||||
if (aLine == mLines.front()) {
|
||||
|
|
|
@ -255,7 +255,7 @@ nsFirstLetterFrame::Reflow(nsPresContext* aPresContext,
|
|||
// only time that the first-letter-frame is not reflowing in a
|
||||
// line context is when its floating.
|
||||
nsHTMLReflowState rs(aPresContext, aReflowState, kid, availSize);
|
||||
nsLineLayout ll(aPresContext, nsnull, &aReflowState);
|
||||
nsLineLayout ll(aPresContext, nsnull, &aReflowState, nsnull);
|
||||
ll.BeginLineReflow(0, 0, NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE,
|
||||
PR_FALSE, PR_TRUE);
|
||||
rs.mLineLayout = ≪
|
||||
|
|
|
@ -914,7 +914,11 @@ nsFirstLineFrame::Reflow(nsPresContext* aPresContext,
|
|||
}
|
||||
}
|
||||
|
||||
NS_ASSERTION(!aReflowState.mLineLayout->GetInFirstLine(),
|
||||
"Nested first-line frames? BOGUS");
|
||||
aReflowState.mLineLayout->SetInFirstLine(PR_TRUE);
|
||||
rv = ReflowFrames(aPresContext, aReflowState, irs, aMetrics, aStatus);
|
||||
aReflowState.mLineLayout->SetInFirstLine(PR_FALSE);
|
||||
|
||||
// Note: the line layout code will properly compute our overflow state for us
|
||||
|
||||
|
|
|
@ -93,7 +93,8 @@
|
|||
|
||||
nsLineLayout::nsLineLayout(nsPresContext* aPresContext,
|
||||
nsSpaceManager* aSpaceManager,
|
||||
const nsHTMLReflowState* aOuterReflowState)
|
||||
const nsHTMLReflowState* aOuterReflowState,
|
||||
const nsLineList::iterator* aLine)
|
||||
: mPresContext(aPresContext),
|
||||
mSpaceManager(aSpaceManager),
|
||||
mBlockReflowState(aOuterReflowState),
|
||||
|
@ -133,6 +134,11 @@ nsLineLayout::nsLineLayout(nsPresContext* aPresContext,
|
|||
mCurrentSpan = mRootSpan = nsnull;
|
||||
mSpanDepth = 0;
|
||||
|
||||
if (aLine) {
|
||||
SetFlag(LL_GOTLINEBOX, PR_TRUE);
|
||||
mLineBox = *aLine;
|
||||
}
|
||||
|
||||
mCompatMode = mPresContext->CompatibilityMode();
|
||||
}
|
||||
|
||||
|
@ -808,7 +814,6 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame,
|
|||
#endif // IBMBIDI
|
||||
|
||||
nsIAtom* frameType = aFrame->GetType();
|
||||
|
||||
PRInt32 savedOptionalBreakOffset;
|
||||
nsIContent* savedOptionalBreakContent =
|
||||
GetLastOptionalBreakPosition(&savedOptionalBreakOffset);
|
||||
|
@ -1393,7 +1398,7 @@ PRBool IsPercentageAwareFrame(nsPresContext *aPresContext, nsIFrame *aFrame)
|
|||
|
||||
|
||||
void
|
||||
nsLineLayout::VerticalAlignLine(nsLineBox* aLineBox)
|
||||
nsLineLayout::VerticalAlignLine()
|
||||
{
|
||||
// Synthesize a PerFrameData for the block frame
|
||||
PerFrameData rootPFD;
|
||||
|
@ -1402,7 +1407,6 @@ nsLineLayout::VerticalAlignLine(nsLineBox* aLineBox)
|
|||
rootPFD.mAscent = 0;
|
||||
rootPFD.mDescent = 0;
|
||||
mRootSpan->mFrame = &rootPFD;
|
||||
mLineBox = aLineBox;
|
||||
|
||||
// Partially place the children of the block frame. The baseline for
|
||||
// this operation is set to zero so that the y coordinates for all
|
||||
|
@ -1507,32 +1511,31 @@ nsLineLayout::VerticalAlignLine(nsLineBox* aLineBox)
|
|||
}
|
||||
// check to see if the frame is an inline replace element
|
||||
// and if it is percent-aware. If so, mark the line.
|
||||
if ((PR_FALSE==aLineBox->ResizeReflowOptimizationDisabled()) &&
|
||||
if ((PR_FALSE==mLineBox->ResizeReflowOptimizationDisabled()) &&
|
||||
pfd->mFrameType & NS_CSS_FRAME_TYPE_INLINE)
|
||||
{
|
||||
if (IsPercentageAwareFrame(mPresContext, pfd->mFrame))
|
||||
aLineBox->DisableResizeReflowOptimization();
|
||||
mLineBox->DisableResizeReflowOptimization();
|
||||
}
|
||||
}
|
||||
|
||||
// Fill in returned line-box and max-element-width data
|
||||
aLineBox->mBounds.x = psd->mLeftEdge;
|
||||
aLineBox->mBounds.y = mTopEdge;
|
||||
aLineBox->mBounds.width = psd->mX - psd->mLeftEdge;
|
||||
aLineBox->mBounds.height = lineHeight;
|
||||
mLineBox->mBounds.x = psd->mLeftEdge;
|
||||
mLineBox->mBounds.y = mTopEdge;
|
||||
mLineBox->mBounds.width = psd->mX - psd->mLeftEdge;
|
||||
mLineBox->mBounds.height = lineHeight;
|
||||
mFinalLineHeight = lineHeight;
|
||||
aLineBox->SetAscent(baselineY - mTopEdge);
|
||||
mLineBox->SetAscent(baselineY - mTopEdge);
|
||||
#ifdef NOISY_VERTICAL_ALIGN
|
||||
printf(
|
||||
" [line]==> bounds{x,y,w,h}={%d,%d,%d,%d} lh=%d a=%d\n",
|
||||
aLineBox->mBounds.x, aLineBox->mBounds.y,
|
||||
aLineBox->mBounds.width, aLineBox->mBounds.height,
|
||||
mFinalLineHeight, aLineBox->GetAscent());
|
||||
mLineBox->mBounds.x, mLineBox->mBounds.y,
|
||||
mLineBox->mBounds.width, mLineBox->mBounds.height,
|
||||
mFinalLineHeight, mLineBox->GetAscent());
|
||||
#endif
|
||||
|
||||
// Undo root-span mFrame pointer to prevent brane damage later on...
|
||||
mRootSpan->mFrame = nsnull;
|
||||
mLineBox = nsnull;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -66,7 +66,8 @@ class nsLineLayout {
|
|||
public:
|
||||
nsLineLayout(nsPresContext* aPresContext,
|
||||
nsSpaceManager* aSpaceManager,
|
||||
const nsHTMLReflowState* aOuterReflowState);
|
||||
const nsHTMLReflowState* aOuterReflowState,
|
||||
const nsLineList::iterator* aLine);
|
||||
~nsLineLayout();
|
||||
|
||||
void Init(nsBlockReflowState* aState, nscoord aMinLineHeight,
|
||||
|
@ -126,7 +127,7 @@ public:
|
|||
PushFrame(aFrame);
|
||||
}
|
||||
|
||||
void VerticalAlignLine(nsLineBox* aLineBox);
|
||||
void VerticalAlignLine();
|
||||
|
||||
PRBool TrimTrailingWhiteSpace();
|
||||
|
||||
|
@ -161,7 +162,9 @@ protected:
|
|||
#define LL_LINEENDSINSOFTBR 0x00000400
|
||||
#define LL_NEEDBACKUP 0x00000800
|
||||
#define LL_LASTTEXTFRAME_WRAPPINGENABLED 0x00001000
|
||||
#define LL_LASTFLAG LL_LASTTEXTFRAME_WRAPPINGENABLED
|
||||
#define LL_INFIRSTLINE 0x00002000
|
||||
#define LL_GOTLINEBOX 0x00004000
|
||||
#define LL_LASTFLAG LL_GOTLINEBOX
|
||||
|
||||
PRUint16 mFlags;
|
||||
|
||||
|
@ -274,7 +277,7 @@ public:
|
|||
* @param aWrappingEnabled whether that text had word-wrapping enabled
|
||||
* (white-space:normal or -moz-pre-wrap)
|
||||
*/
|
||||
nsIFrame* GetTrailingTextFrame(PRBool* aWrappingEnabled) {
|
||||
nsIFrame* GetTrailingTextFrame(PRBool* aWrappingEnabled) const {
|
||||
*aWrappingEnabled = GetFlag(LL_LASTTEXTFRAME_WRAPPINGENABLED);
|
||||
return mTrailingTextFrame;
|
||||
}
|
||||
|
@ -298,6 +301,14 @@ public:
|
|||
mFirstLetterFrame = aFrame;
|
||||
}
|
||||
|
||||
PRBool GetInFirstLine() const {
|
||||
return GetFlag(LL_INFIRSTLINE);
|
||||
}
|
||||
|
||||
void SetInFirstLine(PRBool aSetting) {
|
||||
SetFlag(LL_INFIRSTLINE, aSetting);
|
||||
}
|
||||
|
||||
//----------------------------------------
|
||||
|
||||
static PRBool TreatFrameAsBlock(nsIFrame* aFrame);
|
||||
|
@ -390,8 +401,11 @@ public:
|
|||
* some other kind of frame when inline frames are reflowed in a non-block
|
||||
* context (e.g. MathML).
|
||||
*/
|
||||
nsIFrame* GetLineContainerFrame() { return mBlockReflowState->frame; }
|
||||
|
||||
nsIFrame* GetLineContainerFrame() const { return mBlockReflowState->frame; }
|
||||
const nsLineList::iterator* GetLine() const {
|
||||
return GetFlag(LL_GOTLINEBOX) ? &mLineBox : nsnull;
|
||||
}
|
||||
|
||||
protected:
|
||||
// This state is constant for a given block frame doing line layout
|
||||
nsSpaceManager* mSpaceManager;
|
||||
|
@ -427,7 +441,7 @@ protected:
|
|||
PRInt32 mTextJustificationNumSpaces;
|
||||
PRInt32 mTextJustificationNumLetters;
|
||||
|
||||
nsLineBox* mLineBox;
|
||||
nsLineList::iterator mLineBox;
|
||||
|
||||
PRInt32 mTotalPlacedFrames;
|
||||
|
||||
|
|
|
@ -985,7 +985,7 @@ nsMathMLContainerFrame::ReflowForeignChild(nsIFrame* aChildFrame,
|
|||
// provide a local, self-contained linelayout where to reflow the nsInlineFrame
|
||||
nsSize availSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
|
||||
nsLineLayout ll(aPresContext, aReflowState.mSpaceManager,
|
||||
aReflowState.parentReflowState);
|
||||
aReflowState.parentReflowState, nsnull);
|
||||
ll.BeginLineReflow(0, 0, availSize.width, availSize.height, PR_FALSE, PR_FALSE);
|
||||
PRBool pushedFrame;
|
||||
ll.ReflowFrame(aChildFrame, aStatus, &aDesiredSize, pushedFrame);
|
||||
|
|
Загрузка…
Ссылка в новой задаче