Changeset 150743 in webkit


Ignore:
Timestamp:
May 27, 2013 2:41:47 AM (11 years ago)
Author:
abucur@adobe.com
Message:

[CSS Regions] Remove the offsetFromLogicalTopOfFirstPage parameter from layout functions
https://bugs.webkit.org/show_bug.cgi?id=116441

Reviewed by David Hyatt.

The patch changes the following things:

  • exposes offsetFromLogicalTopOfFirstPage() to all the RenderBoxes;
  • offsetFromLogicalTopOfFirstPage() is now safe to call from any box inside a flow thread, not only the

currently being laid out;

  • removes the offsetFromLogicalTopOfFirstPage parameter from all the layout functions

that didn't actually required it; when the value is necessary, the offsetFromLogicalTopOfFirstPage
function is called instead;

  • RenderFlowThread now handles its own logic for obtaining the offset from logical top of the first

region for a box, based on the layout states pushed on RenderView; it provides a better caching mechanism
that can be used for all the ancestor containing blocks of the current box being laid out.

The RenderBoxRegionInfo structures are cached only based on the box and the region. This means that
passing around a value for offsetFromLogicalTopOfFirstPage different in some cases than others was
risky. If there is a possibility of having a different box info result for a different offset
then the cache is not working correctly.

Tests: No function change, no tests.

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::computeStartPositionDeltaForChildAvoidingFloats):
(WebCore::RenderBlock::logicalLeftOffsetForContent):
(WebCore::RenderBlock::logicalRightOffsetForContent):
(WebCore::RenderBlock::getClearDelta):
(WebCore::RenderBlock::lineWidthForPaginatedLineChanged):
(WebCore::RenderBlock::offsetFromLogicalTopOfFirstPage):
(WebCore::RenderBlock::logicalWidthChangedInRegions):

  • rendering/RenderBlock.h:

(WebCore::RenderBlock::availableLogicalWidthForLine):
(WebCore::RenderBlock::logicalRightOffsetForLine):
(WebCore::RenderBlock::logicalLeftOffsetForLine):
(WebCore::RenderBlock::startOffsetForLine):
(WebCore::RenderBlock::endOffsetForLine):
(WebCore::RenderBlock::availableLogicalWidthForContent):
(WebCore::RenderBlock::startOffsetForContent):
(WebCore::RenderBlock::endOffsetForContent):
(WebCore::RenderBlock::logicalLeftOffsetForContent):
(WebCore::RenderBlock::logicalRightOffsetForContent):

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::borderBoxRectInRegion):
(WebCore::RenderBox::constrainLogicalWidthInRegionByMinMax):
(WebCore::RenderBox::shrinkLogicalWidthToAvoidFloats):
(WebCore::RenderBox::containingBlockLogicalWidthForContentInRegion):
(WebCore::RenderBox::containingBlockAvailableLineWidthInRegion):
(WebCore::RenderBox::computeLogicalWidthInRegion):
(WebCore::RenderBox::computeLogicalWidthInRegionUsing):
(WebCore::RenderBox::renderBoxRegionInfo):
(WebCore::RenderBox::containingBlockLogicalWidthForPositioned):
(WebCore::RenderBox::containingBlockLogicalHeightForPositioned):
(WebCore::computeInlineStaticDistance):
(WebCore::RenderBox::computePositionedLogicalWidth):
(WebCore::RenderBox::computePositionedLogicalWidthUsing):
(WebCore::RenderBox::computePositionedLogicalHeight):
(WebCore::RenderBox::computePositionedLogicalHeightUsing):
(WebCore::RenderBox::computePositionedLogicalWidthReplaced):
(WebCore::RenderBox::computePositionedLogicalHeightReplaced):
(WebCore::RenderBox::offsetFromLogicalTopOfFirstPage):

  • rendering/RenderBox.h:
  • rendering/RenderFlexibleBox.cpp:

(WebCore::RenderFlexibleBox::computeMainAxisExtentForChild):

  • rendering/RenderFlowThread.cpp:

(WebCore::RenderFlowThread::logicalWidthChangedInRegionsForBlock):
(WebCore::RenderFlowThread::hasCachedOffsetFromLogicalTopOfFirstRegion):
(WebCore::RenderFlowThread::cachedOffsetFromLogicalTopOfFirstRegion):
(WebCore::RenderFlowThread::setOffsetFromLogicalTopOfFirstRegion):
(WebCore::RenderFlowThread::clearOffsetFromLogicalTopOfFirstRegion):
(WebCore::RenderFlowThread::currentActiveRenderBox):
(WebCore::RenderFlowThread::pushFlowThreadLayoutState):
(WebCore::RenderFlowThread::popFlowThreadLayoutState):
(WebCore::RenderFlowThread::offsetFromLogicalTopOfFirstRegion):
(WebCore::RenderFlowThread::adjustedPositionRelativeToOffsetParent):

  • rendering/RenderFlowThread.h:
  • rendering/RenderTable.cpp:

(WebCore::RenderTable::updateLogicalWidth):

  • rendering/RenderView.cpp:

(WebCore::RenderView::pushLayoutState):
(WebCore::RenderView::pushLayoutStateForCurrentFlowThread):
(WebCore::RenderView::popLayoutStateForCurrentFlowThread):

  • rendering/RenderView.h:

(WebCore::RenderView::pushLayoutState):
(WebCore::RenderView::popLayoutState):

