Changeset 55636 in webkit


Ignore:
Timestamp:
Mar 7, 2010 10:15:02 AM (14 years ago)
Author:
mitz@apple.com
Message:

<rdar://problem/7722008> Column breaking ignores floats
https://bugs.webkit.org/show_bug.cgi?id=35837

Reviewed by Simon Fraser.

WebCore:

Test: fast/multicol/float-truncation.html

Introduce an earlier column-break if otherwise a float that could fit
inside a single column will be split between columns.

It is still possible for floats to be needlessly broken if initially
they fit in the column, but normal flow truncation then shortens the
column.

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::visibleTopOfHighestFloatExtendingBelow): Added.
Returns the visible top of the highest descendant float that visibly
extends below the given y offset, ignoring floats that are taller than
the given maximum height.
(WebCore::RenderBlock::layoutColumns): If the initial column height
would cause a float to be split, truncate above the float.

  • rendering/RenderBlock.h:

LayoutTests:

  • fast/multicol/float-truncation-expected.txt: Added.
  • fast/multicol/float-truncation.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r55635 r55636  
     12010-03-07  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Simon Fraser.
     4
     5        <rdar://problem/7722008> Column breaking ignores floats
     6        https://bugs.webkit.org/show_bug.cgi?id=35837
     7
     8        * fast/multicol/float-truncation-expected.txt: Added.
     9        * fast/multicol/float-truncation.html: Added.
     10
    1112010-03-07  Dmitry Titov  <dimich@chromium.org>
    212
  • trunk/WebCore/ChangeLog

    r55635 r55636  
     12010-03-07  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Simon Fraser.
     4
     5        <rdar://problem/7722008> Column breaking ignores floats
     6        https://bugs.webkit.org/show_bug.cgi?id=35837
     7
     8        Test: fast/multicol/float-truncation.html
     9
     10        Introduce an earlier column-break if otherwise a float that could fit
     11        inside a single column will be split between columns.
     12
     13        It is still possible for floats to be needlessly broken if initially
     14        they fit in the column, but normal flow truncation then shortens the
     15        column.
     16
     17        * rendering/RenderBlock.cpp:
     18        (WebCore::RenderBlock::visibleTopOfHighestFloatExtendingBelow): Added.
     19        Returns the visible top of the highest descendant float that visibly
     20        extends below the given y offset, ignoring floats that are taller than
     21        the given maximum height.
     22        (WebCore::RenderBlock::layoutColumns): If the initial column height
     23        would cause a float to be split, truncate above the float.
     24        * rendering/RenderBlock.h:
     25
    1262010-03-07  Dmitry Titov  <dimich@chromium.org>
    227
  • trunk/WebCore/rendering/RenderBlock.cpp

    r55630 r55636  
    31833183}
    31843184
     3185int RenderBlock::visibleTopOfHighestFloatExtendingBelow(int bottom, int maxHeight) const
     3186{
     3187    int top = bottom;
     3188    if (m_floatingObjects) {
     3189        FloatingObject* floatingObject;
     3190        for (DeprecatedPtrListIterator<FloatingObject> it(*m_floatingObjects); (floatingObject = it.current()); ++it) {
     3191            RenderBox* floatingBox = floatingObject->m_renderer;
     3192            IntRect visibleOverflow = floatingBox->visibleOverflowRect();
     3193            visibleOverflow.move(floatingBox->x(), floatingBox->y());
     3194            if (visibleOverflow.y() < top && visibleOverflow.bottom() > bottom && visibleOverflow.height() <= maxHeight && floatingBox->containingBlock() == this)
     3195                top = visibleOverflow.y();
     3196        }
     3197    }
     3198
     3199    if (!childrenInline()) {
     3200        for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
     3201            if (child->isFloatingOrPositioned() || !child->isRenderBlock())
     3202                continue;
     3203            RenderBlock* childBlock = toRenderBlock(child);
     3204            top = min(top, childBlock->y() + childBlock->visibleTopOfHighestFloatExtendingBelow(bottom - childBlock->y(), maxHeight));
     3205        }
     3206    }
     3207
     3208    return top;
     3209}
     3210
    31853211int RenderBlock::getClearDelta(RenderBox* child, int yPos)
    31863212{
     
    37243750        // This represents the real column position.
    37253751        IntRect colRect(currX, top, desiredColumnWidth, colHeight);
    3726        
     3752
     3753        int truncationPoint = visibleTopOfHighestFloatExtendingBelow(currY + colHeight, colHeight);
     3754
    37273755        // For the simulated paint, we pretend like everything is in one long strip.
    3728         IntRect pageRect(left, currY, desiredColumnWidth, colHeight);
     3756        IntRect pageRect(left, currY, desiredColumnWidth, truncationPoint - currY);
    37293757        v->setPrintRect(pageRect);
    3730         v->setTruncatedAt(currY + colHeight);
     3758        v->setTruncatedAt(truncationPoint);
    37313759        GraphicsContext context((PlatformGraphicsContext*)0);
    37323760        RenderObject::PaintInfo paintInfo(&context, pageRect, PaintPhaseForeground, false, 0, 0);
     
    37433771        int adjustedBottom = v->bestTruncatedAt();
    37443772        if (adjustedBottom <= currY)
    3745             adjustedBottom = currY + colHeight;
     3773            adjustedBottom = truncationPoint;
    37463774       
    37473775        colRect.setHeight(adjustedBottom - currY);
  • trunk/WebCore/rendering/RenderBlock.h

    r55630 r55636  
    372372    void calcColumnWidth();
    373373    int layoutColumns(int endOfContent = -1, int requestedColumnHeight = -1);
     374    int visibleTopOfHighestFloatExtendingBelow(int bottom, int maxHeight) const;
    374375
    375376    bool expandsToEncloseOverhangingFloats() const;
Note: See TracChangeset for help on using the changeset viewer.