Changeset 95855 in webkit


Ignore:
Timestamp:
Sep 23, 2011 1:25:11 PM (13 years ago)
Author:
hyatt@apple.com
Message:

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

Push through multiple regions when an object doesn't fit in any of them. Unlike with pages and
columns, when regions have a non-uniform height, we may need to push through multiple regions
in order to find one that fits.

Added an optimization for quickly noticing if regions do have a uniform height so that we can
treat them like columns and pages if so.

Also fixed the end line matchup to properly null out endLine when no next line box exists. The new
layout tests I wrote to cover this feature exposed this crasher, so fixing it in order to land
the new tests.

Reviewed by Anders Carlsson.

Source/WebCore:

Added new tests in fast/regions.

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::adjustForUnsplittableChild):
(WebCore::RenderBlock::pushToNextPageWithMinimumLogicalHeight):
(WebCore::RenderBlock::adjustLinePositionForPagination):

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

(WebCore::RenderBlock::matchedEndLine):

  • rendering/RenderFlowThread.cpp:

(WebCore::RenderFlowThread::RenderFlowThread):
(WebCore::RenderFlowThread::layout):

  • rendering/RenderFlowThread.h:

LayoutTests:

  • fast/regions/webkit-flow-float-pushed-to-last-region.html: Added.
  • fast/regions/webkit-flow-float-unable-to-push.html: Added.
  • platform/mac/fast/regions/webkit-flow-float-pushed-to-last-region-expected.png: Added.
  • platform/mac/fast/regions/webkit-flow-float-pushed-to-last-region-expected.txt: Added.
  • platform/mac/fast/regions/webkit-flow-float-unable-to-push-expected.png: Added.
  • platform/mac/fast/regions/webkit-flow-float-unable-to-push-expected.txt: Added.
