Title: [272718] trunk
Revision
272718
Author
[email protected]
Date
2021-02-11 02:55:20 -0800 (Thu, 11 Feb 2021)

Log Message

Handle min-width/min-height:auto for aspect-ratio
https://bugs.webkit.org/show_bug.cgi?id=220582

Patch by Rob Buis <[email protected]> on 2021-02-11
Reviewed by Antti Koivisto.

Source/WebCore:

Implement automatic minimum size [1] handling for aspect-ratio
as specified here [2].

[1] https://drafts.csswg.org/css-sizing-3/#automatic-minimum-size
[2] https://drafts.csswg.org/css-sizing-4/#aspect-ratio-minimum

* rendering/RenderBox.cpp:
(WebCore::RenderBox::constrainLogicalWidthInFragmentByMinMax const):
(WebCore::RenderBox::constrainLogicalHeightByMinMax const):
(WebCore::RenderBox::computePositionedLogicalWidthUsing const):
(WebCore::RenderBox::computePositionedLogicalHeight const):
(WebCore::RenderBox::computePositionedLogicalHeightUsing const):

LayoutTests:

Enable tests that pass now.

* TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (272717 => 272718)


--- trunk/LayoutTests/ChangeLog	2021-02-11 10:30:29 UTC (rev 272717)
+++ trunk/LayoutTests/ChangeLog	2021-02-11 10:55:20 UTC (rev 272718)
@@ -1,3 +1,14 @@
+2021-02-11  Rob Buis  <[email protected]>
+
+        Handle min-width/min-height:auto for aspect-ratio
+        https://bugs.webkit.org/show_bug.cgi?id=220582
+
+        Reviewed by Antti Koivisto.
+
+        Enable tests that pass now.
+
+        * TestExpectations:
+
 2021-02-11  Myles C. Maxfield  <[email protected]>
 
         Remove another use of FontSelector from within CSSFontFace

Modified: trunk/LayoutTests/TestExpectations (272717 => 272718)


--- trunk/LayoutTests/TestExpectations	2021-02-11 10:30:29 UTC (rev 272717)
+++ trunk/LayoutTests/TestExpectations	2021-02-11 10:55:20 UTC (rev 272718)
@@ -4555,13 +4555,7 @@
 webkit.org/b/214462 imported/w3c/web-platform-tests/css/css-scoping/shadow-directionality-002.tentative.html [ ImageOnlyFailure ]
 webkit.org/b/214462 imported/w3c/web-platform-tests/css/css-scoping/slotted-placeholder.html [ ImageOnlyFailure ]
 
-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/abspos-012.html [ ImageOnlyFailure ]
-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/abspos-013.html [ ImageOnlyFailure ]
 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/abspos-014.html [ ImageOnlyFailure ]
-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/block-aspect-ratio-009.html [ ImageOnlyFailure ]
-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/block-aspect-ratio-014.html [ ImageOnlyFailure ]
-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/block-aspect-ratio-015.html [ ImageOnlyFailure ]
-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/block-aspect-ratio-017.html [ ImageOnlyFailure ]
 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/block-aspect-ratio-024.html [ ImageOnlyFailure ]
 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/block-aspect-ratio-028.html [ ImageOnlyFailure ]
 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/block-aspect-ratio-030.html [ ImageOnlyFailure ]
@@ -4569,6 +4563,7 @@
 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-002.html [ ImageOnlyFailure ]
 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-004.html [ ImageOnlyFailure ]
 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-005.html [ ImageOnlyFailure ]
+webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-008.html [ ImageOnlyFailure ]
 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-009.html [ ImageOnlyFailure ]
 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-011.html [ ImageOnlyFailure ]
 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/flex-aspect-ratio-012.html [ ImageOnlyFailure ]

Modified: trunk/Source/WebCore/ChangeLog (272717 => 272718)


--- trunk/Source/WebCore/ChangeLog	2021-02-11 10:30:29 UTC (rev 272717)
+++ trunk/Source/WebCore/ChangeLog	2021-02-11 10:55:20 UTC (rev 272718)
@@ -1,3 +1,23 @@
+2021-02-11  Rob Buis  <[email protected]>
+
+        Handle min-width/min-height:auto for aspect-ratio
+        https://bugs.webkit.org/show_bug.cgi?id=220582
+
+        Reviewed by Antti Koivisto.
+
+        Implement automatic minimum size [1] handling for aspect-ratio
+        as specified here [2].
+
+        [1] https://drafts.csswg.org/css-sizing-3/#automatic-minimum-size
+        [2] https://drafts.csswg.org/css-sizing-4/#aspect-ratio-minimum
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::constrainLogicalWidthInFragmentByMinMax const):
+        (WebCore::RenderBox::constrainLogicalHeightByMinMax const):
+        (WebCore::RenderBox::computePositionedLogicalWidthUsing const):
+        (WebCore::RenderBox::computePositionedLogicalHeight const):
+        (WebCore::RenderBox::computePositionedLogicalHeightUsing const):
+
 2021-02-11  Myles C. Maxfield  <[email protected]>
 
         Remove another use of FontSelector from within CSSFontFace

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (272717 => 272718)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2021-02-11 10:30:29 UTC (rev 272717)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2021-02-11 10:55:20 UTC (rev 272718)
@@ -662,7 +662,13 @@
 
     if (!styleToUse.logicalMaxWidth().isUndefined())
         logicalWidth = std::min(logicalWidth, computeLogicalWidthInFragmentUsing(MaxSize, styleToUse.logicalMaxWidth(), availableWidth, cb, fragment));
