Changeset 169110 in webkit


Ignore:
Timestamp:
May 20, 2014 7:34:56 AM (10 years ago)
Author:
stavila@adobe.com
Message:

[CSS Regions] Block incorrectly sized when containing an unsplittable box
https://bugs.webkit.org/show_bug.cgi?id=132601

Reviewed by Antti Koivisto.

Source/WebCore:
When laying out elements in a region, when an inline element is encountered
the size of its parent must not be increased beyond the bottom of the current region,
unless if its the last region. This will ensure that the next sibling of the
inline element is correctly laid out at the top of the next region, instead
of leaving an empty space equal to the height of the overflow, as it did until now.

Tests: fast/regions/inline-block-inside-anonymous-overflow.html

fast/regions/inline-block-overflow.html

  • rendering/RenderBlockFlow.cpp:

(WebCore::RenderBlockFlow::adjustLinePositionForPagination):
(WebCore::RenderBlockFlow::hasNextPage):

  • rendering/RenderBlockFlow.h:
  • rendering/RenderBlockLineLayout.cpp:

(WebCore::RenderBlockFlow::layoutRunsAndFloatsInRange):
(WebCore::RenderBlockFlow::linkToEndLineIfNeeded):
(WebCore::RenderBlockFlow::determineStartPosition):
(WebCore::RenderBlockFlow::checkPaginationAndFloatsAtEndLine):

LayoutTests:
Added tests for the layout of elements following inline-block elements
that overflow their region, with and without anonymous blocks.

  • fast/regions/inline-block-inside-anonymous-overflow-expected.html: Added.
  • fast/regions/inline-block-inside-anonymous-overflow.html: Added.
  • fast/regions/inline-block-overflow-expected.html: Added.
  • fast/regions/inline-block-overflow.html: Added.
