Changeset 189594 in webkit


Ignore:
Timestamp:
Sep 10, 2015 3:15:46 PM (9 years ago)
Author:
hyatt@apple.com
Message:

[New Block-Inside-Inline Model] Self-collapsing block check needs to account for anonymous inline blocks
https://bugs.webkit.org/show_bug.cgi?id=149042

Reviewed by Dean Jackson.

Source/WebCore:

Added new tests in fast/block/inside-inlines/

  • rendering/InlineFlowBox.cpp:
  • rendering/InlineFlowBox.h:

(WebCore::InlineFlowBox::anonymousInlineBlock):
Add a new accessor to get the anonymousInlineBlock() for lines that wrap them.

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::childrenPreventSelfCollapsing):
(WebCore::RenderBlock::isSelfCollapsingBlock):
isSelfCollapsingBlock() now calls a virtual method that checks lines/children called childrenPreventSelfCollapsing.
This lets us farm out the lines check to the derived RenderBlockFlow class.

  • rendering/RenderBlock.h:

(WebCore::RenderBlock::childrenPreventSelfCollapsing):
Added new virtual method for checking children.

  • rendering/RenderBlockFlow.cpp:
  • rendering/RenderBlockFlow.h:

(WebCore::RenderBlockFlow::childrenPreventSelfCollapsing):
Overridden to ensure that blocks can still be self-collapsing if they only contain anonymous inline-block lines that
are also self-collapsing.

LayoutTests:

  • fast/block/inside-inlines/new-model/self-collapsing-test-expected.html: Added.
  • fast/block/inside-inlines/new-model/self-collapsing-test.html: Added.
  • fast/block/inside-inlines/self-collapsing-test-expected.html: Added.
  • fast/block/inside-inlines/self-collapsing-test.html: Added.