Location:
trunk/Source/WebCore
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r150741 r150743  
     12013-05-27  Andrei Bucur  <abucur@adobe.com>
     2
     3        [CSS Regions] Remove the offsetFromLogicalTopOfFirstPage parameter from layout functions
     4        https://bugs.webkit.org/show_bug.cgi?id=116441
     5
     6        Reviewed by David Hyatt.
     7
     8        The patch changes the following things:
     9        - exposes offsetFromLogicalTopOfFirstPage() to all the RenderBoxes;
     10        - offsetFromLogicalTopOfFirstPage() is now safe to call from any box inside a flow thread, not only the
     11        currently being laid out;
     12        - removes the offsetFromLogicalTopOfFirstPage parameter from all the layout functions
     13        that didn't actually required it; when the value is necessary, the offsetFromLogicalTopOfFirstPage
     14        function is called instead;
     15        - RenderFlowThread now handles its own logic for obtaining the offset from logical top of the first
     16        region for a box, based on the layout states pushed on RenderView; it provides a better caching mechanism
     17        that can be used for all the ancestor containing blocks of the current box being laid out.
     18
     19        The RenderBoxRegionInfo structures are cached only based on the box and the region. This means that
     20        passing around a value for offsetFromLogicalTopOfFirstPage different in some cases than others was
     21        risky. If there is a possibility of having a different box info result for a different offset
     22        then the cache is not working correctly.
     23
     24        Tests: No function change, no tests.
     25
     26        * rendering/RenderBlock.cpp:
     27        (WebCore::RenderBlock::computeStartPositionDeltaForChildAvoidingFloats):
     28        (WebCore::RenderBlock::logicalLeftOffsetForContent):
     29        (WebCore::RenderBlock::logicalRightOffsetForContent):
     30        (WebCore::RenderBlock::getClearDelta):
     31        (WebCore::RenderBlock::lineWidthForPaginatedLineChanged):
     32        (WebCore::RenderBlock::offsetFromLogicalTopOfFirstPage):
     33        (WebCore::RenderBlock::logicalWidthChangedInRegions):
     34        * rendering/RenderBlock.h:
     35        (WebCore::RenderBlock::availableLogicalWidthForLine):
     36        (WebCore::RenderBlock::logicalRightOffsetForLine):
     37        (WebCore::RenderBlock::logicalLeftOffsetForLine):
     38        (WebCore::RenderBlock::startOffsetForLine):
     39        (WebCore::RenderBlock::endOffsetForLine):
     40        (WebCore::RenderBlock::availableLogicalWidthForContent):
     41        (WebCore::RenderBlock::startOffsetForContent):
     42        (WebCore::RenderBlock::endOffsetForContent):
     43        (WebCore::RenderBlock::logicalLeftOffsetForContent):
     44        (WebCore::RenderBlock::logicalRightOffsetForContent):
     45        * rendering/RenderBox.cpp:
     46        (WebCore::RenderBox::borderBoxRectInRegion):
     47        (WebCore::RenderBox::constrainLogicalWidthInRegionByMinMax):
     48        (WebCore::RenderBox::shrinkLogicalWidthToAvoidFloats):
     49        (WebCore::RenderBox::containingBlockLogicalWidthForContentInRegion):
     50        (WebCore::RenderBox::containingBlockAvailableLineWidthInRegion):
     51        (WebCore::RenderBox::computeLogicalWidthInRegion):
     52        (WebCore::RenderBox::computeLogicalWidthInRegionUsing):
     53        (WebCore::RenderBox::renderBoxRegionInfo):
     54        (WebCore::RenderBox::containingBlockLogicalWidthForPositioned):
     55        (WebCore::RenderBox::containingBlockLogicalHeightForPositioned):
     56        (WebCore::computeInlineStaticDistance):
     57        (WebCore::RenderBox::computePositionedLogicalWidth):
     58        (WebCore::RenderBox::computePositionedLogicalWidthUsing):
     59        (WebCore::RenderBox::computePositionedLogicalHeight):
     60        (WebCore::RenderBox::computePositionedLogicalHeightUsing):
     61        (WebCore::RenderBox::computePositionedLogicalWidthReplaced):
     62        (WebCore::RenderBox::computePositionedLogicalHeightReplaced):
     63        (WebCore::RenderBox::offsetFromLogicalTopOfFirstPage):
     64        * rendering/RenderBox.h:
     65        * rendering/RenderFlexibleBox.cpp:
     66        (WebCore::RenderFlexibleBox::computeMainAxisExtentForChild):
     67        * rendering/RenderFlowThread.cpp:
     68        (WebCore::RenderFlowThread::logicalWidthChangedInRegionsForBlock):
     69        (WebCore::RenderFlowThread::hasCachedOffsetFromLogicalTopOfFirstRegion):
     70        (WebCore::RenderFlowThread::cachedOffsetFromLogicalTopOfFirstRegion):
     71        (WebCore::RenderFlowThread::setOffsetFromLogicalTopOfFirstRegion):
     72        (WebCore::RenderFlowThread::clearOffsetFromLogicalTopOfFirstRegion):
     73        (WebCore::RenderFlowThread::currentActiveRenderBox):
     74        (WebCore::RenderFlowThread::pushFlowThreadLayoutState):
     75        (WebCore::RenderFlowThread::popFlowThreadLayoutState):
     76        (WebCore::RenderFlowThread::offsetFromLogicalTopOfFirstRegion):
     77        (WebCore::RenderFlowThread::adjustedPositionRelativeToOffsetParent):
     78        * rendering/RenderFlowThread.h:
     79        * rendering/RenderTable.cpp:
     80        (WebCore::RenderTable::updateLogicalWidth):
     81        * rendering/RenderView.cpp:
     82        (WebCore::RenderView::pushLayoutState):
     83        (WebCore::RenderView::pushLayoutStateForCurrentFlowThread):
     84        (WebCore::RenderView::popLayoutStateForCurrentFlowThread):
     85        * rendering/RenderView.h:
     86        (WebCore::RenderView::pushLayoutState):
     87        (WebCore::RenderView::popLayoutState):
     88
    1892013-05-27  Allan Sandfeld Jensen  <allan.jensen@digia.com>
    290
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r150611 r150743  
    23722372}
    23732373
    2374 LayoutUnit RenderBlock::computeStartPositionDeltaForChildAvoidingFloats(const RenderBox* child, LayoutUnit childMarginStart,
    2375     RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage)
    2376 {
    2377     LayoutUnit startPosition = startOffsetForContent(region, offsetFromLogicalTopOfFirstPage);
     2374LayoutUnit RenderBlock::computeStartPositionDeltaForChildAvoidingFloats(const RenderBox* child, LayoutUnit childMarginStart, RenderRegion* region)
     2375{
     2376    LayoutUnit startPosition = startOffsetForContent(region);
    23782377
    23792378    // Add in our start margin.
     
    23832382    LayoutUnit blockOffset = logicalTopForChild(child);
    23842383    if (region)
    2385         blockOffset = max(blockOffset, blockOffset + (region->logicalTopForFlowThreadContent() - offsetFromLogicalTopOfFirstPage));
    2386 
    2387     LayoutUnit startOff = startOffsetForLine(blockOffset, false, region, offsetFromLogicalTopOfFirstPage, logicalHeightForChild(child));
     2384        blockOffset = max(blockOffset, blockOffset + (region->logicalTopForFlowThreadContent() - offsetFromLogicalTopOfFirstPage()));
     2385
     2386    LayoutUnit startOff = startOffsetForLine(blockOffset, false, region, logicalHeightForChild(child));
    23882387
    23892388    if (style()->textAlign() != WEBKIT_CENTER && !child->style()->marginStartUsing(style()).isAuto()) {
     
    43924391}
    43934392
    4394 LayoutUnit RenderBlock::logicalLeftOffsetForContent(RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage) const
     4393LayoutUnit RenderBlock::logicalLeftOffsetForContent(RenderRegion* region) const
    43954394{
    43964395    LayoutUnit logicalLeftOffset = style()->isHorizontalWritingMode() ? borderLeft() + paddingLeft() : borderTop() + paddingTop();
    43974396    if (!region)
    43984397        return logicalLeftOffset;
    4399     LayoutRect boxRect = borderBoxRectInRegion(region, offsetFromLogicalTopOfFirstPage);
     4398    LayoutRect boxRect = borderBoxRectInRegion(region);
    44004399    return logicalLeftOffset + (isHorizontalWritingMode() ? boxRect.x() : boxRect.y());
    44014400}
    44024401
    4403 LayoutUnit RenderBlock::logicalRightOffsetForContent(RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage) const
     4402LayoutUnit RenderBlock::logicalRightOffsetForContent(RenderRegion* region) const
    44044403{
    44054404    LayoutUnit logicalRightOffset = style()->isHorizontalWritingMode() ? borderLeft() + paddingLeft() : borderTop() + paddingTop();
     
    44074406    if (!region)
    44084407        return logicalRightOffset;
    4409     LayoutRect boxRect = borderBoxRectInRegion(region, offsetFromLogicalTopOfFirstPage);
     4408    LayoutRect boxRect = borderBoxRectInRegion(region);
    44104409    return logicalRightOffset - (logicalWidth() - (isHorizontalWritingMode() ? boxRect.maxX() : boxRect.maxY()));
    44114410}
     
    49344933
    49354934            RenderRegion* region = regionAtBlockOffset(logicalTopForChild(child));
    4936             LayoutRect borderBox = child->borderBoxRectInRegion(region, offsetFromLogicalTopOfFirstPage() + logicalTopForChild(child), DoNotCacheRenderBoxRegionInfo);
     4935            LayoutRect borderBox = child->borderBoxRectInRegion(region, DoNotCacheRenderBoxRegionInfo);
    49374936            LayoutUnit childLogicalWidthAtOldLogicalTopOffset = isHorizontalWritingMode() ? borderBox.width() : borderBox.height();
    49384937
     
    49464945            child->updateLogicalWidth();
    49474946            region = regionAtBlockOffset(logicalTopForChild(child));
    4948             borderBox = child->borderBoxRectInRegion(region, offsetFromLogicalTopOfFirstPage() + logicalTopForChild(child), DoNotCacheRenderBoxRegionInfo);
     4947            borderBox = child->borderBoxRectInRegion(region, DoNotCacheRenderBoxRegionInfo);
    49494948            LayoutUnit childLogicalWidthAtNewLogicalTopOffset = isHorizontalWritingMode() ? borderBox.width() : borderBox.height();
    49504949
     
    76717670    if (rootBox->containingRegion() == currentRegion)
    76727671        return false;
    7673     return rootBox->paginatedLineWidth() != availableLogicalWidthForContent(currentRegion, offsetFromLogicalTopOfFirstPage());
     7672    return rootBox->paginatedLineWidth() != availableLogicalWidthForContent(currentRegion);
    76747673}
    76757674
     
    76797678    if (layoutState && !layoutState->isPaginated())
    76807679        return 0;
     7680
     7681    RenderFlowThread* flowThread = flowThreadContainingBlock();
     7682    if (flowThread)
     7683        return flowThread->offsetFromLogicalTopOfFirstRegion(this);
     7684
    76817685    if (layoutState) {
    7682         // FIXME: Sanity check that the renderer in the layout state is ours, since otherwise the computation will be off.
    7683         // Right now this assert gets hit inside computeLogicalHeight for percentage margins, since they're computed using
    7684         // widths which can vary in each region. Until we patch that, we can't have this assert.
    7685         // ASSERT(layoutState->m_renderer == this);
     7686        ASSERT(layoutState->m_renderer == this);
    76867687
    76877688        LayoutSize offsetDelta = layoutState->m_layoutOffset - layoutState->m_pageOffset;
    76887689        return isHorizontalWritingMode() ? offsetDelta.height() : offsetDelta.width();
    76897690    }
    7690     // FIXME: Right now, this assert is hit outside layout, from logicalLeftSelectionOffset in selectionGapRectsForRepaint (called from FrameSelection::selectAll).
    7691     // ASSERT(inRenderFlowThread());
    7692 
    7693     // FIXME: This is a slower path that doesn't use layout state and relies on getting your logical top inside the enclosing flow thread. It doesn't
    7694     // work with columns or pages currently, but it should once they have been switched over to using flow threads.
    7695     RenderFlowThread* flowThread = flowThreadContainingBlock();
    7696     if (!flowThread)
    7697         return 0;
    7698 
    7699     const RenderBlock* currentBlock = this;
    7700     LayoutRect blockRect(0, 0, width(), height());
    7701 
    7702     while (currentBlock && !currentBlock->isRenderFlowThread()) {
    7703         RenderBlock* containerBlock = currentBlock->containingBlock();
    7704         ASSERT(containerBlock);
    7705         if (!containerBlock)
    7706             return 0;
    7707         LayoutPoint currentBlockLocation = currentBlock->location();
    7708 
    7709         if (containerBlock->style()->writingMode() != currentBlock->style()->writingMode()) {
    7710             // We have to put the block rect in container coordinates
    7711             // and we have to take into account both the container and current block flipping modes
    7712             if (containerBlock->style()->isFlippedBlocksWritingMode()) {
    7713                 if (containerBlock->isHorizontalWritingMode())
    7714                     blockRect.setY(currentBlock->height() - blockRect.maxY());
    7715                 else
    7716                     blockRect.setX(currentBlock->width() - blockRect.maxX());
    7717             }
    7718             currentBlock->flipForWritingMode(blockRect);
    7719         }
    7720         blockRect.moveBy(currentBlockLocation);
    7721         currentBlock = containerBlock;
    7722     };
    7723     return currentBlock->isHorizontalWritingMode() ? blockRect.y() : blockRect.x();
     7691   
     7692    ASSERT_NOT_REACHED();
     7693    return 0;
    77247694}
    77257695
     
    77557725        return false;
    77567726   
    7757     return flowThread->logicalWidthChangedInRegions(this, offsetFromLogicalTopOfFirstPage());
     7727    return flowThread->logicalWidthChangedInRegionsForBlock(this);
    77587728}
    77597729
  • trunk/Source/WebCore/rendering/RenderBlock.h

    r150527 r150743  
    168168    // Versions that can compute line offsets with the region and page offset passed in. Used for speed to avoid having to
    169169    // compute the region all over again when you already know it.
    170     LayoutUnit availableLogicalWidthForLine(LayoutUnit position, bool shouldIndentText, RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage, LayoutUnit logicalHeight = 0) const
    171     {
    172         return max<LayoutUnit>(0, logicalRightOffsetForLine(position, shouldIndentText, region, offsetFromLogicalTopOfFirstPage, logicalHeight)
    173             - logicalLeftOffsetForLine(position, shouldIndentText, region, offsetFromLogicalTopOfFirstPage, logicalHeight));
    174     }
    175     LayoutUnit logicalRightOffsetForLine(LayoutUnit position, bool shouldIndentText, RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage, LayoutUnit logicalHeight = 0, ShapeOutsideFloatOffsetMode offsetMode = ShapeOutsideFloatShapeOffset) const
    176     {
    177         return logicalRightOffsetForLine(position, logicalRightOffsetForContent(region, offsetFromLogicalTopOfFirstPage), shouldIndentText, 0, logicalHeight, offsetMode);
    178     }
    179     LayoutUnit logicalLeftOffsetForLine(LayoutUnit position, bool shouldIndentText, RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage, LayoutUnit logicalHeight = 0, ShapeOutsideFloatOffsetMode offsetMode = ShapeOutsideFloatShapeOffset) const
    180     {
    181         return logicalLeftOffsetForLine(position, logicalLeftOffsetForContent(region, offsetFromLogicalTopOfFirstPage), shouldIndentText, 0, logicalHeight, offsetMode);
    182     }
    183     LayoutUnit startOffsetForLine(LayoutUnit position, bool shouldIndentText, RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage, LayoutUnit logicalHeight = 0) const
    184     {
    185         return style()->isLeftToRightDirection() ? logicalLeftOffsetForLine(position, shouldIndentText, region, offsetFromLogicalTopOfFirstPage, logicalHeight)
    186             : logicalWidth() - logicalRightOffsetForLine(position, shouldIndentText, region, offsetFromLogicalTopOfFirstPage, logicalHeight);
    187     }
    188     LayoutUnit endOffsetForLine(LayoutUnit position, bool shouldIndentText, RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage, LayoutUnit logicalHeight = 0) const
    189     {
    190         return !style()->isLeftToRightDirection() ? logicalLeftOffsetForLine(position, shouldIndentText, region, offsetFromLogicalTopOfFirstPage, logicalHeight)
    191             : logicalWidth() - logicalRightOffsetForLine(position, shouldIndentText, region, offsetFromLogicalTopOfFirstPage, logicalHeight);
     170    LayoutUnit availableLogicalWidthForLine(LayoutUnit position, bool shouldIndentText, RenderRegion* region, LayoutUnit logicalHeight = 0) const
     171    {
     172        return max<LayoutUnit>(0, logicalRightOffsetForLine(position, shouldIndentText, region, logicalHeight)
     173            - logicalLeftOffsetForLine(position, shouldIndentText, region, logicalHeight));
     174    }
     175    LayoutUnit logicalRightOffsetForLine(LayoutUnit position, bool shouldIndentText, RenderRegion* region, LayoutUnit logicalHeight = 0, ShapeOutsideFloatOffsetMode offsetMode = ShapeOutsideFloatShapeOffset) const
     176    {
     177        return logicalRightOffsetForLine(position, logicalRightOffsetForContent(region), shouldIndentText, 0, logicalHeight, offsetMode);
     178    }
     179    LayoutUnit logicalLeftOffsetForLine(LayoutUnit position, bool shouldIndentText, RenderRegion* region, LayoutUnit logicalHeight = 0, ShapeOutsideFloatOffsetMode offsetMode = ShapeOutsideFloatShapeOffset) const
     180    {
     181        return logicalLeftOffsetForLine(position, logicalLeftOffsetForContent(region), shouldIndentText, 0, logicalHeight, offsetMode);
     182    }
     183    LayoutUnit startOffsetForLine(LayoutUnit position, bool shouldIndentText, RenderRegion* region, LayoutUnit logicalHeight = 0) const
     184    {
     185        return style()->isLeftToRightDirection() ? logicalLeftOffsetForLine(position, shouldIndentText, region, logicalHeight)
     186            : logicalWidth() - logicalRightOffsetForLine(position, shouldIndentText, region, logicalHeight);
     187    }
     188    LayoutUnit endOffsetForLine(LayoutUnit position, bool shouldIndentText, RenderRegion* region, LayoutUnit logicalHeight = 0) const
     189    {
     190        return !style()->isLeftToRightDirection() ? logicalLeftOffsetForLine(position, shouldIndentText, region, logicalHeight)
     191            : logicalWidth() - logicalRightOffsetForLine(position, shouldIndentText, region, logicalHeight);
    192192    }
    193193
    194194    LayoutUnit availableLogicalWidthForLine(LayoutUnit position, bool shouldIndentText, LayoutUnit logicalHeight = 0) const
    195195    {
    196         return availableLogicalWidthForLine(position, shouldIndentText, regionAtBlockOffset(position), offsetFromLogicalTopOfFirstPage(), logicalHeight);
     196        return availableLogicalWidthForLine(position, shouldIndentText, regionAtBlockOffset(position), logicalHeight);
    197197    }
    198198    LayoutUnit logicalRightOffsetForLine(LayoutUnit position, bool shouldIndentText, LayoutUnit logicalHeight = 0, ShapeOutsideFloatOffsetMode offsetMode = ShapeOutsideFloatShapeOffset) const
     
    395395    virtual void scrollbarsChanged(bool /*horizontalScrollbarChanged*/, bool /*verticalScrollbarChanged*/) { };
    396396
    397     LayoutUnit logicalLeftOffsetForContent(RenderRegion*, LayoutUnit offsetFromLogicalTopOfFirstPage) const;
    398     LayoutUnit logicalRightOffsetForContent(RenderRegion*, LayoutUnit offsetFromLogicalTopOfFirstPage) const;
    399     LayoutUnit availableLogicalWidthForContent(RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage) const
     397    LayoutUnit logicalLeftOffsetForContent(RenderRegion*) const;
     398    LayoutUnit logicalRightOffsetForContent(RenderRegion*) const;
     399    LayoutUnit availableLogicalWidthForContent(RenderRegion* region) const
    400400    {
    401         return max<LayoutUnit>(0, logicalRightOffsetForContent(region, offsetFromLogicalTopOfFirstPage) -
    402             logicalLeftOffsetForContent(region, offsetFromLogicalTopOfFirstPage)); }
    403     LayoutUnit startOffsetForContent(RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage) const
    404     {
    405         return style()->isLeftToRightDirection() ? logicalLeftOffsetForContent(region, offsetFromLogicalTopOfFirstPage)
    406             : logicalWidth() - logicalRightOffsetForContent(region, offsetFromLogicalTopOfFirstPage);
    407     }
    408     LayoutUnit endOffsetForContent(RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage) const
    409     {
    410         return !style()->isLeftToRightDirection() ? logicalLeftOffsetForContent(region, offsetFromLogicalTopOfFirstPage)
    411             : logicalWidth() - logicalRightOffsetForContent(region, offsetFromLogicalTopOfFirstPage);
     401        return max<LayoutUnit>(0, logicalRightOffsetForContent(region) - logicalLeftOffsetForContent(region)); }
     402    LayoutUnit startOffsetForContent(RenderRegion* region) const
     403    {
     404        return style()->isLeftToRightDirection() ? logicalLeftOffsetForContent(region) : logicalWidth() - logicalRightOffsetForContent(region);
     405    }
     406    LayoutUnit endOffsetForContent(RenderRegion* region) const
     407    {
     408        return !style()->isLeftToRightDirection() ? logicalLeftOffsetForContent(region) : logicalWidth() - logicalRightOffsetForContent(region);
    412409    }
    413410    LayoutUnit logicalLeftOffsetForContent(LayoutUnit blockOffset) const
    414411    {
    415         return logicalLeftOffsetForContent(regionAtBlockOffset(blockOffset), offsetFromLogicalTopOfFirstPage());
     412        return logicalLeftOffsetForContent(regionAtBlockOffset(blockOffset));
    416413    }
    417414    LayoutUnit logicalRightOffsetForContent(LayoutUnit blockOffset) const
    418415    {
    419         return logicalRightOffsetForContent(regionAtBlockOffset(blockOffset), offsetFromLogicalTopOfFirstPage());
     416        return logicalRightOffsetForContent(regionAtBlockOffset(blockOffset));
    420417    }
    421418    LayoutUnit availableLogicalWidthForContent(LayoutUnit blockOffset) const
    422419    {
    423         return availableLogicalWidthForContent(regionAtBlockOffset(blockOffset), offsetFromLogicalTopOfFirstPage());
     420        return availableLogicalWidthForContent(regionAtBlockOffset(blockOffset));
    424421    }
    425422    LayoutUnit startOffsetForContent(LayoutUnit blockOffset) const
    426423    {
    427         return startOffsetForContent(regionAtBlockOffset(blockOffset), offsetFromLogicalTopOfFirstPage());
     424        return startOffsetForContent(regionAtBlockOffset(blockOffset));
    428425    }
    429426    LayoutUnit endOffsetForContent(LayoutUnit blockOffset) const
    430427    {
    431         return endOffsetForContent(regionAtBlockOffset(blockOffset), offsetFromLogicalTopOfFirstPage());
     428        return endOffsetForContent(regionAtBlockOffset(blockOffset));
    432429    }
    433430    LayoutUnit logicalLeftOffsetForContent() const { return isHorizontalWritingMode() ? borderLeft() + paddingLeft() : borderTop() + paddingTop(); }
     
    439436    void updateStaticInlinePositionForChild(RenderBox*, LayoutUnit logicalTop);
    440437
    441     LayoutUnit computeStartPositionDeltaForChildAvoidingFloats(const RenderBox* child, LayoutUnit childMarginStart, RenderRegion* = 0, LayoutUnit offsetFromLogicalTopOfFirstPage = 0);
     438    LayoutUnit computeStartPositionDeltaForChildAvoidingFloats(const RenderBox* child, LayoutUnit childMarginStart, RenderRegion* = 0);
    442439
    443440    void placeRunInIfNeeded(RenderObject* newChild);
     
    11441141
    11451142public:
    1146     LayoutUnit offsetFromLogicalTopOfFirstPage() const;
     1143    virtual LayoutUnit offsetFromLogicalTopOfFirstPage() const;
    11471144    RenderRegion* regionAtBlockOffset(LayoutUnit) const;
    11481145    RenderRegion* clampToStartAndEndRegions(RenderRegion*) const;
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r150503 r150743  
    110110}
    111111
    112 LayoutRect RenderBox::borderBoxRectInRegion(RenderRegion* region, LayoutUnit offsetFromTopOfFirstPage, RenderBoxRegionInfoFlags cacheFlag) const
     112LayoutRect RenderBox::borderBoxRectInRegion(RenderRegion* region, RenderBoxRegionInfoFlags cacheFlag) const
    113113{
    114114    if (!region)
     
    116116   
    117117    // Compute the logical width and placement in this region.
    118     RenderBoxRegionInfo* boxInfo = renderBoxRegionInfo(region, offsetFromTopOfFirstPage, cacheFlag);
     118    RenderBoxRegionInfo* boxInfo = renderBoxRegionInfo(region, cacheFlag);
    119119    if (!boxInfo)
    120120        return borderBoxRect();
     
    127127    // FIXME: Doesn't work right with perpendicular writing modes.
    128128    const RenderBlock* currentBox = containingBlock();
    129     offsetFromTopOfFirstPage -= logicalTop();
    130     RenderBoxRegionInfo* currentBoxInfo = currentBox->renderBoxRegionInfo(region, offsetFromTopOfFirstPage);
     129    RenderBoxRegionInfo* currentBoxInfo = currentBox->renderBoxRegionInfo(region);
    131130    while (currentBoxInfo && currentBoxInfo->isShifted()) {
    132131        if (currentBox->style()->direction() == LTR)
     
    134133        else
    135134            logicalLeft -= (currentBox->logicalWidth() - currentBoxInfo->logicalWidth()) - currentBoxInfo->logicalLeft();
    136         offsetFromTopOfFirstPage -= logicalTop();
    137135        currentBox = currentBox->containingBlock();
    138136        region = currentBox->clampToStartAndEndRegions(region);
    139         currentBoxInfo = currentBox->renderBoxRegionInfo(region, offsetFromTopOfFirstPage);
     137        currentBoxInfo = currentBox->renderBoxRegionInfo(region);
    140138    }
    141139   
     
    492490}
    493491
    494 LayoutUnit RenderBox::constrainLogicalWidthInRegionByMinMax(LayoutUnit logicalWidth, LayoutUnit availableWidth, RenderBlock* cb, RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage) const
     492LayoutUnit RenderBox::constrainLogicalWidthInRegionByMinMax(LayoutUnit logicalWidth, LayoutUnit availableWidth, RenderBlock* cb, RenderRegion* region) const
    495493{
    496494    RenderStyle* styleToUse = style();
    497495    if (!styleToUse->logicalMaxWidth().isUndefined())
    498         logicalWidth = min(logicalWidth, computeLogicalWidthInRegionUsing(MaxSize, styleToUse->logicalMaxWidth(), availableWidth, cb, region, offsetFromLogicalTopOfFirstPage));
    499     return max(logicalWidth, computeLogicalWidthInRegionUsing(MinSize, styleToUse->logicalMinWidth(), availableWidth, cb, region, offsetFromLogicalTopOfFirstPage));
     496        logicalWidth = min(logicalWidth, computeLogicalWidthInRegionUsing(MaxSize, styleToUse->logicalMaxWidth(), availableWidth, cb, region));
     497    return max(logicalWidth, computeLogicalWidthInRegionUsing(MinSize, styleToUse->logicalMinWidth(), availableWidth, cb, region));
    500498}
    501499
     
    16001598}
    16011599
    1602 LayoutUnit RenderBox::shrinkLogicalWidthToAvoidFloats(LayoutUnit childMarginStart, LayoutUnit childMarginEnd, const RenderBlock* cb, RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage) const
     1600LayoutUnit RenderBox::shrinkLogicalWidthToAvoidFloats(LayoutUnit childMarginStart, LayoutUnit childMarginEnd, const RenderBlock* cb, RenderRegion* region) const
    16031601{   
    16041602    RenderRegion* containingBlockRegion = 0;
    16051603    LayoutUnit logicalTopPosition = logicalTop();
    1606     LayoutUnit adjustedPageOffsetForContainingBlock = offsetFromLogicalTopOfFirstPage - logicalTop();
    16071604    if (region) {
    1608         LayoutUnit offsetFromLogicalTopOfRegion = region ? region->logicalTopForFlowThreadContent() - offsetFromLogicalTopOfFirstPage : LayoutUnit();
     1605        LayoutUnit offsetFromLogicalTopOfRegion = region ? region->logicalTopForFlowThreadContent() - offsetFromLogicalTopOfFirstPage() : LayoutUnit();
    16091606        logicalTopPosition = max(logicalTopPosition, logicalTopPosition + offsetFromLogicalTopOfRegion);
    16101607        containingBlockRegion = cb->clampToStartAndEndRegions(region);
    16111608    }
    16121609
    1613     LayoutUnit result = cb->availableLogicalWidthForLine(logicalTopPosition, false, containingBlockRegion, adjustedPageOffsetForContainingBlock) - childMarginStart - childMarginEnd;
     1610    LayoutUnit result = cb->availableLogicalWidthForLine(logicalTopPosition, false, containingBlockRegion) - childMarginStart - childMarginEnd;
    16141611
    16151612    // We need to see if margins on either the start side or the end side can contain the floats in question. If they can,
     
    16191616    // "consumed" by the float. Negative margins aren't consumed by the float, and so we ignore them.
    16201617    if (childMarginStart > 0) {
    1621         LayoutUnit startContentSide = cb->startOffsetForContent(containingBlockRegion, adjustedPageOffsetForContainingBlock);
     1618        LayoutUnit startContentSide = cb->startOffsetForContent(containingBlockRegion);
    16221619        LayoutUnit startContentSideWithMargin = startContentSide + childMarginStart;
    1623         LayoutUnit startOffset = cb->startOffsetForLine(logicalTopPosition, false, containingBlockRegion, adjustedPageOffsetForContainingBlock);
     1620        LayoutUnit startOffset = cb->startOffsetForLine(logicalTopPosition, false, containingBlockRegion);
    16241621        if (startOffset > startContentSideWithMargin)
    16251622            result += childMarginStart;
     
    16291626   
    16301627    if (childMarginEnd > 0) {
    1631         LayoutUnit endContentSide = cb->endOffsetForContent(containingBlockRegion, adjustedPageOffsetForContainingBlock);
     1628        LayoutUnit endContentSide = cb->endOffsetForContent(containingBlockRegion);
    16321629        LayoutUnit endContentSideWithMargin = endContentSide + childMarginEnd;
    1633         LayoutUnit endOffset = cb->endOffsetForLine(logicalTopPosition, false, containingBlockRegion, adjustedPageOffsetForContainingBlock);
     1630        LayoutUnit endOffset = cb->endOffsetForLine(logicalTopPosition, false, containingBlockRegion);
    16341631        if (endOffset > endContentSideWithMargin)
    16351632            result += childMarginEnd;
     
    16591656}
    16601657
    1661 LayoutUnit RenderBox::containingBlockLogicalWidthForContentInRegion(RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage) const
     1658LayoutUnit RenderBox::containingBlockLogicalWidthForContentInRegion(RenderRegion* region) const
    16621659{
    16631660    if (!region)
     
    16691666    // If it should, the following line should call containingBlockLogicalWidthForContent.
    16701667    LayoutUnit result = cb->availableLogicalWidth();
    1671     RenderBoxRegionInfo* boxInfo = cb->renderBoxRegionInfo(containingBlockRegion, offsetFromLogicalTopOfFirstPage - logicalTop());
     1668    RenderBoxRegionInfo* boxInfo = cb->renderBoxRegionInfo(containingBlockRegion);
    16721669    if (!boxInfo)
    16731670        return result;
     
    16751672}
    16761673
    1677 LayoutUnit RenderBox::containingBlockAvailableLineWidthInRegion(RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage) const
     1674LayoutUnit RenderBox::containingBlockAvailableLineWidthInRegion(RenderRegion* region) const
    16781675{
    16791676    RenderBlock* cb = containingBlock();
    16801677    RenderRegion* containingBlockRegion = 0;
    16811678    LayoutUnit logicalTopPosition = logicalTop();
    1682     LayoutUnit adjustedPageOffsetForContainingBlock = offsetFromLogicalTopOfFirstPage - logicalTop();
    16831679    if (region) {
    1684         LayoutUnit offsetFromLogicalTopOfRegion = region ? region->logicalTopForFlowThreadContent() - offsetFromLogicalTopOfFirstPage : LayoutUnit();
     1680        LayoutUnit offsetFromLogicalTopOfRegion = region ? region->logicalTopForFlowThreadContent() - offsetFromLogicalTopOfFirstPage() : LayoutUnit();
    16851681        logicalTopPosition = max(logicalTopPosition, logicalTopPosition + offsetFromLogicalTopOfRegion);
    16861682        containingBlockRegion = cb->clampToStartAndEndRegions(region);
    16871683    }
    1688     return cb->availableLogicalWidthForLine(logicalTopPosition, false, containingBlockRegion, adjustedPageOffsetForContainingBlock, availableLogicalHeight(IncludeMarginBorderPadding));
     1684    return cb->availableLogicalWidthForLine(logicalTopPosition, false, containingBlockRegion, availableLogicalHeight(IncludeMarginBorderPadding));
    16891685}
    16901686
     
    20822078}
    20832079
    2084 void RenderBox::computeLogicalWidthInRegion(LogicalExtentComputedValues& computedValues, RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage) const
     2080void RenderBox::computeLogicalWidthInRegion(LogicalExtentComputedValues& computedValues, RenderRegion* region) const
    20852081{
    20862082    computedValues.m_extent = logicalWidth();
     
    20922088        // FIXME: This calculation is not patched for block-flow yet.
    20932089        // https://bugs.webkit.org/show_bug.cgi?id=46500
    2094         computePositionedLogicalWidth(computedValues, region, offsetFromLogicalTopOfFirstPage);
     2090        computePositionedLogicalWidth(computedValues, region);
    20952091        return;
    20962092    }
     
    21192115
    21202116    RenderBlock* cb = containingBlock();
    2121     LayoutUnit containerLogicalWidth = max<LayoutUnit>(0, containingBlockLogicalWidthForContentInRegion(region, offsetFromLogicalTopOfFirstPage));
     2117    LayoutUnit containerLogicalWidth = max<LayoutUnit>(0, containingBlockLogicalWidthForContentInRegion(region));
    21222118    bool hasPerpendicularContainingBlock = cb->isHorizontalWritingMode() != isHorizontalWritingMode();
    21232119   
     
    21392135        if (hasPerpendicularContainingBlock)
    21402136            containerWidthInInlineDirection = perpendicularContainingBlockLogicalHeight();
    2141         LayoutUnit preferredWidth = computeLogicalWidthInRegionUsing(MainOrPreferredSize, styleToUse->logicalWidth(), containerWidthInInlineDirection, cb, region, offsetFromLogicalTopOfFirstPage);
    2142         computedValues.m_extent = constrainLogicalWidthInRegionByMinMax(preferredWidth, containerWidthInInlineDirection, cb, region, offsetFromLogicalTopOfFirstPage);
     2137        LayoutUnit preferredWidth = computeLogicalWidthInRegionUsing(MainOrPreferredSize, styleToUse->logicalWidth(), containerWidthInInlineDirection, cb, region);
     2138        computedValues.m_extent = constrainLogicalWidthInRegionByMinMax(preferredWidth, containerWidthInInlineDirection, cb, region);
    21432139    }
    21442140
     
    21512147        LayoutUnit containerLogicalWidthForAutoMargins = containerLogicalWidth;
    21522148        if (avoidsFloats() && cb->containsFloats())
    2153             containerLogicalWidthForAutoMargins = containingBlockAvailableLineWidthInRegion(region, offsetFromLogicalTopOfFirstPage);
     2149            containerLogicalWidthForAutoMargins = containingBlockAvailableLineWidthInRegion(region);
    21542150        bool hasInvertedDirection = cb->style()->isLeftToRightDirection() != style()->isLeftToRightDirection();
    21552151        computeInlineDirectionMargins(cb, containerLogicalWidthForAutoMargins, computedValues.m_extent,
     
    22102206
    22112207LayoutUnit RenderBox::computeLogicalWidthInRegionUsing(SizeType widthType, Length logicalWidth, LayoutUnit availableLogicalWidth,
    2212     const RenderBlock* cb, RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage) const
     2208    const RenderBlock* cb, RenderRegion* region) const
    22132209{
    22142210    if (!logicalWidth.isIntrinsicOrAuto()) {
     
    22252221
    22262222    if (shrinkToAvoidFloats() && cb->containsFloats())
    2227         logicalWidthResult = min(logicalWidthResult, shrinkLogicalWidthToAvoidFloats(marginStart, marginEnd, cb, region, offsetFromLogicalTopOfFirstPage));       
     2223        logicalWidthResult = min(logicalWidthResult, shrinkLogicalWidthToAvoidFloats(marginStart, marginEnd, cb, region));       
    22282224
    22292225    if (widthType == MainOrPreferredSize && sizesLogicalWidthToFitContent(widthType))
     
    23532349}
    23542350
    2355 RenderBoxRegionInfo* RenderBox::renderBoxRegionInfo(RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage, RenderBoxRegionInfoFlags cacheFlag) const
     2351RenderBoxRegionInfo* RenderBox::renderBoxRegionInfo(RenderRegion* region, RenderBoxRegionInfoFlags cacheFlag) const
    23562352{
    23572353    // Make sure nobody is trying to call this with a null region.
     
    23732369
    23742370    LogicalExtentComputedValues computedValues;
    2375     computeLogicalWidthInRegion(computedValues, region, offsetFromLogicalTopOfFirstPage);
     2371    computeLogicalWidthInRegion(computedValues, region);
    23762372
    23772373    // Now determine the insets based off where this object is supposed to be positioned.
    23782374    RenderBlock* cb = containingBlock();
    23792375    RenderRegion* clampedContainingBlockRegion = cb->clampToStartAndEndRegions(region);
    2380     RenderBoxRegionInfo* containingBlockInfo = cb->renderBoxRegionInfo(clampedContainingBlockRegion,
    2381         offsetFromLogicalTopOfFirstPage - logicalTop());
     2376    RenderBoxRegionInfo* containingBlockInfo = cb->renderBoxRegionInfo(clampedContainingBlockRegion);
    23822377    LayoutUnit containingBlockLogicalWidth = cb->logicalWidth();
    23832378    LayoutUnit containingBlockLogicalWidthInRegion = containingBlockInfo ? containingBlockInfo->logicalWidth() : containingBlockLogicalWidth;
     
    23962391   
    23972392    if (!isOutOfFlowPositioned() && avoidsFloats() && cb->containsFloats()) {
    2398         LayoutUnit startPositionDelta = cb->computeStartPositionDeltaForChildAvoidingFloats(this, marginStartInRegion, region, offsetFromLogicalTopOfFirstPage);
     2393        LayoutUnit startPositionDelta = cb->computeStartPositionDeltaForChildAvoidingFloats(this, marginStartInRegion, region);
    23992394        if (cb->style()->isLeftToRightDirection())
    24002395            logicalLeftDelta += startPositionDelta;
     
    29022897}
    29032898
    2904 LayoutUnit RenderBox::containingBlockLogicalWidthForPositioned(const RenderBoxModelObject* containingBlock, RenderRegion* region,
    2905     LayoutUnit offsetFromLogicalTopOfFirstPage, bool checkForPerpendicularWritingMode) const
     2899LayoutUnit RenderBox::containingBlockLogicalWidthForPositioned(const RenderBoxModelObject* containingBlock, RenderRegion* region, bool checkForPerpendicularWritingMode) const
    29062900{
    29072901    // Container for position:fixed is the frame.
     
    29252919                return toRenderFlowThread(containingBlock)->contentLogicalWidthOfFirstRegion();
    29262920            if (isWritingModeRoot()) {
    2927                 LayoutUnit cbPageOffset = offsetFromLogicalTopOfFirstPage - logicalTop();
     2921                LayoutUnit cbPageOffset = cb->offsetFromLogicalTopOfFirstPage();
    29282922                RenderRegion* cbRegion = cb->regionAtBlockOffset(cbPageOffset);
    29292923                if (cbRegion) {
    29302924                    cbRegion = cb->clampToStartAndEndRegions(cbRegion);
    2931                     boxInfo = cb->renderBoxRegionInfo(cbRegion, cbPageOffset);
     2925                    boxInfo = cb->renderBoxRegionInfo(cbRegion);
    29322926                }
    29332927            }
    29342928        } else if (region && flowThread->isHorizontalWritingMode() == containingBlock->isHorizontalWritingMode()) {
    29352929            RenderRegion* containingBlockRegion = cb->clampToStartAndEndRegions(region);
    2936             boxInfo = cb->renderBoxRegionInfo(containingBlockRegion, offsetFromLogicalTopOfFirstPage - logicalTop());
     2930            boxInfo = cb->renderBoxRegionInfo(containingBlockRegion);
    29372931        }
    29382932        return (boxInfo) ? max<LayoutUnit>(0, cb->clientLogicalWidth() - (cb->logicalWidth() - boxInfo->logicalWidth())) : cb->clientLogicalWidth();
     
    29702964
    29712965    if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWritingMode() != isHorizontalWritingMode())
    2972         return containingBlockLogicalWidthForPositioned(containingBlock, 0, 0, false);
     2966        return containingBlockLogicalWidthForPositioned(containingBlock, 0, false);
    29732967
    29742968    if (containingBlock->isBox()) {
     
    30153009                    const RenderBlock* cb = toRenderBlock(curr);
    30163010                    region = cb->clampToStartAndEndRegions(region);
    3017                     RenderBoxRegionInfo* boxInfo = cb->renderBoxRegionInfo(region, region->logicalTopForFlowThreadContent());
     3011                    RenderBoxRegionInfo* boxInfo = cb->renderBoxRegionInfo(region);
    30183012                    if (boxInfo)
    30193013                        staticPosition += boxInfo->logicalLeft();
     
    30323026                    staticPosition -= enclosingBox->logicalWidth();
    30333027                if (region && curr->isRenderBlock()) {
    3034                      const RenderBlock* cb = toRenderBlock(curr);
    3035                      region = cb->clampToStartAndEndRegions(region);
    3036                      RenderBoxRegionInfo* boxInfo = cb->renderBoxRegionInfo(region, region->logicalTopForFlowThreadContent());
    3037                      if (boxInfo) {
     3028                    const RenderBlock* cb = toRenderBlock(curr);
     3029                    region = cb->clampToStartAndEndRegions(region);
     3030                    RenderBoxRegionInfo* boxInfo = cb->renderBoxRegionInfo(region);
     3031                    if (boxInfo) {
    30383032                        if (curr != containerBlock)
    30393033                            staticPosition -= cb->logicalWidth() - (boxInfo->logicalLeft() + boxInfo->logicalWidth());
     
    30503044}
    30513045
    3052 void RenderBox::computePositionedLogicalWidth(LogicalExtentComputedValues& computedValues, RenderRegion* region, LayoutUnit offsetFromLogicalTopOfFirstPage) const
     3046void RenderBox::computePositionedLogicalWidth(LogicalExtentComputedValues& computedValues, RenderRegion* region) const
    30533047{
    30543048    if (isReplaced()) {
     
    30793073    const RenderBoxModelObject* containerBlock = toRenderBoxModelObject(container());
    30803074   
    3081     const LayoutUnit containerLogicalWidth = containingBlockLogicalWidthForPositioned(containerBlock, region, offsetFromLogicalTopOfFirstPage);
     3075    const LayoutUnit containerLogicalWidth = containingBlockLogicalWidthForPositioned(containerBlock, region);
    30823076
    30833077    // Use the container block's direction except when calculating the static distance
     
    31713165        LayoutUnit logicalLeftPos = computedValues.m_position;
    31723166        const RenderBlock* cb = toRenderBlock(containerBlock);
    3173         LayoutUnit cbPageOffset = offsetFromLogicalTopOfFirstPage - logicalTop();
     3167        LayoutUnit cbPageOffset = cb->offsetFromLogicalTopOfFirstPage();
    31743168        RenderRegion* cbRegion = cb->regionAtBlockOffset(cbPageOffset);
    31753169        if (cbRegion) {
    31763170            cbRegion = cb->clampToStartAndEndRegions(cbRegion);
    3177             RenderBoxRegionInfo* boxInfo = cb->renderBoxRegionInfo(cbRegion, cbPageOffset);
     3171            RenderBoxRegionInfo* boxInfo = cb->renderBoxRegionInfo(cbRegion);
    31783172            if (boxInfo) {
    31793173                logicalLeftPos += boxInfo->logicalLeft();
     
    32093203    LayoutUnit logicalLeftValue = 0;
    32103204
    3211     const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidthForPositioned(containerBlock, 0, 0, false);
     3205    const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidthForPositioned(containerBlock, 0, false);
    32123206
    32133207    bool logicalWidthIsAuto = logicalWidth.isIntrinsicOrAuto();
     
    34943488        if (cbRegion) {
    34953489            cbRegion = cb->clampToStartAndEndRegions(cbRegion);
    3496             RenderBoxRegionInfo* boxInfo = cb->renderBoxRegionInfo(cbRegion, cbPageOffset);
     3490            RenderBoxRegionInfo* boxInfo = cb->renderBoxRegionInfo(cbRegion);
    34973491            if (boxInfo) {
    34983492                logicalTopPos += boxInfo->logicalLeft();
     
    35373531    LayoutUnit contentLogicalHeight = logicalHeight - bordersPlusPadding;
    35383532
    3539     const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidthForPositioned(containerBlock, 0, 0, false);
     3533    const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidthForPositioned(containerBlock, 0, false);
    35403534
    35413535    LayoutUnit logicalTopValue = 0;
     
    36633657
    36643658    const LayoutUnit containerLogicalWidth = containingBlockLogicalWidthForPositioned(containerBlock);
    3665     const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidthForPositioned(containerBlock, 0, 0, false);
     3659    const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidthForPositioned(containerBlock, 0, false);
    36663660
    36673661    // To match WinIE, in quirks mode use the parent's 'direction' property
     
    38323826
    38333827    const LayoutUnit containerLogicalHeight = containingBlockLogicalHeightForPositioned(containerBlock);
    3834     const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidthForPositioned(containerBlock, 0, 0, false);
     3828    const LayoutUnit containerRelativeLogicalWidth = containingBlockLogicalWidthForPositioned(containerBlock, 0, false);
    38353829
    38363830    // Variables to solve.
     
    45994593}
    46004594
     4595LayoutUnit RenderBox::offsetFromLogicalTopOfFirstPage() const
     4596{
     4597    LayoutState* layoutState = view()->layoutState();
     4598    if ((layoutState && !layoutState->isPaginated()) || (!layoutState && !flowThreadContainingBlock()))
     4599        return 0;
     4600
     4601    RenderBlock* containerBlock = containingBlock();
     4602    return containerBlock->offsetFromLogicalTopOfFirstPage() + logicalTop();
     4603}
     4604
    46014605} // namespace WebCore
  • trunk/Source/WebCore/rendering/RenderBox.h

    r150312 r150743  
    8383    LayoutUnit logicalHeight() const { return style()->isHorizontalWritingMode() ? height() : width(); }
    8484
    85     LayoutUnit constrainLogicalWidthInRegionByMinMax(LayoutUnit, LayoutUnit, RenderBlock*, RenderRegion* = 0, LayoutUnit offsetFromLogicalTopOfFirstPage = 0) const;
     85    LayoutUnit constrainLogicalWidthInRegionByMinMax(LayoutUnit, LayoutUnit, RenderBlock*, RenderRegion* = 0) const;
    8686    LayoutUnit constrainLogicalHeightByMinMax(LayoutUnit) const;
    8787    LayoutUnit constrainContentBoxLogicalHeightByMinMax(LayoutUnit) const;
     
    361361
    362362    enum RenderBoxRegionInfoFlags { CacheRenderBoxRegionInfo, DoNotCacheRenderBoxRegionInfo };
    363     LayoutRect borderBoxRectInRegion(RenderRegion*, LayoutUnit offsetFromLogicalTopOfFirstPage = 0, RenderBoxRegionInfoFlags = CacheRenderBoxRegionInfo) const;
     363    LayoutRect borderBoxRectInRegion(RenderRegion*, RenderBoxRegionInfoFlags = CacheRenderBoxRegionInfo) const;
    364364    void clearRenderBoxRegionInfo();
     365    virtual LayoutUnit offsetFromLogicalTopOfFirstPage() const;
    365366   
    366367    void positionLineBox(InlineBox*);
     
    384385    LayoutUnit containingBlockLogicalHeightForContent(AvailableLogicalHeightType) const;
    385386
    386     LayoutUnit containingBlockLogicalWidthForContentInRegion(RenderRegion*, LayoutUnit offsetFromLogicalTopOfFirstPage) const;
    387     LayoutUnit containingBlockAvailableLineWidthInRegion(RenderRegion*, LayoutUnit offsetFromLogicalTopOfFirstPage) const;
     387    LayoutUnit containingBlockLogicalWidthForContentInRegion(RenderRegion*) const;
     388    LayoutUnit containingBlockAvailableLineWidthInRegion(RenderRegion*) const;
    388389    LayoutUnit perpendicularContainingBlockLogicalHeight() const;
    389390
     
    392393    virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop, LogicalExtentComputedValues&) const;
    393394
    394     RenderBoxRegionInfo* renderBoxRegionInfo(RenderRegion*, LayoutUnit offsetFromLogicalTopOfFirstPage, RenderBoxRegionInfoFlags = CacheRenderBoxRegionInfo) const;
    395     void computeLogicalWidthInRegion(LogicalExtentComputedValues&, RenderRegion* = 0, LayoutUnit offsetFromLogicalTopOfFirstPage = 0) const;
     395    RenderBoxRegionInfo* renderBoxRegionInfo(RenderRegion*, RenderBoxRegionInfoFlags = CacheRenderBoxRegionInfo) const;
     396    void computeLogicalWidthInRegion(LogicalExtentComputedValues&, RenderRegion* = 0) const;
    396397
    397398    bool stretchesToViewport() const
     
    408409    bool sizesLogicalWidthToFitContent(SizeType) const;
    409410
    410     LayoutUnit shrinkLogicalWidthToAvoidFloats(LayoutUnit childMarginStart, LayoutUnit childMarginEnd, const RenderBlock* cb, RenderRegion*, LayoutUnit offsetFromLogicalTopOfFirstPage) const;
    411 
    412     LayoutUnit computeLogicalWidthInRegionUsing(SizeType, Length logicalWidth, LayoutUnit availableLogicalWidth, const RenderBlock* containingBlock, RenderRegion*, LayoutUnit offsetFromLogicalTopOfFirstPage) const;
     411    LayoutUnit shrinkLogicalWidthToAvoidFloats(LayoutUnit childMarginStart, LayoutUnit childMarginEnd, const RenderBlock* cb, RenderRegion*) const;
     412
     413    LayoutUnit computeLogicalWidthInRegionUsing(SizeType, Length logicalWidth, LayoutUnit availableLogicalWidth, const RenderBlock* containingBlock, RenderRegion*) const;
    413414    LayoutUnit computeLogicalHeightUsing(const Length& height) const;
    414415    LayoutUnit computeContentLogicalHeight(const Length& height) const;
     
    608609#endif
    609610
    610     void computePositionedLogicalWidth(LogicalExtentComputedValues&, RenderRegion* = 0, LayoutUnit offsetFromLogicalTopOfFirstPage = 0) const;
     611    void computePositionedLogicalWidth(LogicalExtentComputedValues&, RenderRegion* = 0) const;
    611612
    612613    LayoutUnit computeIntrinsicLogicalWidthUsing(Length logicalWidthLength, LayoutUnit availableLogicalWidth, LayoutUnit borderAndPadding) const;
     
    637638    bool skipContainingBlockForPercentHeightCalculation(const RenderBox* containingBlock) const;
    638639   
    639     LayoutUnit containingBlockLogicalWidthForPositioned(const RenderBoxModelObject* containingBlock, RenderRegion* = 0,
    640         LayoutUnit offsetFromLogicalTopOfFirstPage = 0, bool checkForPerpendicularWritingMode = true) const;
     640    LayoutUnit containingBlockLogicalWidthForPositioned(const RenderBoxModelObject* containingBlock, RenderRegion* = 0, bool checkForPerpendicularWritingMode = true) const;
    641641    LayoutUnit containingBlockLogicalHeightForPositioned(const RenderBoxModelObject* containingBlock, bool checkForPerpendicularWritingMode = true) const;
    642642
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp

    r150278 r150743  
    547547        return child->computeContentLogicalHeight(size);
    548548    // FIXME: Figure out how this should work for regions and pass in the appropriate values.
    549     LayoutUnit offsetFromLogicalTopOfFirstPage = 0;
    550549    RenderRegion* region = 0;
    551     return child->computeLogicalWidthInRegionUsing(sizeType, size, contentLogicalWidth(), this, region, offsetFromLogicalTopOfFirstPage) - child->borderAndPaddingLogicalWidth();
     550    return child->computeLogicalWidthInRegionUsing(sizeType, size, contentLogicalWidth(), this, region) - child->borderAndPaddingLogicalWidth();
    552551}
    553552
  • trunk/Source/WebCore/rendering/RenderFlowThread.cpp

    r150427 r150743  
    433433            if (boxModelObject.isBox()) {
    434434                // Use borderBoxRectInRegion to account for variations such as percentage margins.
    435                 LayoutRect borderBoxRect = toRenderBox(&boxModelObject)->borderBoxRectInRegion(startRegion, 0, RenderBox::DoNotCacheRenderBoxRegionInfo);
     435                LayoutRect borderBoxRect = toRenderBox(&boxModelObject)->borderBoxRectInRegion(startRegion, RenderBox::DoNotCacheRenderBoxRegionInfo);
    436436                referencePoint.move(borderBoxRect.location().x(), 0);
    437437            }
     
    570570}
    571571
    572 bool RenderFlowThread::logicalWidthChangedInRegions(const RenderBlock* block, LayoutUnit offsetFromLogicalTopOfFirstPage)
     572bool RenderFlowThread::logicalWidthChangedInRegionsForBlock(const RenderBlock* block)
    573573{
    574574    if (!hasRegions())
     
    596596
    597597        LayoutUnit oldLogicalWidth = oldInfo->logicalWidth();
    598         RenderBoxRegionInfo* newInfo = block->renderBoxRegionInfo(region, offsetFromLogicalTopOfFirstPage);
     598        RenderBoxRegionInfo* newInfo = block->renderBoxRegionInfo(region);
    599599        if (!newInfo || newInfo->logicalWidth() != oldLogicalWidth)
    600600            return true;
     
    10441044}
    10451045
     1046bool RenderFlowThread::hasCachedOffsetFromLogicalTopOfFirstRegion(const RenderBox* box) const
     1047{
     1048    return m_boxesToOffsetMap.contains(box);
     1049}
     1050
     1051LayoutUnit RenderFlowThread::cachedOffsetFromLogicalTopOfFirstRegion(const RenderBox* box) const
     1052{
     1053    return m_boxesToOffsetMap.get(box);
     1054}
     1055
     1056void RenderFlowThread::setOffsetFromLogicalTopOfFirstRegion(const RenderBox* box, LayoutUnit offset)
     1057{
     1058    m_boxesToOffsetMap.set(box, offset);
     1059}
     1060
     1061void RenderFlowThread::clearOffsetFromLogicalTopOfFirstRegion(const RenderBox* box)
     1062{
     1063    ASSERT(m_boxesToOffsetMap.contains(box));
     1064    m_boxesToOffsetMap.remove(box);
     1065}
     1066
     1067const RenderBox* RenderFlowThread::currentActiveRenderBox() const
     1068{
     1069    const RenderObject* currentObject = m_activeObjectsStack.isEmpty() ? 0 : m_activeObjectsStack.last();
     1070    if (currentObject && currentObject->isBox())
     1071        return toRenderBox(currentObject);
     1072
     1073    return 0;
     1074}
     1075
     1076void RenderFlowThread::pushFlowThreadLayoutState(const RenderObject* object)
     1077{
     1078    const RenderBox* currentBoxDescendant = currentActiveRenderBox();
     1079    LayoutState* layoutState = view()->layoutState();
     1080    if (currentBoxDescendant && layoutState && layoutState->isPaginated()) {
     1081        ASSERT(layoutState->m_renderer == currentBoxDescendant);
     1082        LayoutSize offsetDelta = layoutState->m_layoutOffset - layoutState->m_pageOffset;
     1083        setOffsetFromLogicalTopOfFirstRegion(currentBoxDescendant, currentBoxDescendant->isHorizontalWritingMode() ? offsetDelta.height() : offsetDelta.width());
     1084    }
     1085
     1086    m_activeObjectsStack.add(object);
     1087}
     1088
     1089void RenderFlowThread::popFlowThreadLayoutState()
     1090{
     1091    m_activeObjectsStack.removeLast();
     1092
     1093    const RenderBox* currentBoxDescendant = currentActiveRenderBox();
     1094    LayoutState* layoutState = view()->layoutState();
     1095    if (currentBoxDescendant && layoutState && layoutState->isPaginated())
     1096        clearOffsetFromLogicalTopOfFirstRegion(currentBoxDescendant);
     1097}
     1098
     1099LayoutUnit RenderFlowThread::offsetFromLogicalTopOfFirstRegion(const RenderBlock* currentBlock) const
     1100{
     1101    // First check if we cached the offset for the block if it's an ancestor containing block of the box
     1102    // being currently laid out.
     1103    if (hasCachedOffsetFromLogicalTopOfFirstRegion(currentBlock))
     1104        return cachedOffsetFromLogicalTopOfFirstRegion(currentBlock);
     1105
     1106    // If it's the current box being laid out, use the layout state.
     1107    const RenderBox* currentBoxDescendant = currentActiveRenderBox();
     1108    if (currentBlock == currentBoxDescendant) {
     1109        LayoutState* layoutState = view()->layoutState();
     1110        ASSERT(layoutState->m_renderer == currentBlock);
     1111        ASSERT(layoutState && layoutState->isPaginated());
     1112        LayoutSize offsetDelta = layoutState->m_layoutOffset - layoutState->m_pageOffset;
     1113        return currentBoxDescendant->isHorizontalWritingMode() ? offsetDelta.height() : offsetDelta.width();
     1114    }
     1115
     1116    // As a last resort, take the slow path.
     1117    LayoutRect blockRect(0, 0, currentBlock->width(), currentBlock->height());
     1118    while (currentBlock && !currentBlock->isRenderFlowThread()) {
     1119        RenderBlock* containerBlock = currentBlock->containingBlock();
     1120        ASSERT(containerBlock);
     1121        if (!containerBlock)
     1122            return 0;
     1123        LayoutPoint currentBlockLocation = currentBlock->location();
     1124
     1125        if (containerBlock->style()->writingMode() != currentBlock->style()->writingMode()) {
     1126            // We have to put the block rect in container coordinates
     1127            // and we have to take into account both the container and current block flipping modes
     1128            if (containerBlock->style()->isFlippedBlocksWritingMode()) {
     1129                if (containerBlock->isHorizontalWritingMode())
     1130                    blockRect.setY(currentBlock->height() - blockRect.maxY());
     1131                else
     1132                    blockRect.setX(currentBlock->width() - blockRect.maxX());
     1133            }
     1134            currentBlock->flipForWritingMode(blockRect);
     1135        }
     1136        blockRect.moveBy(currentBlockLocation);
     1137        currentBlock = containerBlock;
     1138    }
     1139
     1140    return currentBlock->isHorizontalWritingMode() ? blockRect.y() : blockRect.x();
     1141}
     1142
    10461143void RenderFlowThread::RegionSearchAdapter::collectIfNeeded(const RegionInterval& interval)
    10471144{
  • trunk/Source/WebCore/rendering/RenderFlowThread.h

    r150383 r150743  
    116116
    117117    void removeRenderBoxRegionInfo(RenderBox*);
    118     bool logicalWidthChangedInRegions(const RenderBlock*, LayoutUnit offsetFromLogicalTopOfFirstPage);
     118    bool logicalWidthChangedInRegionsForBlock(const RenderBlock*);
    119119
    120120    LayoutUnit contentLogicalWidthOfFirstRegion() const;
     
    163163    void clearNeedsTwoPhasesLayout() { m_needsTwoPhasesLayout = false; }
    164164
     165    void pushFlowThreadLayoutState(const RenderObject*);
     166    void popFlowThreadLayoutState();
     167    LayoutUnit offsetFromLogicalTopOfFirstRegion(const RenderBlock*) const;
     168
    165169protected:
    166170    virtual const char* renderName() const = 0;
     
    185189
    186190    virtual void autoGenerateRegionsToBlockOffset(LayoutUnit) { };
     191
     192    inline bool hasCachedOffsetFromLogicalTopOfFirstRegion(const RenderBox*) const;
     193    inline LayoutUnit cachedOffsetFromLogicalTopOfFirstRegion(const RenderBox*) const;
     194    inline void setOffsetFromLogicalTopOfFirstRegion(const RenderBox*, LayoutUnit);
     195    inline void clearOffsetFromLogicalTopOfFirstRegion(const RenderBox*);
     196
     197    inline const RenderBox* currentActiveRenderBox() const;
    187198
    188199    RenderRegionList m_regionList;
     
    244255    RenderObjectToRegionMap m_breakAfterToRegionMap;
    245256
     257    typedef ListHashSet<const RenderObject*> RenderObjectStack;
     258    RenderObjectStack m_activeObjectsStack;
     259    typedef HashMap<const RenderBox*, LayoutUnit> RenderBoxToOffsetMap;
     260    RenderBoxToOffsetMap m_boxesToOffsetMap;
     261
    246262    unsigned m_autoLogicalHeightRegionsCount;
    247263
  • trunk/Source/WebCore/rendering/RenderTable.cpp

    r150355 r150743  
    267267        if (shrinkToAvoidFloats() && cb->containsFloats() && !hasPerpendicularContainingBlock) {
    268268            // FIXME: Work with regions someday.
    269             availableContentLogicalWidth = shrinkLogicalWidthToAvoidFloats(marginStart, marginEnd, cb, 0, 0);
     269            availableContentLogicalWidth = shrinkLogicalWidthToAvoidFloats(marginStart, marginEnd, cb, 0);
    270270        }
    271271
     
    298298        LayoutUnit containerLogicalWidthForAutoMargins = availableLogicalWidth;
    299299        if (avoidsFloats() && cb->containsFloats())
    300             containerLogicalWidthForAutoMargins = containingBlockAvailableLineWidthInRegion(0, 0); // FIXME: Work with regions someday.
     300            containerLogicalWidthForAutoMargins = containingBlockAvailableLineWidthInRegion(0); // FIXME: Work with regions someday.
    301301        ComputedMarginValues marginValues;
    302302        bool hasInvertedDirection =  cb->style()->isLeftToRightDirection() == style()->isLeftToRightDirection();
  • trunk/Source/WebCore/rendering/RenderView.cpp

    r148921 r150743  
    10271027    ASSERT(m_layoutState == 0);
    10281028
     1029    pushLayoutStateForCurrentFlowThread(root);
    10291030    m_layoutState = new (renderArena()) LayoutState(root);
    10301031}
     
    11411142}
    11421143
     1144void RenderView::pushLayoutStateForCurrentFlowThread(const RenderObject* object)
     1145{
     1146    if (!m_flowThreadController)
     1147        return;
     1148
     1149    RenderFlowThread* currentFlowThread = m_flowThreadController->currentRenderFlowThread();
     1150    if (!currentFlowThread)
     1151        return;
     1152
     1153    currentFlowThread->pushFlowThreadLayoutState(object);
     1154}
     1155
     1156void RenderView::popLayoutStateForCurrentFlowThread()
     1157{
     1158    if (!m_flowThreadController)
     1159        return;
     1160
     1161    RenderFlowThread* currentFlowThread = m_flowThreadController->currentRenderFlowThread();
     1162    if (!currentFlowThread)
     1163        return;
     1164
     1165    currentFlowThread->popFlowThreadLayoutState();
     1166}
     1167
    11431168RenderBlock::IntervalArena* RenderView::intervalArena()
    11441169{
  • trunk/Source/WebCore/rendering/RenderView.h

    r150312 r150743  
    254254#endif
    255255            ) {
     256            pushLayoutStateForCurrentFlowThread(renderer);
    256257            m_layoutState = new (renderArena()) LayoutState(m_layoutState, renderer, offset, pageHeight, pageHeightChanged, colInfo);
    257258            return true;
     
    265266        m_layoutState = state->m_next;
    266267        state->destroy(renderArena());
     268        popLayoutStateForCurrentFlowThread();
    267269    }
    268270
     
    283285    size_t getRetainedWidgets(Vector<RenderWidget*>&);
    284286    void releaseWidgets(Vector<RenderWidget*>&);
     287
     288    void pushLayoutStateForCurrentFlowThread(const RenderObject*);
     289    void popLayoutStateForCurrentFlowThread();
    285290   
    286291    friend class LayoutStateMaintainer;
Note: See TracChangeset for help on using the changeset viewer.