Title: [280889] trunk
Revision
280889
Author
[email protected]
Date
2021-08-11 00:53:06 -0700 (Wed, 11 Aug 2021)

Log Message

REGRESSION (r277997): Max-height not applied for image
https://bugs.webkit.org/show_bug.cgi?id=228872

Reviewed by Antti Koivisto.

Source/WebCore:

The image get stretched because constrainLogicalHeightByMinMax uses the intrinsic height for the minimum height.
According to [1], the automatic minimum size in the ratio-dependent axis of a box is its min-content size,
not the intrinsic size. To fix this, the ratio-dependent minimum height of a box should be computed from aspect-ratio
if it doesn't have any child, otherwise, then it should consider the intrinsic height.

[1] https://www.w3.org/TR/css-sizing-4/#aspect-ratio-minimum

* rendering/RenderBox.cpp:
(WebCore::RenderBox::constrainLogicalHeightByMinMax const): The minimum height is computed from aspect-ratio if it doesn't have any child.

LayoutTests:

* TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (280888 => 280889)


--- trunk/LayoutTests/ChangeLog	2021-08-11 07:46:55 UTC (rev 280888)
+++ trunk/LayoutTests/ChangeLog	2021-08-11 07:53:06 UTC (rev 280889)
@@ -1,3 +1,12 @@
+2021-08-11  Cathie Chen  <[email protected]>
+
+        REGRESSION (r277997): Max-height not applied for image
+        https://bugs.webkit.org/show_bug.cgi?id=228872
+
+        Reviewed by Antti Koivisto.
+
+        * TestExpectations:
+
 2021-08-10  Lauro Moura  <[email protected]>
 
         [WPE] Garden new css-counter imageonly failures

Modified: trunk/LayoutTests/TestExpectations (280888 => 280889)


--- trunk/LayoutTests/TestExpectations	2021-08-11 07:46:55 UTC (rev 280888)
+++ trunk/LayoutTests/TestExpectations	2021-08-11 07:53:06 UTC (rev 280889)
@@ -4702,8 +4702,6 @@
 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-022.html [ ImageOnlyFailure ]
 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-025.html [ ImageOnlyFailure ]
 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-026.html [ ImageOnlyFailure ]
-webkit.org/b/228872 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-029.html [ ImageOnlyFailure ]
-webkit.org/b/228872 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-030.html [ ImageOnlyFailure ]
 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/contain-intrinsic-size/contain-intrinsic-size-001.html [ ImageOnlyFailure ]
 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/contain-intrinsic-size/contain-intrinsic-size-002.html [ ImageOnlyFailure ]
 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/contain-intrinsic-size/contain-intrinsic-size-003.html [ ImageOnlyFailure ]

Modified: trunk/Source/WebCore/ChangeLog (280888 => 280889)


--- trunk/Source/WebCore/ChangeLog	2021-08-11 07:46:55 UTC (rev 280888)
+++ trunk/Source/WebCore/ChangeLog	2021-08-11 07:53:06 UTC (rev 280889)
@@ -1,3 +1,20 @@
+2021-08-11  Cathie Chen  <[email protected]>
+
+        REGRESSION (r277997): Max-height not applied for image
+        https://bugs.webkit.org/show_bug.cgi?id=228872
+
+        Reviewed by Antti Koivisto.
+
+        The image get stretched because constrainLogicalHeightByMinMax uses the intrinsic height for the minimum height.
+        According to [1], the automatic minimum size in the ratio-dependent axis of a box is its min-content size,
+        not the intrinsic size. To fix this, the ratio-dependent minimum height of a box should be computed from aspect-ratio
+        if it doesn't have any child, otherwise, then it should consider the intrinsic height. 
+
+        [1] https://www.w3.org/TR/css-sizing-4/#aspect-ratio-minimum
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::constrainLogicalHeightByMinMax const): The minimum height is computed from aspect-ratio if it doesn't have any child.
+
 2021-08-11  Rob Buis  <[email protected]>
 
         [SVG] Attribute change triggers redundant (and out of order) setNeedsLayout call

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (280888 => 280889)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2021-08-11 07:46:55 UTC (rev 280888)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2021-08-11 07:53:06 UTC (rev 280889)
@@ -677,8 +677,12 @@
             logicalHeight = std::min(logicalHeight, maxH.value());
     }
     auto logicalMinHeight = styleToUse.logicalMinHeight();
-    if (logicalMinHeight.isAuto() && shouldComputeLogicalHeightFromAspectRatio() && intrinsicContentHeight && styleToUse.overflowBlockDirection() == Overflow::Visible)
-        logicalMinHeight = Length(*intrinsicContentHeight, LengthType::Fixed);
+    if (logicalMinHeight.isAuto() && shouldComputeLogicalHeightFromAspectRatio() && intrinsicContentHeight && styleToUse.overflowBlockDirection() == Overflow::Visible) {
+        auto heightFromAspectRatio = blockSizeFromAspectRatio(horizontalBorderAndPaddingExtent(), verticalBorderAndPaddingExtent(), LayoutUnit(style().logicalAspectRatio()), style().boxSizingForAspectRatio(), logicalWidth()) - borderAndPaddingLogicalHeight();
+        if (firstChild())
+            heightFromAspectRatio = std::max(heightFromAspectRatio, *intrinsicContentHeight);
+        logicalMinHeight = Length(heightFromAspectRatio, LengthType::Fixed);
+    }
     if (logicalMinHeight.isMinContent() || logicalMinHeight.isMaxContent())
         logicalMinHeight = Length();
     if (std::optional<LayoutUnit> computedLogicalHeight = computeLogicalHeightUsing(MinSize, logicalMinHeight, intrinsicContentHeight))
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to