Changeset 68957 in webkit


Ignore:
Timestamp:
Oct 1, 2010 5:13:00 PM (14 years ago)
Author:
hyatt@apple.com
Message:

https://bugs.webkit.org/show_bug.cgi?id=47021

Reviewed by Dan Bernstein.

Patch the floatBottom function and its friends. Rename them and consolidate them to be block-flow-aware.

Nothing testable yet, since most of the float code is still unpatched.

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::layoutBlock):
(WebCore::RenderBlock::layoutBlockChildren):
(WebCore::RenderBlock::layoutBlockChild):
(WebCore::RenderBlock::positionNewFloats):
(WebCore::RenderBlock::newLine):
(WebCore::RenderBlock::nextFloatLogicalBottomBelow):
(WebCore::RenderBlock::lowestFloatLogicalBottom):
(WebCore::RenderBlock::clearFloats):
(WebCore::RenderBlock::addOverhangingFloats):
(WebCore::RenderBlock::getClearDelta):

  • rendering/RenderBlock.h:

(WebCore::RenderBlock::logicalBottomForFloat):
(WebCore::RenderBlock::hasOverhangingFloats):

  • rendering/RenderBlockLineLayout.cpp:

(WebCore::RenderBlock::fitBelowFloats):

Location:
trunk/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r68954 r68957  
     12010-10-01  David Hyatt  <hyatt@apple.com>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=47021
     6       
     7        Patch the floatBottom function and its friends.  Rename them and consolidate them to be block-flow-aware.
     8
     9        Nothing testable yet, since most of the float code is still unpatched.
     10
     11        * rendering/RenderBlock.cpp:
     12        (WebCore::RenderBlock::layoutBlock):
     13        (WebCore::RenderBlock::layoutBlockChildren):
     14        (WebCore::RenderBlock::layoutBlockChild):
     15        (WebCore::RenderBlock::positionNewFloats):
     16        (WebCore::RenderBlock::newLine):
     17        (WebCore::RenderBlock::nextFloatLogicalBottomBelow):
     18        (WebCore::RenderBlock::lowestFloatLogicalBottom):
     19        (WebCore::RenderBlock::clearFloats):
     20        (WebCore::RenderBlock::addOverhangingFloats):
     21        (WebCore::RenderBlock::getClearDelta):
     22        * rendering/RenderBlock.h:
     23        (WebCore::RenderBlock::logicalBottomForFloat):
     24        (WebCore::RenderBlock::hasOverhangingFloats):
     25        * rendering/RenderBlockLineLayout.cpp:
     26        (WebCore::RenderBlock::fitBelowFloats):
     27
    1282010-10-01  Anders Carlsson  <andersca@apple.com>
    229
  • trunk/WebCore/rendering/RenderBlock.cpp

    r68926 r68957  
    11991199    int repaintTop = 0;
    12001200    int repaintBottom = 0;
    1201     int maxFloatBottom = 0;
     1201    int maxFloatLogicalBottom = 0;
    12021202    if (!firstChild() && !isAnonymousBlock())
    12031203        setChildrenInline(true);
     
    12051205        layoutInlineChildren(relayoutChildren, repaintTop, repaintBottom);
    12061206    else
    1207         layoutBlockChildren(relayoutChildren, maxFloatBottom);
     1207        layoutBlockChildren(relayoutChildren, maxFloatLogicalBottom);
    12081208
    12091209    // Expand our intrinsic height to encompass floats.
    12101210    int toAdd = borderAfter() + paddingAfter() + scrollbarLogicalHeight();
    1211     if (floatBottom() > (logicalHeight() - toAdd) && expandsToEncloseOverhangingFloats())
    1212         setLogicalHeight(floatBottom() + toAdd);
     1211    if (lowestFloatLogicalBottom() > (logicalHeight() - toAdd) && expandsToEncloseOverhangingFloats())
     1212        setLogicalHeight(lowestFloatLogicalBottom() + toAdd);
    12131213   
    12141214    if (layoutColumns(hasSpecifiedPageHeight, pageHeight, statePusher))
     
    12201220    int newHeight = logicalHeight();
    12211221    if (oldHeight != newHeight) {
    1222         if (oldHeight > newHeight && maxFloatBottom > newHeight && !childrenInline()) {
     1222        if (oldHeight > newHeight && maxFloatLogicalBottom > newHeight && !childrenInline()) {
    12231223            // One of our children's floats may have become an overhanging float for us. We need to look for it.
    12241224            for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
    12251225                if (child->isBlockFlow() && !child->isFloatingOrPositioned()) {
    12261226                    RenderBlock* block = toRenderBlock(child);
    1227                     if (block->floatBottom() + block->logicalTop() > newHeight)
     1227                    if (block->lowestFloatLogicalBottom() + block->logicalTop() > newHeight)
    12281228                        addOverhangingFloats(block, -block->x(), -block->y(), false);
    12291229                }
     
    17401740}
    17411741
    1742 void RenderBlock::layoutBlockChildren(bool relayoutChildren, int& maxFloatBottom)
     1742void RenderBlock::layoutBlockChildren(bool relayoutChildren, int& maxFloatLogicalBottom)
    17431743{
    17441744    if (gPercentHeightDescendantsMap) {
     
    17741774    RenderObject* legend = layoutLegend(relayoutChildren);
    17751775
    1776     int previousFloatBottom = 0;
    1777     maxFloatBottom = 0;
     1776    int previousFloatLogicalBottom = 0;
     1777    maxFloatLogicalBottom = 0;
    17781778
    17791779    RenderBox* next = firstChildBox();
     
    18021802
    18031803        // Lay out the child.
    1804         layoutBlockChild(child, marginInfo, previousFloatBottom, maxFloatBottom);
     1804        layoutBlockChild(child, marginInfo, previousFloatLogicalBottom, maxFloatLogicalBottom);
    18051805    }
    18061806   
     
    18101810}
    18111811
    1812 void RenderBlock::layoutBlockChild(RenderBox* child, MarginInfo& marginInfo, int& previousFloatBottom, int& maxFloatBottom)
     1812void RenderBlock::layoutBlockChild(RenderBox* child, MarginInfo& marginInfo, int& previousFloatLogicalBottom, int& maxFloatLogicalBottom)
    18131813{
    18141814    int oldPosMarginBefore = maxPositiveMarginBefore();
     
    18461846        // If an element might be affected by the presence of floats, then always mark it for
    18471847        // layout.
    1848         int fb = max(previousFloatBottom, floatBottom());
     1848        int fb = max(previousFloatLogicalBottom, lowestFloatLogicalBottom());
    18491849        if (fb > logicalTopEstimate)
    18501850            markDescendantsWithFloats = true;
     
    18551855            childRenderBlock->markAllDescendantsWithFloatsForLayout();
    18561856        if (!child->isBlockFlowRoot())
    1857             previousFloatBottom = max(previousFloatBottom, oldLogicalTop + childRenderBlock->floatBottom());
     1857            previousFloatLogicalBottom = max(previousFloatLogicalBottom, oldLogicalTop + childRenderBlock->lowestFloatLogicalBottom());
    18581858    }
    18591859
     
    19511951    // of this block), then the parent gets notified of the floats now.
    19521952    if (childRenderBlock && childRenderBlock->containsFloats())
    1953         maxFloatBottom = max(maxFloatBottom, addOverhangingFloats(toRenderBlock(child), -child->x(), -child->y(), !childNeededLayout));
     1953        maxFloatLogicalBottom = max(maxFloatLogicalBottom, addOverhangingFloats(toRenderBlock(child), -child->x(), -child->y(), !childNeededLayout));
    19541954
    19551955    IntSize childOffset(child->x() - oldRect.x(), child->y() - oldRect.y());
     
    30303030
    30313031        if (o->style()->clear() & CLEFT)
    3032             y = max(leftBottom(), y);
     3032            y = max(lowestFloatLogicalBottom(FloatingObject::FloatLeft), y);
    30333033        if (o->style()->clear() & CRIGHT)
    3034             y = max(rightBottom(), y);
     3034            y = max(lowestFloatLogicalBottom(FloatingObject::FloatRight), y);
    30353035
    30363036        if (o->style()->floating() == FLEFT) {
     
    31393139    {
    31403140        case CLEFT:
    3141             newY = leftBottom();
     3141            newY = lowestFloatLogicalBottom(FloatingObject::FloatLeft);
    31423142            break;
    31433143        case CRIGHT:
    3144             newY = rightBottom();
     3144            newY = lowestFloatLogicalBottom(FloatingObject::FloatRight);
    31453145            break;
    31463146        case CBOTH:
    3147             newY = floatBottom();
     3147            newY = lowestFloatLogicalBottom();
    31483148        default:
    31493149            break;
     
    32773277}
    32783278
    3279 int RenderBlock::nextFloatBottomBelow(int height) const
     3279int RenderBlock::nextFloatLogicalBottomBelow(int logicalHeight) const
    32803280{
    32813281    if (!m_floatingObjects)
     
    32863286    DeprecatedPtrListIterator<FloatingObject> it(*m_floatingObjects);
    32873287    for ( ; (r = it.current()); ++it) {
    3288         if (r->bottom() > height)
    3289             bottom = min(r->bottom(), bottom);
     3288        int floatBottom = logicalBottomForFloat(r);
     3289        if (floatBottom > logicalHeight)
     3290            bottom = min(floatBottom, bottom);
    32903291    }
    32913292
     
    32933294}
    32943295
    3295 int
    3296 RenderBlock::floatBottom() const
    3297 {
    3298     if (!m_floatingObjects) return 0;
    3299     int bottom = 0;
     3296int RenderBlock::lowestFloatLogicalBottom(FloatingObject::Type floatType) const
     3297{
     3298    if (!m_floatingObjects)
     3299        return 0;
     3300    int lowestFloatBottom = 0;
    33003301    FloatingObject* r;
    33013302    DeprecatedPtrListIterator<FloatingObject> it(*m_floatingObjects);
    3302     for ( ; (r = it.current()); ++it )
    3303         if (r->bottom() > bottom)
    3304             bottom = r->bottom();
    3305     return bottom;
     3303    for ( ; (r = it.current()); ++it) {
     3304        if (r->type() & floatType)
     3305            lowestFloatBottom = max(lowestFloatBottom, logicalBottomForFloat(r));
     3306    }
     3307    return lowestFloatBottom;
    33063308}
    33073309
     
    35843586}
    35853587
    3586 int RenderBlock::leftBottom()
    3587 {
    3588     if (!m_floatingObjects) return 0;
    3589     int bottom = 0;
    3590     FloatingObject* r;
    3591     DeprecatedPtrListIterator<FloatingObject> it(*m_floatingObjects);
    3592     for ( ; (r = it.current()); ++it)
    3593         if (r->bottom() > bottom && r->type() == FloatingObject::FloatLeft)
    3594             bottom = r->bottom();
    3595 
    3596     return bottom;
    3597 }
    3598 
    3599 int RenderBlock::rightBottom()
    3600 {
    3601     if (!m_floatingObjects) return 0;
    3602     int bottom = 0;
    3603     FloatingObject* r;
    3604     DeprecatedPtrListIterator<FloatingObject> it(*m_floatingObjects);
    3605     for ( ; (r = it.current()); ++it)
    3606         if (r->bottom() > bottom && r->type() == FloatingObject::FloatRight)
    3607             bottom = r->bottom();
    3608 
    3609     return bottom;
    3610 }
    3611 
    36123588void RenderBlock::markLinesDirtyInVerticalRange(int top, int bottom, RootInlineBox* highest)
    36133589{
     
    36863662   
    36873663    RenderBlock* block = toRenderBlock(prev);
    3688     if (block->m_floatingObjects && block->floatBottom() > offset)
     3664    if (block->m_floatingObjects && block->lowestFloatLogicalBottom() > offset)
    36893665        addIntrudingFloats(block, xoffset, offset);
    36903666
     
    37333709        return 0;
    37343710
    3735     int lowestFloatBottom = 0;
     3711    int lowestFloatLogicalBottom = 0;
    37363712
    37373713    // Floats that will remain the child's responsibility to paint should factor into its
     
    37403716    for (FloatingObject* r; (r = it.current()); ++it) {
    37413717        int bottom = child->y() + r->bottom();
    3742         lowestFloatBottom = max(lowestFloatBottom, bottom);
     3718        lowestFloatLogicalBottom = max(lowestFloatLogicalBottom, bottom);
    37433719
    37443720        if (bottom > height()) {
     
    37763752            child->addOverflowFromChild(r->m_renderer, IntSize(r->left() + r->m_renderer->marginLeft(), r->top() + r->m_renderer->marginTop()));
    37773753    }
    3778     return lowestFloatBottom;
     3754    return lowestFloatLogicalBottom;
    37793755}
    37803756
     
    39123888            break;
    39133889        case CLEFT:
    3914             bottom = leftBottom();
     3890            bottom = lowestFloatLogicalBottom(FloatingObject::FloatLeft);
    39153891            break;
    39163892        case CRIGHT:
    3917             bottom = rightBottom();
     3893            bottom = lowestFloatLogicalBottom(FloatingObject::FloatRight);
    39183894            break;
    39193895        case CBOTH:
    3920             bottom = floatBottom();
     3896            bottom = lowestFloatLogicalBottom();
    39213897            break;
    39223898    }
     
    39463922                return y - yPos;
    39473923
    3948             y = nextFloatBottomBelow(y);
     3924            y = nextFloatLogicalBottomBelow(y);
    39493925            ASSERT(y >= yPos);
    39503926            if (y < yPos)
  • trunk/WebCore/rendering/RenderBlock.h

    r68926 r68957  
    186186    int collapsedMarginBeforeForChild(RenderBox* child) const;
    187187    int collapsedMarginAfterForChild(RenderBox* child) const;
    188    
     188
    189189    class MarginValues {
    190190    public:
     
    332332    virtual void repaintOverhangingFloats(bool paintAllDescendants);
    333333
    334     void layoutBlockChildren(bool relayoutChildren, int& maxFloatBottom);
     334    void layoutBlockChildren(bool relayoutChildren, int& maxFloatLogicalBottom);
    335335    void layoutInlineChildren(bool relayoutChildren, int& repaintTop, int& repaintBottom);
    336336
     
    360360
    361361    struct FloatingObject : Noncopyable {
    362         enum Type {
    363             FloatLeft,
    364             FloatRight
    365         };
    366 
     362        // Note that Type uses bits so you can use FloatBoth as a mask to query for both left and right.
     363        enum Type { FloatLeft = 1, FloatRight = 2, FloatBoth = 3 };
     364   
    367365        FloatingObject(Type type, const IntRect& frameRect = IntRect())
    368366            : m_renderer(0)
     
    395393        IntRect m_frameRect;
    396394        int m_paginationStrut;
    397         unsigned m_type : 1; // Type (left or right aligned)
     395        unsigned m_type : 2; // Type (left or right aligned)
    398396        bool m_shouldPaint : 1;
    399397        bool m_isDescendant : 1;
    400398    };
    401399
     400    int logicalBottomForFloat(FloatingObject* child) const { return style()->isVerticalBlockFlow() ? child->bottom() : child->right(); }
     401   
    402402    // The following functions' implementations are in RenderBlockLineLayout.cpp.
    403403    RootInlineBox* determineStartPosition(bool& firstLine, bool& fullLayout, bool& previousLineBrokeCleanly,
     
    452452    virtual bool avoidsFloats() const;
    453453
    454     bool hasOverhangingFloats() { return parent() && !hasColumns() && floatBottom() > height(); }
     454    bool hasOverhangingFloats() { return parent() && !hasColumns() && lowestFloatLogicalBottom() > logicalHeight(); }
    455455    void addIntrudingFloats(RenderBlock* prev, int xoffset, int yoffset);
    456456    int addOverhangingFloats(RenderBlock* child, int xoffset, int yoffset, bool makeChildPaintOtherFloats);
    457457
    458     int nextFloatBottomBelow(int) const;
    459     int floatBottom() const;
    460     inline int leftBottom();
    461     inline int rightBottom();
    462 
     458    int lowestFloatLogicalBottom(FloatingObject::Type = FloatingObject::FloatBoth) const;
     459    int nextFloatLogicalBottomBelow(int) const;
     460   
    463461    virtual bool hitTestColumns(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
    464462    virtual bool hitTestContents(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty, HitTestAction);
     
    603601    };
    604602
    605     void layoutBlockChild(RenderBox* child, MarginInfo&, int& previousFloatBottom, int& maxFloatBottom);
     603    void layoutBlockChild(RenderBox* child, MarginInfo&, int& previousFloatLogicalBottom, int& maxFloatLogicalBottom);
    606604    void adjustPositionedBlock(RenderBox* child, const MarginInfo&);
    607605    void adjustFloatingBlock(const MarginInfo&);
  • trunk/WebCore/rendering/RenderBlockLineLayout.cpp

    r68926 r68957  
    13311331    ASSERT(widthToFit > availableWidth);
    13321332
    1333     int floatBottom;
    1334     int lastFloatBottom = height();
     1333    int floatLogicalBottom;
     1334    int lastFloatLogicalBottom = height();
    13351335    int newLineWidth = availableWidth;
    13361336    while (true) {
    1337         floatBottom = nextFloatBottomBelow(lastFloatBottom);
    1338         if (!floatBottom)
     1337        floatLogicalBottom = nextFloatLogicalBottomBelow(lastFloatLogicalBottom);
     1338        if (!floatLogicalBottom)
    13391339            break;
    13401340
    1341         newLineWidth = availableLogicalWidthForLine(floatBottom, firstLine);
    1342         lastFloatBottom = floatBottom;
     1341        newLineWidth = availableLogicalWidthForLine(floatLogicalBottom, firstLine);
     1342        lastFloatLogicalBottom = floatLogicalBottom;
    13431343        if (newLineWidth >= widthToFit)
    13441344            break;
     
    13461346
    13471347    if (newLineWidth > availableWidth) {
    1348         setLogicalHeight(lastFloatBottom);
     1348        setLogicalHeight(lastFloatLogicalBottom);
    13491349        availableWidth = newLineWidth;
    13501350    }
Note: See TracChangeset for help on using the changeset viewer.