Location:
trunk
Files:
6 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r95852 r95855  
     12011-09-23  David Hyatt  <hyatt@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=68719
     4       
     5        Push through multiple regions when an object doesn't fit in any of them. Unlike with pages and
     6        columns, when regions have a non-uniform height, we may need to push through multiple regions
     7        in order to find one that fits.
     8       
     9        Added an optimization for quickly noticing if regions do have a uniform height so that we can
     10        treat them like columns and pages if so.
     11
     12        Also fixed the end line matchup to properly null out endLine when no next line box exists. The new
     13        layout tests I wrote to cover this feature exposed this crasher, so fixing it in order to land
     14        the new tests.
     15
     16        Reviewed by Anders Carlsson.
     17
     18        * fast/regions/webkit-flow-float-pushed-to-last-region.html: Added.
     19        * fast/regions/webkit-flow-float-unable-to-push.html: Added.
     20        * platform/mac/fast/regions/webkit-flow-float-pushed-to-last-region-expected.png: Added.
     21        * platform/mac/fast/regions/webkit-flow-float-pushed-to-last-region-expected.txt: Added.
     22        * platform/mac/fast/regions/webkit-flow-float-unable-to-push-expected.png: Added.
     23        * platform/mac/fast/regions/webkit-flow-float-unable-to-push-expected.txt: Added.
     24
    1252011-09-23  Konstantin Scheglov  <scheglov@google.com>
    226
  • trunk/Source/WebCore/ChangeLog

    r95852 r95855  
     12011-09-23  David Hyatt  <hyatt@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=68719
     4       
     5        Push through multiple regions when an object doesn't fit in any of them. Unlike with pages and
     6        columns, when regions have a non-uniform height, we may need to push through multiple regions
     7        in order to find one that fits.
     8       
     9        Added an optimization for quickly noticing if regions do have a uniform height so that we can
     10        treat them like columns and pages if so.
     11
     12        Also fixed the end line matchup to properly null out endLine when no next line box exists. The new
     13        layout tests I wrote to cover this feature exposed this crasher, so fixing it in order to land
     14        the new tests.
     15
     16        Reviewed by Anders Carlsson.
     17
     18        Added new tests in fast/regions.
     19
     20        * rendering/RenderBlock.cpp:
     21        (WebCore::RenderBlock::adjustForUnsplittableChild):
     22        (WebCore::RenderBlock::pushToNextPageWithMinimumLogicalHeight):
     23        (WebCore::RenderBlock::adjustLinePositionForPagination):
     24        * rendering/RenderBlock.h:
     25        * rendering/RenderBlockLineLayout.cpp:
     26        (WebCore::RenderBlock::matchedEndLine):
     27        * rendering/RenderFlowThread.cpp:
     28        (WebCore::RenderFlowThread::RenderFlowThread):
     29        (WebCore::RenderFlowThread::layout):
     30        * rendering/RenderFlowThread.h:
     31
    1322011-09-23  Konstantin Scheglov  <scheglov@google.com>
    233
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r95777 r95855  
    62296229        layoutState->m_columnInfo->updateMinimumColumnHeight(childLogicalHeight);
    62306230    LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset);
    6231     if (!pageLogicalHeight || (childLogicalHeight > pageLogicalHeight && !view()->hasRenderFlowThread()))
     6231    bool hasUniformPageLogicalHeight = !view()->hasRenderFlowThread() || view()->currentRenderFlowThread()->regionsHaveUniformLogicalHeight();
     6232    if (!pageLogicalHeight || (hasUniformPageLogicalHeight && childLogicalHeight > pageLogicalHeight))
    62326233        return logicalOffset;
    62336234    LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logicalOffset);
    6234     if (remainingLogicalHeight < childLogicalHeight)
     6235    if (remainingLogicalHeight < childLogicalHeight) {
     6236        if (!hasUniformPageLogicalHeight && !pushToNextPageWithMinimumLogicalHeight(remainingLogicalHeight, logicalOffset, childLogicalHeight))
     6237            return logicalOffset;
    62356238        return logicalOffset + remainingLogicalHeight;
     6239    }
    62366240    return logicalOffset;
     6241}
     6242
     6243bool RenderBlock::pushToNextPageWithMinimumLogicalHeight(LayoutUnit& adjustment, LayoutUnit logicalOffset, LayoutUnit minimumLogicalHeight) const
     6244{
     6245    bool checkedRegion = false;
     6246    for (LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset + adjustment); pageLogicalHeight;
     6247         pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset + adjustment)) {
     6248         if (minimumLogicalHeight <= pageLogicalHeight)
     6249            return true;
     6250         adjustment += pageLogicalHeight;
     6251         checkedRegion = true;
     6252    }
     6253    return !checkedRegion;
    62376254}
    62386255
     
    62686285    lineBox->setPaginationStrut(0);
    62696286    LayoutUnit pageLogicalHeight = pageLogicalHeightForOffset(logicalOffset);
    6270     if (!pageLogicalHeight || (lineHeight > pageLogicalHeight && !renderView->hasRenderFlowThread()))
     6287    bool hasUniformPageLogicalHeight = !view()->hasRenderFlowThread() || view()->currentRenderFlowThread()->regionsHaveUniformLogicalHeight();
     6288    if (!pageLogicalHeight || (hasUniformPageLogicalHeight && lineHeight > pageLogicalHeight))
    62716289        return;
    62726290    const bool includeBoundaryPoint = false;
    62736291    LayoutUnit remainingLogicalHeight = pageRemainingLogicalHeightForOffset(logicalOffset, includeBoundaryPoint);
    62746292    if (remainingLogicalHeight < lineHeight) {
     6293        // If we have a non-uniform page height, then we have to shift further possibly.
     6294        if (!hasUniformPageLogicalHeight && !pushToNextPageWithMinimumLogicalHeight(remainingLogicalHeight, logicalOffset, lineHeight))
     6295            return;
    62756296        LayoutUnit totalLogicalHeight = lineHeight + max<LayoutUnit>(0, logicalOffset);
    6276         if (lineBox == firstRootBox() && totalLogicalHeight < pageLogicalHeight && !isPositioned() && !isTableCell())
     6297        LayoutUnit pageLogicalHeightAtNewOffset = hasUniformPageLogicalHeight ? pageLogicalHeight : pageLogicalHeightForOffset(logicalOffset + remainingLogicalHeight);
     6298        if (lineBox == firstRootBox() && totalLogicalHeight < pageLogicalHeightAtNewOffset && !isPositioned() && !isTableCell())
    62776299            setPaginationStrut(remainingLogicalHeight + max<LayoutUnit>(0, logicalOffset));
    62786300        else {
  • trunk/Source/WebCore/rendering/RenderBlock.h

    r95756 r95855  
    825825    LayoutUnit pageLogicalHeightForOffset(LayoutUnit offset) const;
    826826    LayoutUnit pageRemainingLogicalHeightForOffset(LayoutUnit offset, bool includeBoundaryPoint = true) const;
     827    bool pushToNextPageWithMinimumLogicalHeight(LayoutUnit& adjustment, LayoutUnit logicalOffset, LayoutUnit minimumLogicalHeight) const;
    827828
    828829    LayoutUnit adjustForUnsplittableChild(RenderBox* child, LayoutUnit logicalOffset, bool includeMargins = false); // If the child is unsplittable and can't fit on the current page, return the top of the next page/column.
  • trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp

    r95756 r95855  
    16151615            bool matched = false;
    16161616            RootInlineBox* result = line->nextRootBox();
     1617            layoutState.setEndLine(result);
    16171618            if (result) {
    16181619                layoutState.setEndLineLogicalTop(line->lineBottomWithLeading());
    1619                 layoutState.setEndLine(result);
    16201620                matched = checkPaginationAndFloatsAtEndLine(layoutState);
    16211621            }
  • trunk/Source/WebCore/rendering/RenderFlowThread.cpp

    r95740 r95855  
    4949    , m_regionsInvalidated(false)
    5050    , m_regionsHaveUniformLogicalWidth(true)
     51    , m_regionsHaveUniformLogicalHeight(true)
    5152    , m_regionFittingDisableCount(0)
    5253{
     
    307308        m_hasValidRegions = false;
    308309        m_regionsHaveUniformLogicalWidth = true;
     310        m_regionsHaveUniformLogicalHeight = true;
    309311        LayoutUnit previousRegionLogicalWidth = 0;
     312        LayoutUnit previousRegionLogicalHeight = 0;
    310313        if (hasRegions()) {
    311314            int logicalHeight = 0;
     
    319322               
    320323                LayoutUnit regionLogicalWidth;
     324                LayoutUnit regionLogicalHeight;
    321325
    322326                IntRect regionRect;
     
    325329                    logicalHeight += regionRect.height();
    326330                    regionLogicalWidth = region->contentWidth();
     331                    regionLogicalHeight = region->contentHeight();
    327332                } else {
    328333                    regionRect = IntRect(logicalHeight, 0, region->contentWidth(), region->contentHeight());
    329334                    logicalHeight += regionRect.width();
    330335                    regionLogicalWidth = region->contentHeight();
     336                    regionLogicalHeight = region->contentWidth();
    331337                }
    332338
    333339                if (!m_hasValidRegions)
    334340                    m_hasValidRegions = true;
    335                 else if (m_regionsHaveUniformLogicalWidth && previousRegionLogicalWidth != regionLogicalWidth)
    336                     m_regionsHaveUniformLogicalWidth = false;
     341                else {
     342                    if (m_regionsHaveUniformLogicalWidth && previousRegionLogicalWidth != regionLogicalWidth)
     343                        m_regionsHaveUniformLogicalWidth = false;
     344                    if (m_regionsHaveUniformLogicalHeight && previousRegionLogicalHeight != regionLogicalHeight)
     345                        m_regionsHaveUniformLogicalHeight = false;
     346                }
    337347
    338348                previousRegionLogicalWidth = regionLogicalWidth;
  • trunk/Source/WebCore/rendering/RenderFlowThread.h

    r95740 r95855  
    107107
    108108    bool regionsHaveUniformLogicalWidth() const { return m_regionsHaveUniformLogicalWidth; }
    109    
     109    bool regionsHaveUniformLogicalHeight() const { return m_regionsHaveUniformLogicalHeight; }
     110
    110111    RenderRegion* mapFromFlowToRegion(TransformState&) const;
    111112
     
    141142    bool m_regionsInvalidated;
    142143    bool m_regionsHaveUniformLogicalWidth;
     144    bool m_regionsHaveUniformLogicalHeight;
    143145    unsigned m_regionFittingDisableCount;
    144146};
Note: See TracChangeset for help on using the changeset viewer.