[LFC] Add margin box verification back now that Display::Box has non-computed horizon...
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 31 Aug 2018 18:07:46 +0000 (18:07 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 31 Aug 2018 18:07:46 +0000 (18:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=189193

Reviewed by Antti Koivisto.

Source/WebCore:

Use the non-computed margin values to verify correctness.
This patch also fixes a margin collapsing issue when the inflow box has a float sibling. The float
sibling does not prevent collapsing with the parent's top/bottom margin.

Test: fast/block/block-only/floating-and-next-previous-inflow-with-margin-with-no-border.html

* layout/Verification.cpp:
(WebCore::Layout::outputMismatchingBlockBoxInformationIfNeeded):
(WebCore::Layout::LayoutContext::verifyAndOutputMismatchingLayoutTree const):
* layout/blockformatting/BlockMarginCollapse.cpp:
(WebCore::Layout::isMarginTopCollapsedWithParent):
(WebCore::Layout::BlockFormattingContext::MarginCollapse::isMarginBottomCollapsedWithParent):

Tools:

* LayoutReloaded/misc/LFC-passing-tests.txt:

LayoutTests:

* fast/block/block-only/floating-and-next-previous-inflow-with-margin-with-no-border-expected.txt: Added.
* fast/block/block-only/floating-and-next-previous-inflow-with-margin-with-no-border.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/block/block-only/floating-and-next-previous-inflow-with-margin-with-no-border-expected.txt [new file with mode: 0644]
LayoutTests/fast/block/block-only/floating-and-next-previous-inflow-with-margin-with-no-border.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/layout/Verification.cpp
Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp
Tools/ChangeLog
Tools/LayoutReloaded/misc/LFC-passing-tests.txt

index 0d55460..79d6cc8 100644 (file)
@@ -1,3 +1,13 @@
+2018-08-31  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC] Add margin box verification back now that Display::Box has non-computed horizontal margin.
+        https://bugs.webkit.org/show_bug.cgi?id=189193
+
+        Reviewed by Antti Koivisto.
+
+        * fast/block/block-only/floating-and-next-previous-inflow-with-margin-with-no-border-expected.txt: Added.
+        * fast/block/block-only/floating-and-next-previous-inflow-with-margin-with-no-border.html: Added.
+
 2018-08-31  Per Arne Vollan  <pvollan@apple.com>
 
         [Win] Some tests are failing on ews200 after upgrading iTunes.
diff --git a/LayoutTests/fast/block/block-only/floating-and-next-previous-inflow-with-margin-with-no-border-expected.txt b/LayoutTests/fast/block/block-only/floating-and-next-previous-inflow-with-margin-with-no-border-expected.txt
new file mode 100644 (file)
index 0000000..d413691
--- /dev/null
@@ -0,0 +1,10 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x128
+  RenderBlock {HTML} at (0,0) size 800x128
+    RenderBody {BODY} at (8,20) size 784x100
+      RenderBlock {DIV} at (0,0) size 100x100
+        RenderBlock (floating) {DIV} at (0,0) size 10x10
+        RenderBlock {DIV} at (0,0) size 10x10
+        RenderBlock {DIV} at (0,10) size 10x10
+        RenderBlock (floating) {DIV} at (0,40) size 10x10
diff --git a/LayoutTests/fast/block/block-only/floating-and-next-previous-inflow-with-margin-with-no-border.html b/LayoutTests/fast/block/block-only/floating-and-next-previous-inflow-with-margin-with-no-border.html
new file mode 100644 (file)
index 0000000..e9c2cca
--- /dev/null
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+div {
+       outline: 1px solid black;
+       width: 10px;
+       height: 10px;
+}
+</style>
+</head>
+<body>
+<div style="width: 100px; height: 100px;">
+    <div style="float: left;"></div>
+    <div style="margin-top: 20px;"></div>
+    <div style="margin-bottom: 20px;"></div>
+    <div style="float: left;"></div>
+</div>
+</body>
+</html>
index 6853599..419ea9c 100644 (file)
@@ -1,3 +1,23 @@
+2018-08-31  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC] Add margin box verification back now that Display::Box has non-computed horizontal margin.
+        https://bugs.webkit.org/show_bug.cgi?id=189193
+
+        Reviewed by Antti Koivisto.
+
+        Use the non-computed margin values to verify correctness.
+        This patch also fixes a margin collapsing issue when the inflow box has a float sibling. The float
+        sibling does not prevent collapsing with the parent's top/bottom margin.
+
+        Test: fast/block/block-only/floating-and-next-previous-inflow-with-margin-with-no-border.html
+
+        * layout/Verification.cpp:
+        (WebCore::Layout::outputMismatchingBlockBoxInformationIfNeeded):
+        (WebCore::Layout::LayoutContext::verifyAndOutputMismatchingLayoutTree const):
+        * layout/blockformatting/BlockMarginCollapse.cpp:
+        (WebCore::Layout::isMarginTopCollapsedWithParent):
+        (WebCore::Layout::BlockFormattingContext::MarginCollapse::isMarginBottomCollapsedWithParent):
+
 2018-08-31  Antti Koivisto  <antti@apple.com>
 
         Replace OptionSet |= and -= operators with add() and remove() functions
