Changeset 30530 in webkit


Ignore:
Timestamp:
Feb 23, 2008 8:00:21 PM (16 years ago)
Author:
mitz@apple.com
Message:

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.
Location:
trunk
Files:
5 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r30519 r30530  
     12008-02-23  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Dave Hyatt.
     4
     5        - test that non-autowrapping text clear floats
     6
     7        * fast/text/whitespace/nowrap-clear-float.html: Added.
     8        * platform/mac-leopard/fast/text/whitespace: Added.
     9        * platform/mac-leopard/fast/text/whitespace/nowrap-clear-float-expected.checksum: Added.
     10        * platform/mac-leopard/fast/text/whitespace/nowrap-clear-float-expected.png: Added.
     11        * platform/mac/fast/text/whitespace/nowrap-clear-float-expected.txt: Added.
     12
    1132008-02-23  Dan Bernstein  <mitz@apple.com>
    214
  • trunk/WebCore/ChangeLog

    r30529 r30530  
     12008-02-23  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Dave Hyatt.
     4
     5        - make non-autowrapping text clear floats
     6
     7        Test: fast/text/whitespace/nowrap-clear-float.html
     8
     9        * rendering/RenderBlock.cpp:
     10        (WebCore::RenderBlock::nextFloatBottomBelow): Renamed nearestFloat() to
     11        this and changed to avoid comparing bottom to 0 in each iteration.
     12        (WebCore::RenderBlock::getClearDelta): Updated comment for the rename.
     13        * rendering/RenderBlock.h:
     14        * rendering/bidi.cpp:
     15        (WebCore::RenderBlock::fitBelowFloats): Added. Factored out of
     16        findNextLineBreak() and simplified.
     17        (WebCore::RenderBlock::findNextLineBreak): Changed to call
     18        fitBelowFloats(). Fixed the bug by trying to fit below floats in the
     19        case of non-wrapping text. Removed some redundancy.
     20
    1212008-02-23  Sam Weinig  <sam@webkit.org>
    222
  • trunk/WebCore/rendering/RenderBlock.cpp

    r30415 r30530  
    23642364}
    23652365
    2366 int
    2367 RenderBlock::nearestFloatBottom(int height) const
    2368 {
    2369     if (!m_floatingObjects) return 0;
    2370     int bottom = 0;
     2366int RenderBlock::nextFloatBottomBelow(int height) const
     2367{
     2368    if (!m_floatingObjects)
     2369        return 0;
     2370
     2371    int bottom = INT_MAX;
    23712372    FloatingObject* r;
    23722373    DeprecatedPtrListIterator<FloatingObject> it(*m_floatingObjects);
    2373     for ( ; (r = it.current()); ++it )
    2374         if (r->endY>height && (r->endY<bottom || bottom==0))
    2375             bottom=r->endY;
    2376     return max(bottom, height);
     2374    for ( ; (r = it.current()); ++it) {
     2375        if (r->endY > height)
     2376            bottom = min(r->endY, bottom);
     2377    }
     2378
     2379    return bottom == INT_MAX ? 0 : bottom;
    23772380}
    23782381
     
    28172820    // 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).
    28182821    // FIXME: Note that the remaining space checks aren't quite accurate, since you should be able to clear only some floats (the minimum # needed
    2819     // to fit) and not all (we should be using nearestFloatBottom and looping).
     2822    // to fit) and not all (we should be using nextFloatBottomBelow and looping).
    28202823    // Do not allow tables to wrap in quirks or even in almost strict mode
    28212824    // (ebay on the PLT, finance.yahoo.com in the real world, versiontracker.com forces even almost strict mode not to work)
  • trunk/WebCore/rendering/RenderBlock.h

    r30415 r30530  
    137137    bool generatesLineBoxesForInlineChild(RenderObject*);
    138138    int skipWhitespace(BidiIterator&, BidiState&);
     139    void fitBelowFloats(int widthToFit, int& availableWidth);
    139140    BidiIterator findNextLineBreak(BidiIterator& start, BidiState& info);
    140141    RootInlineBox* constructLine(const BidiIterator& start, const BidiIterator& end);
     
    179180    int addOverhangingFloats(RenderBlock* child, int xoffset, int yoffset, bool makeChildPaintOtherFloats);
    180181
    181     int nearestFloatBottom(int height) const;
     182    int nextFloatBottomBelow(int) const;
    182183    int floatBottom() const;
    183184    inline int leftBottom();
  • trunk/WebCore/rendering/bidi.cpp

    r30460 r30530  
    13501350}
    13511351
     1352void RenderBlock::fitBelowFloats(int widthToFit, int& availableWidth)
     1353{
     1354    ASSERT(widthToFit > availableWidth);
     1355
     1356    int floatBottom;
     1357    int lastFloatBottom = m_height;
     1358    int newLineWidth = availableWidth;
     1359    while (true) {
     1360        floatBottom = nextFloatBottomBelow(lastFloatBottom);
     1361        if (!floatBottom)
     1362            break;
     1363
     1364        newLineWidth = lineWidth(floatBottom);
     1365        lastFloatBottom = floatBottom;
     1366        if (newLineWidth >= widthToFit)
     1367            break;
     1368    }
     1369
     1370    if (newLineWidth > availableWidth) {
     1371        m_height = lastFloatBottom;
     1372        availableWidth = newLineWidth;
     1373    }
     1374}
     1375
    13521376BidiIterator RenderBlock::findNextLineBreak(BidiIterator &start, BidiState &bidi)
    13531377{
     
    16531677                    applyWordSpacing =  wordSpacing && currentCharacterIsSpace && !previousCharacterIsSpace;
    16541678
    1655                     if (autoWrap && w + tmpW > width && !w) {
    1656                         int fb = nearestFloatBottom(m_height);
    1657                         int newLineWidth = lineWidth(fb);
    1658                         // See if |tmpW| will fit on the new line.  As long as it does not,
    1659                         // keep adjusting our float bottom until we find some room.
    1660                         int lastFloatBottom = m_height;
    1661                         while (lastFloatBottom < fb && tmpW > newLineWidth) {
    1662                             lastFloatBottom = fb;
    1663                             fb = nearestFloatBottom(fb);
    1664                             newLineWidth = lineWidth(fb);
    1665                         }
    1666                        
    1667                         if (!w && m_height < fb && width < newLineWidth) {
    1668                             m_height = fb;
    1669                             width = newLineWidth;
    1670                         }
    1671                     }
    1672        
     1679                    if (!w && autoWrap && tmpW > width)
     1680                        fitBelowFloats(tmpW, width);
     1681
    16731682                    if (autoWrap || breakWords) {
    16741683                        // If we break only after white-space, consider the current character
     
    18231832                    } else if (nextText->isWordBreak())
    18241833                        checkForBreak = true;
    1825                     bool willFitOnLine = (w + tmpW <= width);
     1834                    bool willFitOnLine = w + tmpW <= width;
     1835                    if (!willFitOnLine && !w) {
     1836                        fitBelowFloats(tmpW, width);
     1837                        willFitOnLine = tmpW <= width;
     1838                    }
    18261839                    bool canPlaceOnLine = willFitOnLine || !autoWrapWasEverTrueOnLine;
    18271840                    if (canPlaceOnLine && checkForBreak) {
     
    18391852            if (currentCharacterIsSpace && !ignoringSpaces && o->style()->collapseWhiteSpace())
    18401853                trailingSpaceObject = 0;
    1841            
    1842             int fb = nearestFloatBottom(m_height);
    1843             int newLineWidth = lineWidth(fb);
    1844             // See if |tmpW| will fit on the new line.  As long as it does not,
    1845             // keep adjusting our float bottom until we find some room.
    1846             int lastFloatBottom = m_height;
    1847             while (lastFloatBottom < fb && tmpW > newLineWidth) {
    1848                 lastFloatBottom = fb;
    1849                 fb = nearestFloatBottom(fb);
    1850                 newLineWidth = lineWidth(fb);
    1851             }           
    1852             if (!w && m_height < fb && width < newLineWidth) {
    1853                 m_height = fb;
    1854                 width = newLineWidth;
    1855             }
     1854
     1855            if (w)
     1856                goto end;
     1857
     1858            fitBelowFloats(tmpW, width);
    18561859
    18571860            // |width| may have been adjusted because we got shoved down past a float (thus
Note: See TracChangeset for help on using the changeset viewer.