зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1291110 Part 4 - Use line BSize to query available space when updating nsLineLayout. r=dbaron
In nsBlockFrame::PlaceLine(), we query the float available space by using the line's BSize(), which may cause the line to reflow again due to available space shrunk. The first issue lies in the second reflow. That is, we do not leverage the line's BSize() computed in the first reflow to query the float available space when updating the inline reflow engine in BlockReflowInput::AddFloat(). So some tall inline elements could still overlap the floats as in the first reflow. To solve this, we cache current line's BSize so that it could be used to update the inline reflow engine when redo the line. Another issue is in nsBlockFrame::PlaceLine(). When determined whether the available space is shrunk, we use the float manager's state *before* placing the line. So if current line has floats, they're not considered. To solve this, we use the current set of floats to get the float available space for comparison, and leave the original aFloatAvailableSpace to provide the information when redoing the line. MozReview-Commit-ID: GqqNlphgxYS --HG-- extra : rebase_source : e2c64ab1ac363c7a08e532dc043bee69d6455049
This commit is contained in:
Родитель
8fa65e4f5d
Коммит
384e9e119b
|
@ -628,7 +628,13 @@ BlockReflowInput::AddFloat(nsLineLayout* aLineLayout,
|
|||
if (placed) {
|
||||
// Pass on updated available space to the current inline reflow engine
|
||||
WritingMode wm = mReflowInput.GetWritingMode();
|
||||
nsFlowAreaRect floatAvailSpace = GetFloatAvailableSpace(mBCoord);
|
||||
// If we have mLineBSize, we are reflowing the line again due to
|
||||
// LineReflowStatus::RedoMoreFloats. We should use mLineBSize to query the
|
||||
// correct available space.
|
||||
nsFlowAreaRect floatAvailSpace =
|
||||
mLineBSize.isNothing()
|
||||
? GetFloatAvailableSpace(mBCoord)
|
||||
: GetFloatAvailableSpaceForBSize(mBCoord, mLineBSize.value(), nullptr);
|
||||
LogicalRect availSpace(wm, floatAvailSpace.mRect.IStart(wm), mBCoord,
|
||||
floatAvailSpace.mRect.ISize(wm),
|
||||
floatAvailSpace.mRect.BSize(wm));
|
||||
|
|
|
@ -376,6 +376,12 @@ public:
|
|||
// The amount of computed block-direction size "consumed" by previous-in-flows.
|
||||
nscoord mConsumedBSize;
|
||||
|
||||
// Cache the current line's BSize if nsBlockFrame::PlaceLine() fails to
|
||||
// place the line. When redoing the line, it will be used to query the
|
||||
// accurate float available space in AddFloat() and
|
||||
// nsBlockFrame::PlaceLine().
|
||||
mozilla::Maybe<nscoord> mLineBSize;
|
||||
|
||||
private:
|
||||
bool CanPlaceFloat(nscoord aFloatISize,
|
||||
const nsFlowAreaRect& aFloatAvailableSpace);
|
||||
|
|
|
@ -3766,6 +3766,7 @@ nsBlockFrame::ReflowInlineFrames(BlockReflowInput& aState,
|
|||
LineReflowStatus lineReflowStatus;
|
||||
do {
|
||||
nscoord availableSpaceBSize = 0;
|
||||
aState.mLineBSize.reset();
|
||||
do {
|
||||
bool allowPullUp = true;
|
||||
nsIFrame* forceBreakInFrame = nullptr;
|
||||
|
@ -4469,45 +4470,66 @@ nsBlockFrame::PlaceLine(BlockReflowInput& aState,
|
|||
}
|
||||
aLineLayout.VerticalAlignLine();
|
||||
|
||||
// We want to compare to the available space that we would have had in
|
||||
// the line's BSize *before* we placed any floats in the line itself.
|
||||
// Floats that are in the line are handled during line reflow (and may
|
||||
// result in floats being pushed to below the line or (I HOPE???) in a
|
||||
// reflow with a forced break position).
|
||||
LogicalRect oldFloatAvailableSpace(aFloatAvailableSpace);
|
||||
// We want to consider the floats in the current line when determining
|
||||
// whether the float available space is shrunk. If mLineBSize doesn't
|
||||
// exist, we are in the first pass trying to place the line. Calling
|
||||
// GetFloatAvailableSpace() like we did in BlockReflowInput::AddFloat()
|
||||
// for UpdateBand().
|
||||
|
||||
// floatAvailableSpaceWithOldLineBSize is the float available space with
|
||||
// the old BSize, but including the floats that were added in this line.
|
||||
LogicalRect floatAvailableSpaceWithOldLineBSize =
|
||||
aState.mLineBSize.isNothing()
|
||||
? aState.GetFloatAvailableSpace(aLine->BStart()).mRect
|
||||
: aState.GetFloatAvailableSpaceForBSize(aLine->BStart(),
|
||||
aState.mLineBSize.value(),
|
||||
nullptr).mRect;
|
||||
|
||||
// As we redo for floats, we can't reduce the amount of BSize we're
|
||||
// checking.
|
||||
aAvailableSpaceBSize = std::max(aAvailableSpaceBSize, aLine->BSize());
|
||||
aFloatAvailableSpace =
|
||||
LogicalRect floatAvailableSpaceWithLineBSize =
|
||||
aState.GetFloatAvailableSpaceForBSize(aLine->BStart(),
|
||||
aAvailableSpaceBSize,
|
||||
aFloatStateBeforeLine).mRect;
|
||||
NS_ASSERTION(aFloatAvailableSpace.BStart(wm) ==
|
||||
oldFloatAvailableSpace.BStart(wm), "yikes");
|
||||
// Restore the BSize to the position of the next band.
|
||||
aFloatAvailableSpace.BSize(wm) = oldFloatAvailableSpace.BSize(wm);
|
||||
|
||||
// Enforce both IStart() and IEnd() never move outwards to prevent
|
||||
// infinite grow-shrink loops.
|
||||
const nscoord iStartDiff =
|
||||
aFloatAvailableSpace.IStart(wm) - oldFloatAvailableSpace.IStart(wm);
|
||||
const nscoord iEndDiff =
|
||||
aFloatAvailableSpace.IEnd(wm) - oldFloatAvailableSpace.IEnd(wm);
|
||||
if (iStartDiff < 0) {
|
||||
aFloatAvailableSpace.IStart(wm) -= iStartDiff;
|
||||
aFloatAvailableSpace.ISize(wm) += iStartDiff;
|
||||
}
|
||||
if (iEndDiff > 0) {
|
||||
aFloatAvailableSpace.ISize(wm) -= iEndDiff;
|
||||
}
|
||||
nullptr).mRect;
|
||||
|
||||
// If the available space between the floats is smaller now that we
|
||||
// know the BSize, return false (and cause another pass with
|
||||
// LineReflowStatus::RedoMoreFloats). We ensure aAvailableSpaceBSize
|
||||
// never decreases, which means that we can't reduce the set of floats
|
||||
// we intersect, which means that the available space cannot grow.
|
||||
if (AvailableSpaceShrunk(wm, oldFloatAvailableSpace, aFloatAvailableSpace,
|
||||
false)) {
|
||||
if (AvailableSpaceShrunk(wm, floatAvailableSpaceWithOldLineBSize,
|
||||
floatAvailableSpaceWithLineBSize, false)) {
|
||||
// Prepare data for redoing the line.
|
||||
aState.mLineBSize = Some(aLine->BSize());
|
||||
|
||||
// Since we want to redo the line, we update aFloatAvailableSpace by
|
||||
// using the aFloatStateBeforeLine, which is the float manager's state
|
||||
// before the line is placed.
|
||||
LogicalRect oldFloatAvailableSpace(aFloatAvailableSpace);
|
||||
aFloatAvailableSpace =
|
||||
aState.GetFloatAvailableSpaceForBSize(aLine->BStart(),
|
||||
aAvailableSpaceBSize,
|
||||
aFloatStateBeforeLine).mRect;
|
||||
NS_ASSERTION(aFloatAvailableSpace.BStart(wm) ==
|
||||
oldFloatAvailableSpace.BStart(wm), "yikes");
|
||||
// Restore the BSize to the position of the next band.
|
||||
aFloatAvailableSpace.BSize(wm) = oldFloatAvailableSpace.BSize(wm);
|
||||
|
||||
// Enforce both IStart() and IEnd() never move outwards to prevent
|
||||
// infinite grow-shrink loops.
|
||||
const nscoord iStartDiff =
|
||||
aFloatAvailableSpace.IStart(wm) - oldFloatAvailableSpace.IStart(wm);
|
||||
const nscoord iEndDiff =
|
||||
aFloatAvailableSpace.IEnd(wm) - oldFloatAvailableSpace.IEnd(wm);
|
||||
if (iStartDiff < 0) {
|
||||
aFloatAvailableSpace.IStart(wm) -= iStartDiff;
|
||||
aFloatAvailableSpace.ISize(wm) += iStartDiff;
|
||||
}
|
||||
if (iEndDiff > 0) {
|
||||
aFloatAvailableSpace.ISize(wm) -= iEndDiff;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
<!DOCTYPE html>
|
||||
<style>
|
||||
.container {
|
||||
position: relative;
|
||||
width: 250px;
|
||||
height: 300px;
|
||||
border: 1px solid blue;
|
||||
}
|
||||
|
||||
.float1 {
|
||||
position: absolute;
|
||||
width: 100px;
|
||||
height: 50px;
|
||||
background-color: green;
|
||||
}
|
||||
|
||||
.float2 {
|
||||
position: absolute;
|
||||
top: 50px;
|
||||
width: 180px;
|
||||
height: 50px;
|
||||
background-color: lightgreen;
|
||||
}
|
||||
|
||||
.box {
|
||||
position: absolute;
|
||||
left: 180px;
|
||||
width: 30px;
|
||||
height: 80px;
|
||||
background-color: blue;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="container">
|
||||
<div class="float1"></div>
|
||||
<div class="float2"></div>
|
||||
<div class="box"></div>
|
||||
</div>
|
||||
<p>The test pass if the inline blue box does not overlap any of the green float boxes.</p>
|
|
@ -0,0 +1,37 @@
|
|||
<!DOCTYPE html>
|
||||
<style>
|
||||
.container {
|
||||
width: 250px;
|
||||
height: 300px;
|
||||
border: 1px solid blue;
|
||||
}
|
||||
|
||||
.float1 {
|
||||
float: left;
|
||||
width: 100px;
|
||||
height: 50px;
|
||||
background-color: green;
|
||||
}
|
||||
|
||||
.float2 {
|
||||
float: left;
|
||||
width: 180px;
|
||||
height: 50px;
|
||||
background-color: lightgreen;
|
||||
}
|
||||
|
||||
.box {
|
||||
display: inline-block;
|
||||
width: 30px;
|
||||
height: 80px;
|
||||
background-color: blue;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="container">
|
||||
<div class="float1"></div>
|
||||
<div class="float2"></div>
|
||||
<div class="box"></div>
|
||||
</div>
|
||||
<p>The test pass if the inline blue box does not overlap any of the green float boxes.</p>
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
<!DOCTYPE html>
|
||||
<style>
|
||||
.container {
|
||||
position: relative;
|
||||
width: 250px;
|
||||
height: 300px;
|
||||
border: 1px solid blue;
|
||||
}
|
||||
|
||||
.float1 {
|
||||
position: absolute;
|
||||
width: 100px;
|
||||
height: 50px;
|
||||
background-color: green;
|
||||
}
|
||||
|
||||
.float2 {
|
||||
position: absolute;
|
||||
top: 50px;
|
||||
left: 70px;
|
||||
width: 180px;
|
||||
height: 50px;
|
||||
background-color: lightgreen;
|
||||
}
|
||||
|
||||
.box {
|
||||
position: absolute;
|
||||
top: 50px;
|
||||
width: 30px;
|
||||
height: 80px;
|
||||
background-color: blue;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="container">
|
||||
<div class="float1"></div>
|
||||
<div class="float2"></div>
|
||||
<div class="box"></div>
|
||||
</div>
|
||||
<p>The test pass if the inline blue box does not overlap any of the green float boxes.</p>
|
|
@ -0,0 +1,36 @@
|
|||
<!DOCTYPE html>
|
||||
<style>
|
||||
.container {
|
||||
width: 250px;
|
||||
height: 300px;
|
||||
border: 1px solid blue;
|
||||
}
|
||||
|
||||
.float1 {
|
||||
float: left;
|
||||
width: 100px;
|
||||
height: 50px;
|
||||
background-color: green;
|
||||
}
|
||||
|
||||
.float2 {
|
||||
float: right;
|
||||
width: 180px;
|
||||
height: 50px;
|
||||
background-color: lightgreen;
|
||||
}
|
||||
|
||||
.box {
|
||||
display: inline-block;
|
||||
width: 30px;
|
||||
height: 80px;
|
||||
background-color: blue;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="container">
|
||||
<div class="float1"></div>
|
||||
<div class="float2"></div>
|
||||
<div class="box"></div>
|
||||
</div>
|
||||
<p>The test pass if the inline blue box does not overlap any of the green float boxes.</p>
|
|
@ -10,7 +10,7 @@ fuzzy-if(gtkWidget,1,10) == float-outside-block-push.html float-outside-block-pu
|
|||
== relative-float-2.html relative-float-2-ref.html
|
||||
== zero-height-float-base.html zero-height-float-ref.html
|
||||
fails == zero-height-float.html zero-height-float-ref.html # bug 81710
|
||||
fails == 345369-1.html 345369-1-ref.html
|
||||
== 345369-1.html 345369-1-ref.html
|
||||
fails == 345369-2.html 345369-2-ref.html
|
||||
== 345369-3.html 345369-3-ref.html
|
||||
== 345369-4.html 345369-4-ref.html
|
||||
|
@ -24,6 +24,8 @@ fails == 345369-2.html 345369-2-ref.html
|
|||
== 1260031-1.html?display:table 1260031-1-ref.html
|
||||
== 1260031-1.html?display:table-cell 1260031-1-ref.html
|
||||
== 1260031-1.html?overflow:hidden 1260031-1-ref.html
|
||||
== 1291110-1.html 1291110-1-ref.html
|
||||
== 1291110-2.html 1291110-2-ref.html
|
||||
== float-in-rtl-1a.html float-in-rtl-1-ref.html
|
||||
fuzzy-if(skiaContent,1,27000) == float-in-rtl-1b.html float-in-rtl-1-ref.html
|
||||
fuzzy-if(skiaContent,1,27000) == float-in-rtl-1c.html float-in-rtl-1-ref.html
|
||||
|
|
Загрузка…
Ссылка в новой задаче