Commit cfd9b7b0 authored by mitz@apple.com's avatar mitz@apple.com

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
parent 10268d17
2008-02-23 Dan Bernstein <mitz@apple.com>
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.
2008-02-23 Dan Bernstein <mitz@apple.com>
- undo an accidental change to a test's expected results from r30431.
<div style="width: 200px;">
<div style="float: left; width: 100px; height: 100px; background-color: lightblue;"></div>
<span style="white-space: nowrap">This text should be below the blue square.</span>
</div>
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x584
RenderBlock {DIV} at (0,0) size 200x118
RenderBlock (floating) {DIV} at (0,0) size 100x100 [bgcolor=#ADD8E6]
RenderInline {SPAN} at (0,0) size 266x18
RenderText {#text} at (0,100) size 266x18
text run at (0,100) width 266: "This text should be below the blue square."
RenderText {#text} at (0,0) size 0x0
2008-02-23 Dan Bernstein <mitz@apple.com>
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.
2008-02-23 Sam Weinig <sam@webkit.org>
Reviewed by Oliver Hunt.
......@@ -2363,17 +2363,20 @@ RenderBlock::lineWidth(int y) const
return (result < 0) ? 0 : result;
}
int
RenderBlock::nearestFloatBottom(int height) const
int RenderBlock::nextFloatBottomBelow(int height) const
{
if (!m_floatingObjects) return 0;
int bottom = 0;
if (!m_floatingObjects)
return 0;
int bottom = INT_MAX;
FloatingObject* r;
DeprecatedPtrListIterator<FloatingObject> it(*m_floatingObjects);
for ( ; (r = it.current()); ++it )
if (r->endY>height && (r->endY<bottom || bottom==0))
bottom=r->endY;
return max(bottom, height);
for ( ; (r = it.current()); ++it) {
if (r->endY > height)
bottom = min(r->endY, bottom);
}
return bottom == INT_MAX ? 0 : bottom;
}
int
......@@ -2816,7 +2819,7 @@ int RenderBlock::getClearDelta(RenderObject *child)
// We also clear floats if we are too big to sit on the same line as a float (and wish to avoid floats by default).
// 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).
// to fit) and not all (we should be using nextFloatBottomBelow and looping).
// Do not allow tables to wrap in quirks or even in almost strict mode
// (ebay on the PLT, finance.yahoo.com in the real world, versiontracker.com forces even almost strict mode not to work)
int result = clearSet ? max(0, bottom - child->yPos()) : 0;
......
......@@ -136,6 +136,7 @@ public:
RootInlineBox*& endLine, int& endYPos, int& repaintBottom, int& repaintTop);
bool generatesLineBoxesForInlineChild(RenderObject*);
int skipWhitespace(BidiIterator&, BidiState&);
void fitBelowFloats(int widthToFit, int& availableWidth);
BidiIterator findNextLineBreak(BidiIterator& start, BidiState& info);
RootInlineBox* constructLine(const BidiIterator& start, const BidiIterator& end);
InlineFlowBox* createLineBoxes(RenderObject*);
......@@ -178,7 +179,7 @@ public:
void addIntrudingFloats(RenderBlock* prev, int xoffset, int yoffset);
int addOverhangingFloats(RenderBlock* child, int xoffset, int yoffset, bool makeChildPaintOtherFloats);
int nearestFloatBottom(int height) const;
int nextFloatBottomBelow(int) const;
int floatBottom() const;
inline int leftBottom();
inline int rightBottom();
......
......@@ -1349,6 +1349,30 @@ static bool shouldSkipWhitespaceAfterStartObject(RenderBlock* block, RenderObjec
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 @@ BidiIterator RenderBlock::findNextLineBreak(BidiIterator &start, BidiState &bidi
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 @@ BidiIterator RenderBlock::findNextLineBreak(BidiIterator &start, BidiState &bidi
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 @@ BidiIterator RenderBlock::findNextLineBreak(BidiIterator &start, BidiState &bidi
// 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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment