diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index 9429c9a24e6b..54d58d36a52d 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -553,26 +553,54 @@ nsBlockFrame::DrainOverflowList() void nsBlockFrame::ClearFloaters(nsBlockReflowState& aState, PRUint8 aBreakType) { - if (aState.mCurrentBand.count <= 1) { - // No floaters in this band therefore nothing to clear - return; - } + for (;;) { + if (aState.mCurrentBand.count <= 1) { + // No floaters in this band therefore nothing to clear + break; + } - // Find the Y coordinate to clear to - nscoord clearYMost = aState.mY; - nsRect tmp; - PRInt32 i; - for (i = 0; i < aState.mCurrentBand.count; i++) { - nsStyleDisplay* display; - nsBandTrapezoid* trapezoid = &aState.mCurrentBand.data[i]; - if (trapezoid->state != nsBandTrapezoid::Available) { - if (nsBandTrapezoid::OccupiedMultiple == trapezoid->state) { - PRInt32 fn, numFrames = trapezoid->frames->Count(); - NS_ASSERTION(numFrames > 0, "bad trapezoid frame list"); - for (fn = 0; fn < numFrames; fn++) { - nsIFrame* f = (nsIFrame*) trapezoid->frames->ElementAt(fn); - f->GetStyleData(eStyleStruct_Display, (nsStyleStruct*&)display); + // Find the Y coordinate to clear to + nscoord clearYMost = aState.mY; + nsRect tmp; + PRInt32 i; + for (i = 0; i < aState.mCurrentBand.count; i++) { + nsStyleDisplay* display; + nsBandTrapezoid* trapezoid = &aState.mCurrentBand.data[i]; + if (trapezoid->state != nsBandTrapezoid::Available) { + if (nsBandTrapezoid::OccupiedMultiple == trapezoid->state) { + PRInt32 fn, numFrames = trapezoid->frames->Count(); + NS_ASSERTION(numFrames > 0, "bad trapezoid frame list"); + for (fn = 0; fn < numFrames; fn++) { + nsIFrame* f = (nsIFrame*) trapezoid->frames->ElementAt(fn); + f->GetStyleData(eStyleStruct_Display, (nsStyleStruct*&)display); + switch (display->mFloats) { + case NS_STYLE_FLOAT_LEFT: + if ((NS_STYLE_CLEAR_LEFT == aBreakType) || + (NS_STYLE_CLEAR_LEFT_AND_RIGHT == aBreakType)) { + trapezoid->GetRect(tmp); + nscoord ym = tmp.YMost(); + if (ym > clearYMost) { + clearYMost = ym; + } + } + break; + case NS_STYLE_FLOAT_RIGHT: + if ((NS_STYLE_CLEAR_RIGHT == aBreakType) || + (NS_STYLE_CLEAR_LEFT_AND_RIGHT == aBreakType)) { + trapezoid->GetRect(tmp); + nscoord ym = tmp.YMost(); + if (ym > clearYMost) { + clearYMost = ym; + } + } + break; + } + } + } + else { + trapezoid->frame->GetStyleData(eStyleStruct_Display, + (nsStyleStruct*&)display); switch (display->mFloats) { case NS_STYLE_FLOAT_LEFT: if ((NS_STYLE_CLEAR_LEFT == aBreakType) || @@ -597,43 +625,22 @@ nsBlockFrame::ClearFloaters(nsBlockReflowState& aState, PRUint8 aBreakType) } } } - else { - trapezoid->frame->GetStyleData(eStyleStruct_Display, - (nsStyleStruct*&)display); - switch (display->mFloats) { - case NS_STYLE_FLOAT_LEFT: - if ((NS_STYLE_CLEAR_LEFT == aBreakType) || - (NS_STYLE_CLEAR_LEFT_AND_RIGHT == aBreakType)) { - trapezoid->GetRect(tmp); - nscoord ym = tmp.YMost(); - if (ym > clearYMost) { - clearYMost = ym; - } - } - break; - case NS_STYLE_FLOAT_RIGHT: - if ((NS_STYLE_CLEAR_RIGHT == aBreakType) || - (NS_STYLE_CLEAR_LEFT_AND_RIGHT == aBreakType)) { - trapezoid->GetRect(tmp); - nscoord ym = tmp.YMost(); - if (ym > clearYMost) { - clearYMost = ym; - } - } - break; - } - } } + + if (clearYMost == aState.mY) { + // Nothing to clear + break; + } + + NS_FRAME_LOG(NS_FRAME_TRACE_CHILD_REFLOW, + ("nsBlockFrame::ClearFloaters: mY=%d clearYMost=%d\n", + aState.mY, clearYMost)); + + aState.mY = clearYMost + 1; + + // Get a new band + GetAvailableSpace(aState, aState.mY); } - - NS_FRAME_LOG(NS_FRAME_TRACE_CHILD_REFLOW, - ("nsBlockFrame::ClearFloaters: mY=%d clearYMost=%d\n", - aState.mY, clearYMost)); - - aState.mY = clearYMost; - - // Get a new band - GetAvailableSpace(aState, aState.mY); } nsresult diff --git a/layout/generic/nsBlockReflowState.cpp b/layout/generic/nsBlockReflowState.cpp index 9429c9a24e6b..54d58d36a52d 100644 --- a/layout/generic/nsBlockReflowState.cpp +++ b/layout/generic/nsBlockReflowState.cpp @@ -553,26 +553,54 @@ nsBlockFrame::DrainOverflowList() void nsBlockFrame::ClearFloaters(nsBlockReflowState& aState, PRUint8 aBreakType) { - if (aState.mCurrentBand.count <= 1) { - // No floaters in this band therefore nothing to clear - return; - } + for (;;) { + if (aState.mCurrentBand.count <= 1) { + // No floaters in this band therefore nothing to clear + break; + } - // Find the Y coordinate to clear to - nscoord clearYMost = aState.mY; - nsRect tmp; - PRInt32 i; - for (i = 0; i < aState.mCurrentBand.count; i++) { - nsStyleDisplay* display; - nsBandTrapezoid* trapezoid = &aState.mCurrentBand.data[i]; - if (trapezoid->state != nsBandTrapezoid::Available) { - if (nsBandTrapezoid::OccupiedMultiple == trapezoid->state) { - PRInt32 fn, numFrames = trapezoid->frames->Count(); - NS_ASSERTION(numFrames > 0, "bad trapezoid frame list"); - for (fn = 0; fn < numFrames; fn++) { - nsIFrame* f = (nsIFrame*) trapezoid->frames->ElementAt(fn); - f->GetStyleData(eStyleStruct_Display, (nsStyleStruct*&)display); + // Find the Y coordinate to clear to + nscoord clearYMost = aState.mY; + nsRect tmp; + PRInt32 i; + for (i = 0; i < aState.mCurrentBand.count; i++) { + nsStyleDisplay* display; + nsBandTrapezoid* trapezoid = &aState.mCurrentBand.data[i]; + if (trapezoid->state != nsBandTrapezoid::Available) { + if (nsBandTrapezoid::OccupiedMultiple == trapezoid->state) { + PRInt32 fn, numFrames = trapezoid->frames->Count(); + NS_ASSERTION(numFrames > 0, "bad trapezoid frame list"); + for (fn = 0; fn < numFrames; fn++) { + nsIFrame* f = (nsIFrame*) trapezoid->frames->ElementAt(fn); + f->GetStyleData(eStyleStruct_Display, (nsStyleStruct*&)display); + switch (display->mFloats) { + case NS_STYLE_FLOAT_LEFT: + if ((NS_STYLE_CLEAR_LEFT == aBreakType) || + (NS_STYLE_CLEAR_LEFT_AND_RIGHT == aBreakType)) { + trapezoid->GetRect(tmp); + nscoord ym = tmp.YMost(); + if (ym > clearYMost) { + clearYMost = ym; + } + } + break; + case NS_STYLE_FLOAT_RIGHT: + if ((NS_STYLE_CLEAR_RIGHT == aBreakType) || + (NS_STYLE_CLEAR_LEFT_AND_RIGHT == aBreakType)) { + trapezoid->GetRect(tmp); + nscoord ym = tmp.YMost(); + if (ym > clearYMost) { + clearYMost = ym; + } + } + break; + } + } + } + else { + trapezoid->frame->GetStyleData(eStyleStruct_Display, + (nsStyleStruct*&)display); switch (display->mFloats) { case NS_STYLE_FLOAT_LEFT: if ((NS_STYLE_CLEAR_LEFT == aBreakType) || @@ -597,43 +625,22 @@ nsBlockFrame::ClearFloaters(nsBlockReflowState& aState, PRUint8 aBreakType) } } } - else { - trapezoid->frame->GetStyleData(eStyleStruct_Display, - (nsStyleStruct*&)display); - switch (display->mFloats) { - case NS_STYLE_FLOAT_LEFT: - if ((NS_STYLE_CLEAR_LEFT == aBreakType) || - (NS_STYLE_CLEAR_LEFT_AND_RIGHT == aBreakType)) { - trapezoid->GetRect(tmp); - nscoord ym = tmp.YMost(); - if (ym > clearYMost) { - clearYMost = ym; - } - } - break; - case NS_STYLE_FLOAT_RIGHT: - if ((NS_STYLE_CLEAR_RIGHT == aBreakType) || - (NS_STYLE_CLEAR_LEFT_AND_RIGHT == aBreakType)) { - trapezoid->GetRect(tmp); - nscoord ym = tmp.YMost(); - if (ym > clearYMost) { - clearYMost = ym; - } - } - break; - } - } } + + if (clearYMost == aState.mY) { + // Nothing to clear + break; + } + + NS_FRAME_LOG(NS_FRAME_TRACE_CHILD_REFLOW, + ("nsBlockFrame::ClearFloaters: mY=%d clearYMost=%d\n", + aState.mY, clearYMost)); + + aState.mY = clearYMost + 1; + + // Get a new band + GetAvailableSpace(aState, aState.mY); } - - NS_FRAME_LOG(NS_FRAME_TRACE_CHILD_REFLOW, - ("nsBlockFrame::ClearFloaters: mY=%d clearYMost=%d\n", - aState.mY, clearYMost)); - - aState.mY = clearYMost; - - // Get a new band - GetAvailableSpace(aState, aState.mY); } nsresult diff --git a/layout/generic/nsBlockReflowState.h b/layout/generic/nsBlockReflowState.h index 9429c9a24e6b..54d58d36a52d 100644 --- a/layout/generic/nsBlockReflowState.h +++ b/layout/generic/nsBlockReflowState.h @@ -553,26 +553,54 @@ nsBlockFrame::DrainOverflowList() void nsBlockFrame::ClearFloaters(nsBlockReflowState& aState, PRUint8 aBreakType) { - if (aState.mCurrentBand.count <= 1) { - // No floaters in this band therefore nothing to clear - return; - } + for (;;) { + if (aState.mCurrentBand.count <= 1) { + // No floaters in this band therefore nothing to clear + break; + } - // Find the Y coordinate to clear to - nscoord clearYMost = aState.mY; - nsRect tmp; - PRInt32 i; - for (i = 0; i < aState.mCurrentBand.count; i++) { - nsStyleDisplay* display; - nsBandTrapezoid* trapezoid = &aState.mCurrentBand.data[i]; - if (trapezoid->state != nsBandTrapezoid::Available) { - if (nsBandTrapezoid::OccupiedMultiple == trapezoid->state) { - PRInt32 fn, numFrames = trapezoid->frames->Count(); - NS_ASSERTION(numFrames > 0, "bad trapezoid frame list"); - for (fn = 0; fn < numFrames; fn++) { - nsIFrame* f = (nsIFrame*) trapezoid->frames->ElementAt(fn); - f->GetStyleData(eStyleStruct_Display, (nsStyleStruct*&)display); + // Find the Y coordinate to clear to + nscoord clearYMost = aState.mY; + nsRect tmp; + PRInt32 i; + for (i = 0; i < aState.mCurrentBand.count; i++) { + nsStyleDisplay* display; + nsBandTrapezoid* trapezoid = &aState.mCurrentBand.data[i]; + if (trapezoid->state != nsBandTrapezoid::Available) { + if (nsBandTrapezoid::OccupiedMultiple == trapezoid->state) { + PRInt32 fn, numFrames = trapezoid->frames->Count(); + NS_ASSERTION(numFrames > 0, "bad trapezoid frame list"); + for (fn = 0; fn < numFrames; fn++) { + nsIFrame* f = (nsIFrame*) trapezoid->frames->ElementAt(fn); + f->GetStyleData(eStyleStruct_Display, (nsStyleStruct*&)display); + switch (display->mFloats) { + case NS_STYLE_FLOAT_LEFT: + if ((NS_STYLE_CLEAR_LEFT == aBreakType) || + (NS_STYLE_CLEAR_LEFT_AND_RIGHT == aBreakType)) { + trapezoid->GetRect(tmp); + nscoord ym = tmp.YMost(); + if (ym > clearYMost) { + clearYMost = ym; + } + } + break; + case NS_STYLE_FLOAT_RIGHT: + if ((NS_STYLE_CLEAR_RIGHT == aBreakType) || + (NS_STYLE_CLEAR_LEFT_AND_RIGHT == aBreakType)) { + trapezoid->GetRect(tmp); + nscoord ym = tmp.YMost(); + if (ym > clearYMost) { + clearYMost = ym; + } + } + break; + } + } + } + else { + trapezoid->frame->GetStyleData(eStyleStruct_Display, + (nsStyleStruct*&)display); switch (display->mFloats) { case NS_STYLE_FLOAT_LEFT: if ((NS_STYLE_CLEAR_LEFT == aBreakType) || @@ -597,43 +625,22 @@ nsBlockFrame::ClearFloaters(nsBlockReflowState& aState, PRUint8 aBreakType) } } } - else { - trapezoid->frame->GetStyleData(eStyleStruct_Display, - (nsStyleStruct*&)display); - switch (display->mFloats) { - case NS_STYLE_FLOAT_LEFT: - if ((NS_STYLE_CLEAR_LEFT == aBreakType) || - (NS_STYLE_CLEAR_LEFT_AND_RIGHT == aBreakType)) { - trapezoid->GetRect(tmp); - nscoord ym = tmp.YMost(); - if (ym > clearYMost) { - clearYMost = ym; - } - } - break; - case NS_STYLE_FLOAT_RIGHT: - if ((NS_STYLE_CLEAR_RIGHT == aBreakType) || - (NS_STYLE_CLEAR_LEFT_AND_RIGHT == aBreakType)) { - trapezoid->GetRect(tmp); - nscoord ym = tmp.YMost(); - if (ym > clearYMost) { - clearYMost = ym; - } - } - break; - } - } } + + if (clearYMost == aState.mY) { + // Nothing to clear + break; + } + + NS_FRAME_LOG(NS_FRAME_TRACE_CHILD_REFLOW, + ("nsBlockFrame::ClearFloaters: mY=%d clearYMost=%d\n", + aState.mY, clearYMost)); + + aState.mY = clearYMost + 1; + + // Get a new band + GetAvailableSpace(aState, aState.mY); } - - NS_FRAME_LOG(NS_FRAME_TRACE_CHILD_REFLOW, - ("nsBlockFrame::ClearFloaters: mY=%d clearYMost=%d\n", - aState.mY, clearYMost)); - - aState.mY = clearYMost; - - // Get a new band - GetAvailableSpace(aState, aState.mY); } nsresult diff --git a/layout/html/base/src/nsBlockFrame.cpp b/layout/html/base/src/nsBlockFrame.cpp index 9429c9a24e6b..54d58d36a52d 100644 --- a/layout/html/base/src/nsBlockFrame.cpp +++ b/layout/html/base/src/nsBlockFrame.cpp @@ -553,26 +553,54 @@ nsBlockFrame::DrainOverflowList() void nsBlockFrame::ClearFloaters(nsBlockReflowState& aState, PRUint8 aBreakType) { - if (aState.mCurrentBand.count <= 1) { - // No floaters in this band therefore nothing to clear - return; - } + for (;;) { + if (aState.mCurrentBand.count <= 1) { + // No floaters in this band therefore nothing to clear + break; + } - // Find the Y coordinate to clear to - nscoord clearYMost = aState.mY; - nsRect tmp; - PRInt32 i; - for (i = 0; i < aState.mCurrentBand.count; i++) { - nsStyleDisplay* display; - nsBandTrapezoid* trapezoid = &aState.mCurrentBand.data[i]; - if (trapezoid->state != nsBandTrapezoid::Available) { - if (nsBandTrapezoid::OccupiedMultiple == trapezoid->state) { - PRInt32 fn, numFrames = trapezoid->frames->Count(); - NS_ASSERTION(numFrames > 0, "bad trapezoid frame list"); - for (fn = 0; fn < numFrames; fn++) { - nsIFrame* f = (nsIFrame*) trapezoid->frames->ElementAt(fn); - f->GetStyleData(eStyleStruct_Display, (nsStyleStruct*&)display); + // Find the Y coordinate to clear to + nscoord clearYMost = aState.mY; + nsRect tmp; + PRInt32 i; + for (i = 0; i < aState.mCurrentBand.count; i++) { + nsStyleDisplay* display; + nsBandTrapezoid* trapezoid = &aState.mCurrentBand.data[i]; + if (trapezoid->state != nsBandTrapezoid::Available) { + if (nsBandTrapezoid::OccupiedMultiple == trapezoid->state) { + PRInt32 fn, numFrames = trapezoid->frames->Count(); + NS_ASSERTION(numFrames > 0, "bad trapezoid frame list"); + for (fn = 0; fn < numFrames; fn++) { + nsIFrame* f = (nsIFrame*) trapezoid->frames->ElementAt(fn); + f->GetStyleData(eStyleStruct_Display, (nsStyleStruct*&)display); + switch (display->mFloats) { + case NS_STYLE_FLOAT_LEFT: + if ((NS_STYLE_CLEAR_LEFT == aBreakType) || + (NS_STYLE_CLEAR_LEFT_AND_RIGHT == aBreakType)) { + trapezoid->GetRect(tmp); + nscoord ym = tmp.YMost(); + if (ym > clearYMost) { + clearYMost = ym; + } + } + break; + case NS_STYLE_FLOAT_RIGHT: + if ((NS_STYLE_CLEAR_RIGHT == aBreakType) || + (NS_STYLE_CLEAR_LEFT_AND_RIGHT == aBreakType)) { + trapezoid->GetRect(tmp); + nscoord ym = tmp.YMost(); + if (ym > clearYMost) { + clearYMost = ym; + } + } + break; + } + } + } + else { + trapezoid->frame->GetStyleData(eStyleStruct_Display, + (nsStyleStruct*&)display); switch (display->mFloats) { case NS_STYLE_FLOAT_LEFT: if ((NS_STYLE_CLEAR_LEFT == aBreakType) || @@ -597,43 +625,22 @@ nsBlockFrame::ClearFloaters(nsBlockReflowState& aState, PRUint8 aBreakType) } } } - else { - trapezoid->frame->GetStyleData(eStyleStruct_Display, - (nsStyleStruct*&)display); - switch (display->mFloats) { - case NS_STYLE_FLOAT_LEFT: - if ((NS_STYLE_CLEAR_LEFT == aBreakType) || - (NS_STYLE_CLEAR_LEFT_AND_RIGHT == aBreakType)) { - trapezoid->GetRect(tmp); - nscoord ym = tmp.YMost(); - if (ym > clearYMost) { - clearYMost = ym; - } - } - break; - case NS_STYLE_FLOAT_RIGHT: - if ((NS_STYLE_CLEAR_RIGHT == aBreakType) || - (NS_STYLE_CLEAR_LEFT_AND_RIGHT == aBreakType)) { - trapezoid->GetRect(tmp); - nscoord ym = tmp.YMost(); - if (ym > clearYMost) { - clearYMost = ym; - } - } - break; - } - } } + + if (clearYMost == aState.mY) { + // Nothing to clear + break; + } + + NS_FRAME_LOG(NS_FRAME_TRACE_CHILD_REFLOW, + ("nsBlockFrame::ClearFloaters: mY=%d clearYMost=%d\n", + aState.mY, clearYMost)); + + aState.mY = clearYMost + 1; + + // Get a new band + GetAvailableSpace(aState, aState.mY); } - - NS_FRAME_LOG(NS_FRAME_TRACE_CHILD_REFLOW, - ("nsBlockFrame::ClearFloaters: mY=%d clearYMost=%d\n", - aState.mY, clearYMost)); - - aState.mY = clearYMost; - - // Get a new band - GetAvailableSpace(aState, aState.mY); } nsresult diff --git a/layout/html/base/src/nsBlockReflowState.cpp b/layout/html/base/src/nsBlockReflowState.cpp index 9429c9a24e6b..54d58d36a52d 100644 --- a/layout/html/base/src/nsBlockReflowState.cpp +++ b/layout/html/base/src/nsBlockReflowState.cpp @@ -553,26 +553,54 @@ nsBlockFrame::DrainOverflowList() void nsBlockFrame::ClearFloaters(nsBlockReflowState& aState, PRUint8 aBreakType) { - if (aState.mCurrentBand.count <= 1) { - // No floaters in this band therefore nothing to clear - return; - } + for (;;) { + if (aState.mCurrentBand.count <= 1) { + // No floaters in this band therefore nothing to clear + break; + } - // Find the Y coordinate to clear to - nscoord clearYMost = aState.mY; - nsRect tmp; - PRInt32 i; - for (i = 0; i < aState.mCurrentBand.count; i++) { - nsStyleDisplay* display; - nsBandTrapezoid* trapezoid = &aState.mCurrentBand.data[i]; - if (trapezoid->state != nsBandTrapezoid::Available) { - if (nsBandTrapezoid::OccupiedMultiple == trapezoid->state) { - PRInt32 fn, numFrames = trapezoid->frames->Count(); - NS_ASSERTION(numFrames > 0, "bad trapezoid frame list"); - for (fn = 0; fn < numFrames; fn++) { - nsIFrame* f = (nsIFrame*) trapezoid->frames->ElementAt(fn); - f->GetStyleData(eStyleStruct_Display, (nsStyleStruct*&)display); + // Find the Y coordinate to clear to + nscoord clearYMost = aState.mY; + nsRect tmp; + PRInt32 i; + for (i = 0; i < aState.mCurrentBand.count; i++) { + nsStyleDisplay* display; + nsBandTrapezoid* trapezoid = &aState.mCurrentBand.data[i]; + if (trapezoid->state != nsBandTrapezoid::Available) { + if (nsBandTrapezoid::OccupiedMultiple == trapezoid->state) { + PRInt32 fn, numFrames = trapezoid->frames->Count(); + NS_ASSERTION(numFrames > 0, "bad trapezoid frame list"); + for (fn = 0; fn < numFrames; fn++) { + nsIFrame* f = (nsIFrame*) trapezoid->frames->ElementAt(fn); + f->GetStyleData(eStyleStruct_Display, (nsStyleStruct*&)display); + switch (display->mFloats) { + case NS_STYLE_FLOAT_LEFT: + if ((NS_STYLE_CLEAR_LEFT == aBreakType) || + (NS_STYLE_CLEAR_LEFT_AND_RIGHT == aBreakType)) { + trapezoid->GetRect(tmp); + nscoord ym = tmp.YMost(); + if (ym > clearYMost) { + clearYMost = ym; + } + } + break; + case NS_STYLE_FLOAT_RIGHT: + if ((NS_STYLE_CLEAR_RIGHT == aBreakType) || + (NS_STYLE_CLEAR_LEFT_AND_RIGHT == aBreakType)) { + trapezoid->GetRect(tmp); + nscoord ym = tmp.YMost(); + if (ym > clearYMost) { + clearYMost = ym; + } + } + break; + } + } + } + else { + trapezoid->frame->GetStyleData(eStyleStruct_Display, + (nsStyleStruct*&)display); switch (display->mFloats) { case NS_STYLE_FLOAT_LEFT: if ((NS_STYLE_CLEAR_LEFT == aBreakType) || @@ -597,43 +625,22 @@ nsBlockFrame::ClearFloaters(nsBlockReflowState& aState, PRUint8 aBreakType) } } } - else { - trapezoid->frame->GetStyleData(eStyleStruct_Display, - (nsStyleStruct*&)display); - switch (display->mFloats) { - case NS_STYLE_FLOAT_LEFT: - if ((NS_STYLE_CLEAR_LEFT == aBreakType) || - (NS_STYLE_CLEAR_LEFT_AND_RIGHT == aBreakType)) { - trapezoid->GetRect(tmp); - nscoord ym = tmp.YMost(); - if (ym > clearYMost) { - clearYMost = ym; - } - } - break; - case NS_STYLE_FLOAT_RIGHT: - if ((NS_STYLE_CLEAR_RIGHT == aBreakType) || - (NS_STYLE_CLEAR_LEFT_AND_RIGHT == aBreakType)) { - trapezoid->GetRect(tmp); - nscoord ym = tmp.YMost(); - if (ym > clearYMost) { - clearYMost = ym; - } - } - break; - } - } } + + if (clearYMost == aState.mY) { + // Nothing to clear + break; + } + + NS_FRAME_LOG(NS_FRAME_TRACE_CHILD_REFLOW, + ("nsBlockFrame::ClearFloaters: mY=%d clearYMost=%d\n", + aState.mY, clearYMost)); + + aState.mY = clearYMost + 1; + + // Get a new band + GetAvailableSpace(aState, aState.mY); } - - NS_FRAME_LOG(NS_FRAME_TRACE_CHILD_REFLOW, - ("nsBlockFrame::ClearFloaters: mY=%d clearYMost=%d\n", - aState.mY, clearYMost)); - - aState.mY = clearYMost; - - // Get a new band - GetAvailableSpace(aState, aState.mY); } nsresult diff --git a/layout/html/base/src/nsBlockReflowState.h b/layout/html/base/src/nsBlockReflowState.h index 9429c9a24e6b..54d58d36a52d 100644 --- a/layout/html/base/src/nsBlockReflowState.h +++ b/layout/html/base/src/nsBlockReflowState.h @@ -553,26 +553,54 @@ nsBlockFrame::DrainOverflowList() void nsBlockFrame::ClearFloaters(nsBlockReflowState& aState, PRUint8 aBreakType) { - if (aState.mCurrentBand.count <= 1) { - // No floaters in this band therefore nothing to clear - return; - } + for (;;) { + if (aState.mCurrentBand.count <= 1) { + // No floaters in this band therefore nothing to clear + break; + } - // Find the Y coordinate to clear to - nscoord clearYMost = aState.mY; - nsRect tmp; - PRInt32 i; - for (i = 0; i < aState.mCurrentBand.count; i++) { - nsStyleDisplay* display; - nsBandTrapezoid* trapezoid = &aState.mCurrentBand.data[i]; - if (trapezoid->state != nsBandTrapezoid::Available) { - if (nsBandTrapezoid::OccupiedMultiple == trapezoid->state) { - PRInt32 fn, numFrames = trapezoid->frames->Count(); - NS_ASSERTION(numFrames > 0, "bad trapezoid frame list"); - for (fn = 0; fn < numFrames; fn++) { - nsIFrame* f = (nsIFrame*) trapezoid->frames->ElementAt(fn); - f->GetStyleData(eStyleStruct_Display, (nsStyleStruct*&)display); + // Find the Y coordinate to clear to + nscoord clearYMost = aState.mY; + nsRect tmp; + PRInt32 i; + for (i = 0; i < aState.mCurrentBand.count; i++) { + nsStyleDisplay* display; + nsBandTrapezoid* trapezoid = &aState.mCurrentBand.data[i]; + if (trapezoid->state != nsBandTrapezoid::Available) { + if (nsBandTrapezoid::OccupiedMultiple == trapezoid->state) { + PRInt32 fn, numFrames = trapezoid->frames->Count(); + NS_ASSERTION(numFrames > 0, "bad trapezoid frame list"); + for (fn = 0; fn < numFrames; fn++) { + nsIFrame* f = (nsIFrame*) trapezoid->frames->ElementAt(fn); + f->GetStyleData(eStyleStruct_Display, (nsStyleStruct*&)display); + switch (display->mFloats) { + case NS_STYLE_FLOAT_LEFT: + if ((NS_STYLE_CLEAR_LEFT == aBreakType) || + (NS_STYLE_CLEAR_LEFT_AND_RIGHT == aBreakType)) { + trapezoid->GetRect(tmp); + nscoord ym = tmp.YMost(); + if (ym > clearYMost) { + clearYMost = ym; + } + } + break; + case NS_STYLE_FLOAT_RIGHT: + if ((NS_STYLE_CLEAR_RIGHT == aBreakType) || + (NS_STYLE_CLEAR_LEFT_AND_RIGHT == aBreakType)) { + trapezoid->GetRect(tmp); + nscoord ym = tmp.YMost(); + if (ym > clearYMost) { + clearYMost = ym; + } + } + break; + } + } + } + else { + trapezoid->frame->GetStyleData(eStyleStruct_Display, + (nsStyleStruct*&)display); switch (display->mFloats) { case NS_STYLE_FLOAT_LEFT: if ((NS_STYLE_CLEAR_LEFT == aBreakType) || @@ -597,43 +625,22 @@ nsBlockFrame::ClearFloaters(nsBlockReflowState& aState, PRUint8 aBreakType) } } } - else { - trapezoid->frame->GetStyleData(eStyleStruct_Display, - (nsStyleStruct*&)display); - switch (display->mFloats) { - case NS_STYLE_FLOAT_LEFT: - if ((NS_STYLE_CLEAR_LEFT == aBreakType) || - (NS_STYLE_CLEAR_LEFT_AND_RIGHT == aBreakType)) { - trapezoid->GetRect(tmp); - nscoord ym = tmp.YMost(); - if (ym > clearYMost) { - clearYMost = ym; - } - } - break; - case NS_STYLE_FLOAT_RIGHT: - if ((NS_STYLE_CLEAR_RIGHT == aBreakType) || - (NS_STYLE_CLEAR_LEFT_AND_RIGHT == aBreakType)) { - trapezoid->GetRect(tmp); - nscoord ym = tmp.YMost(); - if (ym > clearYMost) { - clearYMost = ym; - } - } - break; - } - } } + + if (clearYMost == aState.mY) { + // Nothing to clear + break; + } + + NS_FRAME_LOG(NS_FRAME_TRACE_CHILD_REFLOW, + ("nsBlockFrame::ClearFloaters: mY=%d clearYMost=%d\n", + aState.mY, clearYMost)); + + aState.mY = clearYMost + 1; + + // Get a new band + GetAvailableSpace(aState, aState.mY); } - - NS_FRAME_LOG(NS_FRAME_TRACE_CHILD_REFLOW, - ("nsBlockFrame::ClearFloaters: mY=%d clearYMost=%d\n", - aState.mY, clearYMost)); - - aState.mY = clearYMost; - - // Get a new band - GetAvailableSpace(aState, aState.mY); } nsresult