Changeset 240546 in webkit


Ignore:
Timestamp:
Jan 26, 2019 7:01:34 AM (5 years ago)
Author:
Alan Bujtas
Message:

[LFC][BFC] Ignore last inflow child's collapsed through margin after when computing containing block's height.
https://bugs.webkit.org/show_bug.cgi?id=193865

Reviewed by Antti Koivisto.

Source/WebCore:

Height computation ->
10.6.3 Block-level non-replaced elements in normal flow when 'overflow' computes to 'visible'
...the bottom edge of the bottom (possibly collapsed) margin of its last in-flow child, if the child's bottom
margin does not collapse with the element's bottom margin

<div style="border: 1px solid green">

<div style="margin-top: 100px;"></div>

</div>

When the child vertical margins collapse through (margin-top = margin-bottom = 100px), the bottom edge of the bottom margin is
the same as the bottom edge of the top margin which is alredy taken into use while positioning so technically the bottom margin value should be ignored.

Test: fast/block/margin-collapse/collapsed-through-child-simple.html

  • layout/MarginTypes.h:

(WebCore::Layout::UsedVerticalMargin::isCollapsedThrough const):

  • layout/blockformatting/BlockFormattingContextGeometry.cpp:

(WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):

  • layout/displaytree/DisplayBox.h:

(WebCore::Display::Box::hasCollapsedThroughMargin const):

Tools:

  • LayoutReloaded/misc/LFC-passing-tests.txt:

LayoutTests:

  • fast/block/margin-collapse/collapsed-through-child-simple-expected.html: Added.
  • fast/block/margin-collapse/collapsed-through-child-simple.html: Added.
Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r240540 r240546  
     12019-01-26  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC][BFC] Ignore last inflow child's collapsed through margin after when computing containing block's height.
     4        https://bugs.webkit.org/show_bug.cgi?id=193865
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * fast/block/margin-collapse/collapsed-through-child-simple-expected.html: Added.
     9        * fast/block/margin-collapse/collapsed-through-child-simple.html: Added.
     10
    1112019-01-25  Devin Rousso  <drousso@apple.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r240545 r240546  
     12019-01-26  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC][BFC] Ignore last inflow child's collapsed through margin after when computing containing block's height.
     4        https://bugs.webkit.org/show_bug.cgi?id=193865
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Height computation ->
     9        // 10.6.3 Block-level non-replaced elements in normal flow when 'overflow' computes to 'visible'
     10        // ...the bottom edge of the bottom (possibly collapsed) margin of its last in-flow child, if the child's bottom
     11        // margin does not collapse with the element's bottom margin
     12
     13        <div style="border: 1px solid green">
     14          <div style="margin-top: 100px;"></div>
     15        </div>
     16
     17        When the child vertical margins collapse through (margin-top = margin-bottom = 100px), the bottom edge of the bottom margin is
     18        the same as the bottom edge of the top margin which is alredy taken into use while positioning so technically the bottom margin value should be ignored.
     19
     20        Test: fast/block/margin-collapse/collapsed-through-child-simple.html
     21
     22        * layout/MarginTypes.h:
     23        (WebCore::Layout::UsedVerticalMargin::isCollapsedThrough const):
     24        * layout/blockformatting/BlockFormattingContextGeometry.cpp:
     25        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):
     26        * layout/displaytree/DisplayBox.h:
     27        (WebCore::Display::Box::hasCollapsedThroughMargin const):
     28
    1292019-01-26  Zalan Bujtas  <zalan@apple.com>
    230
  • trunk/Source/WebCore/layout/MarginTypes.h

    r239863 r240546  
    4141    LayoutUnit before() const { return m_collapsedValues.before.valueOr(m_nonCollapsedValues.before); }
    4242    LayoutUnit after() const { return m_collapsedValues.after.valueOr(m_nonCollapsedValues.after); }
     43    bool isCollapsedThrough() const { return m_collapsedValues.isCollapsedThrough; }
    4344
    4445    struct NonCollapsedValues {
  • trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp

    r240337 r240546  
    8686        if (!MarginCollapse::marginAfterCollapsesWithParentMarginAfter(layoutState, *lastInFlowChild)) {
    8787            auto& lastInFlowDisplayBox = layoutState.displayBoxForLayoutBox(*lastInFlowChild);
    88             return { lastInFlowDisplayBox.bottom() + lastInFlowDisplayBox.marginAfter() - borderAndPaddingTop, nonCollapsedMargin };
     88            auto bottomEdgeOfBottomMargin = lastInFlowDisplayBox.bottom() + (lastInFlowDisplayBox.hasCollapsedThroughMargin() ? LayoutUnit() : lastInFlowDisplayBox.marginAfter());
     89            return { bottomEdgeOfBottomMargin - borderAndPaddingTop, nonCollapsedMargin };
    8990        }
    9091
  • trunk/Source/WebCore/layout/displaytree/DisplayBox.h

    r240475 r240546  
    144144    LayoutUnit marginAfter() const;
    145145    LayoutUnit marginEnd() const;
     146    bool hasCollapsedThroughMargin() const { return m_verticalMargin.isCollapsedThrough(); }
    146147    bool hasClearance() const { return m_hasClearance; }
    147148
  • trunk/Tools/ChangeLog

    r240541 r240546  
     12019-01-26  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC][BFC] Ignore last inflow child's collapsed through margin after when computing containing block's height.
     4        https://bugs.webkit.org/show_bug.cgi?id=193865
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * LayoutReloaded/misc/LFC-passing-tests.txt:
     9
    1102019-01-25  Ryosuke Niwa  <rniwa@webkit.org>
    211
  • trunk/Tools/LayoutReloaded/misc/LFC-passing-tests.txt

    r240475 r240546  
    135135fast/block/margin-collapse/040.html
    136136fast/block/margin-collapse/044.html
     137fast/block/margin-collapse/collapsed-through-child-simple.html
    137138fast/block/positioning/003.html
    138139fast/block/positioning/004.html
Note: See TracChangeset for help on using the changeset viewer.