Changeset 100048 in webkit


Ignore:
Timestamp:
Nov 11, 2011 5:12:58 PM (12 years ago)
Author:
eae@chromium.org
Message:

Switch remaining RenderBlock/Box methods to to new layout types
https://bugs.webkit.org/show_bug.cgi?id=72075

Reviewed by Eric Seidel.

Move margins, floats and line layout block logic to layout abstraction.

No new tests.

  • rendering/RenderBlockLineLayout.cpp:

(WebCore::borderPaddingMarginStart):
(WebCore::borderPaddingMarginEnd):
(WebCore::inlineLogicalWidth):
(WebCore::setStaticPositions):
(WebCore::LineLayoutState::LineLayoutState):
(WebCore::LineLayoutState::setRepaintRange):
(WebCore::LineLayoutState::updateRepaintRangeFromBox):
(WebCore::RenderBlock::layoutRunsAndFloatsInRange):
(WebCore::RenderBlock::linkToEndLineIfNeeded):
(WebCore::RenderBlock::layoutInlineChildren):
(WebCore::RenderBlock::checkFloatsInCleanLine):
(WebCore::RenderBlock::determineStartPosition):
(WebCore::RenderBlock::checkPaginationAndFloatsAtEndLine):
(WebCore::RenderBlock::LineBreaker::nextLineBreak):
(WebCore::RenderBlock::addOverflowFromInlineChildren):
(WebCore::RenderBlock::checkLinesForTextOverflow):
(WebCore::RenderBlock::positionNewFloatOnLine):

  • rendering/RenderBox.cpp:

(WebCore::RenderBox::containingBlockLogicalWidthForContentInRegion):
(WebCore::RenderBox::offsetFromContainer):
(WebCore::RenderBox::positionLineBox):
(WebCore::RenderBox::computeInlineDirectionMargins):
(WebCore::RenderBox::containingBlockLogicalWidthForPositioned):
(WebCore::RenderBox::containingBlockLogicalHeightForPositioned):

  • rendering/RenderBox.h:

