Title: [272307] trunk
Revision
272307
Author
[email protected]
Date
2021-02-03 05:05:51 -0800 (Wed, 03 Feb 2021)

Log Message

Support aspect-ratio on grid items
https://bugs.webkit.org/show_bug.cgi?id=220977

Patch by Rob Buis <[email protected]> on 2021-02-03
Reviewed by Javier Fernandez.

Source/WebCore:

Support aspect-ratio for grid items by correcting
the auto-size determination for row/columns-axis
when the child has aspect-ratio set.

* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::hasAutoSizeInColumnAxis const):
(WebCore::RenderGrid::hasAutoSizeInRowAxis const):
* rendering/RenderGrid.h:

LayoutTests:

Enable some tests that pass now.

* TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (272306 => 272307)


--- trunk/LayoutTests/ChangeLog	2021-02-03 11:48:31 UTC (rev 272306)
+++ trunk/LayoutTests/ChangeLog	2021-02-03 13:05:51 UTC (rev 272307)
@@ -1,3 +1,14 @@
+2021-02-03  Rob Buis  <[email protected]>
+
+        Support aspect-ratio on grid items
+        https://bugs.webkit.org/show_bug.cgi?id=220977
+
+        Reviewed by Javier Fernandez.
+
+        Enable some tests that pass now.
+
+        * TestExpectations:
+
 2021-02-03  Youenn Fablet  <[email protected]>
 
         Enable webrtc video capture in GPUProcess for iOS WebKitTestRunner

Modified: trunk/LayoutTests/TestExpectations (272306 => 272307)


--- trunk/LayoutTests/TestExpectations	2021-02-03 11:48:31 UTC (rev 272306)
+++ trunk/LayoutTests/TestExpectations	2021-02-03 13:05:51 UTC (rev 272307)
@@ -4440,10 +4440,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/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/grid-aspect-ratio-007.html [ ImageOnlyFailure ]
-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/grid-aspect-ratio-009.html [ ImageOnlyFailure ]
-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/grid-aspect-ratio-011.html [ ImageOnlyFailure ]
-webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/grid-aspect-ratio-012.html [ ImageOnlyFailure ]
 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/intrinsic-size-001.html [ ImageOnlyFailure ]
 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/intrinsic-size-002.html [ ImageOnlyFailure ]
 webkit.org/b/214463 imported/w3c/web-platform-tests/css/css-sizing/aspect-ratio/intrinsic-size-004.html [ ImageOnlyFailure ]

Modified: trunk/Source/WebCore/ChangeLog (272306 => 272307)


--- trunk/Source/WebCore/ChangeLog	2021-02-03 11:48:31 UTC (rev 272306)
+++ trunk/Source/WebCore/ChangeLog	2021-02-03 13:05:51 UTC (rev 272307)
@@ -1,3 +1,19 @@
+2021-02-03  Rob Buis  <[email protected]>
+
+        Support aspect-ratio on grid items
+        https://bugs.webkit.org/show_bug.cgi?id=220977
+
+        Reviewed by Javier Fernandez.
+
+        Support aspect-ratio for grid items by correcting
+        the auto-size determination for row/columns-axis
+        when the child has aspect-ratio set.
+
+        * rendering/RenderGrid.cpp:
+        (WebCore::RenderGrid::hasAutoSizeInColumnAxis const):
+        (WebCore::RenderGrid::hasAutoSizeInRowAxis const):
+        * rendering/RenderGrid.h:
+
 2021-02-01  Antoine Quint  <[email protected]>
 
         Animation of "rotate" or "scale" property does not correctly account for static "translate" property

Modified: trunk/Source/WebCore/rendering/RenderGrid.cpp (272306 => 272307)


--- trunk/Source/WebCore/rendering/RenderGrid.cpp	2021-02-03 11:48:31 UTC (rev 272306)
+++ trunk/Source/WebCore/rendering/RenderGrid.cpp	2021-02-03 13:05:51 UTC (rev 272307)
@@ -1859,4 +1859,36 @@
     return "RenderGrid";
 }
 
+bool RenderGrid::hasAutoSizeInColumnAxis(const RenderBox& child) const
+{
+    if (child.style().hasAspectRatio()) {
+        if (isHorizontalWritingMode() == child.isHorizontalWritingMode()) {
+            // A non-auto inline size means the same for block size (column axis size) because of the aspect ratio.
+            if (!child.style().logicalWidth().isAuto())
+                return false;
+        } else {
+            const Length& logicalHeight = child.style().logicalHeight();
+            if (logicalHeight.isFixed() || (logicalHeight.isPercentOrCalculated() && child.percentageLogicalHeightIsResolvable()))
+                return false;
+        }
+    }
+    return isHorizontalWritingMode() ? child.style().height().isAuto() : child.style().width().isAuto();
+}
+
+bool RenderGrid::hasAutoSizeInRowAxis(const RenderBox& child) const
+{
+    if (child.style().hasAspectRatio()) {
+        if (isHorizontalWritingMode() == child.isHorizontalWritingMode()) {
+            // A non-auto block size means the same for inline size (row axis size) because of the aspect ratio.
+            const Length& logicalHeight = child.style().logicalHeight();
+            if (logicalHeight.isFixed() || (logicalHeight.isPercentOrCalculated() && child.percentageLogicalHeightIsResolvable()))
+                return false;
+        } else {
+            if (!child.style().logicalWidth().isAuto())
+                return false;
+        }
+    }
+    return isHorizontalWritingMode() ? child.style().width().isAuto() : child.style().height().isAuto();
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/RenderGrid.h (272306 => 272307)


--- trunk/Source/WebCore/rendering/RenderGrid.h	2021-02-03 11:48:31 UTC (rev 272306)
+++ trunk/Source/WebCore/rendering/RenderGrid.h	2021-02-03 13:05:51 UTC (rev 272307)
@@ -159,8 +159,8 @@
     StyleSelfAlignmentData justifySelfForChild(const RenderBox&, const RenderStyle* = nullptr) const;
     StyleSelfAlignmentData alignSelfForChild(const RenderBox&, const RenderStyle* = nullptr) const;
     void applyStretchAlignmentToChildIfNeeded(RenderBox&);
-    bool hasAutoSizeInColumnAxis(const RenderBox& child) const { return isHorizontalWritingMode() ? child.style().height().isAuto() : child.style().width().isAuto(); }
-    bool hasAutoSizeInRowAxis(const RenderBox& child) const { return isHorizontalWritingMode() ? child.style().width().isAuto() : child.style().height().isAuto(); }
+    bool hasAutoSizeInColumnAxis(const RenderBox& child) const;
+    bool hasAutoSizeInRowAxis(const RenderBox& child) const;
     bool allowedToStretchChildAlongColumnAxis(const RenderBox& child) const { return alignSelfForChild(child).position() == ItemPosition::Stretch && hasAutoSizeInColumnAxis(child) && !hasAutoMarginsInColumnAxis(child); }
     bool allowedToStretchChildAlongRowAxis(const RenderBox& child) const { return justifySelfForChild(child).position() == ItemPosition::Stretch && hasAutoSizeInRowAxis(child) && !hasAutoMarginsInRowAxis(child); }
     bool hasAutoMarginsInColumnAxis(const RenderBox&) const;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to