Changeset 161278 in webkit


Ignore:
Timestamp:
Jan 3, 2014, 12:22:09 PM (12 years ago)
Author:
akling@apple.com
Message:

Deploy more child renderer iterators in RenderBlockFlow.
<https://webkit.org/b/126434>

Reviewed by Sam Weinig.

  • rendering/RenderBlockFlow.cpp:

(WebCore::shouldCheckLines):

Make this helper take a RenderBlockFlow instead of a RenderObject
and simplified it a bit. RenderDeprecatedFlexibleBox does not
derive from RenderBlockFlow so those checks can be omitted.

(WebCore::RenderBlockFlow::layoutBlock):
(WebCore::RenderBlockFlow::markAllDescendantsWithFloatsForLayout):
(WebCore::RenderBlockFlow::lineAtIndex):
(WebCore::RenderBlockFlow::lineCount):
(WebCore::RenderBlockFlow::clearTruncation):

Use childrenOfType to iterate over block and block-flow children.
Tweaked some early return/continue to reduce nesting.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r161276 r161278  
     12014-01-03  Andreas Kling  <akling@apple.com>
     2
     3        Deploy more child renderer iterators in RenderBlockFlow.
     4        <https://webkit.org/b/126434>
     5
     6        Reviewed by Sam Weinig.
     7
     8        * rendering/RenderBlockFlow.cpp:
     9        (WebCore::shouldCheckLines):
     10
     11            Make this helper take a RenderBlockFlow instead of a RenderObject
     12            and simplified it a bit. RenderDeprecatedFlexibleBox does not
     13            derive from RenderBlockFlow so those checks can be omitted.
     14
     15        (WebCore::RenderBlockFlow::layoutBlock):
     16        (WebCore::RenderBlockFlow::markAllDescendantsWithFloatsForLayout):
     17        (WebCore::RenderBlockFlow::lineAtIndex):
     18        (WebCore::RenderBlockFlow::lineCount):
     19        (WebCore::RenderBlockFlow::clearTruncation):
     20
     21            Use childrenOfType to iterate over block and block-flow children.
     22            Tweaked some early return/continue to reduce nesting.
     23
    1242014-01-03  Simon Fraser  <simon.fraser@apple.com>
    225
  • trunk/Source/WebCore/rendering/RenderBlockFlow.cpp

    r160598 r161278  
    387387        if (oldHeight > newHeight && maxFloatLogicalBottom > newHeight && !childrenInline()) {
    388388            // One of our children's floats may have become an overhanging float for us. We need to look for it.
    389             for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
    390                 if (child->isRenderBlockFlow() && !child->isFloatingOrOutOfFlowPositioned()) {
    391                     RenderBlockFlow& block = toRenderBlockFlow(*child);
    392                     if (block.lowestFloatLogicalBottom() + block.logicalTop() > newHeight)
    393                         addOverhangingFloats(block, false);
    394                 }
     389            for (auto& blockFlow : childrenOfType<RenderBlockFlow>(*this)) {
     390                if (blockFlow.isFloatingOrOutOfFlowPositioned())
     391                    continue;
     392                if (blockFlow.lowestFloatLogicalBottom() + blockFlow.logicalTop() > newHeight)
     393                    addOverhangingFloats(blockFlow, false);
    395394            }
    396395        }
     
    24632462        removeFloatingObject(*floatToRemove);
    24642463
     2464    if (childrenInline())
     2465        return;
     2466
    24652467    // Iterate over our children and mark them as needed.
    2466     if (!childrenInline()) {
    2467         for (RenderObject* child = firstChild(); child; child = child->nextSibling()) {
    2468             if ((!floatToRemove && child->isFloatingOrOutOfFlowPositioned()) || !child->isRenderBlock())
    2469                 continue;
    2470             if (!child->isRenderBlockFlow()) {
    2471                 RenderBlock* childBlock = toRenderBlock(child);
    2472                 if (childBlock->shrinkToAvoidFloats() && childBlock->everHadLayout())
    2473                     childBlock->setChildNeedsLayout(markParents);
    2474                 continue;
    2475             }
    2476             RenderBlockFlow* childBlock = toRenderBlockFlow(child);
    2477             if ((floatToRemove ? childBlock->containsFloat(*floatToRemove) : childBlock->containsFloats()) || childBlock->shrinkToAvoidFloats())
    2478                 childBlock->markAllDescendantsWithFloatsForLayout(floatToRemove, inLayout);
    2479         }
     2468    for (auto& block : childrenOfType<RenderBlock>(*this)) {
     2469        if (!floatToRemove && block.isFloatingOrOutOfFlowPositioned())
     2470            continue;
     2471        if (!block.isRenderBlockFlow()) {
     2472            if (block.shrinkToAvoidFloats() && block.everHadLayout())
     2473                block.setChildNeedsLayout(markParents);
     2474            continue;
     2475        }
     2476        auto& blockFlow = toRenderBlockFlow(block);
     2477        if ((floatToRemove ? blockFlow.containsFloat(*floatToRemove) : blockFlow.containsFloats()) || blockFlow.shrinkToAvoidFloats())
     2478            blockFlow.markAllDescendantsWithFloatsForLayout(floatToRemove, inLayout);
    24802479    }
    24812480}
     
    28632862}
    28642863
    2865 static bool shouldCheckLines(RenderObject& obj)
    2866 {
    2867     return !obj.isFloatingOrOutOfFlowPositioned() && !obj.isRunIn() && obj.isRenderBlockFlow() && obj.style().height().isAuto() && (!obj.isDeprecatedFlexibleBox() || obj.style().boxOrient() == VERTICAL);
     2864static bool shouldCheckLines(const RenderBlockFlow& blockFlow)
     2865{
     2866    return !blockFlow.isFloatingOrOutOfFlowPositioned() && !blockFlow.isRunIn() && blockFlow.style().height().isAuto();
    28682867}
    28692868
     
    28802879                return box;
    28812880        }
    2882     } else {
    2883         for (auto child = firstChild(); child; child = child->nextSibling()) {
    2884             if (!shouldCheckLines(*child))
    2885                 continue;
    2886             if (RootInlineBox* box = toRenderBlockFlow(child)->lineAtIndex(i))
    2887                 return box;
    2888         }
     2881        return nullptr;
     2882    }
     2883
     2884    for (auto& blockFlow : childrenOfType<RenderBlockFlow>(*this)) {
     2885        if (!shouldCheckLines(blockFlow))
     2886            continue;
     2887        if (RootInlineBox* box = blockFlow.lineAtIndex(i))
     2888            return box;
    28892889    }
    28902890
     
    29082908            }
    29092909        }
    2910     } else {
    2911         for (auto child = firstChild(); child; child = child->nextSibling()) {
    2912             if (shouldCheckLines(*child)) {
    2913                 bool recursiveFound = false;
    2914                 count += toRenderBlockFlow(child)->lineCount(stopRootInlineBox, &recursiveFound);
    2915                 if (recursiveFound) {
    2916                     if (found)
    2917                         *found = true;
    2918                     break;
    2919                 }
    2920             }
     2910        return count;
     2911    }
     2912
     2913    for (auto& blockFlow : childrenOfType<RenderBlockFlow>(*this)) {
     2914        if (!shouldCheckLines(blockFlow))
     2915            continue;
     2916        bool recursiveFound = false;
     2917        count += blockFlow.lineCount(stopRootInlineBox, &recursiveFound);
     2918        if (recursiveFound) {
     2919            if (found)
     2920                *found = true;
     2921            break;
    29212922        }
    29222923    }
     
    29382939        RenderBox* normalFlowChildWithoutLines = 0;
    29392940        for (auto obj = block.firstChildBox(); obj; obj = obj->nextSiblingBox()) {
    2940             if (shouldCheckLines(*obj)) {
     2941            if (obj->isRenderBlockFlow() && shouldCheckLines(toRenderBlockFlow(*obj))) {
    29412942                int result = getHeightForLineCount(toRenderBlockFlow(*obj), lineCount, false, count);
    29422943                if (result != -1)
     
    29692970        for (auto box = firstRootBox(); box; box = box->nextRootBox())
    29702971            box->clearTruncation();
    2971     } else {
    2972         for (auto child = firstChild(); child; child = child->nextSibling()) {
    2973             if (shouldCheckLines(*child))
    2974                 toRenderBlockFlow(child)->clearTruncation();
    2975         }
     2972        return;
     2973    }
     2974
     2975    for (auto& blockFlow : childrenOfType<RenderBlockFlow>(*this)) {
     2976        if (shouldCheckLines(blockFlow))
     2977            blockFlow.clearTruncation();
    29762978    }
    29772979}
Note: See TracChangeset for help on using the changeset viewer.