From 02a180ff5015baaaaa209b5ea762b6355c632d93 Mon Sep 17 00:00:00 2001 From: "commit-queue@webkit.org" Date: Fri, 22 Jan 2021 16:29:46 +0000 Subject: [PATCH] [css-grid] Relayout grid items when definiteness changes. https://bugs.webkit.org/show_bug.cgi?id=220657 LayoutTests/imported/w3c: Tests percentage-size-subitems-002.html and relative-grandchild.html are imported from WPT. Patch by Ziran Sun on 2021-01-22 Reviewed by Manuel Rego Casasnovas. * web-platform-tests/css/css-grid/grid-items/percentage-size-subitems-002-expected.html: Added. * web-platform-tests/css/css-grid/grid-items/percentage-size-subitems-002.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-grid/relative-grandchild.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-grid/relative-grandchild-expected.xht: Added. * web-platform-tests/css/css-grid/grid-items/w3c-import.log: Source/WebCore: Patch by Ziran Sun on 2021-01-22 Reviewed by Manuel Rego Casasnovas. When setting an override logical-height the definiteness can change causing %-height children to resolve differently. This change adds this check to determine if a grid-item needs relayout. It is an import of Chromium changes at https://chromium-review.googlesource.com/c/chromium/src/+/2474917 Instead of adding maybeHasPercentHeightDescendant() in WebKit, this change calls hasPercentHeightDescendants(). In Chromium it wasn't possible to use hasPercentHeightDescendants() because of this quirk: https://quirks.spec.whatwg.org/#the-percentage-height-calculation-quirk WebKit doesn't seem to use the quirk for grid according to the image in https://github.com/w3c/csswg-drafts/issues/5545 This also fixes issues in test: grid-child-percent-basis-resize-1.html Tests have been ported in WPT at https://github.com/web-platform-tests/wpt/pull/26136 Tests: imported/w3c/web-platform-tests/css/css-grid/grid-items/percentage-size-subitems-002.html imported/w3c/web-platform-tests/css/css-grid/relative-grandchild.html * rendering/RenderGrid.cpp: (WebCore::RenderGrid::applyStretchAlignmentToChildIfNeeded): LayoutTests: Patch by Ziran Sun on 2021-01-22 Reviewed by Manuel Rego Casasnovas. * TestExpectations: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@271745 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- LayoutTests/ChangeLog | 9 ++++++ LayoutTests/TestExpectations | 1 - LayoutTests/imported/w3c/ChangeLog | 16 ++++++++++ ...percentage-size-subitems-002-expected.html | 4 +++ .../percentage-size-subitems-002.html | 10 +++++++ .../css/css-grid/grid-items/w3c-import.log | 1 + .../css-grid/relative-grandchild-expected.xht | 19 ++++++++++++ .../css/css-grid/relative-grandchild.html | 10 +++++++ .../css/css-grid/w3c-import.log | 1 + Source/WebCore/ChangeLog | 30 +++++++++++++++++++ Source/WebCore/rendering/RenderGrid.cpp | 8 +++-- 11 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/percentage-size-subitems-002-expected.html create mode 100644 LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/percentage-size-subitems-002.html create mode 100644 LayoutTests/imported/w3c/web-platform-tests/css/css-grid/relative-grandchild-expected.xht create mode 100644 LayoutTests/imported/w3c/web-platform-tests/css/css-grid/relative-grandchild.html diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index a5f4aef97c020..0ab65109b8c8e 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,12 @@ +2021-01-22 Ziran Sun + + [css-grid] Relayout grid items when definiteness changes. + https://bugs.webkit.org/show_bug.cgi?id=220657 + + Reviewed by Manuel Rego Casasnovas. + + * TestExpectations: + 2021-01-21 Rob Buis Handle shapeMargin becoming NaN diff --git a/LayoutTests/TestExpectations b/LayoutTests/TestExpectations index 79b1d6408709c..8caf3bab8d888 100644 --- a/LayoutTests/TestExpectations +++ b/LayoutTests/TestExpectations @@ -3970,7 +3970,6 @@ webkit.org/b/212246 imported/w3c/web-platform-tests/css/css-grid/alignment/grid- webkit.org/b/212246 imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-alignment-baseline-with-grid-002.html [ ImageOnlyFailure ] webkit.org/b/212246 imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-alignment-baseline-with-grid-003.html [ ImageOnlyFailure ] webkit.org/b/212246 imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-alignment-baseline-with-grid-004.html [ ImageOnlyFailure ] -webkit.org/b/212246 imported/w3c/web-platform-tests/css/css-grid/grid-child-percent-basis-resize-1.html [ ImageOnlyFailure ] webkit.org/b/212246 imported/w3c/web-platform-tests/css/css-grid/grid-model/grid-areas-overflowing-grid-container-001.html [ ImageOnlyFailure ] webkit.org/b/212246 imported/w3c/web-platform-tests/css/css-grid/grid-model/grid-areas-overflowing-grid-container-002.html [ ImageOnlyFailure ] webkit.org/b/212246 imported/w3c/web-platform-tests/css/css-grid/grid-model/grid-areas-overflowing-grid-container-003.html [ ImageOnlyFailure ] diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog index c681fa54bf1eb..84bc8c4599f03 100644 --- a/LayoutTests/imported/w3c/ChangeLog +++ b/LayoutTests/imported/w3c/ChangeLog @@ -1,3 +1,19 @@ +2021-01-22 Ziran Sun + + [css-grid] Relayout grid items when definiteness changes. + https://bugs.webkit.org/show_bug.cgi?id=220657 + + Tests percentage-size-subitems-002.html and relative-grandchild.html are + imported from WPT. + + Reviewed by Manuel Rego Casasnovas. + + * web-platform-tests/css/css-grid/grid-items/percentage-size-subitems-002-expected.html: Added. + * web-platform-tests/css/css-grid/grid-items/percentage-size-subitems-002.html: Added. + * LayoutTests/imported/w3c/web-platform-tests/css/css-grid/relative-grandchild.html: Added. + * LayoutTests/imported/w3c/web-platform-tests/css/css-grid/relative-grandchild-expected.xht: Added. + * web-platform-tests/css/css-grid/grid-items/w3c-import.log: + 2021-01-21 Devin Rousso [Apple Pay] use the first item in `shippingOptions` even when it's not `selected` diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/percentage-size-subitems-002-expected.html b/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/percentage-size-subitems-002-expected.html new file mode 100644 index 0000000000000..82fcaa3b2aa4a --- /dev/null +++ b/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/percentage-size-subitems-002-expected.html @@ -0,0 +1,4 @@ + + +

