Changeset 27486 in webkit


Ignore:
Timestamp:
Nov 6, 2007 1:03:35 PM (16 years ago)
Author:
mitz@apple.com
Message:

WebCore:

Reviewed by Antti Koivisto and Dave Hyatt.

  • fix <rdar://problem/5582961> Incorrect layout and floating object list corruption when CSS decreases a block's height

Test: fast/block/float/overhanging-after-height-decrease.html

  • rendering/RenderBlock.cpp: (WebCore::RenderBlock::layoutBlock): If after calculating the height it turns out that there are overhanging floats that were not overhanging before, rescan children with overhanging floats and add them. (WebCore::RenderBlock::layoutBlockChildren): Added a parameter that returns the lowest float bottom of any of the children. (WebCore::RenderBlock::addOverhangingFloats): Changed to return the lowest float bottom.
  • rendering/RenderBlock.h:

LayoutTests:

Reviewed by Antti Koivisto and Dave Hyatt.

  • test for <rdar://problem/5582961> Incorrect layout and floating object list corruption when CSS decreases a block's height
  • fast/block/float/overhanging-after-height-decrease.html: Added.
  • platform/mac-leopard/fast/block: Added.
  • platform/mac-leopard/fast/block/float: Added.
  • platform/mac-leopard/fast/block/float/overhanging-after-height-decrease-expected.checksum: Added.
  • platform/mac-leopard/fast/block/float/overhanging-after-height-decrease-expected.png: Added.
  • platform/mac/fast/block/float/overhanging-after-height-decrease-expected.txt: Added.
