Title: [240474] trunk/Source/WebCore
Revision
240474
Author
za...@apple.com
Date
2019-01-25 08:46:47 -0800 (Fri, 25 Jan 2019)

Log 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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (240473 => 240474)


--- trunk/Source/WebCore/ChangeLog	2019-01-25 15:54:54 UTC (rev 240473)
+++ trunk/Source/WebCore/ChangeLog	2019-01-25 16:46:47 UTC (rev 240474)
@@ -1,3 +1,21 @@
+2019-01-25  Zalan Bujtas  <za...@apple.com>
+
+        [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):
+
 2019-01-25  Antoine Quint  <grao...@apple.com>
 
         Use ENABLE_POINTER_EVENTS for the touch-action property

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (240473 => 240474)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2019-01-25 15:54:54 UTC (rev 240473)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2019-01-25 16:46:47 UTC (rev 240474)
@@ -431,6 +431,8 @@
     displayBox.setTop(adjustedVerticalPositionAfterMarginCollapsing(layoutBox, verticalMargin));
     displayBox.setContentBoxHeight(heightAndMargin.height);
     displayBox.setVerticalMargin(verticalMargin);
+
+    MarginCollapse::updatePositiveNegativeMarginValues(layoutState, layoutBox);
     // Adjust the previous sibling's margin bottom now that this box's vertical margin is computed.
     MarginCollapse::updateMarginAfterForPreviousSibling(layoutState, layoutBox);
 }

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h (240473 => 240474)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h	2019-01-25 15:54:54 UTC (rev 240473)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h	2019-01-25 16:46:47 UTC (rev 240474)
@@ -97,6 +97,7 @@
         static EstimatedMarginBefore estimatedMarginBefore(const LayoutState&, const Box&);
         static LayoutUnit marginBeforeIgnoringCollapsingThrough(const LayoutState&, const Box&, const UsedVerticalMargin::NonCollapsedValues&);
         static void updateMarginAfterForPreviousSibling(const LayoutState&, const Box&);
+        static void updatePositiveNegativeMarginValues(const LayoutState&, const Box&);
 
         static bool marginBeforeCollapsesWithParentMarginBefore(const LayoutState&, const Box&);
         static bool marginBeforeCollapsesWithFirstInFlowChildMarginBefore(const LayoutState&, const Box&);

Modified: trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp (240473 => 240474)


--- trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp	2019-01-25 15:54:54 UTC (rev 240473)
+++ trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp	2019-01-25 16:46:47 UTC (rev 240474)
@@ -606,6 +606,22 @@
     return marginValue(positiveNegativeMarginBefore(layoutState, layoutBox, nonCollapsedValues)).valueOr(nonCollapsedValues.before);
 }
 
+void BlockFormattingContext::MarginCollapse::updatePositiveNegativeMarginValues(const LayoutState& layoutState, const Box& layoutBox)
+{
+    ASSERT(layoutBox.isBlockLevelBox());
+    auto nonCollapsedValues = layoutState.displayBoxForLayoutBox(layoutBox).verticalMargin().nonCollapsedValues();
+
+    auto positiveNegativeMarginBefore = MarginCollapse::positiveNegativeMarginBefore(layoutState, layoutBox, nonCollapsedValues);
+    auto positiveNegativeMarginAfter = MarginCollapse::positiveNegativeMarginAfter(layoutState, layoutBox, nonCollapsedValues);
+
+    if (MarginCollapse::marginsCollapseThrough(layoutState, layoutBox)) {
+        positiveNegativeMarginBefore = computedPositiveAndNegativeMargin(positiveNegativeMarginBefore, positiveNegativeMarginAfter);
+        positiveNegativeMarginAfter = positiveNegativeMarginBefore;
+    }
+    auto& blockFormattingState = downcast<BlockFormattingState>(layoutState.formattingStateForBox(layoutBox));
+    blockFormattingState.setPositiveAndNegativeVerticalMargin(layoutBox, { positiveNegativeMarginBefore, positiveNegativeMarginAfter });
+}
+
 UsedVerticalMargin::CollapsedValues BlockFormattingContext::MarginCollapse::collapsedVerticalValues(const LayoutState& layoutState, const Box& layoutBox, const UsedVerticalMargin::NonCollapsedValues& nonCollapsedValues)
 {
     if (layoutBox.isAnonymous())
@@ -625,10 +641,6 @@
         positiveNegativeMarginAfter = positiveNegativeMarginBefore;
     }
 
-    // FIXME: Move state saving out of this function.
-    auto& blockFormattingState = downcast<BlockFormattingState>(layoutState.formattingStateForBox(layoutBox));
-    blockFormattingState.setPositiveAndNegativeVerticalMargin(layoutBox, { positiveNegativeMarginBefore, positiveNegativeMarginAfter });
-
     auto beforeMarginIsCollapsedValue = marginBeforeCollapsesWithFirstInFlowChildMarginBefore(layoutState, layoutBox) || marginBeforeCollapsesWithPreviousSiblingMarginAfter(layoutState, layoutBox);
     auto afterMarginIsCollapsedValue = marginAfterCollapsesWithLastInFlowChildMarginAfter(layoutState, layoutBox);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to