Location:
trunk
Files:
4 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r189579 r189594  
     12015-09-10  David Hyatt  <hyatt@apple.com>
     2
     3        [New Block-Inside-Inline Model] Self-collapsing block check needs to account for anonymous inline blocks
     4        https://bugs.webkit.org/show_bug.cgi?id=149042
     5
     6        Reviewed by Dean Jackson.
     7
     8        * fast/block/inside-inlines/new-model/self-collapsing-test-expected.html: Added.
     9        * fast/block/inside-inlines/new-model/self-collapsing-test.html: Added.
     10        * fast/block/inside-inlines/self-collapsing-test-expected.html: Added.
     11        * fast/block/inside-inlines/self-collapsing-test.html: Added.
     12
    1132015-09-10  Dewei Zhu  <dewei_zhu@apple.com>
    214
  • trunk/Source/WebCore/ChangeLog

    r189581 r189594  
     12015-09-10  David Hyatt  <hyatt@apple.com>
     2
     3        [New Block-Inside-Inline Model] Self-collapsing block check needs to account for anonymous inline blocks
     4        https://bugs.webkit.org/show_bug.cgi?id=149042
     5
     6        Reviewed by Dean Jackson.
     7
     8        Added new tests in fast/block/inside-inlines/
     9
     10        * rendering/InlineFlowBox.cpp:
     11        * rendering/InlineFlowBox.h:
     12        (WebCore::InlineFlowBox::anonymousInlineBlock):
     13        Add a new accessor to get the anonymousInlineBlock() for lines that wrap them.
     14
     15        * rendering/RenderBlock.cpp:
     16        (WebCore::RenderBlock::childrenPreventSelfCollapsing):
     17        (WebCore::RenderBlock::isSelfCollapsingBlock):
     18        isSelfCollapsingBlock() now calls a virtual method that checks lines/children called childrenPreventSelfCollapsing.
     19        This lets us farm out the lines check to the derived RenderBlockFlow class.
     20
     21        * rendering/RenderBlock.h:
     22        (WebCore::RenderBlock::childrenPreventSelfCollapsing):
     23        Added new virtual method for checking children.
     24
     25        * rendering/RenderBlockFlow.cpp:
     26        * rendering/RenderBlockFlow.h:
     27        (WebCore::RenderBlockFlow::childrenPreventSelfCollapsing):
     28        Overridden to ensure that blocks can still be self-collapsing if they only contain anonymous inline-block lines that
     29        are also self-collapsing.
     30
    1312015-09-10  Jinyoung Hur  <hur.ims@navercorp.com>
    232
  • trunk/Source/WebCore/rendering/InlineFlowBox.cpp

    r189144 r189594  
    6969
    7070#endif
     71
     72RenderBlockFlow* InlineFlowBox::anonymousInlineBlock() const
     73{
     74    return m_hasAnonymousInlineBlock ? &downcast<RenderBlockFlow>(firstChild()->renderer()) : nullptr;
     75}
    7176
    7277LayoutUnit InlineFlowBox::getFlowSpacingLogicalWidth()
  • trunk/Source/WebCore/rendering/InlineFlowBox.h

    r182279 r189594  
    215215    bool hasAnonymousInlineBlock() const { return m_hasAnonymousInlineBlock; }
    216216    void setHasAnonymousInlineBlock(bool b) { m_hasAnonymousInlineBlock = b; }
    217 
     217    RenderBlockFlow* anonymousInlineBlock() const;
     218   
    218219    void checkConsistency() const;
    219220    void setHasBadChildList();
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r189144 r189594  
    796796}
    797797
     798bool RenderBlock::childrenPreventSelfCollapsing() const
     799{
     800    // Whether or not we collapse is dependent on whether all our normal flow children
     801    // are also self-collapsing.
     802    for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) {
     803        if (child->isFloatingOrOutOfFlowPositioned())
     804            continue;
     805        if (!child->isSelfCollapsingBlock())
     806            return true;
     807    }
     808    return false;
     809}
     810
    798811bool RenderBlock::isSelfCollapsingBlock() const
    799812{
     
    822835    // If the height is 0 or auto, then whether or not we are a self-collapsing block depends
    823836    // on whether we have content that is all self-collapsing or not.
    824     if (hasAutoHeight || ((logicalHeightLength.isFixed() || logicalHeightLength.isPercentOrCalculated()) && logicalHeightLength.isZero())) {
    825         // If the block has inline children, see if we generated any line boxes.  If we have any
    826         // line boxes, then we can't be self-collapsing, since we have content.
    827         if (childrenInline())
    828             return !hasLines();
    829        
    830         // Whether or not we collapse is dependent on whether all our normal flow children
    831         // are also self-collapsing.
    832         for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) {
    833             if (child->isFloatingOrOutOfFlowPositioned())
    834                 continue;
    835             if (!child->isSelfCollapsingBlock())
    836                 return false;
    837         }
    838         return true;
    839     }
     837    if (hasAutoHeight || ((logicalHeightLength.isFixed() || logicalHeightLength.isPercentOrCalculated()) && logicalHeightLength.isZero()))
     838        return !childrenPreventSelfCollapsing();
     839
    840840    return false;
    841841}
  • trunk/Source/WebCore/rendering/RenderBlock.h

    r187502 r189594  
    414414    virtual void addChildIgnoringContinuation(RenderObject* newChild, RenderObject* beforeChild) override;
    415415
    416     virtual bool isSelfCollapsingBlock() const override final;
     416    virtual bool isSelfCollapsingBlock() const override;
     417    virtual bool childrenPreventSelfCollapsing() const;
     418   
    417419    // FIXME-BLOCKFLOW: Remove virtualizaion when all callers have moved to RenderBlockFlow
    418420    virtual bool hasLines() const { return false; }
  • trunk/Source/WebCore/rendering/RenderBlockFlow.cpp

    r189144 r189594  
    943943
    944944    return MarginValues(childBeforePositive, childBeforeNegative, childAfterPositive, childAfterNegative);
     945}
     946
     947bool RenderBlockFlow::childrenPreventSelfCollapsing() const
     948{
     949    if (!childrenInline())
     950        return RenderBlock::childrenPreventSelfCollapsing();
     951
     952    // If the block has inline children, see if we generated any line boxes. If we have any
     953    // line boxes, then we can only be self-collapsing if we have nothing but anonymous inline blocks
     954    // that are also self-collapsing inside us.
     955    if (!hasLines())
     956        return false;
     957   
     958    if (simpleLineLayout())
     959        return true; // We have simple line layout lines, so we can't be self-collapsing.
     960   
     961    for (auto* child = firstRootBox(); child; child = child->nextRootBox()) {
     962        if (!child->hasAnonymousInlineBlock() || !child->anonymousInlineBlock()->isSelfCollapsingBlock())
     963            return true;
     964    }
     965    return false; // We have no line boxes, so we must be self-collapsing.
    945966}
    946967
  • trunk/Source/WebCore/rendering/RenderBlockFlow.h

    r186686 r189594  
    255255    void handleAfterSideOfBlock(LayoutUnit top, LayoutUnit bottom, MarginInfo&);
    256256    void setCollapsedBottomMargin(const MarginInfo&);
     257
     258    virtual bool childrenPreventSelfCollapsing() const override final;
    257259
    258260    bool shouldBreakAtLineToAvoidWidow() const { return hasRareBlockFlowData() && rareBlockFlowData()->m_lineBreakToAvoidWidow >= 0; }
Note: See TracChangeset for help on using the changeset viewer.