Title: [287355] trunk
Revision
287355
Author
[email protected]
Date
2021-12-22 07:27:57 -0800 (Wed, 22 Dec 2021)

Log Message

[REGRESSION][[css-flexbox] child elements are shrunk to fit into container after r286206
https://bugs.webkit.org/show_bug.cgi?id=234361

Reviewed by Manuel Rego Casasnovas.

LayoutTests/imported/w3c:

* web-platform-tests/css/css-flexbox/flexbox-iframe-intrinsic-size-001-expected.html: Added.
* web-platform-tests/css/css-flexbox/flexbox-iframe-intrinsic-size-001.html: Added.
* web-platform-tests/css/css-flexbox/w3c-import.log:

Source/WebCore:

The patch from r286206 fixed the sizing of flex items with intrinsic aspect ratios but no intrinsic sizes
as happens with many SVG images. That fix was however way too general as it was targeted at any replaced
element. The problem of generalizing it is that replaced elements as iframes do not have intrinsic aspect
ratios although they have a default size (300x150px). Constraining the new code to SVG images fixes the
regression.

Replacing is<RenderReplaced>(child) with is<RenderSVGRoot>(child) wouldn't be enough as we need to consider
the newly added LegacySVGRoot that was added as part of the SVG layout refactoring.

Test: imported/w3c/web-platform-tests/css/css-flexbox/flexbox-iframe-intrinsic-size-001.html

* rendering/RenderFlexibleBox.cpp:
(WebCore::isSVGRootWithIntrinsicAspectRatio):
(WebCore::childHasAspectRatio):
(WebCore::RenderFlexibleBox::computeMainSizeFromAspectRatioUsing const):
(WebCore::RenderFlexibleBox::childHasComputableAspectRatio const):
(WebCore::isRenderReplacedWithIntrinsicAspectRatio): Deleted.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (287354 => 287355)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-12-22 12:31:35 UTC (rev 287354)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-12-22 15:27:57 UTC (rev 287355)
@@ -1,3 +1,14 @@
+2021-12-21  Sergio Villar Senin  <[email protected]>
+
+        [REGRESSION][[css-flexbox] child elements are shrunk to fit into container after r286206
+        https://bugs.webkit.org/show_bug.cgi?id=234361
+
+        Reviewed by Manuel Rego Casasnovas.
+
+        * web-platform-tests/css/css-flexbox/flexbox-iframe-intrinsic-size-001-expected.html: Added.
+        * web-platform-tests/css/css-flexbox/flexbox-iframe-intrinsic-size-001.html: Added.
+        * web-platform-tests/css/css-flexbox/w3c-import.log:
+
 2021-12-21  Tim Nguyen  <[email protected]>
 
         <dialog> should generate implied end tags

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flexbox-iframe-intrinsic-size-001-expected.html (0 => 287355)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flexbox-iframe-intrinsic-size-001-expected.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flexbox-iframe-intrinsic-size-001-expected.html	2021-12-22 15:27:57 UTC (rev 287355)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<style>
+div {
+    height: 400px;
+    border: 0;
+}
+div > div {
+    width: 50%;
+    float: left;
+}
+
+</style>
+<p>This test PASS if you see two equally sized blue and green boxes.</p>
+<div>
+    <div style='background: blue;'></div>
+    <div style='background: green;'></div>
+</div>
+
+
Property changes on: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flexbox-iframe-intrinsic-size-001-expected.html
___________________________________________________________________

Added: svn:eol-style

+LF \ No newline at end of property

Added: svn:mime-type

+text/html \ No newline at end of property

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flexbox-iframe-intrinsic-size-001.html (0 => 287355)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flexbox-iframe-intrinsic-size-001.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flexbox-iframe-intrinsic-size-001.html	2021-12-22 15:27:57 UTC (rev 287355)
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<link rel="author" title="Sergio Villar Senin" href=""
+<link rel="help" href="" title="Part E">
+<link rel="help" href="" title="For boxes with no preferred aspect ratio">
+<link rel="match" href=""
+<meta name="assert" content="Checks that the default iframe size does not imply having an aspect ratio." />
+<style>
+div {
+    display: flex;
+    height: 400px;
+}
+
+iframe {
+    flex: 1 1 auto;
+    border: 0;
+}
+</style>
+<p>This test PASS if you see two equally sized blue and green boxes.</p>
+<div>
+    <iframe style='background: blue;'></iframe>
+    <iframe style='background: green;'></iframe>
+</div>
+
+
Property changes on: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flexbox-iframe-intrinsic-size-001.html
___________________________________________________________________

Added: svn:eol-style

+LF \ No newline at end of property

Added: svn:mime-type

+text/html \ No newline at end of property

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/w3c-import.log (287354 => 287355)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/w3c-import.log	2021-12-22 12:31:35 UTC (rev 287354)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/w3c-import.log	2021-12-22 15:27:57 UTC (rev 287355)
@@ -763,6 +763,8 @@
 /LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flexbox-flex-wrap-wrap.htm
 /LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flexbox-gap-position-absolute-expected.html
 /LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flexbox-gap-position-absolute.html
+/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flexbox-iframe-intrinsic-size-001-expected.html
+/LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flexbox-iframe-intrinsic-size-001.html
 /LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flexbox-items-as-stacking-contexts-001-expected.xhtml
 /LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flexbox-items-as-stacking-contexts-001.xhtml
 /LayoutTests/imported/w3c/web-platform-tests/css/css-flexbox/flexbox-items-as-stacking-contexts-002-expected.html

Modified: trunk/Source/WebCore/ChangeLog (287354 => 287355)


--- trunk/Source/WebCore/ChangeLog	2021-12-22 12:31:35 UTC (rev 287354)
+++ trunk/Source/WebCore/ChangeLog	2021-12-22 15:27:57 UTC (rev 287355)
@@ -1,3 +1,28 @@
+2021-12-21  Sergio Villar Senin  <[email protected]>
+
+        [REGRESSION][[css-flexbox] child elements are shrunk to fit into container after r286206
+        https://bugs.webkit.org/show_bug.cgi?id=234361
+
+        Reviewed by Manuel Rego Casasnovas.
+
+        The patch from r286206 fixed the sizing of flex items with intrinsic aspect ratios but no intrinsic sizes
+        as happens with many SVG images. That fix was however way too general as it was targeted at any replaced
+        element. The problem of generalizing it is that replaced elements as iframes do not have intrinsic aspect
+        ratios although they have a default size (300x150px). Constraining the new code to SVG images fixes the
+        regression.
+
+        Replacing is<RenderReplaced>(child) with is<RenderSVGRoot>(child) wouldn't be enough as we need to consider
+        the newly added LegacySVGRoot that was added as part of the SVG layout refactoring.
+
+        Test: imported/w3c/web-platform-tests/css/css-flexbox/flexbox-iframe-intrinsic-size-001.html
+
+        * rendering/RenderFlexibleBox.cpp:
+        (WebCore::isSVGRootWithIntrinsicAspectRatio):
+        (WebCore::childHasAspectRatio):
+        (WebCore::RenderFlexibleBox::computeMainSizeFromAspectRatioUsing const):
+        (WebCore::RenderFlexibleBox::childHasComputableAspectRatio const):
+        (WebCore::isRenderReplacedWithIntrinsicAspectRatio): Deleted.
+
 2021-12-22  Frédéric Wang  <[email protected]>
 
         null ptr deref in DocumentTimeline::animate

Modified: trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp (287354 => 287355)


--- trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2021-12-22 12:31:35 UTC (rev 287354)
+++ trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp	2021-12-22 15:27:57 UTC (rev 287355)
@@ -39,6 +39,7 @@
 #include "RenderLayoutState.h"
 #include "RenderObjectEnums.h"
 #include "RenderReplaced.h"
+#include "RenderSVGRoot.h"
 #include "RenderStyleConstants.h"
 #include "RenderTable.h"
 #include "RenderView.h"
@@ -624,9 +625,9 @@
 // FIXME: consider adding this check to RenderBox::hasIntrinsicAspectRatio(). We could even make it
 // virtual returning false by default. RenderReplaced will overwrite it with the current implementation
 // plus this extra check. See wkb.ug/231955.
-static bool isRenderReplacedWithIntrinsicAspectRatio(const RenderBox& child)
+static bool isSVGRootWithIntrinsicAspectRatio(const RenderBox& child)
 {
-    if (!is<RenderReplaced>(child))
+    if (!child.isSVGRootOrLegacySVGRoot())
         return false;
     // It's common for some replaced elements, such as SVGs, to have intrinsic aspect ratios but no intrinsic sizes.
     // That's why it isn't enough just to check for intrinsic sizes in those cases.
@@ -635,7 +636,7 @@
 
 static bool childHasAspectRatio(const RenderBox& child)
 {
-    return child.hasIntrinsicAspectRatio() || child.style().hasAspectRatio() || isRenderReplacedWithIntrinsicAspectRatio(child);
+    return child.hasIntrinsicAspectRatio() || child.style().hasAspectRatio() || isSVGRootWithIntrinsicAspectRatio(child);
 }
 
 std::optional<LayoutUnit> RenderFlexibleBox::computeMainAxisExtentForChild(RenderBox& child, SizeType sizeType, const Length& size)
@@ -923,7 +924,7 @@
     }
 
     double ratio;
-    if (is<RenderReplaced>(child))
+    if (child.isSVGRootOrLegacySVGRoot())
         ratio = downcast<RenderReplaced>(child).computeIntrinsicAspectRatio();
     else {
         auto childIntrinsicSize = child.intrinsicSize();
@@ -977,7 +978,7 @@
 {
     if (!childHasAspectRatio(child))
         return false;
-    return child.intrinsicSize().height() || child.style().hasAspectRatio() || isRenderReplacedWithIntrinsicAspectRatio(child);
+    return child.intrinsicSize().height() || child.style().hasAspectRatio() || isSVGRootWithIntrinsicAspectRatio(child);
 }
 
 bool RenderFlexibleBox::childHasComputableAspectRatioAndCrossSizeIsConsideredDefinite(const RenderBox& child)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to