--- trunk/KDE/kdelibs/khtml/rendering/render_block.cpp 2010/01/28 10:28:10 1081434
+++ trunk/KDE/kdelibs/khtml/rendering/render_block.cpp 2010/01/28 10:28:19 1081435
@@ -2697,17 +2697,33 @@
break;
}
- // We also clear floats if we are too big to sit on the same line as a float, and happen to flow around floats.
- // FIXME: Note that the remaining space checks aren't quite accurate, since you should be able to clear only some floats (the minimum # needed
- // to fit) and not all (we should be using nearestFloatBottom and looping).
+ // We also clear floats if we are too big to sit on the same line as
+ // a float, and happen to flow around floats.
int result = clearSet ? qMax(0, bottom - yPos) : 0;
- if (!result && child->flowAroundFloats() && !style()->width().isAuto()) {
- bool canClearLine;
- int lw = lineWidth(yPos, &canClearLine);
- if (((child->style()->width().isPercent() && child->width() > lw) ||
- (child->style()->width().isFixed() && child->minWidth() > lw)) &&
- child->minWidth() <= availableWidth() && canClearLine)
- result = qMax(0, floatBottom() - yPos);
+ if (!result && child->flowAroundFloats()) {
+ bool canClear = true;
+ bool needsRecalc = child->usesLineWidth();
+ int cury = yPos;
+ int childw = 0;
+ int aw = availableWidth();
+ while (true) {
+ int curw = lineWidth(cury, &canClear);
+ if (!canClear || curw == aw)
+ return cury-yPos;
+ if (!childw || needsRecalc) {
+ int oy = child->yPos();
+ int ow = child->width();
+ child->setPos(child->xPos(), cury);
+ child->calcWidth();
+ childw = child->width();
+ child->setPos(child->xPos(), oy);
+ child->setWidth(ow);
+ }
+ if (childw <= curw)
+ return cury-yPos;
+ if (!(cury = nearestFloatBottom(cury)))
+ return 0;
+ }
}
return result;
}