WebCore:
Reviewed by Dave Hyatt.
- make non-autowrapping text clear floats
Test: fast/text/whitespace/nowrap-clear-float.html
* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::nextFloatBottomBelow): Renamed nearestFloat() to
this and changed to avoid comparing bottom to 0 in each iteration.
(WebCore::RenderBlock::getClearDelta): Updated comment for the rename.
* rendering/RenderBlock.h:
* rendering/bidi.cpp:
(WebCore::RenderBlock::fitBelowFloats): Added. Factored out of
findNextLineBreak() and simplified.
(WebCore::RenderBlock::findNextLineBreak): Changed to call
fitBelowFloats(). Fixed the bug by trying to fit below floats in the
case of non-wrapping text. Removed some redundancy.
LayoutTests:
Reviewed by Dave Hyatt.
- test that non-autowrapping text clear floats
* fast/text/whitespace/nowrap-clear-float.html: Added.
* platform/mac-leopard/fast/text/whitespace: Added.
* platform/mac-leopard/fast/text/whitespace/nowrap-clear-float-expected.checksum: Added.
* platform/mac-leopard/fast/text/whitespace/nowrap-clear-float-expected.png: Added.
* platform/mac/fast/text/whitespace/nowrap-clear-float-expected.txt: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@30530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/rendering/bidi.cpp b/WebCore/rendering/bidi.cpp
index 9acf79d..c9edd5f 100644
--- a/WebCore/rendering/bidi.cpp
+++ b/WebCore/rendering/bidi.cpp
@@ -1349,6 +1349,30 @@
return false;
}
+void RenderBlock::fitBelowFloats(int widthToFit, int& availableWidth)
+{
+ ASSERT(widthToFit > availableWidth);
+
+ int floatBottom;
+ int lastFloatBottom = m_height;
+ int newLineWidth = availableWidth;
+ while (true) {
+ floatBottom = nextFloatBottomBelow(lastFloatBottom);
+ if (!floatBottom)
+ break;
+
+ newLineWidth = lineWidth(floatBottom);
+ lastFloatBottom = floatBottom;
+ if (newLineWidth >= widthToFit)
+ break;
+ }
+
+ if (newLineWidth > availableWidth) {
+ m_height = lastFloatBottom;
+ availableWidth = newLineWidth;
+ }
+}
+
BidiIterator RenderBlock::findNextLineBreak(BidiIterator &start, BidiState &bidi)
{
// eliminate spaces at beginning of line
@@ -1652,24 +1676,9 @@
applyWordSpacing = wordSpacing && currentCharacterIsSpace && !previousCharacterIsSpace;
- if (autoWrap && w + tmpW > width && !w) {
- int fb = nearestFloatBottom(m_height);
- int newLineWidth = lineWidth(fb);
- // See if |tmpW| will fit on the new line. As long as it does not,
- // keep adjusting our float bottom until we find some room.
- int lastFloatBottom = m_height;
- while (lastFloatBottom < fb && tmpW > newLineWidth) {
- lastFloatBottom = fb;
- fb = nearestFloatBottom(fb);
- newLineWidth = lineWidth(fb);
- }
-
- if (!w && m_height < fb && width < newLineWidth) {
- m_height = fb;
- width = newLineWidth;
- }
- }
-
+ if (!w && autoWrap && tmpW > width)
+ fitBelowFloats(tmpW, width);
+
if (autoWrap || breakWords) {
// If we break only after white-space, consider the current character
// as candidate width for this line.
@@ -1822,7 +1831,11 @@
checkForBreak = true;
} else if (nextText->isWordBreak())
checkForBreak = true;
- bool willFitOnLine = (w + tmpW <= width);
+ bool willFitOnLine = w + tmpW <= width;
+ if (!willFitOnLine && !w) {
+ fitBelowFloats(tmpW, width);
+ willFitOnLine = tmpW <= width;
+ }
bool canPlaceOnLine = willFitOnLine || !autoWrapWasEverTrueOnLine;
if (canPlaceOnLine && checkForBreak) {
w += tmpW;
@@ -1838,21 +1851,11 @@
// if we have floats, try to get below them.
if (currentCharacterIsSpace && !ignoringSpaces && o->style()->collapseWhiteSpace())
trailingSpaceObject = 0;
-
- int fb = nearestFloatBottom(m_height);
- int newLineWidth = lineWidth(fb);
- // See if |tmpW| will fit on the new line. As long as it does not,
- // keep adjusting our float bottom until we find some room.
- int lastFloatBottom = m_height;
- while (lastFloatBottom < fb && tmpW > newLineWidth) {
- lastFloatBottom = fb;
- fb = nearestFloatBottom(fb);
- newLineWidth = lineWidth(fb);
- }
- if (!w && m_height < fb && width < newLineWidth) {
- m_height = fb;
- width = newLineWidth;
- }
+
+ if (w)
+ goto end;
+
+ fitBelowFloats(tmpW, width);
// |width| may have been adjusted because we got shoved down past a float (thus
// giving us more room), so we need to retest, and only jump to