Changeset 240474 in webkit


Ignore:
Timestamp:
Jan 25, 2019 8:46:47 AM (5 years ago)
Author:
Alan Bujtas
Message:

[LFC][BFC][MarginCollapsing] Move positive/negative margin value updating to a dedicated function
https://bugs.webkit.org/show_bug.cgi?id=193812

Reviewed by Antti Koivisto.

Move update logic to BlockFormattingContext::MarginCollapse::updatePositiveNegativeMarginValues().

  • layout/blockformatting/BlockFormattingContext.cpp:

(WebCore::Layout::BlockFormattingContext::computeHeightAndMargin const):

  • layout/blockformatting/BlockFormattingContext.h:
  • layout/blockformatting/BlockMarginCollapse.cpp:

(WebCore::Layout::BlockFormattingContext::MarginCollapse::updatePositiveNegativeMarginValues):
(WebCore::Layout::BlockFormattingContext::MarginCollapse::collapsedVerticalValues):

  • page/FrameViewLayoutContext.cpp:

(WebCore::layoutUsingFormattingContext):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r240472 r240474  
     12019-01-25  Zalan Bujtas  <zalan@apple.com>
     2
     3        [LFC][BFC][MarginCollapsing] Move positive/negative margin value updating to a dedicated function
     4        https://bugs.webkit.org/show_bug.cgi?id=193812
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Move update logic to BlockFormattingContext::MarginCollapse::updatePositiveNegativeMarginValues().
     9
     10        * layout/blockformatting/BlockFormattingContext.cpp:
     11        (WebCore::Layout::BlockFormattingContext::computeHeightAndMargin const):
     12        * layout/blockformatting/BlockFormattingContext.h:
     13        * layout/blockformatting/BlockMarginCollapse.cpp:
     14        (WebCore::Layout::BlockFormattingContext::MarginCollapse::updatePositiveNegativeMarginValues):
     15        (WebCore::Layout::BlockFormattingContext::MarginCollapse::collapsedVerticalValues):
     16        * page/FrameViewLayoutContext.cpp:
     17        (WebCore::layoutUsingFormattingContext):
     18
    1192019-01-25  Antoine Quint  <graouts@apple.com>
    220
  • trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp

    r240467 r240474  
    432432    displayBox.setContentBoxHeight(heightAndMargin.height);
    433433    displayBox.setVerticalMargin(verticalMargin);
     434
     435    MarginCollapse::updatePositiveNegativeMarginValues(layoutState, layoutBox);
    434436    // Adjust the previous sibling's margin bottom now that this box's vertical margin is computed.
    435437    MarginCollapse::updateMarginAfterForPreviousSibling(layoutState, layoutBox);
  • trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h

    r240467 r240474  
    9898        static LayoutUnit marginBeforeIgnoringCollapsingThrough(const LayoutState&, const Box&, const UsedVerticalMargin::NonCollapsedValues&);
    9999        static void updateMarginAfterForPreviousSibling(const LayoutState&, const Box&);
     100        static void updatePositiveNegativeMarginValues(const LayoutState&, const Box&);
    100101
    101102        static bool marginBeforeCollapsesWithParentMarginBefore(const LayoutState&, const Box&);
  • trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp

    r240467 r240474  
    607607}
    608608
     609void BlockFormattingContext::MarginCollapse::updatePositiveNegativeMarginValues(const LayoutState& layoutState, const Box& layoutBox)
     610{
     611    ASSERT(layoutBox.isBlockLevelBox());
     612    auto nonCollapsedValues = layoutState.displayBoxForLayoutBox(layoutBox).verticalMargin().nonCollapsedValues();
     613
     614    auto positiveNegativeMarginBefore = MarginCollapse::positiveNegativeMarginBefore(layoutState, layoutBox, nonCollapsedValues);
     615    auto positiveNegativeMarginAfter = MarginCollapse::positiveNegativeMarginAfter(layoutState, layoutBox, nonCollapsedValues);
     616
     617    if (MarginCollapse::marginsCollapseThrough(layoutState, layoutBox)) {
     618        positiveNegativeMarginBefore = computedPositiveAndNegativeMargin(positiveNegativeMarginBefore, positiveNegativeMarginAfter);
     619        positiveNegativeMarginAfter = positiveNegativeMarginBefore;
     620    }
     621    auto& blockFormattingState = downcast<BlockFormattingState>(layoutState.formattingStateForBox(layoutBox));
     622    blockFormattingState.setPositiveAndNegativeVerticalMargin(layoutBox, { positiveNegativeMarginBefore, positiveNegativeMarginAfter });
     623}
     624
    609625UsedVerticalMargin::CollapsedValues BlockFormattingContext::MarginCollapse::collapsedVerticalValues(const LayoutState& layoutState, const Box& layoutBox, const UsedVerticalMargin::NonCollapsedValues& nonCollapsedValues)
    610626{
     
    626642    }
    627643
    628     // FIXME: Move state saving out of this function.
    629     auto& blockFormattingState = downcast<BlockFormattingState>(layoutState.formattingStateForBox(layoutBox));
    630     blockFormattingState.setPositiveAndNegativeVerticalMargin(layoutBox, { positiveNegativeMarginBefore, positiveNegativeMarginAfter });
    631 
    632644    auto beforeMarginIsCollapsedValue = marginBeforeCollapsesWithFirstInFlowChildMarginBefore(layoutState, layoutBox) || marginBeforeCollapsesWithPreviousSiblingMarginAfter(layoutState, layoutBox);
    633645    auto afterMarginIsCollapsedValue = marginAfterCollapsesWithLastInFlowChildMarginAfter(layoutState, layoutBox);
Note: See TracChangeset for help on using the changeset viewer.