Location:
trunk
Files:
6 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r27485 r27486  
     12007-11-06  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Antti Koivisto and Dave Hyatt.
     4
     5        - test for <rdar://problem/5582961> Incorrect layout and floating object list corruption when CSS decreases a block's height
     6
     7        * fast/block/float/overhanging-after-height-decrease.html: Added.
     8        * platform/mac-leopard/fast/block: Added.
     9        * platform/mac-leopard/fast/block/float: Added.
     10        * platform/mac-leopard/fast/block/float/overhanging-after-height-decrease-expected.checksum: Added.
     11        * platform/mac-leopard/fast/block/float/overhanging-after-height-decrease-expected.png: Added.
     12        * platform/mac/fast/block/float/overhanging-after-height-decrease-expected.txt: Added.
     13
    1142007-11-05  Adele Peterson  <adele@apple.com>
    215
  • trunk/WebCore/ChangeLog

    r27485 r27486  
     12007-11-06  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Antti Koivisto and Dave Hyatt.
     4
     5        - fix <rdar://problem/5582961> Incorrect layout and floating object list corruption when CSS decreases a block's height
     6
     7        Test: fast/block/float/overhanging-after-height-decrease.html
     8
     9        * rendering/RenderBlock.cpp:
     10        (WebCore::RenderBlock::layoutBlock): If after calculating the height
     11        it turns out that there are overhanging floats that were not overhanging
     12        before, rescan children with overhanging floats and add them.
     13        (WebCore::RenderBlock::layoutBlockChildren): Added a parameter that
     14        returns the lowest float bottom of any of the children.
     15        (WebCore::RenderBlock::addOverhangingFloats): Changed to return the
     16        lowest float bottom.
     17        * rendering/RenderBlock.h:
     18
    1192007-11-06  Adele Peterson  <adele@apple.com>
    220
  • trunk/WebCore/rendering/RenderBlock.cpp

    r27478 r27486  
    578578    int repaintTop = 0;
    579579    int repaintBottom = 0;
     580    int maxFloatBottom = 0;
    580581    if (childrenInline())
    581582        layoutInlineChildren(relayoutChildren, repaintTop, repaintBottom);
    582583    else
    583         layoutBlockChildren(relayoutChildren);
     584        layoutBlockChildren(relayoutChildren, maxFloatBottom);
    584585
    585586    // Expand our intrinsic height to encompass floats.
     
    597598    calcHeight();
    598599    if (oldHeight != m_height) {
     600        if (oldHeight > m_height && maxFloatBottom > m_height && !childrenInline()) {
     601            // One of our children's floats may have become an overhanging float for us. We need to look for it.
     602            for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
     603                if (child->isBlockFlow() && !child->isFloatingOrPositioned()) {
     604                    RenderBlock* block = static_cast<RenderBlock*>(child);
     605                    if (block->floatBottom() + block->yPos() > m_height)
     606                        addOverhangingFloats(block, block->xPos(), block->yPos());
     607                }
     608            }
     609        }
    599610        // We have to rebalance columns to the new height.
    600611        layoutColumns(singleColumnBottom);
     
    11331144}
    11341145
    1135 void RenderBlock::layoutBlockChildren(bool relayoutChildren)
     1146void RenderBlock::layoutBlockChildren(bool relayoutChildren, int& maxFloatBottom)
    11361147{
    11371148    int top = borderTop() + paddingTop();
     
    11491160
    11501161    int previousFloatBottom = 0;
     1162    maxFloatBottom = 0;
    11511163
    11521164    RenderObject* child = firstChild();
     
    12361248        // If the child has overhanging floats that intrude into following siblings (or possibly out
    12371249        // of this block), then the parent gets notified of the floats now.
    1238         addOverhangingFloats(static_cast<RenderBlock *>(child), -child->xPos(), -child->yPos());
     1250        maxFloatBottom = max(maxFloatBottom, addOverhangingFloats(static_cast<RenderBlock *>(child), -child->xPos(), -child->yPos()));
    12391251
    12401252        // Update our overflow in case the child spills out the block.
     
    26322644}
    26332645
    2634 void RenderBlock::addOverhangingFloats(RenderBlock* child, int xoff, int yoff)
     2646int RenderBlock::addOverhangingFloats(RenderBlock* child, int xoff, int yoff)
    26352647{
    26362648    // Prevent floats from being added to the canvas by the root element, e.g., <html>.
    26372649    if (child->hasOverflowClip() || !child->containsFloats() || child->isRoot())
    2638         return;
     2650        return 0;
     2651
     2652    int lowestFloatBottom = 0;
    26392653
    26402654    // Floats that will remain the child's responsiblity to paint should factor into its
     
    26432657    DeprecatedPtrListIterator<FloatingObject> it(*child->m_floatingObjects);
    26442658    for (FloatingObject* r; (r = it.current()); ++it) {
    2645         if (child->yPos() + r->endY > height()) {
     2659        int bottom = child->yPos() + r->endY;
     2660        lowestFloatBottom = max(lowestFloatBottom, bottom);
     2661
     2662        if (bottom > height()) {
    26462663            // If the object is not in the list, we add it now.
    26472664            if (!containsFloat(r->node)) {
     
    26772694    }
    26782695    child->addVisualOverflow(floatsOverflowRect);
     2696    return lowestFloatBottom;
    26792697}
    26802698
  • trunk/WebCore/rendering/RenderBlock.h

    r25754 r27486  
    111111    virtual void layout();
    112112    virtual void layoutBlock(bool relayoutChildren);
    113     void layoutBlockChildren(bool relayoutChildren);
     113    void layoutBlockChildren(bool relayoutChildren, int& maxFloatBottom);
    114114    void layoutInlineChildren(bool relayoutChildren, int& repaintTop, int& repaintBottom);
    115115
     
    177177    virtual bool hasOverhangingFloats() { return !hasColumns() && floatBottom() > m_height; }
    178178    void addIntrudingFloats(RenderBlock* prev, int xoffset, int yoffset);
    179     void addOverhangingFloats(RenderBlock* child, int xoffset, int yoffset);
     179    int addOverhangingFloats(RenderBlock* child, int xoffset, int yoffset);
    180180
    181181    int nearestFloatBottom(int height) const;
Note: See TracChangeset for help on using the changeset viewer.