Title: [285232] trunk
Revision
285232
Author
[email protected]
Date
2021-11-03 15:01:56 -0700 (Wed, 03 Nov 2021)

Log Message

Return nullopt in aspect-ratio+intrinsic width case
https://bugs.webkit.org/show_bug.cgi?id=230769

Patch by Rob Buis <[email protected]> on 2021-11-03
Reviewed by Javier Fernandez.

Source/WebCore:

Return nullopt in aspect-ratio+intrinsic width case, while
calculating preferred widths we do not know the container width yet,
so we can't determine the logical height reliably from it.

Test: fast/css-grid-layout/aspect-ratio-auto-repeat-crash.html

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::availableLogicalHeightForPercentageComputation const):

LayoutTests:

* fast/css-grid-layout/aspect-ratio-auto-repeat-crash-expected.txt: Added.
* fast/css-grid-layout/aspect-ratio-auto-repeat-crash.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (285231 => 285232)


--- trunk/LayoutTests/ChangeLog	2021-11-03 21:58:27 UTC (rev 285231)
+++ trunk/LayoutTests/ChangeLog	2021-11-03 22:01:56 UTC (rev 285232)
@@ -1,3 +1,13 @@
+2021-11-03  Rob Buis  <[email protected]>
+
+        Return nullopt in aspect-ratio+intrinsic width case
+        https://bugs.webkit.org/show_bug.cgi?id=230769
+
+        Reviewed by Javier Fernandez.
+
+        * fast/css-grid-layout/aspect-ratio-auto-repeat-crash-expected.txt: Added.
+        * fast/css-grid-layout/aspect-ratio-auto-repeat-crash.html: Added.
+
 2021-11-03  Eric Hutchison  <[email protected]>
 
         Rebaseline http/tests/privateClickMeasurement/attribution-conversion-through-fetch-keepalive.html.

Added: trunk/LayoutTests/fast/css-grid-layout/aspect-ratio-auto-repeat-crash-expected.txt (0 => 285232)


--- trunk/LayoutTests/fast/css-grid-layout/aspect-ratio-auto-repeat-crash-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css-grid-layout/aspect-ratio-auto-repeat-crash-expected.txt	2021-11-03 22:01:56 UTC (rev 285232)
@@ -0,0 +1 @@
+This test has PASSED if it does not CRASH.

Added: trunk/LayoutTests/fast/css-grid-layout/aspect-ratio-auto-repeat-crash.html (0 => 285232)


--- trunk/LayoutTests/fast/css-grid-layout/aspect-ratio-auto-repeat-crash.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css-grid-layout/aspect-ratio-auto-repeat-crash.html	2021-11-03 22:01:56 UTC (rev 285232)
@@ -0,0 +1,19 @@
+<style>
+  html {
+    display: table;
+  }
+  head {
+    aspect-ratio: 1;
+    border-block-end: 15px solid;
+    display: grid;
+    grid-gap: 100%;
+    grid-template-rows: 1% repeat(auto-fill, 20px) 0;
+    padding-bottom: 5px;
+    padding-left: 40px;
+  }
+</style>
+<script>
+if (window.testRunner)
+  testRunner.dumpAsText();
+</script>
+This test has PASSED if it does not CRASH.

Modified: trunk/Source/WebCore/ChangeLog (285231 => 285232)


--- trunk/Source/WebCore/ChangeLog	2021-11-03 21:58:27 UTC (rev 285231)
+++ trunk/Source/WebCore/ChangeLog	2021-11-03 22:01:56 UTC (rev 285232)
@@ -1,3 +1,19 @@
+2021-11-03  Rob Buis  <[email protected]>
+
+        Return nullopt in aspect-ratio+intrinsic width case
+        https://bugs.webkit.org/show_bug.cgi?id=230769
+
+        Reviewed by Javier Fernandez.
+
+        Return nullopt in aspect-ratio+intrinsic width case, while
+        calculating preferred widths we do not know the container width yet,
+        so we can't determine the logical height reliably from it.
+
+        Test: fast/css-grid-layout/aspect-ratio-auto-repeat-crash.html
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::availableLogicalHeightForPercentageComputation const):
+
 2021-11-03  Alex Christensen  <[email protected]>
 
         [ iOS ] TestWebKitAPI.WebKitLegacy.AudioSessionCategoryIOS is crashing

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (285231 => 285232)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2021-11-03 21:58:27 UTC (rev 285231)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2021-11-03 22:01:56 UTC (rev 285232)
@@ -3178,6 +3178,9 @@
         LayoutUnit contentBoxHeight = adjustContentBoxLogicalHeightForBoxSizing((LayoutUnit)styleToUse.logicalHeight().value());
         availableHeight = std::max(0_lu, constrainContentBoxLogicalHeightByMinMax(contentBoxHeight - scrollbarLogicalHeight(), std::nullopt));
     } else if (shouldComputeLogicalHeightFromAspectRatio()) {
+        // Only grid is expected to be in a state where it is calculating pref width and having unknown logical width.
+        if (isRenderGrid() && preferredLogicalWidthsDirty() && !style().logicalWidth().isFixed())
+            return availableHeight;
         availableHeight = blockSizeFromAspectRatio(horizontalBorderAndPaddingExtent(), verticalBorderAndPaddingExtent(), LayoutUnit(style().logicalAspectRatio()), style().boxSizingForAspectRatio(), logicalWidth());
     } else if (isOutOfFlowPositionedWithSpecifiedHeight) {
         // Don't allow this to affect the block' size() member variable, since this
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to