Title: [272569] trunk
Revision
272569
Author
[email protected]
Date
2021-02-08 22:54:33 -0800 (Mon, 08 Feb 2021)

Log Message

Make auto && <ratio> use content box-sizing
https://bugs.webkit.org/show_bug.cgi?id=221527

Patch by Rob Buis <[email protected]> on 2021-02-08
Reviewed by Simon Fraser.

Source/WebCore:

Make auto && <ratio> aspect-ratio use content box-sizing as specified:
https://drafts.csswg.org/css-sizing-4/#valdef-aspect-ratio-auto--ratio

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::availableLogicalHeightForPercentageComputation const):
* rendering/RenderBox.cpp:
(WebCore::RenderBox::computeLogicalHeight const):
(WebCore::RenderBox::availableLogicalHeightUsing const):
(WebCore::RenderBox::computePositionedLogicalHeightUsing const):
(WebCore::RenderBox::computeLogicalWidthFromAspectRatio const):
(WebCore::RenderBox::computeMinMaxLogicalWidthFromAspectRatio const):
* rendering/style/RenderStyle.h:
(WebCore::RenderStyle::boxSizingForAspectRatio const):

LayoutTests:

Enable some tests that pass now.

* TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (272568 => 272569)


--- trunk/LayoutTests/ChangeLog	2021-02-09 06:51:12 UTC (rev 272568)
+++ trunk/LayoutTests/ChangeLog	2021-02-09 06:54:33 UTC (rev 272569)
@@ -1,3 +1,14 @@
+2021-02-08  Rob Buis  <[email protected]>
+
+        Make auto && <ratio> use content box-sizing
+        https://bugs.webkit.org/show_bug.cgi?id=221527
+
+        Reviewed by Simon Fraser.
+
+        Enable some tests that pass now.
+
+        * TestExpectations:
+
 2021-02-08  Simon Fraser  <[email protected]>
 
         REGRESSION (r269458): yahoo.com social / comments bar shows as transparent when scrolling page

Modified: trunk/LayoutTests/TestExpectations (272568 => 272569)


--- trunk/LayoutTests/TestExpectations	2021-02-09 06:51:12 UTC (rev 272568)
+++ trunk/LayoutTests/TestExpectations	2021-02-09 06:54:33 UTC (rev 272569)
@@ -4413,8 +4413,6 @@
 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-004.html [ ImageOnlyFailure ]
-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/block-aspect-ratio-006.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 ]

Modified: trunk/Source/WebCore/ChangeLog (272568 => 272569)