index ef11025..043fbd0 100644 (file)
@@ -121,6 +121,18 @@ static bool outputMismatchingBlockBoxInformationIfNeeded(TextStream& stream, con
         stream.nextLine();
     };
 
+    auto renderBoxLikeMarginBox = [](auto& displayBox) {
+        // Produce a RenderBox matching margin box.
+        auto borderBox = displayBox.borderBox();
+
+        return Display::Box::Rect {
+            borderBox.top() - displayBox.nonCollapsedMarginTop(),
+            borderBox.left() - displayBox.nonComputedMarginLeft(),
+            displayBox.nonComputedMarginLeft() + borderBox.width() + displayBox.nonComputedMarginRight(),
+            displayBox.nonCollapsedMarginTop() + borderBox.height() + displayBox.nonCollapsedMarginBottom()
+        };
+    };
+
     auto* displayBox = context.displayBoxForLayoutBox(layoutBox);
     ASSERT(displayBox);
 
@@ -134,6 +146,11 @@ static bool outputMismatchingBlockBoxInformationIfNeeded(TextStream& stream, con
         return true;
     }
 
+    if (renderer.marginBoxRect() != renderBoxLikeMarginBox(*displayBox)) {
+        outputRect("marginBox", renderer.marginBoxRect(), renderBoxLikeMarginBox(*displayBox));
+        return true;
+    }
+
     if (renderer.borderBoxRect() != displayBox->borderBox()) {
         outputRect("borderBox", renderer.borderBoxRect(), displayBox->borderBox());
         return true;
@@ -149,7 +166,6 @@ static bool outputMismatchingBlockBoxInformationIfNeeded(TextStream& stream, con
         return true;
     }
 
-    // TODO: The RenderBox::marginBox() does not follow the spec and ignores certain constraints. Skip them for now.
     return false;
 }
 
index 7e54af7..d2dd6ca 100644 (file)
@@ -97,8 +97,8 @@ static bool isMarginTopCollapsedWithParent(const LayoutContext& layoutContext, c
     // We never margin collapse the initial containing block.
     ASSERT(layoutBox.parent());
     auto& parent = *layoutBox.parent();
-    // Only the first inlflow child collapses with parent (floating sibling also prevents collapsing). 
-    if (layoutBox.previousInFlowOrFloatingSibling())
+    // Only the first inlflow child collapses with parent.
+    if (layoutBox.previousInFlowSibling())
         return false;
 
     if (parent.establishesBlockFormattingContext())
@@ -274,8 +274,8 @@ bool BlockFormattingContext::MarginCollapse::isMarginBottomCollapsedWithParent(c
     // We never margin collapse the initial containing block.
     ASSERT(layoutBox.parent());
     auto& parent = *layoutBox.parent();
-    // Only the last inlflow child collapses with parent (floating sibling also prevents collapsing). 
-    if (layoutBox.nextInFlowOrFloatingSibling())
+    // Only the last inlflow child collapses with parent.
+    if (layoutBox.nextInFlowSibling())
         return false;
 
     if (parent.establishesBlockFormattingContext())
index cd4a9ad..88b9494 100644 (file)
@@ -1,3 +1,12 @@
+2018-08-31  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC] Add margin box verification back now that Display::Box has non-computed horizontal margin.
+        https://bugs.webkit.org/show_bug.cgi?id=189193
+
+        Reviewed by Antti Koivisto.
+
+        * LayoutReloaded/misc/LFC-passing-tests.txt:
+
 2018-08-31  Antti Koivisto  <antti@apple.com>
 
         Replace OptionSet |= and -= operators with add() and remove() functions
index 506cf8a..640ef44 100644 (file)
@@ -47,6 +47,7 @@ fast/block/block-only/floating-multiple-lefts-in-body.html
 fast/block/block-only/floating-multiple-lefts-multiple-lines.html
 fast/block/block-only/floating-multiple-lefts.html
 fast/block/block-only/floating-and-next-previous-inflow-with-margin.html
+fast/block/block-only/floating-and-next-previous-inflow-with-margin-with-no-border.html
 fast/block/block-only/floating-left-and-right-with-clearance.html
 fast/block/block-only/float-and-siblings-with-margins.html
 fast/block/block-only/margin-collapse-with-clearance.html