-    return std::max(logicalWidth, computeLogicalWidthInFragmentUsing(MinSize, styleToUse.logicalMinWidth(), availableWidth, cb, fragment));
+    auto minLength = styleToUse.logicalMinWidth();
+    if (styleToUse.hasAspectRatio() && styleToUse.logicalWidth().isAuto() && minLength.isAuto() && styleToUse.overflowInlineDirection() == Overflow::Visible) {
+        // Make sure we actually used the aspect ratio.
+        if (shouldComputeLogicalWidthFromAspectRatio())
+            minLength = Length(MinContent);
+    }
+    return std::max(logicalWidth, computeLogicalWidthInFragmentUsing(MinSize, minLength, availableWidth, cb, fragment));
 }
 
 LayoutUnit RenderBox::constrainLogicalHeightByMinMax(LayoutUnit logicalHeight, Optional<LayoutUnit> intrinsicContentHeight) const
@@ -672,7 +678,10 @@
         if (Optional<LayoutUnit> maxH = computeLogicalHeightUsing(MaxSize, styleToUse.logicalMaxHeight(), intrinsicContentHeight))
             logicalHeight = std::min(logicalHeight, maxH.value());
     }
-    if (Optional<LayoutUnit> computedLogicalHeight = computeLogicalHeightUsing(MinSize, styleToUse.logicalMinHeight(), intrinsicContentHeight))
+    auto logicalMinHeight = styleToUse.logicalMinHeight();
+    if (logicalMinHeight.isAuto() && shouldComputeLogicalHeightFromAspectRatio() && intrinsicContentHeight && styleToUse.overflowBlockDirection() == Overflow::Visible)
+        logicalMinHeight = Length(*intrinsicContentHeight, Fixed);
+    if (Optional<LayoutUnit> computedLogicalHeight = computeLogicalHeightUsing(MinSize, logicalMinHeight, intrinsicContentHeight))
         return std::max(logicalHeight, computedLogicalHeight.value());
     return logicalHeight;
 }
@@ -3787,9 +3796,15 @@
 {
     ASSERT(widthType == MinSize || widthType == MainOrPreferredSize || !logicalWidth.isAuto());
     auto originalLogicalWidthType = logicalWidth.type();
-    if (widthType == MinSize && logicalWidth.isAuto())
-        logicalWidth = Length(0, Fixed);
-    else if (widthType == MainOrPreferredSize && logicalWidth.isAuto() && shouldComputeLogicalWidthFromAspectRatio())
+    if (widthType == MinSize && logicalWidth.isAuto()) {
+        if (shouldComputeLogicalWidthFromAspectRatio()) {
+            LayoutUnit minLogicalWidth;
+            LayoutUnit maxLogicalWidth;
+            computeIntrinsicLogicalWidths(minLogicalWidth, maxLogicalWidth);
+            logicalWidth = Length(minLogicalWidth, Fixed);
+        } else
+            logicalWidth = Length(0, Fixed);
+    } else if (widthType == MainOrPreferredSize && logicalWidth.isAuto() && shouldComputeLogicalWidthFromAspectRatio())
         logicalWidth = Length(computeLogicalWidthFromAspectRatio(), Fixed);
     else if (logicalWidth.isIntrinsic())
         logicalWidth = Length(computeIntrinsicLogicalWidthUsing(logicalWidth, containerLogicalWidth, bordersPlusPadding) - bordersPlusPadding, Fixed);
@@ -4060,7 +4075,8 @@
     }
 
     // Calculate constraint equation values for 'min-height' case.
-    if (!styleToUse.logicalMinHeight().isZero() || styleToUse.logicalMinHeight().isIntrinsic()) {
+    Length logicalMinHeight = styleToUse.logicalMinHeight();
+    if (logicalMinHeight.isAuto() || !logicalMinHeight.isZero() || logicalMinHeight.isIntrinsic()) {
         LogicalExtentComputedValues minValues;
 
         computePositionedLogicalHeightUsing(MinSize, styleToUse.logicalMinHeight(), containerBlock, containerLogicalHeight, bordersPlusPadding, logicalHeight,
@@ -4125,8 +4141,12 @@
                                                     LogicalExtentComputedValues& computedValues) const
 {
     ASSERT(heightType == MinSize || heightType == MainOrPreferredSize || !logicalHeightLength.isAuto());
-    if (heightType == MinSize && logicalHeightLength.isAuto())
-        logicalHeightLength = Length(0, Fixed);
+    if (heightType == MinSize && logicalHeightLength.isAuto()) {
+        if (shouldComputeLogicalHeightFromAspectRatio())
+            logicalHeightLength = Length(logicalHeight, Fixed);
+        else
+            logicalHeightLength = Length(0, Fixed);
+    }
 
     // 'top' and 'bottom' cannot both be 'auto' because 'top would of been
     // converted to the static position in computePositionedLogicalHeight()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to