Title: [271293] trunk
Revision
271293
Author
[email protected]
Date
2021-01-08 05:29:01 -0800 (Fri, 08 Jan 2021)

Log Message

Take aspect-ratio into account for percentage resolution
https://bugs.webkit.org/show_bug.cgi?id=220143

Patch by Rob Buis <[email protected]> on 2021-01-08
Reviewed by Darin Adler.

Source/WebCore:

Add aspect-ratio handling to containing block available height
computations to fix percentage resolution on its children.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::availableLogicalHeightForPercentageComputation const):
* rendering/RenderBox.cpp:
(WebCore::RenderBox::availableLogicalHeightUsing const):
(WebCore::blockSizeFromAspectRatio): Deleted.
* rendering/RenderBox.h:
(WebCore::RenderBox::blockSizeFromAspectRatio):

LayoutTests:

Enable some tests that pass now.

* TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (271292 => 271293)


--- trunk/LayoutTests/ChangeLog	2021-01-08 13:27:34 UTC (rev 271292)
+++ trunk/LayoutTests/ChangeLog	2021-01-08 13:29:01 UTC (rev 271293)
@@ -1,3 +1,14 @@
+2021-01-08  Rob Buis  <[email protected]>
+
+        Take aspect-ratio into account for percentage resolution
+        https://bugs.webkit.org/show_bug.cgi?id=220143
+
+        Reviewed by Darin Adler.
+
+        Enable some tests that pass now.
+
+        * TestExpectations:
+
 2021-01-08  Philippe Normand  <[email protected]>
 
         [GStreamer] WebAudio provider should clean-up its bin when the client disappears

Modified: trunk/LayoutTests/TestExpectations (271292 => 271293)


--- trunk/LayoutTests/TestExpectations	2021-01-08 13:27:34 UTC (rev 271292)
+++ trunk/LayoutTests/TestExpectations	2021-01-08 13:29:01 UTC (rev 271293)
@@ -4462,9 +4462,6 @@
 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/intrinsic-size-006.html [ ImageOnlyFailure ]
 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/intrinsic-size-008.html [ ImageOnlyFailure ]
 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/parsing/contain-intrinsic-size-invalid.html [ ImageOnlyFailure ]
-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/percentage-resolution-001.html [ ImageOnlyFailure ]
-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/percentage-resolution-002.html [ ImageOnlyFailure ]
-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/percentage-resolution-004.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 (271292 => 271293)


--- trunk/Source/WebCore/ChangeLog	2021-01-08 13:27:34 UTC (rev 271292)
+++ trunk/Source/WebCore/ChangeLog	2021-01-08 13:29:01 UTC (rev 271293)
@@ -1,3 +1,21 @@
+2021-01-08  Rob Buis  <[email protected]>
+
+        Take aspect-ratio into account for percentage resolution
+        https://bugs.webkit.org/show_bug.cgi?id=220143
+
+        Reviewed by Darin Adler.
+
+        Add aspect-ratio handling to containing block available height
+        computations to fix percentage resolution on its children.
+
+        * rendering/RenderBlock.cpp:
+        (WebCore::RenderBlock::availableLogicalHeightForPercentageComputation const):
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::availableLogicalHeightUsing const):
+        (WebCore::blockSizeFromAspectRatio): Deleted.
+        * rendering/RenderBox.h:
+        (WebCore::RenderBox::blockSizeFromAspectRatio):
+
 2021-01-08  Philippe Normand  <[email protected]>
 
         [GStreamer] WebAudio provider should clean-up its bin when the client disappears

Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (271292 => 271293)


