Title: [292532] trunk
Revision
292532
Author
za...@apple.com
Date
2022-04-07 06:28:51 -0700 (Thu, 07 Apr 2022)

Log Message

A float avoider should never take a vertical position where a float is present even when its used width is zero
https://bugs.webkit.org/show_bug.cgi?id=238895

Reviewed by Antti Koivisto.

Source/WebCore:

A zero width available space is never a valid vertical position for a float avoider even when its width is zero too.

Test: fast/block/float/float-avoider-with-zero-width.html

* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::getClearDelta): skip and check the next candidate poisition when no space is available.

LayoutTests:

* TestExpectations: inline-size-bfc-floats.html: never produced correct rendering, the red box just happened to be hidden (which made this test pass).
* fast/block/float/float-avoider-with-zero-width-expected.html: Added.
* fast/block/float/float-avoider-with-zero-width.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (292531 => 292532)


--- trunk/LayoutTests/ChangeLog	2022-04-07 12:57:58 UTC (rev 292531)
+++ trunk/LayoutTests/ChangeLog	2022-04-07 13:28:51 UTC (rev 292532)
@@ -1,3 +1,14 @@
+2022-04-07  Alan Bujtas  <za...@apple.com>
+
+        A float avoider should never take a vertical position where a float is present even when its used width is zero
+        https://bugs.webkit.org/show_bug.cgi?id=238895
+
+        Reviewed by Antti Koivisto.
+
+        * TestExpectations: inline-size-bfc-floats.html: never produced correct rendering, the red box just happened to be hidden (which made this test pass).
+        * fast/block/float/float-avoider-with-zero-width-expected.html: Added.
+        * fast/block/float/float-avoider-with-zero-width.html: Added.
+
 2022-04-07  Tim Nguyen  <n...@apple.com>
 
         [:has() pseudo-class] Support invalidation for :autofill pseudo class

Modified: trunk/LayoutTests/TestExpectations (292531 => 292532)


--- trunk/LayoutTests/TestExpectations	2022-04-07 12:57:58 UTC (rev 292531)
+++ trunk/LayoutTests/TestExpectations	2022-04-07 13:28:51 UTC (rev 292532)
@@ -4639,7 +4639,6 @@
 webanimations/translate-property-and-translate-animation-with-delay-on-forced-layer.html [ Skip ]
 
 # CSS containment tests that fail
-imported/w3c/web-platform-tests/css/css-contain/contain-inline-size-bfc-floats-001.html [ ImageOnlyFailure ]
 # webkit-ruby-text
 imported/w3c/web-platform-tests/css/css-contain/contain-layout-017.html [ ImageOnlyFailure ]
 imported/w3c/web-platform-tests/css/css-contain/contain-paint-021.html [ ImageOnlyFailure ]
@@ -4696,6 +4695,7 @@
 webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/custom-layout-container-001.https.html [ ImageOnlyFailure ]
 webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/pseudo-elements-002.html [ ImageOnlyFailure ]
 webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/svg-foreignobject-no-size-container.html [ Skip ]
+webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/inline-size-bfc-floats.html [ ImageOnlyFailure ]
 
 # Flaky css-contain test
 imported/w3c/web-platform-tests/css/css-contain/content-visibility/animation-display-lock.html [ Failure Pass ]

Added: trunk/LayoutTests/fast/block/float/float-avoider-with-shrinking-content-expected.html (0 => 292532)


--- trunk/LayoutTests/fast/block/float/float-avoider-with-shrinking-content-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/block/float/float-avoider-with-shrinking-content-expected.html	2022-04-07 13:28:51 UTC (rev 292532)
@@ -0,0 +1,28 @@
+<style>
+.outer {
+  width: 150px;
+}
+
+.float {
+  float: left;
+  background-color: green;
+  width: 100px;
+  height: 100px
+}
+
+.right {
+  float: right;
+  background-color: blue;
+}
+
+.float_avoider {
+  width: 50px;
+  height: 200px;
+  background: yellow;
+}
+</style>
+<div class=outer>
+  <div class="float"></div>
+  <div class="float right"></div>
+  <div class="float float_avoider"></div>
+</div>

Added: trunk/LayoutTests/fast/block/float/float-avoider-with-shrinking-content.html (0 => 292532)


