Changeset 50869 in webkit


Ignore:
Timestamp:
Nov 12, 2009 12:15:48 AM (14 years ago)
Author:
hamaji@chromium.org
Message:

2009-11-12 Yuta Kitamura <yutak@chromium.org>

Reviewed by Eric Seidel.

Prevent text inside a multi-column block from being split into columns.

If the tentative height of a multi-column block was too small, we need to
expand the block height and try to layout again, in order to prevent text
from being split into different columns.

CSS Multicolumn text is split awkwardly
https://bugs.webkit.org/show_bug.cgi?id=22249

  • fast/multicol/single-line.html: Added.
  • fast/multicol/single-line-expected.checksum: Added.
  • fast/multicol/single-line-expected.png: Added.
  • fast/multicol/single-line-expected.txt: Added.

2009-11-12 Yuta Kitamura <yutak@chromium.org>

Reviewed by Eric Seidel.

Prevent text inside a multi-column block from being split into columns.

If the tentative height of a multi-column block was too small, we need to
expand the block height and try to layout again, in order to prevent text
from being split into different columns.

CSS Multicolumn text is split awkwardly
https://bugs.webkit.org/show_bug.cgi?id=22249

Test: fast/multicol/single-line.html

  • rendering/RenderBlock.cpp: (WebCore::RenderBlock::layoutColumns):
  • rendering/RenderBlock.h:
  • rendering/RenderLineBoxList.cpp: (WebCore::RenderLineBoxList::paint):
  • rendering/RenderView.h: (WebCore::RenderView::setTruncatedAt): (WebCore::RenderView::setMinimumColumnHeight): (WebCore::RenderView::minimumColumnHeight):