--- trunk/Source/WebCore/rendering/RenderBlock.cpp	2021-01-08 13:27:34 UTC (rev 271292)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp	2021-01-08 13:29:01 UTC (rev 271293)
@@ -3207,6 +3207,8 @@
     else if (styleToUse.logicalHeight().isFixed()) {
         LayoutUnit contentBoxHeight = adjustContentBoxLogicalHeightForBoxSizing((LayoutUnit)styleToUse.logicalHeight().value());
         availableHeight = std::max(0_lu, constrainContentBoxLogicalHeightByMinMax(contentBoxHeight - scrollbarLogicalHeight(), WTF::nullopt));
+    } else if (shouldComputeLogicalHeightFromAspectRatio()) {
+        availableHeight = blockSizeFromAspectRatio(horizontalBorderAndPaddingExtent(), verticalBorderAndPaddingExtent(), style().logicalAspectRatio(), style().boxSizing(), logicalWidth());
     } else if (styleToUse.logicalHeight().isPercentOrCalculated() && !isOutOfFlowPositionedWithSpecifiedHeight) {
         Optional<LayoutUnit> heightWithScrollbar = computePercentageLogicalHeight(styleToUse.logicalHeight());
         if (heightWithScrollbar) {

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (271292 => 271293)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2021-01-08 13:27:34 UTC (rev 271292)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2021-01-08 13:29:01 UTC (rev 271293)
@@ -2828,14 +2828,6 @@
     setMarginAfter(computedValues.m_margins.m_after);
 }
 
-static LayoutUnit blockSizeFromAspectRatio(LayoutUnit borderPaddingInlineSum, LayoutUnit borderPaddingBlockSum, double aspectRatio, BoxSizing boxSizing, LayoutUnit inlineSize)
-{
-    if (boxSizing == BoxSizing::BorderBox)
-        return inlineSize / LayoutUnit(aspectRatio);
-
-    return ((inlineSize - borderPaddingInlineSum) / LayoutUnit(aspectRatio)) + borderPaddingBlockSum;
-}
-
 RenderBox::LogicalExtentComputedValues RenderBox::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop) const
 {
     LogicalExtentComputedValues computedValues;
@@ -3314,6 +3306,9 @@
             return stretchedHeight.value();
     }
 
+    if (shouldComputeLogicalHeightFromAspectRatio())
+        return blockSizeFromAspectRatio(horizontalBorderAndPaddingExtent(), verticalBorderAndPaddingExtent(), style().logicalAspectRatio(), style().boxSizing(), logicalWidth());
+
     if (h.isPercentOrCalculated() && isOutOfFlowPositioned() && !isRenderFragmentedFlow()) {
         // FIXME: This is wrong if the containingBlock has a perpendicular writing mode.
         LayoutUnit availableHeight = containingBlockLogicalHeightForPositioned(*containingBlock());

Modified: trunk/Source/WebCore/rendering/RenderBox.h (271292 => 271293)


--- trunk/Source/WebCore/rendering/RenderBox.h	2021-01-08 13:27:34 UTC (rev 271292)
+++ trunk/Source/WebCore/rendering/RenderBox.h	2021-01-08 13:29:01 UTC (rev 271293)
@@ -696,6 +696,18 @@
 
     void incrementVisuallyNonEmptyPixelCountIfNeeded(const IntSize&);
 
+    bool shouldComputeLogicalHeightFromAspectRatio() const;
+    bool shouldComputeLogicalWidthFromAspectRatio() const;
+    bool shouldComputeLogicalWidthFromAspectRatioAndInsets() const;
+    LayoutUnit computeLogicalWidthFromAspectRatio(RenderFragmentContainer* = nullptr) const;
+
+    static LayoutUnit blockSizeFromAspectRatio(LayoutUnit borderPaddingInlineSum, LayoutUnit borderPaddingBlockSum, double aspectRatio, BoxSizing boxSizing, LayoutUnit inlineSize)
+    {
+        if (boxSizing == BoxSizing::BorderBox)
+            return inlineSize / LayoutUnit(aspectRatio);
+        return ((inlineSize - borderPaddingInlineSum) / LayoutUnit(aspectRatio)) + borderPaddingBlockSum;
+    }
+
 private:
     bool replacedMinMaxLogicalHeightComputesAsNone(SizeType) const;
 
@@ -744,11 +756,6 @@
     
     void applyTopLeftLocationOffsetWithFlipping(LayoutPoint&) const;
 
-    bool shouldComputeLogicalHeightFromAspectRatio() const;
-    bool shouldComputeLogicalWidthFromAspectRatio() const;
-    bool shouldComputeLogicalWidthFromAspectRatioAndInsets() const;
-    LayoutUnit computeLogicalWidthFromAspectRatio(RenderFragmentContainer* = nullptr) const;
-
 private:
     // The width/height of the contents + borders + padding.  The x/y location is relative to our container (which is not always our parent).
     LayoutRect m_frameRect;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to