--- trunk/Source/WebCore/ChangeLog	2021-02-09 06:51:12 UTC (rev 272568)
+++ trunk/Source/WebCore/ChangeLog	2021-02-09 06:54:33 UTC (rev 272569)
@@ -1,3 +1,24 @@
+2021-02-08  Rob Buis  <[email protected]>
+
+        Make auto && <ratio> use content box-sizing
+        https://bugs.webkit.org/show_bug.cgi?id=221527
+
+        Reviewed by Simon Fraser.
+
+        Make auto && <ratio> aspect-ratio use content box-sizing as specified:
+        https://drafts.csswg.org/css-sizing-4/#valdef-aspect-ratio-auto--ratio
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::availableLogicalHeightForPercentageComputation const):
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::computeLogicalHeight const):
+        (WebCore::RenderBox::availableLogicalHeightUsing const):
+        (WebCore::RenderBox::computePositionedLogicalHeightUsing const):
+        (WebCore::RenderBox::computeLogicalWidthFromAspectRatio const):
+        (WebCore::RenderBox::computeMinMaxLogicalWidthFromAspectRatio const):
+        * rendering/style/RenderStyle.h:
+        (WebCore::RenderStyle::boxSizingForAspectRatio const):
+
 2021-02-08  Simon Fraser  <[email protected]>
 
         REGRESSION (r269458): yahoo.com social / comments bar shows as transparent when scrolling page

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (272568 => 272569)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2021-02-09 06:51:12 UTC (rev 272568)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2021-02-09 06:54:33 UTC (rev 272569)
@@ -3211,7 +3211,7 @@
         LayoutUnit contentBoxHeight = adjustContentBoxLogicalHeightForBoxSizing((LayoutUnit)styleToUse.logicalHeight().value());
         availableHeight = std::max(0_lu, constrainContentBoxLogicalHeightByMinMax(contentBoxHeight - scrollbarLogicalHeight(), WTF::nullopt));
     } else if (shouldComputeLogicalHeightFromAspectRatio()) {
-        availableHeight = blockSizeFromAspectRatio(horizontalBorderAndPaddingExtent(), verticalBorderAndPaddingExtent(), LayoutUnit(style().logicalAspectRatio()), style().boxSizing(), logicalWidth());
+        availableHeight = blockSizeFromAspectRatio(horizontalBorderAndPaddingExtent(), verticalBorderAndPaddingExtent(), LayoutUnit(style().logicalAspectRatio()), style().boxSizingForAspectRatio(), logicalWidth());
     } else if (styleToUse.logicalHeight().isPercentOrCalculated() && !isOutOfFlowPositionedWithSpecifiedHeight) {
         Optional<LayoutUnit> heightWithScrollbar = computePercentageLogicalHeight(styleToUse.logicalHeight());
         if (heightWithScrollbar) {

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (272568 => 272569)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2021-02-09 06:51:12 UTC (rev 272568)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2021-02-09 06:54:33 UTC (rev 272569)
@@ -2944,7 +2944,7 @@
         if (checkMinMaxHeight) {
             LayoutUnit intrinsicHeight = computedValues.m_extent - borderAndPaddingLogicalHeight();
             if (shouldComputeLogicalHeightFromAspectRatio())
-                heightResult = blockSizeFromAspectRatio(horizontalBorderAndPaddingExtent(), verticalBorderAndPaddingExtent(), LayoutUnit(style().logicalAspectRatio()), style().boxSizing(), logicalWidth());
+                heightResult = blockSizeFromAspectRatio(horizontalBorderAndPaddingExtent(), verticalBorderAndPaddingExtent(), LayoutUnit(style().logicalAspectRatio()), style().boxSizingForAspectRatio(), logicalWidth());
             else
                 heightResult = computeLogicalHeightUsing(MainOrPreferredSize, style().logicalHeight(), intrinsicHeight).valueOr(computedValues.m_extent);
             heightResult = constrainLogicalHeightByMinMax(heightResult, intrinsicHeight);
@@ -3376,7 +3376,7 @@
     }
 
     if (shouldComputeLogicalHeightFromAspectRatio())
-        return blockSizeFromAspectRatio(horizontalBorderAndPaddingExtent(), verticalBorderAndPaddingExtent(), LayoutUnit(style().logicalAspectRatio()), style().boxSizing(), logicalWidth());
+        return blockSizeFromAspectRatio(horizontalBorderAndPaddingExtent(), verticalBorderAndPaddingExtent(), LayoutUnit(style().logicalAspectRatio()), style().boxSizingForAspectRatio(), logicalWidth());
 
     if (h.isPercentOrCalculated() && isOutOfFlowPositioned() && !isRenderFragmentedFlow()) {
         // FIXME: This is wrong if the containingBlock has a perpendicular writing mode.
@@ -4153,7 +4153,7 @@
         if (logicalHeightLength.isIntrinsic())
             resolvedLogicalHeight = computeIntrinsicLogicalContentHeightUsing(logicalHeightLength, contentLogicalHeight, bordersPlusPadding).value();
         else if (fromAspectRatio) {
-            resolvedLogicalHeight = blockSizeFromAspectRatio(horizontalBorderAndPaddingExtent(), verticalBorderAndPaddingExtent(), LayoutUnit(style().logicalAspectRatio()), style().boxSizing(), logicalWidth());
+            resolvedLogicalHeight = blockSizeFromAspectRatio(horizontalBorderAndPaddingExtent(), verticalBorderAndPaddingExtent(), LayoutUnit(style().logicalAspectRatio()), style().boxSizingForAspectRatio(), logicalWidth());
             resolvedLogicalHeight = std::max(LayoutUnit(), resolvedLogicalHeight - bordersPlusPadding);
         } else
             resolvedLogicalHeight = adjustContentBoxLogicalHeightForBoxSizing(valueForLength(logicalHeightLength, containerLogicalHeight));
@@ -5111,7 +5111,7 @@
     auto computedValues = computeLogicalHeight(logicalHeight(), logicalTop());
     LayoutUnit logicalHeightforAspectRatio = computedValues.m_extent;
 
-    auto logicalWidth = inlineSizeFromAspectRatio(horizontalBorderAndPaddingExtent(), verticalBorderAndPaddingExtent(), LayoutUnit(style().logicalAspectRatio()), style().boxSizing(), logicalHeightforAspectRatio);
+    auto logicalWidth = inlineSizeFromAspectRatio(horizontalBorderAndPaddingExtent(), verticalBorderAndPaddingExtent(), LayoutUnit(style().logicalAspectRatio()), style().boxSizingForAspectRatio(), logicalHeightforAspectRatio);
 
     LayoutUnit containerWidthInInlineDirection = std::max<LayoutUnit>(0, containingBlockLogicalWidthForContentInFragment(fragment));
     return constrainLogicalWidthInFragmentByMinMax(logicalWidth, containerWidthInInlineDirection, *containingBlock(), fragment);
@@ -5125,9 +5125,9 @@
     LayoutUnit transferredMinSize = LayoutUnit();
     LayoutUnit transferredMaxSize = LayoutUnit::max();
     if (blockMinSize > LayoutUnit())
-        transferredMinSize = inlineSizeFromAspectRatio(horizontalBorderAndPaddingExtent(), verticalBorderAndPaddingExtent(), ratio, style().boxSizing(), blockMinSize);
+        transferredMinSize = inlineSizeFromAspectRatio(horizontalBorderAndPaddingExtent(), verticalBorderAndPaddingExtent(), ratio, style().boxSizingForAspectRatio(), blockMinSize);
     if (blockMaxSize != LayoutUnit::max())
-        transferredMaxSize = inlineSizeFromAspectRatio(horizontalBorderAndPaddingExtent(), verticalBorderAndPaddingExtent(), ratio, style().boxSizing(), blockMaxSize);
+        transferredMaxSize = inlineSizeFromAspectRatio(horizontalBorderAndPaddingExtent(), verticalBorderAndPaddingExtent(), ratio, style().boxSizingForAspectRatio(), blockMaxSize);
     // Minimum size wins over maximum size.
     transferredMaxSize = std::max(transferredMaxSize, transferredMinSize);
     return { transferredMinSize, transferredMaxSize };

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (272568 => 272569)


--- trunk/Source/WebCore/rendering/style/RenderStyle.h	2021-02-09 06:51:12 UTC (rev 272568)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h	2021-02-09 06:54:33 UTC (rev 272569)
@@ -513,6 +513,12 @@
             return aspectRatioWidth() / aspectRatioHeight();
         return aspectRatioHeight() / aspectRatioWidth();
     }
+    BoxSizing boxSizingForAspectRatio() const
+    {
+        if (aspectRatioType() == AspectRatioType::AutoAndRatio)
+            return BoxSizing::ContentBox;
+        return boxSizing();
+    }
     bool hasAspectRatio() const { return aspectRatioType() == AspectRatioType::Ratio || aspectRatioType() == AspectRatioType::AutoAndRatio; }
     BoxAlignment boxAlign() const { return static_cast<BoxAlignment>(m_rareNonInheritedData->deprecatedFlexibleBox->align); }
     BoxDirection boxDirection() const { return static_cast<BoxDirection>(m_inheritedFlags.boxDirection); }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to