Test passes if there is a filled green square.

+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/percentage-size-subitems-002.html b/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/percentage-size-subitems-002.html new file mode 100644 index 0000000000000..17f57bf39d191 --- /dev/null +++ b/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/percentage-size-subitems-002.html @@ -0,0 +1,10 @@ + + + +

Test passes if there is a filled green square.

+
+
+
+
+
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/w3c-import.log b/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/w3c-import.log index fbbaf9e142abf..5d10860d60d57 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/w3c-import.log +++ b/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/w3c-import.log @@ -276,6 +276,7 @@ List of files: /LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/percentage-size-replaced-subitems-001.html /LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/percentage-size-subitems-001-expected.html /LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/percentage-size-subitems-001.html +/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/percentage-size-subitems-002.html /LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/ref-filled-green-100px-square-image.html /LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/remove-svg-grid-item-001-expected.html /LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/remove-svg-grid-item-001.html diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/relative-grandchild-expected.xht b/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/relative-grandchild-expected.xht new file mode 100644 index 0000000000000..05a13794482a9 --- /dev/null +++ b/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/relative-grandchild-expected.xht @@ -0,0 +1,19 @@ + + + + CSS Reftest Reference + + + + +

Test passes if there is a filled green square and no red.

+
+ + diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/relative-grandchild.html b/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/relative-grandchild.html new file mode 100644 index 0000000000000..9c1b7d54e1f56 --- /dev/null +++ b/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/relative-grandchild.html @@ -0,0 +1,10 @@ + + + +

