Title: [238931] trunk/Source/WebCore
Revision
238931
Author
[email protected]
Date
2018-12-06 07:24:56 -0800 (Thu, 06 Dec 2018)

Log Message

[LFC][BFC][MarginCollapsing] HeightAndMargin::margin is always the non-collapsed margin value.
https://bugs.webkit.org/show_bug.cgi?id=192345

Reviewed by Antti Koivisto.

Rename HeightAndMargin::margin to HeightAndMargin::nonCollapsedMargin.

* layout/FormattingContext.cpp:
(WebCore::Layout::FormattingContext::computeOutOfFlowVerticalGeometry const):
* layout/LayoutUnits.h:
(WebCore::Layout::HeightAndMargin::usedMarginValues const):
* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::computeHeightAndMargin const):
* layout/blockformatting/BlockFormattingContextGeometry.cpp:
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowHeightAndMargin):
* layout/blockformatting/BlockFormattingContextQuirks.cpp:
(WebCore::Layout::BlockFormattingContext::Quirks::stretchedHeight):
* layout/inlineformatting/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::computeHeightAndMargin const):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (238930 => 238931)


--- trunk/Source/WebCore/ChangeLog	2018-12-06 15:21:48 UTC (rev 238930)
+++ trunk/Source/WebCore/ChangeLog	2018-12-06 15:24:56 UTC (rev 238931)
@@ -1,5 +1,28 @@
 2018-12-06  Zalan Bujtas  <[email protected]>
 
+        [LFC][BFC][MarginCollapsing] HeightAndMargin::margin is always the non-collapsed margin value.
+        https://bugs.webkit.org/show_bug.cgi?id=192345
+
+        Reviewed by Antti Koivisto.
+
+        Rename HeightAndMargin::margin to HeightAndMargin::nonCollapsedMargin.
+
+        * layout/FormattingContext.cpp:
+        (WebCore::Layout::FormattingContext::computeOutOfFlowVerticalGeometry const):
+        * layout/LayoutUnits.h:
+        (WebCore::Layout::HeightAndMargin::usedMarginValues const):
+        * layout/blockformatting/BlockFormattingContext.cpp:
+        (WebCore::Layout::BlockFormattingContext::computeHeightAndMargin const):
+        * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):
+        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowHeightAndMargin):
+        * layout/blockformatting/BlockFormattingContextQuirks.cpp:
+        (WebCore::Layout::BlockFormattingContext::Quirks::stretchedHeight):
+        * layout/inlineformatting/InlineFormattingContext.cpp:
+        (WebCore::Layout::InlineFormattingContext::computeHeightAndMargin const):
+
+2018-12-06  Zalan Bujtas  <[email protected]>
+
         [LFC][BFC][MarginCollapsing] Add MarginCollapse::establishesBlockFormattingContext
         https://bugs.webkit.org/show_bug.cgi?id=192297
 

Modified: trunk/Source/WebCore/layout/FormattingContext.cpp (238930 => 238931)


--- trunk/Source/WebCore/layout/FormattingContext.cpp	2018-12-06 15:21:48 UTC (rev 238930)
+++ trunk/Source/WebCore/layout/FormattingContext.cpp	2018-12-06 15:24:56 UTC (rev 238931)
@@ -115,11 +115,13 @@
     }
 
     auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox);
-    displayBox.setTop(verticalGeometry.top + verticalGeometry.heightAndMargin.margin.top);
+    // Margins of absolutely positioned boxes do not collapse
+    ASSERT(!verticalGeometry.heightAndMargin.collapsedMargin);
+    auto nonCollapsedVerticalMargins = verticalGeometry.heightAndMargin.usedMarginValues();
+    displayBox.setTop(verticalGeometry.top + nonCollapsedVerticalMargins.top);
     displayBox.setContentBoxHeight(verticalGeometry.heightAndMargin.height);
