Source/WebCore:
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 26 Jan 2019 19:24:10 +0000 (19:24 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 26 Jan 2019 19:24:10 +0000 (19:24 +0000)
[LFC] The initial values for top/bottom in contentHeightForFormattingContextRoot should not be 0.
https://bugs.webkit.org/show_bug.cgi?id=193867

Reviewed by Antti Koivisto.

The initial content top/bottom value is the border top + padding top.

This is only a problem when the box has float children only. While computing the height using the bottom-most float,
we call "top = std::min(floatTop, top)". With 0 initial top value, this returns an incorrect result when the box
has (top)border/padding.

Test: fast/block/block-only/abs-pos-with-border-padding-and-float-child.html

* layout/FormattingContextGeometry.cpp:
(WebCore::Layout::contentHeightForFormattingContextRoot):

Tools:
[LFC] The default values for top/bottom in contentHeightForFormattingContextRoot should not be 0.
https://bugs.webkit.org/show_bug.cgi?id=193867

Reviewed by Antti Koivisto.

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

LayoutTests:
[LFC] The default values for top/bottom in contentHeightForFormattingContextRoot should not be 0.
https://bugs.webkit.org/show_bug.cgi?id=193867

Reviewed by Antti Koivisto.

* fast/block/block-only/abs-pos-with-border-padding-and-float-child-expected.html: Added.
* fast/block/block-only/abs-pos-with-border-padding-and-float-child.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/block/block-only/abs-pos-with-border-padding-and-float-child-expected.html [new file with mode: 0644]
LayoutTests/fast/block/block-only/abs-pos-with-border-padding-and-float-child.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/layout/FormattingContextGeometry.cpp
Tools/ChangeLog
Tools/LayoutReloaded/misc/LFC-passing-tests.txt

index 03c519f..9a9be58 100644 (file)
@@ -1,5 +1,15 @@
 2019-01-26  Zalan Bujtas  <zalan@apple.com>
 
+        [LFC] The default values for top/bottom in contentHeightForFormattingContextRoot should not be 0.
+        https://bugs.webkit.org/show_bug.cgi?id=193867
+
+        Reviewed by Antti Koivisto.
+
+        * fast/block/block-only/abs-pos-with-border-padding-and-float-child-expected.html: Added.
+        * fast/block/block-only/abs-pos-with-border-padding-and-float-child.html: Added.
+
+2019-01-26  Zalan Bujtas  <zalan@apple.com>
+
         [LFC][BFC] Ignore last inflow child's collapsed through margin after when computing containing block's height.
         https://bugs.webkit.org/show_bug.cgi?id=193865
 
diff --git a/LayoutTests/fast/block/block-only/abs-pos-with-border-padding-and-float-child-expected.html b/LayoutTests/fast/block/block-only/abs-pos-with-border-padding-and-float-child-expected.html
new file mode 100644 (file)
index 0000000..37a53f7
--- /dev/null
@@ -0,0 +1,16 @@
+<style>
+.container { 
+    width: 200px;
+    height: 100px;
+    background-color: red;
+    margin-bottom: 300px;
+}
+.float {
+    float: left;
+    width: 200px;
+    height: 200px;
+    background: green;
+}
+</style>
+<div class=container></div>
+<div class=float></div>
diff --git a/LayoutTests/fast/block/block-only/abs-pos-with-border-padding-and-float-child.html b/LayoutTests/fast/block/block-only/abs-pos-with-border-padding-and-float-child.html
new file mode 100644 (file)
index 0000000..83e2992
--- /dev/null
@@ -0,0 +1,16 @@
+<style>
+.container { 
+    position: absolute;
+    padding-top: 300px;
+    border-top: 100px solid red;
+}
+.float {
+    float: left;
+    width: 200px;
+    height: 200px;
+    background: green;
+}
+</style>
+<div class=container>
+    <div class=float></div>
+</div>
index f81fccd..f809958 100644 (file)
@@ -1,5 +1,23 @@
 2019-01-26  Zalan Bujtas  <zalan@apple.com>
 
+        [LFC] The initial values for top/bottom in contentHeightForFormattingContextRoot should not be 0.
+        https://bugs.webkit.org/show_bug.cgi?id=193867
+
+        Reviewed by Antti Koivisto.
+
+        The initial content top/bottom value is the border top + padding top.
+
+        This is only a problem when the box has float children only. While computing the height using the bottom-most float,
+        we call "top = std::min(floatTop, top)". With 0 initial top value, this returns an incorrect result when the box
+        has (top)border/padding.
+
+        Test: fast/block/block-only/abs-pos-with-border-padding-and-float-child.html
+
+        * layout/FormattingContextGeometry.cpp:
+        (WebCore::Layout::contentHeightForFormattingContextRoot):
+
+2019-01-26  Zalan Bujtas  <zalan@apple.com>
+
         [LFC][BFC] Ignore last inflow child's collapsed through margin after when computing containing block's height.
         https://bugs.webkit.org/show_bug.cgi?id=193865
 
index e8479e7..6973160 100644 (file)
@@ -103,8 +103,10 @@ static LayoutUnit contentHeightForFormattingContextRoot(const LayoutState& layou
     if (!is<Container>(layoutBox) || !downcast<Container>(layoutBox).hasInFlowOrFloatingChild())
         return 0;
 
-    LayoutUnit top;
-    LayoutUnit bottom;
+    auto& displayBox = layoutState.displayBoxForLayoutBox(layoutBox);
+    auto borderAndPaddingTop = displayBox.borderTop() + displayBox.paddingTop().valueOr(0);
+    auto top = borderAndPaddingTop;
+    auto bottom = borderAndPaddingTop;
     auto& formattingRootContainer = downcast<Container>(layoutBox);
     if (formattingRootContainer.establishesInlineFormattingContext()) {
         // This is temp and will be replaced by the correct display box once inline runs move over to the display tree.
index eba8e91..1cf82ac 100644 (file)
@@ -1,5 +1,14 @@
 2019-01-26  Zalan Bujtas  <zalan@apple.com>
 
+        [LFC] The default values for top/bottom in contentHeightForFormattingContextRoot should not be 0.
+        https://bugs.webkit.org/show_bug.cgi?id=193867
+
+        Reviewed by Antti Koivisto.
+
+        * LayoutReloaded/misc/LFC-passing-tests.txt:
+
+2019-01-26  Zalan Bujtas  <zalan@apple.com>
+
         [LFC][BFC] Ignore last inflow child's collapsed through margin after when computing containing block's height.
         https://bugs.webkit.org/show_bug.cgi?id=193865
 
index f4cc315..ebf5693 100644 (file)
@@ -81,6 +81,7 @@ fast/block/block-only/out-of-flow-with-containing-block-border-padding.html
 fast/block/block-only/non-auto-top-bottom-left-right-widht-height-out-of-flow.html
 fast/block/block-only/non-auto-top-bottom-height-with-margins.html
 fast/block/block-only/non-auto-top-bottom-height-with-auto-margins.html
+fast/block/block-only/abs-pos-with-border-padding-and-float-child-expected.html
 fast/block/basic/002.html
 fast/block/basic/003.html
 fast/block/basic/004.html