(WebCore::RenderBox::tryLayoutDoingPositionedMovementOnly):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r100047 r100048  
     12011-11-11  Emil A Eklund  <eae@chromium.org>
     2
     3        Switch remaining RenderBlock/Box methods to to new layout types
     4        https://bugs.webkit.org/show_bug.cgi?id=72075
     5
     6        Reviewed by Eric Seidel.
     7
     8        Move margins, floats and line layout block logic to layout abstraction.
     9
     10        No new tests.
     11
     12        * rendering/RenderBlockLineLayout.cpp:
     13        (WebCore::borderPaddingMarginStart):
     14        (WebCore::borderPaddingMarginEnd):
     15        (WebCore::inlineLogicalWidth):
     16        (WebCore::setStaticPositions):
     17        (WebCore::LineLayoutState::LineLayoutState):
     18        (WebCore::LineLayoutState::setRepaintRange):
     19        (WebCore::LineLayoutState::updateRepaintRangeFromBox):
     20        (WebCore::RenderBlock::layoutRunsAndFloatsInRange):
     21        (WebCore::RenderBlock::linkToEndLineIfNeeded):
     22        (WebCore::RenderBlock::layoutInlineChildren):
     23        (WebCore::RenderBlock::checkFloatsInCleanLine):
     24        (WebCore::RenderBlock::determineStartPosition):
     25        (WebCore::RenderBlock::checkPaginationAndFloatsAtEndLine):
     26        (WebCore::RenderBlock::LineBreaker::nextLineBreak):
     27        (WebCore::RenderBlock::addOverflowFromInlineChildren):
     28        (WebCore::RenderBlock::checkLinesForTextOverflow):
     29        (WebCore::RenderBlock::positionNewFloatOnLine):
     30        * rendering/RenderBox.cpp:
     31        (WebCore::RenderBox::containingBlockLogicalWidthForContentInRegion):
     32        (WebCore::RenderBox::offsetFromContainer):
     33        (WebCore::RenderBox::positionLineBox):
     34        (WebCore::RenderBox::computeInlineDirectionMargins):
     35        (WebCore::RenderBox::containingBlockLogicalWidthForPositioned):
     36        (WebCore::RenderBox::containingBlockLogicalHeightForPositioned):
     37        * rendering/RenderBox.h:
     38        (WebCore::RenderBox::tryLayoutDoingPositionedMovementOnly):
     39
    1402011-11-11  Antoine Labour  <piman@chromium.org>
    241
  • trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp

    r97282 r100048  
    227227};
    228228
    229 static inline int borderPaddingMarginStart(RenderInline* child)
     229static inline LayoutUnit borderPaddingMarginStart(RenderInline* child)
    230230{
    231231    return child->marginStart() + child->paddingStart() + child->borderStart();
    232232}
    233233
    234 static inline int borderPaddingMarginEnd(RenderInline* child)
     234static inline LayoutUnit borderPaddingMarginEnd(RenderInline* child)
    235235{
    236236    return child->marginEnd() + child->paddingEnd() + child->borderEnd();
    237237}
    238238
    239 static int inlineLogicalWidth(RenderObject* child, bool start = true, bool end = true)
     239static LayoutUnit inlineLogicalWidth(RenderObject* child, bool start = true, bool end = true)
    240240{
    241241    unsigned lineDepth = 1;
    242     int extraWidth = 0;
     242    LayoutUnit extraWidth = 0;
    243243    RenderObject* parent = child->parent();
    244244    while (parent->isRenderInline() && lineDepth++ < cMaxLineDepth) {
     
    858858    // will work for the common cases
    859859    RenderObject* containerBlock = child->container();
    860     int blockHeight = block->logicalHeight();
     860    LayoutUnit blockHeight = block->logicalHeight();
    861861    if (containerBlock->isRenderInline()) {
    862862        // A relative positioned inline encloses us. In this case, we also have to determine our
     
    10411041class LineLayoutState {
    10421042public:
    1043     LineLayoutState(bool fullLayout, int& repaintLogicalTop, int& repaintLogicalBottom)
     1043    LineLayoutState(bool fullLayout, LayoutUnit& repaintLogicalTop, LayoutUnit& repaintLogicalBottom)
    10441044        : m_lastFloat(0)
    10451045        , m_endLine(0)
     
    10591059    bool usesRepaintBounds() const { return m_usesRepaintBounds; }
    10601060
    1061     void setRepaintRange(int logicalHeight)
     1061    void setRepaintRange(LayoutUnit logicalHeight)
    10621062    {
    10631063        m_usesRepaintBounds = true;
     
    10651065    }
    10661066   
    1067     void updateRepaintRangeFromBox(RootInlineBox* box, int paginationDelta = 0)
     1067    void updateRepaintRangeFromBox(RootInlineBox* box, LayoutUnit paginationDelta = 0)
    10681068    {
    10691069        m_usesRepaintBounds = true;
     
    11081108
    11091109    // FIXME: Should this be a range object instead of two ints?
    1110     int& m_repaintLogicalTop;
    1111     int& m_repaintLogicalBottom;
    1112    
     1110    LayoutUnit& m_repaintLogicalTop;
     1111    LayoutUnit& m_repaintLogicalBottom;
     1112
    11131113    bool m_usesRepaintBounds;
    11141114};
     
    12581258            // inline flow boxes.
    12591259
    1260             int oldLogicalHeight = logicalHeight();
     1260            LayoutUnit oldLogicalHeight = logicalHeight();
    12611261            RootInlineBox* lineBox = createLineBoxesFromBidiRuns(bidiRuns, end, layoutState.lineInfo(), verticalPositionCache, trailingSpaceRun);
    12621262
     
    12701270
    12711271                if (paginated) {
    1272                     int adjustment = 0;
     1272                    LayoutUnit adjustment = 0;
    12731273                    adjustLinePositionForPagination(lineBox, adjustment);
    12741274                    if (adjustment) {
    1275                         int oldLineWidth = availableLogicalWidthForLine(oldLogicalHeight, layoutState.lineInfo().isFirstLine());
     1275                        LayoutUnit oldLineWidth = availableLogicalWidthForLine(oldLogicalHeight, layoutState.lineInfo().isFirstLine());
    12761276                        lineBox->adjustBlockDirectionPosition(adjustment);
    12771277                        if (layoutState.usesRepaintBounds())
     
    13331333            bool paginated = view()->layoutState() && view()->layoutState()->isPaginated();
    13341334            // Attach all the remaining lines, and then adjust their y-positions as needed.
    1335             int delta = logicalHeight() - layoutState.endLineLogicalTop();
     1335            LayoutUnit delta = logicalHeight() - layoutState.endLineLogicalTop();
    13361336            for (RootInlineBox* line = layoutState.endLine(); line; line = line->nextRootBox()) {
    13371337                line->attachLine();
     
    14131413}
    14141414
    1415 void RenderBlock::layoutInlineChildren(bool relayoutChildren, int& repaintLogicalTop, int& repaintLogicalBottom)
     1415void RenderBlock::layoutInlineChildren(bool relayoutChildren, LayoutUnit& repaintLogicalTop, LayoutUnit& repaintLogicalBottom)
    14161416{
    14171417    m_overflow.clear();
     
    15091509        RenderBox* floatingBox = *it;
    15101510        floatingBox->layoutIfNeeded();
    1511         IntSize newSize(floatingBox->width() + floatingBox->marginLeft() + floatingBox->marginRight(), floatingBox->height() + floatingBox->marginTop() + floatingBox->marginBottom());
     1511        LayoutSize newSize(floatingBox->width() + floatingBox->marginLeft() + floatingBox->marginRight(), floatingBox->height() + floatingBox->marginTop() + floatingBox->marginBottom());
    15121512        ASSERT(floatIndex < floats.size());
    15131513        if (floats[floatIndex].object != floatingBox) {
     
    15171517
    15181518        if (floats[floatIndex].rect.size() != newSize) {
    1519             int floatTop = isHorizontalWritingMode() ? floats[floatIndex].rect.y() : floats[floatIndex].rect.x();
    1520             int floatHeight = isHorizontalWritingMode() ? max(floats[floatIndex].rect.height(), newSize.height())
     1519            LayoutUnit floatTop = isHorizontalWritingMode() ? floats[floatIndex].rect.y() : floats[floatIndex].rect.x();
     1520            LayoutUnit floatHeight = isHorizontalWritingMode() ? max(floats[floatIndex].rect.height(), newSize.height())
    15211521                                                                 : max(floats[floatIndex].rect.width(), newSize.width());
    1522             floatHeight = min(floatHeight, numeric_limits<int>::max() - floatTop);
     1522            floatHeight = min(floatHeight, numeric_limits<LayoutUnit>::max() - floatTop);
    15231523            line->markDirty();
    15241524            markLinesDirtyInBlockRange(line->lineBottomWithLeading(), floatTop + floatHeight, line);
     
    15401540        // Paginate all of the clean lines.
    15411541        bool paginated = view()->layoutState() && view()->layoutState()->isPaginated();
    1542         int paginationDelta = 0;
     1542        LayoutUnit paginationDelta = 0;
    15431543        size_t floatIndex = 0;
    15441544        for (curr = firstRootBox(); curr && !curr->isDirty(); curr = curr->nextRootBox()) {
     
    16111611    unsigned numCleanFloats = 0;
    16121612    if (!layoutState.floats().isEmpty()) {
    1613         int savedLogicalHeight = logicalHeight();
     1613        LayoutUnit savedLogicalHeight = logicalHeight();
    16141614        // Restore floats from clean lines.
    16151615        RootInlineBox* line = firstRootBox();
     
    17151715   
    17161716    // See if any floats end in the range along which we want to shift the lines vertically.
    1717     int logicalTop = min(logicalHeight(), layoutState.endLineLogicalTop());
     1717    LayoutUnit logicalTop = min(logicalHeight(), layoutState.endLineLogicalTop());
    17181718
    17191719    RootInlineBox* lastLine = layoutState.endLine();
     
    17211721        lastLine = nextLine;
    17221722
    1723     int logicalBottom = lastLine->lineBottomWithLeading() + abs(lineDelta);
     1723    LayoutUnit logicalBottom = lastLine->lineBottomWithLeading() + abs(lineDelta);
    17241724
    17251725    const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
     
    22192219            // Optimize for a common case. If we can't find whitespace after the list
    22202220            // item, then this is all moot.
    2221             int replacedLogicalWidth = m_block->logicalWidthForChild(replacedBox) + m_block->marginStartForChild(replacedBox) + m_block->marginEndForChild(replacedBox) + inlineLogicalWidth(current.m_obj);
     2221            LayoutUnit replacedLogicalWidth = m_block->logicalWidthForChild(replacedBox) + m_block->marginStartForChild(replacedBox) + m_block->marginEndForChild(replacedBox) + inlineLogicalWidth(current.m_obj);
    22222222            if (current.m_obj->isListMarker()) {
    22232223                if (m_block->style()->collapseWhiteSpace() && shouldSkipWhitespaceAfterStartObject(m_block, current.m_obj, lineMidpointState)) {
     
    25982598void RenderBlock::addOverflowFromInlineChildren()
    25992599{
    2600     int endPadding = hasOverflowClip() ? paddingEnd() : 0;
     2600    LayoutUnit endPadding = hasOverflowClip() ? paddingEnd() : 0;
    26012601    // FIXME: Need to find another way to do this, since scrollbars could show when we don't want them to.
    26022602    if (hasOverflowClip() && !endPadding && node() && node()->rendererIsEditable() && node() == node()->rootEditableElement() && style()->isLeftToRightDirection())
     
    26222622    DEFINE_STATIC_LOCAL(AtomicString, ellipsisStr, (&horizontalEllipsis, 1));
    26232623    const Font& firstLineFont = firstLineStyle()->font();
    2624     int firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, firstLineFont, &horizontalEllipsis, 1, firstLineStyle()));
    2625     int ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : font.width(constructTextRun(this, font, &horizontalEllipsis, 1, style()));
     2624    LayoutUnit firstLineEllipsisWidth = firstLineFont.width(constructTextRun(this, firstLineFont, &horizontalEllipsis, 1, firstLineStyle()));
     2625    LayoutUnit ellipsisWidth = (font == firstLineFont) ? firstLineEllipsisWidth : font.width(constructTextRun(this, font, &horizontalEllipsis, 1, style()));
    26262626
    26272627    // For LTR text truncation, we want to get the right edge of our padding box, and then we want to see
     
    26312631    bool ltr = style()->isLeftToRightDirection();
    26322632    for (RootInlineBox* curr = firstRootBox(); curr; curr = curr->nextRootBox()) {
    2633         int blockRightEdge = logicalRightOffsetForLine(curr->y(), curr == firstRootBox());
    2634         int blockLeftEdge = logicalLeftOffsetForLine(curr->y(), curr == firstRootBox());
    2635         int lineBoxEdge = ltr ? curr->x() + curr->logicalWidth() : curr->x();
     2633        LayoutUnit blockRightEdge = logicalRightOffsetForLine(curr->y(), curr == firstRootBox());
     2634        LayoutUnit blockLeftEdge = logicalLeftOffsetForLine(curr->y(), curr == firstRootBox());
     2635        LayoutUnit lineBoxEdge = ltr ? curr->x() + curr->logicalWidth() : curr->x();
    26362636        if ((ltr && lineBoxEdge > blockRightEdge) || (!ltr && lineBoxEdge < blockLeftEdge)) {
    26372637            // This line spills out of our box in the appropriate direction.  Now we need to see if the line
     
    26392639            // accommodate our truncation string, and no replaced elements (images, tables) can overlap the ellipsis
    26402640            // space.
    2641             int width = curr == firstRootBox() ? firstLineEllipsisWidth : ellipsisWidth;
    2642             int blockEdge = ltr ? blockRightEdge : blockLeftEdge;
     2641            LayoutUnit width = curr == firstRootBox() ? firstLineEllipsisWidth : ellipsisWidth;
     2642            LayoutUnit blockEdge = ltr ? blockRightEdge : blockLeftEdge;
    26432643            if (curr->lineCanAccommodateEllipsis(ltr, blockEdge, lineBoxEdge, width))
    26442644                curr->placeEllipsis(ellipsisStr, ltr, blockLeftEdge, blockRightEdge, width);
     
    26632663    ASSERT(floatingObjectSet.last() == newFloat);
    26642664
    2665     int floatLogicalTop = logicalTopForFloat(newFloat);
     2665    LayoutUnit floatLogicalTop = logicalTopForFloat(newFloat);
    26662666    int paginationStrut = newFloat->m_paginationStrut;
    26672667
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r99630 r100048  
    12981298    if (!boxInfo)
    12991299        return result;
    1300     return max(0, result - (cb->logicalWidth() - boxInfo->logicalWidth()));
     1300    return max<LayoutUnit>(0, result - (cb->logicalWidth() - boxInfo->logicalWidth()));
    13011301}
    13021302
     
    14261426            block->adjustStartEdgeForWritingModeIncludingColumns(columnRect);
    14271427            offset += toSize(columnRect.location());
    1428             IntPoint columnPoint = block->flipForWritingModeIncludingColumns(point + offset);
    1429             offset = toSize(block->flipForWritingModeIncludingColumns(LayoutPoint(offset)));
     1428            LayoutPoint columnPoint = block->flipForWritingModeIncludingColumns(point + offset);
     1429            offset = toLayoutSize(block->flipForWritingModeIncludingColumns(toLayoutPoint(offset)));
    14301430            o->adjustForColumns(offset, columnPoint);
    14311431            offset = block->flipForWritingMode(offset);
     
    14861486        box->destroy(renderArena());
    14871487    } else if (isReplaced()) {
    1488         setLocation(roundedLayoutPoint(FloatPoint(box->x(), box->y())));
     1488        setLocation(roundedLayoutPoint(box->topLeft()));
    14891489        ASSERT(!m_inlineBoxWrapper);
    14901490        m_inlineBoxWrapper = box;
     
    18241824}
    18251825
    1826 void RenderBox::computeInlineDirectionMargins(RenderBlock* containingBlock, int containerWidth, int childWidth)
     1826void RenderBox::computeInlineDirectionMargins(RenderBlock* containingBlock, LayoutUnit containerWidth, LayoutUnit childWidth)
    18271827{
    18281828    const RenderStyle* containingBlockStyle = containingBlock->style();
     
    23232323}
    23242324
    2325 int RenderBox::containingBlockLogicalWidthForPositioned(const RenderBoxModelObject* containingBlock, RenderRegion* region,
     2325LayoutUnit RenderBox::containingBlockLogicalWidthForPositioned(const RenderBoxModelObject* containingBlock, RenderRegion* region,
    23262326    LayoutUnit offsetFromLogicalTopOfFirstPage, bool checkForPerpendicularWritingMode) const
    23272327{
     
    23482348            }
    23492349            if (boxInfo)
    2350                 return max(0, result - (cb->logicalWidth() - boxInfo->logicalWidth()));
     2350                return max<LayoutUnit>(0, result - (cb->logicalWidth() - boxInfo->logicalWidth()));
    23512351        }
    23522352        return result;
     
    23762376}
    23772377
    2378 int RenderBox::containingBlockLogicalHeightForPositioned(const RenderBoxModelObject* containingBlock, bool checkForPerpendicularWritingMode) const
     2378LayoutUnit RenderBox::containingBlockLogicalHeightForPositioned(const RenderBoxModelObject* containingBlock, bool checkForPerpendicularWritingMode) const
    23792379{
    23802380    if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWritingMode() != isHorizontalWritingMode())
  • trunk/Source/WebCore/rendering/RenderBox.h

    r98021 r100048  
    235235    virtual LayoutUnit collapsedMarginAfter() const { return marginAfter(); }
    236236
    237     virtual void absoluteRects(Vector<IntRect>&, const LayoutPoint& accumulatedOffset) const;
     237    virtual void absoluteRects(Vector<LayoutRect>&, const LayoutPoint& accumulatedOffset) const;
    238238    virtual void absoluteQuads(Vector<FloatQuad>&, bool* wasFixed) const;
    239239   
    240     IntRect reflectionBox() const;
     240    LayoutRect reflectionBox() const;
    241241    int reflectionOffset() const;
    242242    // Given a rect in the object's coordinate space, returns the corresponding rect in the reflection.
     
    269269    // Resolve auto margins in the inline direction of the containing block so that objects can be pushed to the start, middle or end
    270270    // of the containing block.
    271     void computeInlineDirectionMargins(RenderBlock* containingBlock, int containerWidth, int childWidth);
     271    void computeInlineDirectionMargins(RenderBlock* containingBlock, LayoutUnit containerWidth, LayoutUnit childWidth);
    272272
    273273    // Used to resolve margins in the containing block's block-flow direction.
     
    378378    bool tryLayoutDoingPositionedMovementOnly()
    379379    {
    380         int oldWidth = width();
     380        LayoutUnit oldWidth = width();
    381381        computeLogicalWidth();
    382382        // If we shrink to fit our width may have changed, so we still need full layout.
     
    469469    bool repaintLayerRectsForImage(WrappedImagePtr image, const FillLayer* layers, bool drawingBackground);
    470470   
    471     int containingBlockLogicalWidthForPositioned(const RenderBoxModelObject* containingBlock, RenderRegion* = 0,
     471    LayoutUnit containingBlockLogicalWidthForPositioned(const RenderBoxModelObject* containingBlock, RenderRegion* = 0,
    472472        LayoutUnit offsetFromLogicalTopOfFirstPage = 0, bool checkForPerpendicularWritingMode = true) const;
    473     int containingBlockLogicalHeightForPositioned(const RenderBoxModelObject* containingBlock, bool checkForPerpendicularWritingMode = true) const;
     473    LayoutUnit containingBlockLogicalHeightForPositioned(const RenderBoxModelObject* containingBlock, bool checkForPerpendicularWritingMode = true) const;
    474474
    475475    void computePositionedLogicalHeight();
Note: See TracChangeset for help on using the changeset viewer.