Bug 492937 - kill nsLineLayout::mPlacedFloats and related code; r+sr=roc
authorArpad Borsos <arpad.borsos@googlemail.com>
Thu, 14 May 2009 11:31:35 +0200
changeset 28380 b766e9dc23358f9c21e4de30aeae350b39b76d4b
parent 28379 49174f70a4986299a632bb21bc0df7e83a9f8141
child 28381 62e0aedc34c327b0b420588c0172492bd144adeb
push idunknown
push userunknown
push dateunknown
bugs492937
milestone1.9.2a1pre
Bug 492937 - kill nsLineLayout::mPlacedFloats and related code; r+sr=roc
layout/generic/nsBlockReflowState.cpp
layout/generic/nsBlockReflowState.h
layout/generic/nsLineLayout.cpp
layout/generic/nsLineLayout.h
--- a/layout/generic/nsBlockReflowState.cpp
+++ b/layout/generic/nsBlockReflowState.cpp
@@ -580,32 +580,30 @@ nsBlockReflowState::AddFloat(nsLineLayou
   // don't let this one go on the current line, since that would violate
   // float ordering.
   nsRect floatAvailableSpace = GetFloatAvailableSpace().mRect;
   if (mBelowCurrentLineFloats.IsEmpty() &&
       (aLineLayout.LineIsEmpty() ||
        mBlock->ComputeFloatWidth(*this, floatAvailableSpace, aPlaceholder) <=
          aAvailableWidth)) {
     // And then place it
-    PRBool isLeftFloat;
     // force it to fit if we're at the top of the block and we can't
     // break before this
     PRBool forceFit = IsAdjacentWithTop() && !aLineLayout.LineIsBreakable();
-    placed = FlowAndPlaceFloat(fc, &isLeftFloat, aReflowStatus, forceFit);
+    placed = FlowAndPlaceFloat(fc, aReflowStatus, forceFit);
     NS_ASSERTION(placed || !forceFit,
                  "If we asked for force-fit, it should have been placed");
     if (forceFit || (placed && !NS_FRAME_IS_TRUNCATED(aReflowStatus))) {
       // Pass on updated available space to the current inline reflow engine
       nsFlowAreaRect floatAvailSpace =
         GetFloatAvailableSpace(mY, forceFit);
       nsRect availSpace(nsPoint(floatAvailSpace.mRect.x + BorderPadding().left,
                                 mY),
                         floatAvailSpace.mRect.Size());
-      aLineLayout.UpdateBand(availSpace, isLeftFloat,
-                             aPlaceholder->GetOutOfFlowFrame());
+      aLineLayout.UpdateBand(availSpace, aPlaceholder->GetOutOfFlowFrame());
       
       // Record this float in the current-line list
       mCurrentLineFloats.Append(fc);
       // If we can't break here, hide the fact that it's truncated
       // XXX We can probably do this more cleanly
       aReflowStatus &= ~NS_FRAME_TRUNCATED;
     }
     else {
@@ -747,17 +745,16 @@ nsBlockReflowState::CanPlaceFloat(const 
     mY = saveY;
   }
 
   return result;
 }
 
 PRBool
 nsBlockReflowState::FlowAndPlaceFloat(nsFloatCache*   aFloatCache,
-                                      PRBool*         aIsLeftFloat,
                                       nsReflowStatus& aReflowStatus,
                                       PRBool          aForceFit)
 {
   aReflowStatus = NS_FRAME_COMPLETE;
   // Save away the Y coordinate before placing the float. We will
   // restore mY at the end after placing the float. This is
   // necessary because any adjustments to mY during the float
   // placement are for the float only, not for any non-floating
@@ -887,35 +884,31 @@ nsBlockReflowState::FlowAndPlaceFloat(ns
 
   // We don't worry about the geometry of the prev in flow, let the continuation
   // place and size itself as required.
 
   // Assign an x and y coordinate to the float. Note that the x,y
   // coordinates are computed <b>relative to the translation in the
   // spacemanager</b> which means that the impacted region will be
   // <b>inside</b> the border/padding area.
-  PRBool isLeftFloat;
   nscoord floatX, floatY;
   if (NS_STYLE_FLOAT_LEFT == floatDisplay->mFloats) {
-    isLeftFloat = PR_TRUE;
     floatX = floatAvailableSpace.mRect.x;
   }
   else {
-    isLeftFloat = PR_FALSE;
     if (!keepFloatOnSameLine) {
       floatX = floatAvailableSpace.mRect.XMost() - floatSize.width;
     } 
     else {
       // this is the IE quirk (see few lines above)
       // the table is kept in the same line: don't let it overlap the
       // previous float 
       floatX = floatAvailableSpace.mRect.x;
     }
   }
-  *aIsLeftFloat = isLeftFloat;
   const nsMargin& borderPadding = BorderPadding();
   floatY = mY - borderPadding.top;
   if (floatY < 0) {
     // CSS2 spec, 9.5.1 rule [4]: "A floating box's outer top may not
     // be higher than the top of its containing block."  (Since the
     // containing block is the content edge of the block box, this
     // means the margin edge of the float can't be higher than the
     // content edge of the block that contains it.)
@@ -931,17 +924,17 @@ nsBlockReflowState::FlowAndPlaceFloat(ns
 
   nsRect region(floatX, floatY, floatSize.width, floatSize.height);
   
   // Don't send rectangles with negative margin-box width or height to
   // the float manager; it can't deal with them.
   if (region.width < 0) {
     // Preserve the right margin-edge for left floats and the left
     // margin-edge for right floats
-    if (isLeftFloat) {
+    if (NS_STYLE_FLOAT_LEFT == floatDisplay->mFloats) {
       region.x = region.XMost();
     }
     region.width = 0;
   }
   if (region.height < 0) {
     region.height = 0;
   }
 #ifdef DEBUG
@@ -1034,19 +1027,18 @@ nsBlockReflowState::PlaceBelowCurrentLin
       if (nsBlockFrame::gNoisyReflow) {
         nsFrame::IndentBy(stdout, nsBlockFrame::gNoiseIndent);
         printf("placing bcl float: ");
         nsFrame::ListTag(stdout, fc->mPlaceholder->GetOutOfFlowFrame());
         printf("\n");
       }
 #endif
       // Place the float
-      PRBool isLeftFloat;
       nsReflowStatus reflowStatus;
-      PRBool placed = FlowAndPlaceFloat(fc, &isLeftFloat, reflowStatus, aForceFit);
+      PRBool placed = FlowAndPlaceFloat(fc, reflowStatus, aForceFit);
       NS_ASSERTION(placed || !aForceFit,
                    "If we're in force-fit mode, we should have placed the float");
 
       if (!placed || (NS_FRAME_IS_TRUNCATED(reflowStatus) && !aForceFit)) {
         // return before processing all of the floats, since the line will be pushed.
         return PR_FALSE;
       }
       else if (NS_FRAME_IS_NOT_COMPLETE(reflowStatus)) {
--- a/layout/generic/nsBlockReflowState.h
+++ b/layout/generic/nsBlockReflowState.h
@@ -114,17 +114,16 @@ public:
                   nsPlaceholderFrame* aPlaceholderFrame,
                   PRBool              aInitialReflow,
                   nscoord             aAvailableWidth,
                   nsReflowStatus&     aReflowStatus);
   PRBool CanPlaceFloat(const nsSize& aFloatSize, PRUint8 aFloats,
                        const nsFlowAreaRect& aFloatAvailableSpace,
                        PRBool aForceFit);
   PRBool FlowAndPlaceFloat(nsFloatCache*   aFloatCache,
-                           PRBool*         aIsLeftFloat,
                            nsReflowStatus& aReflowStatus,
                            PRBool          aForceFit);
   PRBool PlaceBelowCurrentLineFloats(nsFloatCacheFreeList& aFloats, PRBool aForceFit);
 
   // Returns the first coordinate >= aY that clears the
   // floats indicated by aBreakType and has enough width between floats
   // (or no floats remaining) to accomodate aReplacedBlock.
   nscoord ClearFloats(nscoord aY, PRUint8 aBreakType,
--- a/layout/generic/nsLineLayout.cpp
+++ b/layout/generic/nsLineLayout.cpp
@@ -84,19 +84,16 @@
 #undef  NOISY_TRIM
 #undef  REALLY_NOISY_TRIM
 #endif
 
 //----------------------------------------------------------------------
 
 #define FIX_BUG_50257
 
-#define PLACED_LEFT  0x1
-#define PLACED_RIGHT 0x2
-
 nsLineLayout::nsLineLayout(nsPresContext* aPresContext,
                            nsFloatManager* aFloatManager,
                            const nsHTMLReflowState* aOuterReflowState,
                            const nsLineList::iterator* aLine)
   : mPresContext(aPresContext),
     mFloatManager(aFloatManager),
     mBlockReflowState(aOuterReflowState),
     mLastOptionalBreakContent(nsnull),
@@ -113,17 +110,16 @@ nsLineLayout::nsLineLayout(nsPresContext
                "float manager should be present");
   MOZ_COUNT_CTOR(nsLineLayout);
 
   // Stash away some style data that we need
   mStyleText = aOuterReflowState->frame->GetStyleText();
   mTextAlign = mStyleText->mTextAlign;
   mLineNumber = 0;
   mFlags = 0; // default all flags to false except those that follow here...
-  mPlacedFloats = 0;
   mTotalPlacedFrames = 0;
   mTopEdge = 0;
   mTrimmableWidth = 0;
 
   // Instead of always pre-initializing the free-lists for frames and
   // spans, we do it on demand so that situations that only use a few
   // frames and spans won't waste a lot of time in unneeded
   // initialization.
@@ -199,17 +195,16 @@ nsLineLayout::BeginLineReflow(nscoord aX
          aIsTopOfPage ? "top-of-page" : "");
 #endif
 #ifdef DEBUG
   mSpansAllocated = mSpansFreed = mFramesAllocated = mFramesFreed = 0;
 #endif
 
   SetFlag(LL_FIRSTLETTERSTYLEOK, PR_FALSE);
   SetFlag(LL_ISTOPOFPAGE, aIsTopOfPage);
-  mPlacedFloats = 0;
   SetFlag(LL_IMPACTEDBYFLOATS, aImpactedByFloats);
   mTotalPlacedFrames = 0;
   SetFlag(LL_LINEISEMPTY, PR_TRUE);
   SetFlag(LL_LINEENDSINBR, PR_FALSE);
   mSpanDepth = 0;
   mMaxTopBoxHeight = mMaxBottomBoxHeight = 0;
 
   PerSpanData* psd;
@@ -287,24 +282,23 @@ nsLineLayout::EndLineReflow()
 
 // XXX swtich to a single mAvailLineWidth that we adjust as each frame
 // on the line is placed. Each span can still have a per-span mX that
 // tracks where a child frame is going in its span; they don't need a
 // per-span mLeftEdge?
 
 void
 nsLineLayout::UpdateBand(const nsRect& aNewAvailSpace,
-                         PRBool aPlacedLeftFloat,
                          nsIFrame* aFloatFrame)
 {
 #ifdef REALLY_NOISY_REFLOW
-  printf("nsLL::UpdateBand %d, %d, %d, %d, frame=%p placedLeft=%s\n  will set mImpacted to PR_TRUE\n",
+  printf("nsLL::UpdateBand %d, %d, %d, %d, frame=%p\n  will set mImpacted to PR_TRUE\n",
          aNewAvailSpace.x, aNewAvailSpace.y,
          aNewAvailSpace.width, aNewAvailSpace.height,
-         aFloatFrame, aPlacedLeftFloat?"true":"false");
+         aFloatFrame);
 #endif
 #ifdef DEBUG
   if ((aNewAvailSpace.width != NS_UNCONSTRAINEDSIZE) && CRAZY_WIDTH(aNewAvailSpace.width)) {
     nsFrame::ListTag(stdout, mBlockReflowState->frame);
     printf(": UpdateBand: bad caller: width WAS %d(0x%x)\n",
            aNewAvailSpace.width, aNewAvailSpace.width);
   }
   if ((aNewAvailSpace.height != NS_UNCONSTRAINEDSIZE) && CRAZY_HEIGHT(aNewAvailSpace.height)) {
@@ -320,20 +314,19 @@ nsLineLayout::UpdateBand(const nsRect& a
                "shouldn't use unconstrained widths anymore");
   // The root span's mLeftEdge moves to aX
   nscoord deltaX = aNewAvailSpace.x - mRootSpan->mLeftEdge;
   // The width of all spans changes by this much (the root span's
   // mRightEdge moves to aX + aWidth, its new width is aWidth)
   nscoord deltaWidth = aNewAvailSpace.width - (mRootSpan->mRightEdge - mRootSpan->mLeftEdge);
 #ifdef NOISY_REFLOW
   nsFrame::ListTag(stdout, mBlockReflowState->frame);
-  printf(": UpdateBand: %d,%d,%d,%d deltaWidth=%d deltaX=%d %s float\n",
+  printf(": UpdateBand: %d,%d,%d,%d deltaWidth=%d deltaX=%d\n",
          aNewAvailSpace.x, aNewAvailSpace.y,
-         aNewAvailSpace.width, aNewAvailSpace.height, deltaWidth, deltaX,
-         aPlacedLeftFloat ? "left" : "right");
+         aNewAvailSpace.width, aNewAvailSpace.height, deltaWidth, deltaX);
 #endif
 
   // Update the root span position
   mRootSpan->mLeftEdge += deltaX;
   mRootSpan->mRightEdge += deltaX;
   mRootSpan->mX += deltaX;
 
   // Now update the right edges of the open spans to account for any
@@ -360,17 +353,16 @@ nsLineLayout::UpdateBand(const nsRect& a
   // parent therefore they are moved when their parent span is moved.
   if (deltaX != 0) {
     for (PerFrameData* pfd = mRootSpan->mFirstFrame; pfd; pfd = pfd->mNext) {
       pfd->mBounds.x += deltaX;
     }
   }
 
   mTopEdge = aNewAvailSpace.y;
-  mPlacedFloats |= (aPlacedLeftFloat ? PLACED_LEFT : PLACED_RIGHT);
   SetFlag(LL_IMPACTEDBYFLOATS, PR_TRUE);
 
   SetFlag(LL_LASTFLOATWASLETTERFRAME,
           nsGkAtoms::letterFrame == aFloatFrame->GetType());
 }
 
 nsresult
 nsLineLayout::NewPerSpanData(PerSpanData** aResult)
--- a/layout/generic/nsLineLayout.h
+++ b/layout/generic/nsLineLayout.h
@@ -90,22 +90,19 @@ public:
   void EndLineReflow();
 
   /**
    * Called when a float has been placed. This method updates the
    * inline frame and span data to account for any change in positions
    * due to available space for the line boxes changing.
    * @param aX/aY/aWidth/aHeight are the new available
    * space rectangle, relative to the containing block.
-   * @param aPlacedLeftFloat whether we placed a left float or a right
-   * float to trigger the available space change
    * @param aFloatFrame the float frame that was placed.
    */
   void UpdateBand(const nsRect& aNewAvailableSpace,
-                  PRBool aPlacedLeftFloat,
                   nsIFrame* aFloatFrame);
 
   nsresult BeginSpan(nsIFrame* aFrame,
                      const nsHTMLReflowState* aSpanReflowState,
                      nscoord aLeftEdge,
                      nscoord aRightEdge);
 
   // Returns the width of the span
@@ -543,18 +540,16 @@ protected:
   PRInt32 mFramesAllocated, mFramesFreed;
 #endif
   PLArenaPool mArena; // Per span and per frame data, 4 byte aligned
 
   PRUint16 mFlags;
 
   PRUint8 mTextAlign;
 
-  PRUint8 mPlacedFloats;
-
   nsresult NewPerFrameData(PerFrameData** aResult);
 
   nsresult NewPerSpanData(PerSpanData** aResult);
 
   void FreeSpan(PerSpanData* psd);
 
   PRBool InBlockContext() const {
     return mSpanDepth == 0;