Bug 441259. Account for trimmable width when deciding whether we can place a float on the line. Also, only try to place a float at a point where we can have a line break. r+sr=dbaron

This commit is contained in:
Robert O'Callahan 2008-08-12 21:29:35 +12:00
Родитель 904317f506
Коммит 3b2619e8f6
6 изменённых файлов: 56 добавлений и 2 удалений

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

@ -341,7 +341,7 @@ nsLineLayout::UpdateBand(const nsRect& aNewAvailSpace,
for (PerSpanData* psd = mCurrentSpan; psd; psd = psd->mParent) {
psd->mRightEdge += deltaWidth;
psd->mContainsFloat = PR_TRUE;
NS_ASSERTION(psd->mX <= psd->mRightEdge,
NS_ASSERTION(psd->mX - mTrimmableWidth <= psd->mRightEdge,
"We placed a float where there was no room!");
#ifdef NOISY_REFLOW
printf(" span %p: oldRightEdge=%d newRightEdge=%d\n",
@ -873,7 +873,22 @@ nsLineLayout::ReflowFrame(nsIFrame* aFrame,
nsIFrame* outOfFlowFrame = nsLayoutUtils::GetFloatFromPlaceholder(aFrame);
if (outOfFlowFrame) {
nsPlaceholderFrame* placeholder = static_cast<nsPlaceholderFrame*>(aFrame);
nscoord availableWidth = psd->mRightEdge - psd->mX;
// Add mTrimmableWidth to the available width since if the line ends
// here, the width of the inline content will be reduced by
// mTrimmableWidth.
nscoord availableWidth = psd->mRightEdge - (psd->mX - mTrimmableWidth);
if (psd->mNoWrap) {
// If we place floats after inline content where there's
// no break opportunity, we don't know how much additional
// width is required for the non-breaking content after the float,
// so we can't know whether the float plus that content will fit
// on the line. So for now, don't place floats after inline
// content where there's no break opportunity. This is incorrect
// but hopefully rare. Fixing it will require significant
// restructuring of line layout.
// We might as well allow zero-width floats to be placed, though.
availableWidth = 0;
}
// XXXldb What is this test supposed to be?
if (!NS_SUBTREE_DIRTY(aFrame)) {
// incremental reflow of child

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

@ -0,0 +1,11 @@
<!DOCTYPE HTML>
<html>
<head>
<style>
span { display:inline-block; width:50px; height:10px; background:yellow; }
</style>
</head>
<body style="width:100px; border:1px solid black;">
<div style="float:left; width:50px; height:50px; background:green;"></div><span></span>
</body>
</html>

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

@ -0,0 +1,12 @@
<!DOCTYPE HTML>
<html>
<head>
<style>
span { display:inline-block; width:50px; height:10px; background:yellow; }
</style>
</head>
<body style="width:100px; border:1px solid black;">
<span></span>
<div style="float:left; width:50px; height:50px; background:green;"></div>
</body>
</html>

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

@ -0,0 +1,7 @@
<!DOCTYPE HTML>
<html>
<body>
<div style="float:left; width:50px; height:50px; background:green;"></div>
H
</body>
</html>

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

@ -0,0 +1,7 @@
<!DOCTYPE HTML>
<html>
<body style="white-space:nowrap">
H
<div style="float:left; width:50px; height:50px; background:green;"></div>
</body>
</html>

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

@ -873,4 +873,6 @@ random == 429849-1.html 429849-1-ref.html # bug 432288
!= about:blank 438987-2-ref.html # check that backgrounds work at all
== 439004-1.html 439004-1-ref.html
== 439910.html 439910-ref.html
== 441259-1.html 441259-1-ref.html
fails == 441259-2.html 441259-2-ref.html # bug 441400
# == 448987.html 448987-ref.html # Disabled for now - it needs privileges