[LFC] Add Display::Box::nonCollapsedMarginBox for verification purposes.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Jun 2018 15:42:42 +0000 (15:42 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Jun 2018 15:42:42 +0000 (15:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=187140

Reviewed by Antti Koivisto.

* layout/FormattingContext.cpp:
(WebCore::Layout::FormattingContext::computeFloatingHeightAndMargin const):
(WebCore::Layout::FormattingContext::computeOutOfFlowHorizontalGeometry const):
* layout/Verification.cpp:
(WebCore::Layout::outputMismatchingBoxInformationIfNeeded):
* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::computeInFlowHeightAndMargin const):
* layout/displaytree/DisplayBox.cpp:
(WebCore::Display::Box::nonCollapsedMarginBox const):
* layout/displaytree/DisplayBox.h:
(WebCore::Display::Box::setVerticalNonCollapsedMargin):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@233307 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/layout/FormattingContext.cpp
Source/WebCore/layout/Verification.cpp
Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp
Source/WebCore/layout/displaytree/DisplayBox.cpp
Source/WebCore/layout/displaytree/DisplayBox.h

index da74f30..ee9a8bd 100644 (file)
@@ -1,5 +1,24 @@
 2018-06-28  Zalan Bujtas  <zalan@apple.com>
 
+        [LFC] Add Display::Box::nonCollapsedMarginBox for verification purposes.
+        https://bugs.webkit.org/show_bug.cgi?id=187140
+
+        Reviewed by Antti Koivisto.
+
+        * layout/FormattingContext.cpp:
+        (WebCore::Layout::FormattingContext::computeFloatingHeightAndMargin const):
+        (WebCore::Layout::FormattingContext::computeOutOfFlowHorizontalGeometry const):
+        * layout/Verification.cpp:
+        (WebCore::Layout::outputMismatchingBoxInformationIfNeeded):
+        * layout/blockformatting/BlockFormattingContext.cpp:
+        (WebCore::Layout::BlockFormattingContext::computeInFlowHeightAndMargin const):
+        * layout/displaytree/DisplayBox.cpp:
+        (WebCore::Display::Box::nonCollapsedMarginBox const):
+        * layout/displaytree/DisplayBox.h:
+        (WebCore::Display::Box::setVerticalNonCollapsedMargin):
+
+2018-06-28  Zalan Bujtas  <zalan@apple.com>
+
         [LFC] The margin bottom of the document element does not collapse with its last inflow child's bottom margin.
         https://bugs.webkit.org/show_bug.cgi?id=187135
 
index 08f35d9..d818859 100644 (file)
@@ -55,7 +55,8 @@ void FormattingContext::computeFloatingHeightAndMargin(LayoutContext& layoutCont
 {
     auto heightAndMargin = Geometry::floatingHeightAndMargin(layoutContext, layoutBox);
     displayBox.setContentBoxHeight(heightAndMargin.height);
-    displayBox.moveVertically(heightAndMargin.collapsedMargin.value_or(heightAndMargin.margin).top);
+    displayBox.moveVertically(heightAndMargin.margin.top);
+    ASSERT(!heightAndMargin.collapsedMargin);
     displayBox.setVerticalMargin(heightAndMargin.margin);
 }
 
index c7fd790..6697ea8 100644 (file)
@@ -67,10 +67,19 @@ static bool outputMismatchingBoxInformationIfNeeded(TextStream& stream, const La
         return true;
     }
 
-    if (renderer.marginBoxRect() != displayBox->marginBox()) {
+#ifndef NDEBUG
+    if (renderer.marginBoxRect() != displayBox->nonCollapsedMarginBox()) {
+        outputRect("marginBox", renderer.marginBoxRect(), displayBox->nonCollapsedMarginBox());
+        return true;
+    }
+#else
+    // For now in non-debug builds, verify the horizontal margin only
+    if (renderer.marginBoxRect().left() != displayBox->marginBox().left()
+        || renderer.marginBoxRect().right() != displayBox->marginBox().right() ) {
         outputRect("marginBox", renderer.marginBoxRect(), displayBox->marginBox());
         return true;
     }
+#endif
 
     if (renderer.borderBoxRect() != displayBox->borderBox()) {
         outputRect("borderBox", renderer.borderBoxRect(), displayBox->borderBox());
index 4357735..c9c8275 100644 (file)
@@ -193,7 +193,10 @@ void BlockFormattingContext::computeInFlowHeightAndMargin(LayoutContext& layoutC
     auto heightAndMargin = Geometry::inFlowHeightAndMargin(layoutContext, layoutBox);
     displayBox.setContentBoxHeight(heightAndMargin.height);
     displayBox.moveVertically(heightAndMargin.collapsedMargin.value_or(heightAndMargin.margin).top);
-    displayBox.setVerticalMargin(heightAndMargin.margin);
+    displayBox.setVerticalMargin(heightAndMargin.collapsedMargin.value_or(heightAndMargin.margin));
+#ifndef NDEBUG
+    displayBox.setVerticalNonCollapsedMargin(heightAndMargin.margin);
+#endif
 }
 
 void BlockFormattingContext::computeInFlowWidthAndMargin(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
index 2bcc6f4..dc1f31b 100644 (file)
@@ -62,6 +62,20 @@ Box::Rect Box::marginBox() const
     return marginBox;
 }
 
+#ifndef NDEBUG
+Box::Rect Box::nonCollapsedMarginBox() const
+{
+    auto borderBox = this->borderBox();
+
+    Rect marginBox;
+    marginBox.setTop(borderBox.top() - m_nonCollapsedVertivalMargin.top);
+    marginBox.setLeft(borderBox.left() - marginLeft());
+    marginBox.setHeight(borderBox.height() + m_nonCollapsedVertivalMargin.top + m_nonCollapsedVertivalMargin.bottom);
+    marginBox.setWidth(borderBox.width() + marginLeft() + marginRight());
+    return marginBox;
+}
+#endif
+
 Box::Rect Box::borderBox() const
 {
     Rect borderBox;
index ba2d866..52bd9aa 100644 (file)
@@ -147,6 +147,9 @@ public:
     LayoutUnit contentBoxWidth() const;
 
     Rect marginBox() const;
+#ifndef NDEBUG
+    Rect nonCollapsedMarginBox() const;
+#endif
     Rect borderBox() const;
     Rect paddingBox() const;
     Rect contentBox() const;
@@ -186,6 +189,9 @@ private:
 
     void setHorizontalMargin(HorizontalEdges);
     void setVerticalMargin(VerticalEdges);
+#ifndef NDEBUG
+    void setVerticalNonCollapsedMargin(VerticalEdges margin) {  m_nonCollapsedVertivalMargin = margin; }
+#endif
     void setBorder(Edges);
     void setPadding(Edges);
 
@@ -211,6 +217,9 @@ private:
     LayoutUnit m_contentHeight;
 
     Edges m_margin;
+#ifndef NDEBUG
+    VerticalEdges m_nonCollapsedVertivalMargin;
+#endif
     Edges m_border;
     Edges m_padding;