-    ASSERT(!verticalGeometry.heightAndMargin.collapsedMargin);
-    displayBox.setVerticalMargin(verticalGeometry.heightAndMargin.margin);
-    displayBox.setVerticalNonCollapsedMargin(verticalGeometry.heightAndMargin.margin);
+    displayBox.setVerticalMargin(nonCollapsedVerticalMargins);
+    displayBox.setVerticalNonCollapsedMargin(nonCollapsedVerticalMargins);
 }
 
 void FormattingContext::computeBorderAndPadding(const Box& layoutBox) const

Modified: trunk/Source/WebCore/layout/LayoutUnits.h (238930 => 238931)


--- trunk/Source/WebCore/layout/LayoutUnits.h	2018-12-06 15:21:48 UTC (rev 238930)
+++ trunk/Source/WebCore/layout/LayoutUnits.h	2018-12-06 15:24:56 UTC (rev 238931)
@@ -107,10 +107,10 @@
 };
 
 struct HeightAndMargin {
-    VerticalEdges usedMarginValues() const { return collapsedMargin.value_or(margin); }
+    VerticalEdges usedMarginValues() const { return collapsedMargin.value_or(nonCollapsedMargin); }
 
     LayoutUnit height;
-    VerticalEdges margin;
+    VerticalEdges nonCollapsedMargin;
     std::optional<VerticalEdges> collapsedMargin;
 };
 

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (238930 => 238931)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2018-12-06 15:21:48 UTC (rev 238930)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2018-12-06 15:24:56 UTC (rev 238931)
@@ -358,7 +358,7 @@
             auto maxHeightAndMargin = compute(maxHeight);
             // Used height should remain the same.
             ASSERT((layoutState.inQuirksMode() && (layoutBox.isBodyBox() || layoutBox.isDocumentBox())) || maxHeightAndMargin.height == *maxHeight);
-            heightAndMargin = { *maxHeight, maxHeightAndMargin.margin, maxHeightAndMargin.collapsedMargin };
+            heightAndMargin = { *maxHeight, maxHeightAndMargin.nonCollapsedMargin, maxHeightAndMargin.collapsedMargin };
         }
     }
 
@@ -367,18 +367,18 @@
             auto minHeightAndMargin = compute(minHeight);
             // Used height should remain the same.
             ASSERT((layoutState.inQuirksMode() && (layoutBox.isBodyBox() || layoutBox.isDocumentBox())) || minHeightAndMargin.height == *minHeight);
-            heightAndMargin = { *minHeight, minHeightAndMargin.margin, minHeightAndMargin.collapsedMargin };
+            heightAndMargin = { *minHeight, minHeightAndMargin.nonCollapsedMargin, minHeightAndMargin.collapsedMargin };
         }
     }
 
     auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox);
     displayBox.setContentBoxHeight(heightAndMargin.height);
-    displayBox.setVerticalNonCollapsedMargin(heightAndMargin.margin);
-    displayBox.setVerticalMargin(heightAndMargin.collapsedMargin.value_or(heightAndMargin.margin));
+    displayBox.setVerticalNonCollapsedMargin(heightAndMargin.nonCollapsedMargin);
+    displayBox.setVerticalMargin(heightAndMargin.usedMarginValues());
 
     // If this box has already been moved by the estimated vertical margin, no need to move it again.
     if (layoutBox.isFloatingPositioned() || !displayBox.estimatedMarginTop())
-        displayBox.moveVertically(heightAndMargin.collapsedMargin.value_or(heightAndMargin.margin).top);
+        displayBox.moveVertically(heightAndMargin.usedMarginValues().top);
 }
 
 FormattingContext::InstrinsicWidthConstraints BlockFormattingContext::instrinsicWidthConstraints() const

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp (238930 => 238931)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp	2018-12-06 15:21:48 UTC (rev 238930)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp	2018-12-06 15:24:56 UTC (rev 238931)
@@ -104,7 +104,7 @@
 
     auto heightAndMargin = compute();
 
