From 5deb6526214d77d1fa100110af5595212f57519e Mon Sep 17 00:00:00 2001 From: "L. David Baron" Date: Thu, 5 Aug 2010 21:59:20 -0700 Subject: [PATCH] Add bit to lines indicating that they may have a placeholder for a float that was pushed to the next line (and bump the child count up to 32 bits). (Bug 563584, patch 24) r=roc --- layout/generic/nsBlockFrame.cpp | 5 +++-- layout/generic/nsBlockReflowState.cpp | 6 +++++- layout/generic/nsBlockReflowState.h | 3 ++- layout/generic/nsLineBox.h | 23 +++++++++++++++++++---- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index 93ebd3b7b47..a34a0a2a08c 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -2409,7 +2409,8 @@ nsBlockFrame::ReflowLine(nsBlockReflowState& aState, aState.mCurrentLine = aLine; aLine->ClearDirty(); aLine->InvalidateCachedIsEmpty(); - + aLine->ClearHadFloatPushed(); + // Now that we know what kind of line we have, reflow it if (aLine->IsBlock()) { nsRect oldBounds = aLine->mFirstChild->GetRect(); @@ -4213,7 +4214,7 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState, if (aState.mBelowCurrentLineFloats.NotEmpty()) { // Reflow the below-current-line floats, which places on the line's // float list. - aState.PlaceBelowCurrentLineFloats(aState.mBelowCurrentLineFloats); + aState.PlaceBelowCurrentLineFloats(aState.mBelowCurrentLineFloats, aLine); aLine->AppendFloats(aState.mBelowCurrentLineFloats); } diff --git a/layout/generic/nsBlockReflowState.cpp b/layout/generic/nsBlockReflowState.cpp index 6cc54aea801..cc5d9cf949c 100644 --- a/layout/generic/nsBlockReflowState.cpp +++ b/layout/generic/nsBlockReflowState.cpp @@ -605,6 +605,8 @@ nsBlockReflowState::AddFloat(nsLineLayout* aLineLayout, aLineLayout->UpdateBand(availSpace, aFloat); // Record this float in the current-line list mCurrentLineFloats.Append(mFloatCacheFreeList.Alloc(aFloat)); + } else { + (*aLineLayout->GetLine())->SetHadFloatPushed(); } } else { @@ -956,7 +958,8 @@ nsBlockReflowState::PushFloatPastBreak(nsIFrame *aFloat) * Place below-current-line floats. */ void -nsBlockReflowState::PlaceBelowCurrentLineFloats(nsFloatCacheFreeList& aList) +nsBlockReflowState::PlaceBelowCurrentLineFloats(nsFloatCacheFreeList& aList, + nsLineBox* aLine) { nsFloatCache* fc = aList.Head(); while (fc) { @@ -974,6 +977,7 @@ nsBlockReflowState::PlaceBelowCurrentLineFloats(nsFloatCacheFreeList& aList) if (!placed) { aList.Remove(fc); delete fc; + aLine->SetHadFloatPushed(); } fc = next; } diff --git a/layout/generic/nsBlockReflowState.h b/layout/generic/nsBlockReflowState.h index 4e0fe97a81a..44f3386aad4 100644 --- a/layout/generic/nsBlockReflowState.h +++ b/layout/generic/nsBlockReflowState.h @@ -115,7 +115,8 @@ public: private: void PushFloatPastBreak(nsIFrame* aFloat); public: - void PlaceBelowCurrentLineFloats(nsFloatCacheFreeList& aFloats); + void PlaceBelowCurrentLineFloats(nsFloatCacheFreeList& aFloats, + nsLineBox* aLine); // Returns the first coordinate >= aY that clears the // floats indicated by aBreakType and has enough width between floats diff --git a/layout/generic/nsLineBox.h b/layout/generic/nsLineBox.h index 98e0030ec66..32110e373cc 100644 --- a/layout/generic/nsLineBox.h +++ b/layout/generic/nsLineBox.h @@ -174,7 +174,7 @@ protected: //---------------------------------------------------------------------- #define LINE_MAX_BREAK_TYPE ((1 << 4) - 1) -#define LINE_MAX_CHILD_COUNT ((1 << 20) - 1) +#define LINE_MAX_CHILD_COUNT PR_INT32_MAX #if NS_STYLE_CLEAR_LAST_VALUE > 15 need to rearrange the mBits bitfield; @@ -330,8 +330,19 @@ public: PRBool HasBullet() const { return mFlags.mHasBullet; } - - + + // mHadFloatPushed bit + void SetHadFloatPushed() { + mFlags.mHadFloatPushed = PR_TRUE; + } + void ClearHadFloatPushed() { + mFlags.mHadFloatPushed = PR_FALSE; + } + PRBool HadFloatPushed() const { + return mFlags.mHadFloatPushed; + } + + // mChildCount value PRInt32 GetChildCount() const { return (PRInt32) mFlags.mChildCount; @@ -501,9 +512,13 @@ public: // mHasBullet indicates that this is an inline line whose block's // bullet is adjacent to this line and non-empty. PRUint32 mHasBullet : 1; + // Indicates that this line *may* have a placeholder for a float + // that was pushed to a later column or page. + PRUint32 mHadFloatPushed : 1; PRUint32 mBreakType : 4; - PRUint32 mChildCount : 17; + // FIXME: Move this out of FlagBits + PRUint32 mChildCount; }; struct ExtraData {