Location:
trunk
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r169107 r169110  
     12014-05-20  Radu Stavila  <stavila@adobe.com>
     2
     3        [CSS Regions] Block incorrectly sized when containing an unsplittable box
     4        https://bugs.webkit.org/show_bug.cgi?id=132601
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Added tests for the layout of elements following inline-block elements
     9        that overflow their region, with and without anonymous blocks.
     10
     11        * fast/regions/inline-block-inside-anonymous-overflow-expected.html: Added.
     12        * fast/regions/inline-block-inside-anonymous-overflow.html: Added.
     13        * fast/regions/inline-block-overflow-expected.html: Added.
     14        * fast/regions/inline-block-overflow.html: Added.
     15
    1162014-05-20  Zoltan Horvath  <zoltan@webkit.org>
    217
  • trunk/Source/WebCore/ChangeLog

    r169105 r169110  
     12014-05-20  Radu Stavila  <stavila@adobe.com>
     2
     3        [CSS Regions] Block incorrectly sized when containing an unsplittable box
     4        https://bugs.webkit.org/show_bug.cgi?id=132601
     5
     6        Reviewed by Antti Koivisto.
     7
     8        When laying out elements in a region, when an inline element is encountered
     9        the size of its parent must not be increased beyond the bottom of the current region,
     10        unless if its the last region. This will ensure that the next sibling of the
     11        inline element is correctly laid out at the top of the next region, instead
     12        of leaving an empty space equal to the height of the overflow, as it did until now.
     13
     14        Tests: fast/regions/inline-block-inside-anonymous-overflow.html
     15               fast/regions/inline-block-overflow.html
     16
     17        * rendering/RenderBlockFlow.cpp:
     18        (WebCore::RenderBlockFlow::adjustLinePositionForPagination):
     19        (WebCore::RenderBlockFlow::hasNextPage):
     20        * rendering/RenderBlockFlow.h:
     21        * rendering/RenderBlockLineLayout.cpp:
     22        (WebCore::RenderBlockFlow::layoutRunsAndFloatsInRange):
     23        (WebCore::RenderBlockFlow::linkToEndLineIfNeeded):
     24        (WebCore::RenderBlockFlow::determineStartPosition):
     25        (WebCore::RenderBlockFlow::checkPaginationAndFloatsAtEndLine):
     26
    1272014-05-20  Mihnea Ovidenie  <mihnea@adobe.com>
    228
  • trunk/Source/WebCore/rendering/RenderBlockFlow.cpp

    r168836 r169110  
    16211621}
    16221622
    1623 void RenderBlockFlow::adjustLinePositionForPagination(RootInlineBox* lineBox, LayoutUnit& delta, RenderFlowThread* flowThread)
     1623void RenderBlockFlow::adjustLinePositionForPagination(RootInlineBox* lineBox, LayoutUnit& delta, bool& overflowsRegion, RenderFlowThread* flowThread)
    16241624{
    16251625    // FIXME: For now we paginate using line overflow. This ensures that lines don't overlap at all when we
     
    16421642    // Technically if the location we move the line to has a different line width than our old position, then we need to dirty the
    16431643    // line and all following lines.
     1644    overflowsRegion = false;
    16441645    LayoutRect logicalVisualOverflow = lineBox->logicalVisualOverflowRect(lineBox->lineTop(), lineBox->lineBottom());
    16451646    LayoutUnit logicalOffset = std::min(lineBox->lineTopWithLeading(), logicalVisualOverflow.y());
     
    16601661        return;
    16611662    LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logicalOffset, ExcludePageBoundary);
     1663    overflowsRegion = (lineHeight > remainingLogicalHeight);
    16621664
    16631665    int lineIndex = lineCount(lineBox);
     
    16741676            remainingLogicalHeight -= std::min(lineHeight - pageLogicalHeight, std::max<LayoutUnit>(0, logicalVisualOverflow.y() - lineBox->lineTopWithLeading()));
    16751677        }
     1678        LayoutUnit remainingLogicalHeightAtNewOffset = pageRemainingLogicalHeightForOffset(logicalOffset + remainingLogicalHeight, ExcludePageBoundary);
     1679        overflowsRegion = (lineHeight > remainingLogicalHeightAtNewOffset);
    16761680        LayoutUnit totalLogicalHeight = lineHeight + std::max<LayoutUnit>(0, logicalOffset);
    16771681        LayoutUnit pageLogicalHeightAtNewOffset = hasUniformPageLogicalHeight ? pageLogicalHeight : pageLogicalHeightForOffset(logicalOffset + remainingLogicalHeight);
     
    17591763    RenderRegion* endRegion = nullptr;
    17601764    flowThread->getRegionRangeForBox(this, startRegion, endRegion);
    1761     return region != endRegion;
     1765    return (endRegion && region != endRegion);
    17621766}
    17631767
  • trunk/Source/WebCore/rendering/RenderBlockFlow.h

    r168836 r169110  
    591591public:
    592592    // FIXME-BLOCKFLOW: These can be made protected again once all callers have been moved here.
    593     void adjustLinePositionForPagination(RootInlineBox*, LayoutUnit& deltaOffset, RenderFlowThread*); // Computes a deltaOffset value that put a line at the top of the next page if it doesn't fit on the current page.
     593    void adjustLinePositionForPagination(RootInlineBox*, LayoutUnit& deltaOffset, bool& overflowsRegion, RenderFlowThread*); // Computes a deltaOffset value that put a line at the top of the next page if it doesn't fit on the current page.
    594594    void updateRegionForLine(RootInlineBox*) const;
    595595    void createRenderNamedFlowFragmentIfNeeded();
  • trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp

    r169089 r169110  
    11351135                if (paginated) {
    11361136                    LayoutUnit adjustment = 0;
    1137                     adjustLinePositionForPagination(lineBox, adjustment, layoutState.flowThread());
     1137                    bool overflowsRegion;
     1138                    adjustLinePositionForPagination(lineBox, adjustment, overflowsRegion, layoutState.flowThread());
    11381139                    if (adjustment) {
    11391140                        LayoutUnit oldLineWidth = availableLogicalWidthForLine(oldLogicalHeight, layoutState.lineInfo().isFirstLine());
     
    11501151
    11511152                        setLogicalHeight(lineBox->lineBottomWithLeading());
     1153                    }
     1154                   
     1155                    if (RenderFlowThread* flowThread = flowThreadContainingBlock()) {
     1156                        if (flowThread->isRenderNamedFlowThread() && overflowsRegion && hasNextPage(lineBox->lineTop())) {
     1157                            // Limit the height of this block to the end of the current region because
     1158                            // it is also fragmented into the next region.
     1159                            LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logicalTop(), ExcludePageBoundary);
     1160                            if (logicalHeight() > remainingLogicalHeight)
     1161                                setLogicalHeight(remainingLogicalHeight);
     1162                        }
    11521163                    }
    11531164
     
    12661277                if (paginated) {
    12671278                    delta -= line->paginationStrut();
    1268                     adjustLinePositionForPagination(line, delta, layoutState.flowThread());
     1279                    bool overflowsRegion;
     1280                    adjustLinePositionForPagination(line, delta, overflowsRegion, layoutState.flowThread());
    12691281                }
    12701282                if (delta) {
     
    15061518                }
    15071519                paginationDelta -= curr->paginationStrut();
    1508                 adjustLinePositionForPagination(curr, paginationDelta, layoutState.flowThread());
     1520                bool overflowsRegion;
     1521                adjustLinePositionForPagination(curr, paginationDelta, overflowsRegion, layoutState.flowThread());
    15091522                if (paginationDelta) {
    15101523                    if (containsFloats() || !layoutState.floats().isEmpty()) {
     
    16541667                // strut yet.
    16551668                LayoutUnit oldPaginationStrut = lineBox->paginationStrut();
     1669                bool overflowsRegion;
    16561670                lineDelta -= oldPaginationStrut;
    1657                 adjustLinePositionForPagination(lineBox, lineDelta, layoutState.flowThread());
     1671                adjustLinePositionForPagination(lineBox, lineDelta, overflowsRegion, layoutState.flowThread());
    16581672                lineBox->setPaginationStrut(oldPaginationStrut);
    16591673            }
Note: See TracChangeset for help on using the changeset viewer.