Changeset 239331 in webkit


Ignore:
Timestamp:
Dec 18, 2018 7:23:47 AM (5 years ago)
Author:
Alan Bujtas
Message:

[LFC][BFC][MarginCollapsing] Expand marginAfterCollapsesWithNextSibling and marginBeforeCollapsesWithPreviousSibling collapsing logic
https://bugs.webkit.org/show_bug.cgi?id=192791

Reviewed by Antti Koivisto.

  • layout/blockformatting/BlockMarginCollapse.cpp:

(WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginBeforeCollapsesWithPreviousSibling):
(WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginAfterCollapsesWithNextSibling):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r239330 r239331  
     12018-12-18  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC][BFC][MarginCollapsing] Expand marginAfterCollapsesWithNextSibling and marginBeforeCollapsesWithPreviousSibling collapsing logic
     4        https://bugs.webkit.org/show_bug.cgi?id=192791
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * layout/blockformatting/BlockMarginCollapse.cpp:
     9        (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginBeforeCollapsesWithPreviousSibling):
     10        (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginAfterCollapsesWithNextSibling):
     11
    1122018-12-18  Zalan Bujtas  <zalan@apple.com>
    213
  • trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp

    r239330 r239331  
    291291    ASSERT(layoutBox.isBlockLevelBox());
    292292
    293     if (layoutBox.isFloatingPositioned())
    294         return false;
    295 
    296     if (!layoutBox.isPositioned() || layoutBox.isInFlowPositioned())
    297         return true;
    298 
    299     // Out of flow positioned.
    300     ASSERT(layoutBox.isOutOfFlowPositioned());
    301     return layoutBox.style().top().isAuto();
     293    if (!layoutBox.previousInFlowSibling())
     294        return false;
     295
     296    auto& previousInFlowSibling = *layoutBox.previousInFlowSibling();
     297
     298    // Margins between a floated box and any other box do not collapse.
     299    if (layoutBox.isFloatingPositioned() || previousInFlowSibling.isFloatingPositioned())
     300        return false;
     301
     302    // Margins of absolutely positioned boxes do not collapse.
     303    if ((layoutBox.isOutOfFlowPositioned() && !layoutBox.style().top().isAuto())
     304        || (previousInFlowSibling.isOutOfFlowPositioned() && !previousInFlowSibling.style().bottom().isAuto()))
     305        return false;
     306
     307    // Margins of inline-block boxes do not collapse.
     308    if (layoutBox.isInlineBlockBox() || previousInFlowSibling.isInlineBlockBox())
     309        return false;
     310
     311    // The bottom margin of an in-flow block-level element always collapses with the top margin of
     312    // its next in-flow block-level sibling, unless that sibling has clearance.
     313    if (hasClearance(layoutBox))
     314        return false;
     315
     316    return true;
    302317}
    303318
     
    306321    ASSERT(layoutBox.isBlockLevelBox());
    307322
    308     if (layoutBox.isFloatingPositioned())
    309         return false;
    310 
    311     if (!layoutBox.isPositioned() || layoutBox.isInFlowPositioned())
    312         return true;
    313 
    314     // Out of flow positioned.
    315     ASSERT(layoutBox.isOutOfFlowPositioned());
    316     return layoutBox.style().bottom().isAuto();
     323    if (!layoutBox.nextInFlowSibling())
     324        return false;
     325
     326    return marginBeforeCollapsesWithPreviousSibling(*layoutBox.nextInFlowSibling());
    317327}
    318328
Note: See TracChangeset for help on using the changeset viewer.