Bug 220657

Summary: [css-grid] Relayout grid items when definiteness changes.
Product: WebKit Reporter: zsun
Component: CSSAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: changseok, clopez, esprehn+autocc, ews-watchlist, glenn, jfernandez, kondapallykalyan, obrufau, pdr, rego, svillar, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar, WebExposed
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

zsun
Reported 2021-01-15 06:40:23 PST
Previously RenderGrid performed a simple logical-height change check to determine if a grid-item needed relayout. This wasn't correct as when setting an override logical-height the definiteness can change causing %-height children to resolve differently.
Attachments
Patch (7.27 KB, patch)
2021-01-15 07:41 PST, zsun
no flags
Patch (11.55 KB, patch)
2021-01-18 12:14 PST, zsun
no flags
Patch (11.60 KB, patch)
2021-01-19 00:54 PST, zsun
no flags
Patch (9.68 KB, patch)
2021-01-20 07:13 PST, zsun
no flags
Patch (11.70 KB, patch)
2021-01-21 06:27 PST, zsun
no flags
Patch (12.04 KB, patch)
2021-01-22 06:18 PST, zsun
no flags
zsun
Comment 1 2021-01-15 07:41:49 PST
zsun
Comment 2 2021-01-18 12:14:55 PST
zsun
Comment 3 2021-01-19 00:54:04 PST
Oriol Brufau
Comment 4 2021-01-20 04:42:30 PST
Comment on attachment 417863 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=417863&action=review > Source/WebCore/rendering/RenderGrid.cpp:1147 > + if (desiredLogicalHeight != child.logicalHeight() || child.maybeHasPercentHeightDescendant()) { I think it may be possible to use hasPercentHeightDescendant() instead of adding maybeHasPercentHeightDescendant() In Chromium this wasn't possible because of this quirk: https://quirks.spec.whatwg.org/#the-percentage-height-calculation-quirk But WebKit doesn't seem to use the quirk for grid according to the image in https://github.com/w3c/csswg-drafts/issues/5545 > Source/WebCore/rendering/RenderGrid.cpp:1149 > child.setNeedsLayout(MarkOnlyThis); Just noting that the relayout can worsen performance for deeply nested grids. https://bugs.chromium.org/p/chromium/issues/detail?id=1146377#c2 Though it doesn't seem possible to do the right thing in a performant way with this rendering engine. Chromium will only address the performance problem in LayoutNG. > LayoutTests/imported/w3c/ChangeLog:5 > + Nit: can you mention that you are importing tests, not creating new ones? > LayoutTests/imported/w3c/web-platform-tests/css/css-grid/relative-grandchild-expected.xht:5 > + <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" /> Bad text encoding in "Gérard"?
zsun
Comment 5 2021-01-20 07:13:25 PST
zsun
Comment 6 2021-01-20 07:15:05 PST
(In reply to Oriol Brufau from comment #4) > Comment on attachment 417863 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=417863&action=review > > > Source/WebCore/rendering/RenderGrid.cpp:1147 > > + if (desiredLogicalHeight != child.logicalHeight() || child.maybeHasPercentHeightDescendant()) { > > I think it may be possible to use hasPercentHeightDescendant() instead of > adding maybeHasPercentHeightDescendant() > In Chromium this wasn't possible because of this quirk: > https://quirks.spec.whatwg.org/#the-percentage-height-calculation-quirk > But WebKit doesn't seem to use the quirk for grid according to the image in > https://github.com/w3c/csswg-drafts/issues/5545 > Updated > > Source/WebCore/rendering/RenderGrid.cpp:1149 > > child.setNeedsLayout(MarkOnlyThis); > > Just noting that the relayout can worsen performance for deeply nested grids. > https://bugs.chromium.org/p/chromium/issues/detail?id=1146377#c2 > > Though it doesn't seem possible to do the right thing in a performant way > with this rendering engine. Chromium will only address the performance > problem in LayoutNG. > > > LayoutTests/imported/w3c/ChangeLog:5 > > + > > Nit: can you mention that you are importing tests, not creating new ones? > Added > > LayoutTests/imported/w3c/web-platform-tests/css/css-grid/relative-grandchild-expected.xht:5 > > + <link rel="author" title="Gérard Talbot" href="http://www.gtalbot.org/BrowserBugsSection/css21testsuite/" /> > > Bad text encoding in "Gérard"? Not sure why. It seems displaying fine for me.
Manuel Rego Casasnovas
Comment 7 2021-01-21 00:36:00 PST
Comment on attachment 417965 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=417965&action=review > Source/WebCore/ChangeLog:11 > + Reviewed by NOBODY (OOPS!). Nit: This line is wrongly placed. > Source/WebCore/ChangeLog:12 > + Pleaes describe here what the patch is doing. Despite the link to the Chromium patch, it's good to describe things for the change in WebKit as it's not totally equivalent. > Source/WebCore/ChangeLog:14 > + imported/w3c/web-platform-tests/css/css-grid/relative-grandchild.html It looks like Chromium change also has some effects on css/css-grid/grid-child-percent-basis-resize-1.html test, have you checked that on WebKit? > Source/WebCore/rendering/RenderGrid.cpp:1144 > + // Checking the logical-height of a child isn't enough. Setting an override > + // logical-height changes the definiteness, resulting in percentages to > + // resolve differently. Nit: In WebKit you don't need to wrap comments in 80-columns.
zsun
Comment 8 2021-01-21 06:27:59 PST
zsun
Comment 9 2021-01-21 06:28:41 PST
(In reply to Manuel Rego Casasnovas from comment #7) > Comment on attachment 417965 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=417965&action=review > > > Source/WebCore/ChangeLog:11 > > + Reviewed by NOBODY (OOPS!). > > Nit: This line is wrongly placed. > > > Source/WebCore/ChangeLog:12 > > + > > Pleaes describe here what the patch is doing. Despite the link to the > Chromium patch, it's good to describe things for the change in WebKit as > it's not totally equivalent. > > > Source/WebCore/ChangeLog:14 > > + imported/w3c/web-platform-tests/css/css-grid/relative-grandchild.html > > It looks like Chromium change also has some effects on > css/css-grid/grid-child-percent-basis-resize-1.html test, have you checked > that on WebKit? > > > Source/WebCore/rendering/RenderGrid.cpp:1144 > > + // Checking the logical-height of a child isn't enough. Setting an override > > + // logical-height changes the definiteness, resulting in percentages to > > + // resolve differently. > > Nit: In WebKit you don't need to wrap comments in 80-columns. Comments have been addressed. Thank you!
Manuel Rego Casasnovas
Comment 10 2021-01-22 01:24:36 PST
Comment on attachment 418035 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=418035&action=review r=me with the requested changes inline. > Source/WebCore/ChangeLog:8 > + When setting an overide logical-height the definiteness can change causing %-height Nit: s/overide/override/ > Source/WebCore/ChangeLog:-12 > - * rendering/RenderGrid.cpp: > - (WebCore::RenderGrid::applyStretchAlignmentToChildIfNeeded): > - I guess this was a mistake, you shouldn't change other parts of the ChangeLog. > Source/WebCore/rendering/RenderGrid.cpp:1142 > + // Checking the logical-height of a child isn't enough. Setting an override ogical-height s/ogical/logical/ > LayoutTests/TestExpectations:-3970 > -webkit.org/b/212246 imported/w3c/web-platform-tests/css/css-grid/grid-child-percent-basis-resize-1.html [ ImageOnlyFailure ] I believe you have to reflect this in LayoutTests/ChangeLog.
zsun
Comment 11 2021-01-22 06:18:33 PST
zsun
Comment 12 2021-01-22 06:19:30 PST
(In reply to Manuel Rego Casasnovas from comment #10) > Comment on attachment 418035 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=418035&action=review > > r=me with the requested changes inline. > > > Source/WebCore/ChangeLog:8 > > + When setting an overide logical-height the definiteness can change causing %-height > > Nit: s/overide/override/ > > > Source/WebCore/ChangeLog:-12 > > - * rendering/RenderGrid.cpp: > > - (WebCore::RenderGrid::applyStretchAlignmentToChildIfNeeded): > > - > > I guess this was a mistake, you shouldn't change other parts of the > ChangeLog. > > > Source/WebCore/rendering/RenderGrid.cpp:1142 > > + // Checking the logical-height of a child isn't enough. Setting an override ogical-height > > s/ogical/logical/ > > > LayoutTests/TestExpectations:-3970 > > -webkit.org/b/212246 imported/w3c/web-platform-tests/css/css-grid/grid-child-percent-basis-resize-1.html [ ImageOnlyFailure ] > > I believe you have to reflect this in LayoutTests/ChangeLog. All comments have been addressed. Thanks!
Radar WebKit Bug Importer
Comment 13 2021-01-22 06:41:14 PST
EWS
Comment 14 2021-01-22 08:29:53 PST
Committed r271745: <https://trac.webkit.org/changeset/271745> All reviewed patches have been landed. Closing bug and clearing flags on attachment 418145 [details].
Note You need to log in before you can comment on or make changes to this bug.