--- trunk/LayoutTests/fast/block/float/float-avoider-with-shrinking-content.html	                        (rev 0)
+++ trunk/LayoutTests/fast/block/float/float-avoider-with-shrinking-content.html	2022-04-07 13:28:51 UTC (rev 292532)
@@ -0,0 +1,33 @@
+<style>
+.outer {
+  width: 150px;
+}
+
+.float {
+  float: left;
+  background-color: green;
+  width: 100px;
+  height: 100px
+}
+
+.right {
+  float: right;
+  background-color: blue;
+}
+
+.float_avoider {
+  overflow: hidden;
+}
+
+.content {
+  display: inline-block;
+  width: 100px;
+  height: 200px;
+  background: yellow;
+}
+</style>
+<div class=outer>
+  <div class="float"></div>
+  <div class="float right"></div>
+  <div class=float_avoider><span class=content></span></div>
+</div>

Added: trunk/LayoutTests/fast/block/float/float-avoider-with-zero-width-expected.txt (0 => 292532)


--- trunk/LayoutTests/fast/block/float/float-avoider-with-zero-width-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/block/float/float-avoider-with-zero-width-expected.txt	2022-04-07 13:28:51 UTC (rev 292532)
@@ -0,0 +1 @@
+float avoider top position: 108

Added: trunk/LayoutTests/fast/block/float/float-avoider-with-zero-width.html (0 => 292532)


--- trunk/LayoutTests/fast/block/float/float-avoider-with-zero-width.html	                        (rev 0)
+++ trunk/LayoutTests/fast/block/float/float-avoider-with-zero-width.html	2022-04-07 13:28:51 UTC (rev 292532)
@@ -0,0 +1,40 @@
+<style>
+.outer {
+  width: 150px;
+}
+
+.float {
+  float: left;
+  background-color: green;
+  width: 100px;
+  height: 100px
+}
+
+.right {
+  float: right;
+  background-color: blue;
+}
+
+#float_avoider {
+  overflow: hidden;
+  width: 0px;
+}
+
+.content {
+  display: inline-block;
+  width: 100px;
+  height: 200px;
+  background: yellow;
+}
+</style>
+<div class=outer>
+  <div class="float"></div>
+  <div class="float right"></div>
+  <div id=float_avoider><span class=content></span></div>
+</div>
+<pre id=result></pre>
+<script>
+if (window.testRunner)
+  testRunner.dumpAsText();
+result.innerText = "float avoider top position: " + float_avoider.offsetTop;
+</script>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (292531 => 292532)


--- trunk/Source/WebCore/ChangeLog	2022-04-07 12:57:58 UTC (rev 292531)
+++ trunk/Source/WebCore/ChangeLog	2022-04-07 13:28:51 UTC (rev 292532)
@@ -1,3 +1,17 @@
+2022-04-07  Alan Bujtas  <za...@apple.com>
+
+        A float avoider should never take a vertical position where a float is present even when its used width is zero
+        https://bugs.webkit.org/show_bug.cgi?id=238895
+
+        Reviewed by Antti Koivisto.
+
+        A zero width available space is never a valid vertical position for a float avoider even when its width is zero too.
+
+        Test: fast/block/float/float-avoider-with-zero-width.html
+
+        * rendering/RenderBlockFlow.cpp:
+        (WebCore::RenderBlockFlow::getClearDelta): skip and check the next candidate poisition when no space is available.
+
 2022-04-07  Tim Nguyen  <n...@apple.com>
 
         [:has() pseudo-class] Support invalidation for :autofill pseudo class

Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (292531 => 292532)


--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2022-04-07 12:57:58 UTC (rev 292531)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp	2022-04-07 13:28:51 UTC (rev 292532)
@@ -2843,7 +2843,8 @@
             child.setMarginLeft(childOldMarginLeft);
             child.setMarginRight(childOldMarginRight);
             
-            if (childLogicalWidthAtNewLogicalTopOffset <= availableLogicalWidthAtNewLogicalTopOffset) {
+            auto shouldAvoidCurrentVerticalPosition = !availableLogicalWidthAtNewLogicalTopOffset || childLogicalWidthAtNewLogicalTopOffset > availableLogicalWidthAtNewLogicalTopOffset;
+            if (!shouldAvoidCurrentVerticalPosition) {
                 // Even though we may not be moving, if the logical width did shrink because of the presence of new floats, then
                 // we need to force a relayout as though we shifted. This happens because of the dynamic addition of overhanging floats
                 // from previous siblings when negative margins exist on a child (see the addOverhangingFloats call at the end of collapseMargins).
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to