Title: [257682] trunk
Revision
257682
Author
[email protected]
Date
2020-02-29 07:20:55 -0800 (Sat, 29 Feb 2020)

Log Message

[LFC][Floats] The used available width for float avoider with clear always matches the containing block's constraint
https://bugs.webkit.org/show_bug.cgi?id=208411
<rdar://problem/59918356>

Reviewed by Antti Koivisto.

Source/WebCore:

Test: fast/layoutformattingcontext/block-only/float-clear-with-auto-width.html

Float clear pushes the block level box either below the floats, or just one side below but the other side could overlap.
What it means is that the used available width always matches the containing block's constraint.

* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::usedAvailableWidthForFloatAvoider):
(WebCore::Layout::BlockFormattingContext::computeVerticalPositionForFloatClear):

LayoutTests:

* fast/layoutformattingcontext/block-only/float-clear-with-auto-width-expected.html: Added.
* fast/layoutformattingcontext/block-only/float-clear-with-auto-width.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (257681 => 257682)


--- trunk/LayoutTests/ChangeLog	2020-02-29 08:04:13 UTC (rev 257681)
+++ trunk/LayoutTests/ChangeLog	2020-02-29 15:20:55 UTC (rev 257682)
@@ -1,3 +1,14 @@
+2020-02-29  Zalan Bujtas  <[email protected]>
+
+        [LFC][Floats] The used available width for float avoider with clear always matches the containing block's constraint
+        https://bugs.webkit.org/show_bug.cgi?id=208411
+        <rdar://problem/59918356>
+
+        Reviewed by Antti Koivisto.
+
+        * fast/layoutformattingcontext/block-only/float-clear-with-auto-width-expected.html: Added.
+        * fast/layoutformattingcontext/block-only/float-clear-with-auto-width.html: Added.
+
 2020-02-28  Chris Dumez  <[email protected]>
 
         Garbage collection prevents FontFace.loaded promise from getting resolved

Added: trunk/LayoutTests/fast/layoutformattingcontext/block-only/float-clear-with-auto-width-expected.html (0 => 257682)


--- trunk/LayoutTests/fast/layoutformattingcontext/block-only/float-clear-with-auto-width-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/block-only/float-clear-with-auto-width-expected.html	2020-02-29 15:20:55 UTC (rev 257682)
@@ -0,0 +1,16 @@
+<!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+div {
+  width: 300px;
+  height: 60px;
+  background-color: green;
+  margin-top: 40px;
+}
+body { 
+  padding: 1px;
+}
+</style>
+<div></div>
+<div></div>
+<div></div>
+</div>

Added: trunk/LayoutTests/fast/layoutformattingcontext/block-only/float-clear-with-auto-width.html (0 => 257682)


--- trunk/LayoutTests/fast/layoutformattingcontext/block-only/float-clear-with-auto-width.html	                        (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/block-only/float-clear-with-auto-width.html	2020-02-29 15:20:55 UTC (rev 257682)
@@ -0,0 +1,31 @@
+<!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+.left {
+  float: left;
+  width: 100px;
+  height: 40px;
+}
+
+.right {
+  float: right;
+  width: 50px;
+  height: 10px;
+}
+
+.avoider {
+  width: auto;
+  height: 60px;
+  background-color: green;
+}
+</style>
+<div style="width: 300px; height: 300px; padding: 1px;">
+  <div class=left></div>
+  <div class=right></div>
+  <div class=avoider style="clear: left"></div>
+  <div class=left style="height: 60px"></div>
+  <div class=right style="height: 40px"></div>
+  <div class=avoider style="clear: right"></div>
+  <div class=left style="height: 40px"></div>
+  <div class=right style="height: 30px"></div>
+  <div class=avoider style="clear: both"></div>
+</div>

Modified: trunk/Source/WebCore/ChangeLog (257681 => 257682)


--- trunk/Source/WebCore/ChangeLog	2020-02-29 08:04:13 UTC (rev 257681)
+++ trunk/Source/WebCore/ChangeLog	2020-02-29 15:20:55 UTC (rev 257682)
@@ -1,3 +1,20 @@
+2020-02-29  Zalan Bujtas  <[email protected]>
+
+        [LFC][Floats] The used available width for float avoider with clear always matches the containing block's constraint
+        https://bugs.webkit.org/show_bug.cgi?id=208411
+        <rdar://problem/59918356>
+
+        Reviewed by Antti Koivisto.
+
+        Test: fast/layoutformattingcontext/block-only/float-clear-with-auto-width.html
+
+        Float clear pushes the block level box either below the floats, or just one side below but the other side could overlap.
+        What it means is that the used available width always matches the containing block's constraint.
+
+        * layout/blockformatting/BlockFormattingContext.cpp:
+        (WebCore::Layout::BlockFormattingContext::usedAvailableWidthForFloatAvoider):
+        (WebCore::Layout::BlockFormattingContext::computeVerticalPositionForFloatClear):
+
 2020-02-28  Peng Liu  <[email protected]>
 
         [Media in GPU process] Implement the video fullscreen and Picture-in-Picture support

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (257681 => 257682)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2020-02-29 08:04:13 UTC (rev 257681)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp	2020-02-29 15:20:55 UTC (rev 257682)
@@ -192,9 +192,15 @@
     ASSERT(layoutBox.isFloatAvoider());
     if (floatingContext.isEmpty())
         return { };
-    // Vertical static position is not computed yet, so let's just pre-compute it for now.
+    // Float clear pushes the block level box either below the floats, or just one side below but the other side could overlap.
+    // What it means is that the used available width always matches the containing block's constraint.
+    if (layoutBox.hasFloatClear())
+        return { };
+
+    ASSERT(layoutBox.establishesFormattingContext());
+    // Vertical static position is not computed yet for this formatting context root, so let's just pre-compute it for now.
+    precomputeVerticalPosition(layoutBox, horizontalConstraints.containingBlock, verticalConstraints.containingBlock);
     precomputeVerticalPositionForAncestors(layoutBox, horizontalConstraints, verticalConstraints);
-    precomputeVerticalPosition(layoutBox, horizontalConstraints.containingBlock, verticalConstraints.containingBlock);
 
     auto mapLogicalTopToFormattingContextRoot = [&] {
         auto& formattingContextRoot = root();
@@ -346,6 +352,7 @@
     displayBox.setTop(*verticalPositionAndClearance.position);
     if (verticalPositionAndClearance.clearance)
         displayBox.setHasClearance();
+    // FIXME: Reset the margin values on the ancestors/previous siblings now that the float avoider with clearance does not margin collapse anymore.
 }
 
 void BlockFormattingContext::computeWidthAndMargin(const FloatingContext& floatingContext, const Box& layoutBox, const ConstraintsPair<HorizontalConstraints>& horizontalConstraintsPair, const ConstraintsPair<VerticalConstraints>& verticalConstraintsPair)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to