-    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height][Margin] -> inflow non-replaced -> height(" << heightAndMargin.height << "px) margin(" << heightAndMargin.margin.top << "px, " << heightAndMargin.margin.bottom << "px) -> layoutBox(" << &layoutBox << ")");
+    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height][Margin] -> inflow non-replaced -> height(" << heightAndMargin.height << "px) margin(" << heightAndMargin.usedMarginValues().top << "px, " << heightAndMargin.usedMarginValues().bottom << "px) -> layoutBox(" << &layoutBox << ")");
     return heightAndMargin;
 }
 
@@ -263,7 +263,7 @@
 
     heightAndMargin = Quirks::stretchedHeight(layoutState, layoutBox, heightAndMargin);
 
-    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height][Margin] -> inflow non-replaced -> streched to viewport -> height(" << heightAndMargin.height << "px) margin(" << heightAndMargin.margin.top << "px, " << heightAndMargin.margin.bottom << "px) -> layoutBox(" << &layoutBox << ")");
+    LOG_WITH_STREAM(FormattingContextLayout, stream << "[Height][Margin] -> inflow non-replaced -> streched to viewport -> height(" << heightAndMargin.height << "px) margin(" << heightAndMargin.usedMarginValues().top << "px, " << heightAndMargin.usedMarginValues().bottom << "px) -> layoutBox(" << &layoutBox << ")");
     return heightAndMargin;
 }
 

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextQuirks.cpp (238930 => 238931)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextQuirks.cpp	2018-12-06 15:21:48 UTC (rev 238930)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextQuirks.cpp	2018-12-06 15:24:56 UTC (rev 238931)
@@ -79,9 +79,12 @@
     strechedHeight -= documentBoxVerticalBorders + documentBoxVerticalPaddings;
 
     LayoutUnit totalVerticalMargins;
-    if (layoutBox.isDocumentBox())
-        totalVerticalMargins = heightAndMargin.margin.top + heightAndMargin.margin.bottom;
-    else if (layoutBox.isBodyBox()) {
+    if (layoutBox.isDocumentBox()) {
+        auto verticalMargins = heightAndMargin.usedMarginValues();
+        // Document box's margins do not collapse.
+        ASSERT(!heightAndMargin.collapsedMargin);
+        totalVerticalMargins = verticalMargins.top + verticalMargins.bottom;
+    } else if (layoutBox.isBodyBox()) {
         // Here is the quirky part for body box:
         // Stretch the body using the initial containing block's height and shrink it with document box's margin/border/padding.
         // This looks extremely odd when html has non-auto height.
@@ -90,7 +93,7 @@
 
         // This quirk happens when the body height is 0 which means its vertical margins collapse through (top and bottom margins are adjoining).
         // However now that we stretch the body they don't collapse through anymore, so we need to use the non-collapsed values instead.
-        auto bodyBoxVerticalMargins = heightAndMargin.height ? heightAndMargin.usedMarginValues() : heightAndMargin.margin;
+        auto bodyBoxVerticalMargins = heightAndMargin.height ? heightAndMargin.usedMarginValues() : heightAndMargin.nonCollapsedMargin;
         totalVerticalMargins = bodyBoxVerticalMargins.top + bodyBoxVerticalMargins.bottom;
     }
 

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp (238930 => 238931)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp	2018-12-06 15:21:48 UTC (rev 238930)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp	2018-12-06 15:24:56 UTC (rev 238931)
@@ -362,8 +362,8 @@
 
     auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox);
     displayBox.setContentBoxHeight(heightAndMargin.height);
-    displayBox.setVerticalNonCollapsedMargin(heightAndMargin.margin);
-    displayBox.setVerticalMargin(heightAndMargin.collapsedMargin.value_or(heightAndMargin.margin));
+    displayBox.setVerticalNonCollapsedMargin(heightAndMargin.nonCollapsedMargin);
+    displayBox.setVerticalMargin(heightAndMargin.usedMarginValues());
 }
 
 void InlineFormattingContext::layoutFormattingContextRoot(const Box& root) const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to