Location:
trunk
Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r50868 r50869  
     12009-11-12  Yuta Kitamura  <yutak@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Prevent text inside a multi-column block from being split into columns.
     6       
     7        If the tentative height of a multi-column block was too small, we need to
     8        expand the block height and try to layout again, in order to prevent text
     9        from being split into different columns.
     10
     11        CSS Multicolumn text is split awkwardly
     12        https://bugs.webkit.org/show_bug.cgi?id=22249
     13
     14        * fast/multicol/single-line.html: Added.
     15        * fast/multicol/single-line-expected.checksum: Added.
     16        * fast/multicol/single-line-expected.png: Added.
     17        * fast/multicol/single-line-expected.txt: Added.
     18
    1192009-11-11  Kent Tamura  <tkent@chromium.org>
    220
  • trunk/WebCore/ChangeLog

    r50868 r50869  
     12009-11-12  Yuta Kitamura  <yutak@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Prevent text inside a multi-column block from being split into columns.
     6       
     7        If the tentative height of a multi-column block was too small, we need to
     8        expand the block height and try to layout again, in order to prevent text
     9        from being split into different columns.
     10
     11        CSS Multicolumn text is split awkwardly
     12        https://bugs.webkit.org/show_bug.cgi?id=22249
     13
     14        Test: fast/multicol/single-line.html
     15
     16        * rendering/RenderBlock.cpp:
     17        (WebCore::RenderBlock::layoutColumns):
     18        * rendering/RenderBlock.h:
     19        * rendering/RenderLineBoxList.cpp:
     20        (WebCore::RenderLineBoxList::paint):
     21        * rendering/RenderView.h:
     22        (WebCore::RenderView::setTruncatedAt):
     23        (WebCore::RenderView::setMinimumColumnHeight):
     24        (WebCore::RenderView::minimumColumnHeight):
     25
    1262009-11-11  Kent Tamura  <tkent@chromium.org>
    227
  • trunk/WebCore/rendering/RenderBlock.cpp

    r50760 r50869  
    36183618}
    36193619
    3620 int RenderBlock::layoutColumns(int endOfContent)
     3620int RenderBlock::layoutColumns(int endOfContent, int requestedColumnHeight)
    36213621{
    36223622    // Don't do anything if we have no columns
     
    36313631    bool computeIntrinsicHeight = (endOfContent == -1);
    36323632
    3633     // Fill the columns in to the available height.  Attempt to balance the height of the columns
    3634     int availableHeight = contentHeight();
    3635     int colHeight = computeIntrinsicHeight ? availableHeight / desiredColumnCount : availableHeight;
    3636    
     3633    // Fill the columns in to the available height.  Attempt to balance the height of the columns.
    36373634    // Add in half our line-height to help with best-guess initial balancing.
    36383635    int columnSlop = lineHeight(false) / 2;
    36393636    int remainingSlopSpace = columnSlop * desiredColumnCount;
    3640 
    3641     if (computeIntrinsicHeight)
    3642         colHeight += columnSlop;
    3643                                                                            
     3637    int availableHeight = contentHeight();
     3638    int colHeight;
     3639    if (computeIntrinsicHeight && requestedColumnHeight >= 0)
     3640        colHeight = requestedColumnHeight;
     3641    else if (computeIntrinsicHeight)
     3642        colHeight = availableHeight / desiredColumnCount + columnSlop;
     3643    else
     3644        colHeight = availableHeight;
     3645    int originalColHeight = colHeight;
     3646
    36443647    int colGap = columnGap();
    36453648
     
    36573660    unsigned colCount = desiredColumnCount;
    36583661    int maxColBottom = borderTop() + paddingTop();
    3659     int contentBottom = top + availableHeight;
     3662    int contentBottom = top + availableHeight;
     3663    int minimumColumnHeight = -1;
    36603664    for (unsigned i = 0; i < colCount; i++) {
    36613665        // If we aren't constrained, then the last column can just get all the remaining space.
     
    36763680        paintObject(paintInfo, 0, 0);
    36773681        setHasColumns(true);
     3682
     3683        if (computeIntrinsicHeight && v->minimumColumnHeight() > originalColHeight) {
     3684            // The initial column height was too small to contain one line of text.
     3685            minimumColumnHeight = max(minimumColumnHeight, v->minimumColumnHeight());
     3686        }
    36783687
    36793688        int adjustedBottom = v->bestTruncatedAt();
     
    37113720        if (currY < endOfContent && i == colCount - 1 && (computeIntrinsicHeight || contentHeight()))
    37123721            colCount++;
     3722    }
     3723
     3724    if (minimumColumnHeight >= 0) {
     3725        // If originalColHeight was too small, we need to try to layout again.
     3726        return layoutColumns(endOfContent, minimumColumnHeight);
    37133727    }
    37143728
  • trunk/WebCore/rendering/RenderBlock.h

    r50397 r50869  
    369369
    370370    void calcColumnWidth();
    371     int layoutColumns(int endOfContent = -1);
     371    int layoutColumns(int endOfContent = -1, int requestedColumnHeight = -1);
    372372
    373373    bool expandsToEncloseOverhangingFloats() const;
  • trunk/WebCore/rendering/RenderLineBoxList.cpp

    r47590 r50869  
    200200        h = bottom - top;
    201201        yPos = ty + top;
     202        v->setMinimumColumnHeight(h);
    202203        if (yPos < info.rect.bottom() && yPos + h > info.rect.y())
    203204            curr->paint(info, tx, ty);
  • trunk/WebCore/rendering/RenderView.h

    r50583 r50869  
    7676    void setPrintImages(bool enable) { m_printImages = enable; }
    7777    bool printImages() const { return m_printImages; }
    78     void setTruncatedAt(int y) { m_truncatedAt = y; m_bestTruncatedAt = m_truncatorWidth = 0; m_forcedPageBreak = false; }
     78    void setTruncatedAt(int y) { m_truncatedAt = y; m_bestTruncatedAt = m_truncatorWidth = 0; m_minimumColumnHeight = 0; m_forcedPageBreak = false; }
    7979    void setBestTruncatedAt(int y, RenderBoxModelObject* forRenderer, bool forcedBreak = false);
     80    void setMinimumColumnHeight(int height) { m_minimumColumnHeight = height; }
    8081    int bestTruncatedAt() const { return m_bestTruncatedAt; }
     82    int minimumColumnHeight() const { return m_minimumColumnHeight; }
    8183
    8284    int truncatedAt() const { return m_truncatedAt; }
     
    196198    int m_bestTruncatedAt;
    197199    int m_truncatorWidth;
     200    int m_minimumColumnHeight;
    198201    bool m_forcedPageBreak;
    199202    LayoutState* m_layoutState;
Note: See TracChangeset for help on using the changeset viewer.