Test passes if there is a filled green square and no red.

+
+
+
+
+
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/w3c-import.log b/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/w3c-import.log index be3d85d271318..c3660df3482a7 100644 --- a/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/w3c-import.log +++ b/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/w3c-import.log @@ -34,5 +34,6 @@ List of files: /LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-layout-properties.html /LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-tracks-stretched-with-different-flex-factors-sum.html /LayoutTests/imported/w3c/web-platform-tests/css/css-grid/inheritance.html +/LayoutTests/imported/w3c/web-platform-tests/css/css-grid/relative-grandchild.html /LayoutTests/imported/w3c/web-platform-tests/css/css-grid/table-grid-item-dynamic-001-expected.html /LayoutTests/imported/w3c/web-platform-tests/css/css-grid/table-grid-item-dynamic-001.html diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 460e088fa7235..6c9a5c5290c73 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,33 @@ +2021-01-22 Ziran Sun + + [css-grid] Relayout grid items when definiteness changes. + https://bugs.webkit.org/show_bug.cgi?id=220657 + + Reviewed by Manuel Rego Casasnovas. + + When setting an override logical-height the definiteness can change causing %-height + children to resolve differently. This change adds this check to determine if a grid-item + needs relayout. It is an import of Chromium changes at + https://chromium-review.googlesource.com/c/chromium/src/+/2474917 + Instead of adding maybeHasPercentHeightDescendant() in WebKit, this change calls + hasPercentHeightDescendants(). In Chromium it wasn't possible to use + hasPercentHeightDescendants() because of this quirk: + https://quirks.spec.whatwg.org/#the-percentage-height-calculation-quirk + WebKit doesn't seem to use the quirk for grid according to the image in + https://github.com/w3c/csswg-drafts/issues/5545 + + This also fixes issues in test: + grid-child-percent-basis-resize-1.html + + Tests have been ported in WPT at + https://github.com/web-platform-tests/wpt/pull/26136 + + Tests: imported/w3c/web-platform-tests/css/css-grid/grid-items/percentage-size-subitems-002.html + imported/w3c/web-platform-tests/css/css-grid/relative-grandchild.html + + * rendering/RenderGrid.cpp: + (WebCore::RenderGrid::applyStretchAlignmentToChildIfNeeded): + 2021-01-22 Kate Cheney Denying storage access on playstation.com then clicking sign-in fails to show the prompt again diff --git a/Source/WebCore/rendering/RenderGrid.cpp b/Source/WebCore/rendering/RenderGrid.cpp index b7ba407e16fa3..a9c8a88de5778 100644 --- a/Source/WebCore/rendering/RenderGrid.cpp +++ b/Source/WebCore/rendering/RenderGrid.cpp @@ -1138,8 +1138,12 @@ void RenderGrid::applyStretchAlignmentToChildIfNeeded(RenderBox& child) LayoutUnit stretchedLogicalHeight = availableAlignmentSpaceForChildBeforeStretching(GridLayoutFunctions::overridingContainingBlockContentSizeForChild(child, childBlockDirection).value(), child); LayoutUnit desiredLogicalHeight = child.constrainLogicalHeightByMinMax(stretchedLogicalHeight, -1_lu); child.setOverridingLogicalHeight(desiredLogicalHeight); - if (desiredLogicalHeight != child.logicalHeight()) { - // FIXME: Can avoid laying out here in some cases. See https://webkit.org/b/87905. + + // Checking the logical-height of a child isn't enough. Setting an override logical-height + // changes the definiteness, resulting in percentages to resolve differently. + // + // FIXME: Can avoid laying out here in some cases. See https://webkit.org/b/87905. + if (desiredLogicalHeight != child.logicalHeight() || (is(child) && downcast(child).hasPercentHeightDescendants())) { child.setLogicalHeight(0_lu); child.setNeedsLayout(MarkOnlyThis); }