Bug 524025 - Remove LL_* constants in nsLineLayout with separate booleans with field widths. r=dbaron

This commit is contained in:
Leonard Camacho 2012-09-27 21:26:40 -04:30
Родитель 952e98bb47
Коммит 4420e1cb45
2 изменённых файлов: 70 добавлений и 86 удалений

Просмотреть файл

@ -64,7 +64,20 @@ nsLineLayout::nsLineLayout(nsPresContext* aPresContext,
mLastOptionalBreakContentOffset(-1),
mForceBreakContentOffset(-1),
mMinLineHeight(0),
mTextIndent(0)
mTextIndent(0),
mFirstLetterStyleOK(false),
mIsTopOfPage(false),
mImpactedByFloats(false),
mLastFloatWasLetterFrame(false),
mLineIsEmpty(false),
mLineEndsInBR(false),
mNeedBackup(false),
mInFirstLine(false),
mGotLineBox(false),
mInFirstLetter(false),
mHasBullet(false),
mDirtyNextLine(false),
mLineAtStart(false)
{
NS_ASSERTION(aFloatManager || aOuterReflowState->frame->GetType() ==
nsGkAtoms::letterFrame,
@ -74,7 +87,6 @@ nsLineLayout::nsLineLayout(nsPresContext* aPresContext,
// Stash away some style data that we need
mStyleText = aOuterReflowState->frame->GetStyleText();
mLineNumber = 0;
mFlags = 0; // default all flags to false except those that follow here...
mTotalPlacedFrames = 0;
mTopEdge = 0;
mTrimmableWidth = 0;
@ -94,7 +106,7 @@ nsLineLayout::nsLineLayout(nsPresContext* aPresContext,
mSpanDepth = 0;
if (aLine) {
SetFlag(LL_GOTLINEBOX, true);
mGotLineBox = true;
mLineBox = *aLine;
}
}
@ -162,17 +174,17 @@ nsLineLayout::BeginLineReflow(nscoord aX, nscoord aY,
mSpansAllocated = mSpansFreed = mFramesAllocated = mFramesFreed = 0;
#endif
SetFlag(LL_FIRSTLETTERSTYLEOK, false);
SetFlag(LL_ISTOPOFPAGE, aIsTopOfPage);
SetFlag(LL_IMPACTEDBYFLOATS, aImpactedByFloats);
mFirstLetterStyleOK = false;
mIsTopOfPage = aIsTopOfPage;
mImpactedByFloats = aImpactedByFloats;
mTotalPlacedFrames = 0;
SetFlag(LL_LINEISEMPTY, true);
SetFlag(LL_LINEATSTART, true);
SetFlag(LL_LINEENDSINBR, false);
mLineIsEmpty = true;
mLineAtStart = true;
mLineEndsInBR = false;
mSpanDepth = 0;
mMaxTopBoxHeight = mMaxBottomBoxHeight = 0;
if (GetFlag(LL_GOTLINEBOX)) {
if (mGotLineBox) {
mLineBox->ClearHasBullet();
}
@ -200,7 +212,7 @@ nsLineLayout::BeginLineReflow(nscoord aX, nscoord aY,
pctBasis =
nsHTMLReflowState::GetContainingBlockContentWidth(mBlockReflowState);
if (GetFlag(LL_GOTLINEBOX)) {
if (mGotLineBox) {
mLineBox->DisableResizeReflowOptimization();
}
}
@ -325,10 +337,9 @@ nsLineLayout::UpdateBand(const nsRect& aNewAvailSpace,
}
mTopEdge = aNewAvailSpace.y;
SetFlag(LL_IMPACTEDBYFLOATS, true);
mImpactedByFloats = true;
SetFlag(LL_LASTFLOATWASLETTERFRAME,
nsGkAtoms::letterFrame == aFloatFrame->GetType());
mLastFloatWasLetterFrame = nsGkAtoms::letterFrame == aFloatFrame->GetType();
}
nsresult
@ -594,8 +605,8 @@ bool
nsLineLayout::LineIsBreakable() const
{
// XXX mTotalPlacedFrames should go away and we should just use
// LL_LINEISEMPTY here instead
if ((0 != mTotalPlacedFrames) || GetFlag(LL_IMPACTEDBYFLOATS)) {
// mLineIsEmpty here instead
if ((0 != mTotalPlacedFrames) || mImpactedByFloats) {
return true;
}
return false;
@ -737,7 +748,7 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame,
// Capture this state *before* we reflow the frame in case it clears
// the state out. We need to know how to treat the current frame
// when breaking.
bool notSafeToBreak = LineIsEmpty() && !GetFlag(LL_IMPACTEDBYFLOATS);
bool notSafeToBreak = LineIsEmpty() && !mImpactedByFloats;
// Figure out whether we're talking about a textframe here
nsIAtom* frameType = aFrame->GetType();
@ -773,7 +784,7 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame,
aFrame, availSize);
nsHTMLReflowState& reflowState = reflowStateHolder.ref();
reflowState.mLineLayout = this;
reflowState.mFlags.mIsTopOfPage = GetFlag(LL_ISTOPOFPAGE);
reflowState.mFlags.mIsTopOfPage = mIsTopOfPage;
if (reflowState.ComputedWidth() == NS_UNCONSTRAINEDSIZE)
reflowState.availableWidth = availableSpaceOnLine;
pfd->mMargin = reflowState.mComputedMargin;
@ -802,7 +813,7 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame,
// this IsPercentageAware check *after* we've constructed our
// nsHTMLReflowState, because that construction may be what forces aFrame
// to lazily initialize its (possibly-percent-valued) intrinsic size.)
if (GetFlag(LL_GOTLINEBOX) && IsPercentageAware(aFrame)) {
if (mGotLineBox && IsPercentageAware(aFrame)) {
mLineBox->DisableResizeReflowOptimization();
}
@ -1000,10 +1011,10 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame,
aReflowStatus, &optionalBreakAfterFits)) {
if (!isEmpty) {
psd->mHasNonemptyContent = true;
SetFlag(LL_LINEISEMPTY, false);
mLineIsEmpty = false;
if (!pfd->mSpan) {
// nonempty leaf content has been placed
SetFlag(LL_LINEATSTART, false);
mLineAtStart = false;
}
}
@ -1271,7 +1282,7 @@ nsLineLayout::CanPlaceFrame(PerFrameData* pfd,
#endif
// We will want to try backup.
SetFlag(LL_NEEDBACKUP, true);
mNeedBackup = true;
return true;
}
@ -1318,14 +1329,14 @@ nsLineLayout::AddBulletFrame(nsIFrame* aFrame,
const nsHTMLReflowMetrics& aMetrics)
{
NS_ASSERTION(mCurrentSpan == mRootSpan, "bad linelayout user");
NS_ASSERTION(GetFlag(LL_GOTLINEBOX), "must have line box");
NS_ASSERTION(mGotLineBox, "must have line box");
nsIFrame *blockFrame = mBlockReflowState->frame;
NS_ASSERTION(blockFrame->IsFrameOfType(nsIFrame::eBlockFrame),
"must be for block");
if (!static_cast<nsBlockFrame*>(blockFrame)->BulletIsEmpty()) {
SetFlag(LL_HASBULLET, true);
mHasBullet = true;
mLineBox->SetHasBullet();
}
@ -2034,8 +2045,8 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd)
// BR) (NN4/IE5 quirk)
// (1) and (2) above
bool applyMinLH = !psd->mZeroEffectiveSpanBox || GetFlag(LL_HASBULLET);
bool isLastLine = (!mLineBox->IsLineWrapped() && !GetFlag(LL_LINEENDSINBR));
bool applyMinLH = !psd->mZeroEffectiveSpanBox || mHasBullet;
bool isLastLine = (!mLineBox->IsLineWrapped() && !mLineEndsInBR);
if (!applyMinLH && isLastLine) {
nsIContent* blockContent = mRootSpan->mFrame->mFrame->GetContent();
if (blockContent) {
@ -2049,7 +2060,7 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd)
}
}
if (applyMinLH) {
if (psd->mHasNonemptyContent || preMode || GetFlag(LL_HASBULLET)) {
if (psd->mHasNonemptyContent || preMode || mHasBullet) {
#ifdef NOISY_VERTICAL_ALIGN
printf(" [span]==> adjusting min/maxY: currentValues: %d,%d", minY, maxY);
#endif

Просмотреть файл

@ -110,45 +110,6 @@ public:
*/
void RelativePositionFrames(nsOverflowAreas& aOverflowAreas);
//----------------------------------------
// Supporting methods and data for flags
protected:
#define LL_FIRSTLETTERSTYLEOK 0x00000008
#define LL_ISTOPOFPAGE 0x00000010
#define LL_IMPACTEDBYFLOATS 0x00000040
#define LL_LASTFLOATWASLETTERFRAME 0x00000080
#define LL_LINEISEMPTY 0x00000100
#define LL_LINEENDSINBR 0x00000200
#define LL_NEEDBACKUP 0x00000400
#define LL_INFIRSTLINE 0x00000800
#define LL_GOTLINEBOX 0x00001000
#define LL_INFIRSTLETTER 0x00002000
#define LL_HASBULLET 0x00004000
#define LL_DIRTYNEXTLINE 0x00008000
#define LL_LINEATSTART 0x00010000
#define LL_LASTFLAG LL_LINEATSTART
void SetFlag(uint32_t aFlag, bool aValue)
{
NS_ASSERTION(aFlag<=LL_LASTFLAG, "bad flag");
NS_ASSERTION(aValue==false || aValue==true, "bad value");
if (aValue) { // set flag
mFlags |= aFlag;
}
else { // unset flag
mFlags &= ~aFlag;
}
}
bool GetFlag(uint32_t aFlag) const
{
NS_ASSERTION(aFlag<=LL_LASTFLAG, "bad flag");
return !!(mFlags & aFlag);
}
public:
// Support methods for word-wrapping during line reflow
void SetTextJustificationWeights(int32_t aNumSpaces, int32_t aNumLetters) {
@ -162,7 +123,7 @@ public:
*/
bool LineIsEmpty() const
{
return GetFlag(LL_LINEISEMPTY);
return mLineIsEmpty;
}
/**
@ -172,19 +133,19 @@ public:
*/
bool LineAtStart() const
{
return GetFlag(LL_LINEATSTART);
return mLineAtStart;
}
bool LineIsBreakable() const;
bool GetLineEndsInBR() const
{
return GetFlag(LL_LINEENDSINBR);
return mLineEndsInBR;
}
void SetLineEndsInBR(bool aOn)
{
SetFlag(LL_LINEENDSINBR, aOn);
mLineEndsInBR = aOn;
}
//----------------------------------------
@ -202,36 +163,36 @@ public:
//----------------------------------------
bool GetFirstLetterStyleOK() const {
return GetFlag(LL_FIRSTLETTERSTYLEOK);
return mFirstLetterStyleOK;
}
void SetFirstLetterStyleOK(bool aSetting) {
SetFlag(LL_FIRSTLETTERSTYLEOK, aSetting);
mFirstLetterStyleOK = aSetting;
}
bool GetInFirstLetter() const {
return GetFlag(LL_INFIRSTLETTER);
return mInFirstLetter;
}
void SetInFirstLetter(bool aSetting) {
SetFlag(LL_INFIRSTLETTER, aSetting);
mInFirstLetter = aSetting;
}
bool GetInFirstLine() const {
return GetFlag(LL_INFIRSTLINE);
return mInFirstLine;
}
void SetInFirstLine(bool aSetting) {
SetFlag(LL_INFIRSTLINE, aSetting);
mInFirstLine = aSetting;
}
// Calling this during block reflow ensures that the next line of inlines
// will be marked dirty, if there is one.
void SetDirtyNextLine() {
SetFlag(LL_DIRTYNEXTLINE, true);
mDirtyNextLine = true;
}
bool GetDirtyNextLine() {
return GetFlag(LL_DIRTYNEXTLINE);
return mDirtyNextLine;
}
//----------------------------------------
@ -264,7 +225,7 @@ public:
*/
bool NotifyOptionalBreakPosition(nsIContent* aContent, int32_t aOffset,
bool aFits, gfxBreakPriority aPriority) {
NS_ASSERTION(!aFits || !GetFlag(LL_NEEDBACKUP),
NS_ASSERTION(!aFits || !mNeedBackup,
"Shouldn't be updating the break position with a break that fits after we've already flagged an overrun");
// Remember the last break position that fits; if there was no break that fit,
// just remember the first break
@ -278,7 +239,7 @@ public:
mForceBreakContentOffset == aOffset;
}
/**
* Like NotifyOptionalBreakPosition, but here it's OK for LL_NEEDBACKUP
* Like NotifyOptionalBreakPosition, but here it's OK for mNeedBackup
* to be set, because the caller is merely pruning some saved break position(s)
* that are actually not feasible.
*/
@ -292,7 +253,7 @@ public:
* Signal that no backing up will be required after all.
*/
void ClearOptionalBreakPosition() {
SetFlag(LL_NEEDBACKUP, false);
mNeedBackup = false;
mLastOptionalBreakContent = nullptr;
mLastOptionalBreakContentOffset = -1;
mLastOptionalBreakPriority = eNoBreak;
@ -310,7 +271,7 @@ public:
* Check whether frames overflowed the available width and CanPlaceFrame
* requested backing up to a saved break position.
*/
bool NeedsBackup() { return GetFlag(LL_NEEDBACKUP); }
bool NeedsBackup() { return mNeedBackup; }
// Line layout may place too much content on a line, overflowing its available
// width. When that happens, if SetLastOptionalBreakPosition has been
@ -340,10 +301,10 @@ public:
return mBlockReflowState;
}
const nsLineList::iterator* GetLine() const {
return GetFlag(LL_GOTLINEBOX) ? &mLineBox : nullptr;
return mGotLineBox ? &mLineBox : nullptr;
}
nsLineList::iterator* GetLine() {
return GetFlag(LL_GOTLINEBOX) ? &mLineBox : nullptr;
return mGotLineBox ? &mLineBox : nullptr;
}
/**
@ -526,6 +487,20 @@ protected:
// Amount of trimmable whitespace width for the trailing text frame, if any
nscoord mTrimmableWidth;
bool mFirstLetterStyleOK : 1;
bool mIsTopOfPage : 1;
bool mImpactedByFloats : 1;
bool mLastFloatWasLetterFrame : 1;
bool mLineIsEmpty : 1;
bool mLineEndsInBR : 1;
bool mNeedBackup : 1;
bool mInFirstLine : 1;
bool mGotLineBox : 1;
bool mInFirstLetter : 1;
bool mHasBullet : 1;
bool mDirtyNextLine : 1;
bool mLineAtStart : 1;
int32_t mSpanDepth;
#ifdef DEBUG
int32_t mSpansAllocated, mSpansFreed;
@ -533,8 +508,6 @@ protected:
#endif
PLArenaPool mArena; // Per span and per frame data, 4 byte aligned
uint32_t mFlags;
nsresult NewPerFrameData(PerFrameData** aResult);
nsresult NewPerSpanData(PerSpanData** aResult);