Changeset 292689 in webkit


Ignore:
Timestamp:
Apr 10, 2022 2:56:21 PM (2 years ago)
Author:
Alan Bujtas
Message:

Line clamp specific line-count code should be in RenderDeprecatedFlexibleBox
https://bugs.webkit.org/show_bug.cgi?id=239029

Reviewed by Antti Koivisto.

Moving the line-clamp specific code to RenderDeprecatedFlexibleBox enables us to
make RenderBlockFlow::lineCount "children inline" only.

  • rendering/RenderDeprecatedFlexibleBox.cpp:

(WebCore::lineCountFor):
(WebCore::RenderDeprecatedFlexibleBox::applyLineClamp):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r292686 r292689  
     12022-04-10  Alan Bujtas  <zalan@apple.com>
     2
     3        Line clamp specific line-count code should be in RenderDeprecatedFlexibleBox
     4        https://bugs.webkit.org/show_bug.cgi?id=239029
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Moving the line-clamp specific code to RenderDeprecatedFlexibleBox enables us to
     9        make RenderBlockFlow::lineCount "children inline" only.
     10
     11        * rendering/RenderDeprecatedFlexibleBox.cpp:
     12        (WebCore::lineCountFor):
     13        (WebCore::RenderDeprecatedFlexibleBox::applyLineClamp):
     14
    1152022-04-10  Tyler Wilcock  <tyler_w@apple.com>
    216
  • trunk/Source/WebCore/rendering/RenderBlockFlow.cpp

    r292685 r292689  
    32333233int RenderBlockFlow::lineCount() const
    32343234{
    3235     // FIXME: This should be tested by clients.
    3236     if (style().visibility() != Visibility::Visible)
     3235    if (!childrenInline()) {
     3236        ASSERT_NOT_REACHED();
    32373237        return 0;
    3238 
    3239     if (childrenInline()) {
     3238    }
    32403239#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    3241         if (modernLineLayout())
    3242             return modernLineLayout()->lineCount();
     3240    if (modernLineLayout())
     3241        return modernLineLayout()->lineCount();
    32433242#endif
    3244         if (legacyLineLayout())
    3245             return legacyLineLayout()->lineCount();
    3246 
    3247         return 0;
    3248     }
    3249 
    3250     int count = 0;
    3251     for (auto& blockFlow : childrenOfType<RenderBlockFlow>(*this)) {
    3252         if (!shouldIncludeLinesForParentLineCount(blockFlow))
    3253             continue;
    3254         count += blockFlow.lineCount();
    3255     }
    3256 
    3257     return count;
     3243    if (legacyLineLayout())
     3244        return legacyLineLayout()->lineCount();
     3245
     3246    return 0;
    32583247}
    32593248
     
    35513540bool RenderBlockFlow::hasLines() const
    35523541{
    3553     if (!childrenInline())
    3554         return false;
    3555 
    3556 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    3557     if (modernLineLayout())
    3558         return modernLineLayout()->lineCount();
    3559 #endif
    3560 
    3561     return legacyLineLayout() && legacyLineLayout()->lineBoxes().firstLineBox();
     3542    return childrenInline() ? lineCount() : false;
    35623543}
    35633544
     
    38133794            else {
    38143795                for (auto& listItem : childrenOfType<RenderListItem>(*this)) {
     3796                    if (!listItem.childrenInline() || listItem.style().visibility() != Visibility::Visible)
     3797                        continue;
    38153798                    lineCountInBlock += listItem.lineCount();
    38163799                    if (lineCountInBlock > 1)
  • trunk/Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp

    r291992 r292689  
    996996}
    997997
     998static size_t lineCountFor(const RenderBlockFlow& blockFlow)
     999{
     1000    if (blockFlow.style().visibility() != Visibility::Visible)
     1001        return 0;
     1002
     1003    if (blockFlow.childrenInline())
     1004        return blockFlow.lineCount();
     1005
     1006    size_t count = 0;
     1007    for (auto& child : childrenOfType<RenderBlockFlow>(blockFlow)) {
     1008        if (blockFlow.isFloatingOrOutOfFlowPositioned() || !blockFlow.style().height().isAuto())
     1009            continue;
     1010        count += lineCountFor(child);
     1011    }
     1012    return count;
     1013}
     1014
    9981015void RenderDeprecatedFlexibleBox::applyLineClamp(FlexBoxIterator& iterator, bool relayoutChildren)
    9991016{
     
    10161033        child->layoutIfNeeded();
    10171034        if (child->style().height().isAuto() && is<RenderBlockFlow>(*child))
    1018             maxLineCount = std::max(maxLineCount, downcast<RenderBlockFlow>(*child).lineCount());
     1035            maxLineCount = std::max<int>(maxLineCount, lineCountFor(downcast<RenderBlockFlow>(*child)));
    10191036    }
    10201037
     
    10311048
    10321049        RenderBlockFlow& blockChild = downcast<RenderBlockFlow>(*child);
    1033         int lineCount = blockChild.lineCount();
     1050        int lineCount = lineCountFor(blockChild);
    10341051        if (lineCount <= numVisibleLines)
    10351052            continue;
Note: See TracChangeset for help on using the changeset viewer.