REOPENED222100
[css-grid] Fix min/max widths of grid affected by ancestor
https://bugs.webkit.org/show_bug.cgi?id=222100
Summary [css-grid] Fix min/max widths of grid affected by ancestor
zsun
Reported 2021-02-18 05:25:34 PST
The following WPT tests failed in Safari css/css-grid/grid-items/grid-items-percentage-paddings-002.html css/css-grid/grid-items/grid-items-percentage-paddings-vertical-lr-002.html css/css-grid/grid-items/grid-items-percentage-paddings-vertical-rl-002.htm
Attachments
Patch (12.41 KB, patch)
2021-02-18 05:40 PST, zsun
no flags
Patch (10.53 KB, patch)
2021-02-18 09:35 PST, zsun
no flags
Patch (10.51 KB, patch)
2021-02-23 05:36 PST, zsun
no flags
Patch (10.44 KB, patch)
2021-02-23 08:44 PST, zsun
no flags
Patch (10.73 KB, patch)
2021-03-03 12:27 PST, zsun
no flags
Patch (10.65 KB, patch)
2021-03-04 10:24 PST, zsun
no flags
Patch (13.33 KB, patch)
2021-04-02 03:11 PDT, zsun
no flags
Patch (10.93 KB, patch)
2021-04-03 03:25 PDT, zsun
no flags
Patch (10.94 KB, patch)
2021-04-07 08:16 PDT, zsun
no flags
Patch (10.89 KB, patch)
2021-04-08 07:44 PDT, zsun
no flags
zsun
Comment 1 2021-02-18 05:40:49 PST
zsun
Comment 2 2021-02-18 09:35:46 PST
Javier Fernandez
Comment 3 2021-02-22 06:13:40 PST
Comment on attachment 420837 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=420837&action=review > Source/WebCore/ChangeLog:9 > + Before update logical-width, for element that needs prefrredWidth recalcution, s/prefrredWidth/preferredWidth > Source/WebCore/rendering/RenderBox.cpp:2485 > + if (cb->needsPreferredWidthsRecalculation() && !box->preferredLogicalWidthsDirty()) { I supposed box->preferredLogicalWidthsDirty() is false for sure, otherwise we should have entered in the branch above, right ? Perhaps you meant "cb->" here ? Just wondering. > Source/WebCore/rendering/RenderBox.cpp:2498 > + // Laying out this object means that its containing block is also being laid out. This object is special, in that its min/max widths depend on Nit, I think it'd be clearer if we put the comment just above the if statement.
zsun
Comment 4 2021-02-23 05:36:38 PST
zsun
Comment 5 2021-02-23 05:37:36 PST
(In reply to Javier Fernandez from comment #3) > Comment on attachment 420837 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=420837&action=review > > > Source/WebCore/ChangeLog:9 > > + Before update logical-width, for element that needs prefrredWidth recalcution, > > s/prefrredWidth/preferredWidth > > > Source/WebCore/rendering/RenderBox.cpp:2485 > > + if (cb->needsPreferredWidthsRecalculation() && !box->preferredLogicalWidthsDirty()) { > > I supposed box->preferredLogicalWidthsDirty() is false for sure, otherwise > we should have entered in the branch above, right ? > > Perhaps you meant "cb->" here ? Just wondering. > > > Source/WebCore/rendering/RenderBox.cpp:2498 > > + // Laying out this object means that its containing block is also being laid out. This object is special, in that its min/max widths depend on > > Nit, I think it'd be clearer if we put the comment just above the if > statement. Comments have addressed. Thank you!
Javier Fernandez
Comment 6 2021-02-23 07:34:10 PST
Comment on attachment 421305 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=421305&action=review > Source/WebCore/rendering/RenderBox.cpp:2479 > + // If the preferred widths are already dirty at this point (during layout), it actually means that we never need to calculate them, since that should I think we can move the comments above the if clause, and remove the brackets. > Source/WebCore/rendering/RenderBox.cpp:2485 > + // If our containing block also has min/max widths that are affected by the ancestry, we have already dealt with this object as well. Avoid Ditto > Source/WebCore/rendering/RenderBox.cpp:2496 > + if (shouldRecalculateMinMaxWidthsAffectedByAncestor(this)) { Why not using a composed conditional clause instead two nested if ? > Source/WebCore/rendering/RenderBox.cpp:2497 > + // Laying out this object means that its containing block is also being laid out. This object is special, in that its min/max widths depend on We could move the comments here as well, as I suggested before.
zsun
Comment 7 2021-02-23 08:44:17 PST
zsun
Comment 8 2021-02-23 08:45:10 PST
(In reply to Javier Fernandez from comment #6) > Comment on attachment 421305 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=421305&action=review > > > Source/WebCore/rendering/RenderBox.cpp:2479 > > + // If the preferred widths are already dirty at this point (during layout), it actually means that we never need to calculate them, since that should > > I think we can move the comments above the if clause, and remove the > brackets. > > > Source/WebCore/rendering/RenderBox.cpp:2485 > > + // If our containing block also has min/max widths that are affected by the ancestry, we have already dealt with this object as well. Avoid > > Ditto > > > Source/WebCore/rendering/RenderBox.cpp:2496 > > + if (shouldRecalculateMinMaxWidthsAffectedByAncestor(this)) { > > Why not using a composed conditional clause instead two nested if ? > > > Source/WebCore/rendering/RenderBox.cpp:2497 > > + // Laying out this object means that its containing block is also being laid out. This object is special, in that its min/max widths depend on > > We could move the comments here as well, as I suggested before. All review comments have been addressed. Thank you!
Javier Fernandez
Comment 9 2021-02-23 13:00:32 PST
Comment on attachment 421316 [details] Patch r=me
EWS
Comment 10 2021-02-24 13:35:45 PST
Committed r273435: <https://commits.webkit.org/r273435> All reviewed patches have been landed. Closing bug and clearing flags on attachment 421316 [details].
Radar WebKit Bug Importer
Comment 11 2021-02-24 13:36:17 PST
Robert Jenner
Comment 12 2021-02-26 14:49:45 PST
It appears this test may have broken another test: imported/w3c/web-platform-tests/css/css-flexbox/percentage-max-height-003.html Reported at bug: https://bugs.webkit.org/show_bug.cgi?id=222485
WebKit Commit Bot
Comment 13 2021-02-26 16:43:44 PST
Re-opened since this is blocked by bug 222503
zsun
Comment 14 2021-03-03 12:27:25 PST
Javier Fernandez
Comment 15 2021-03-04 05:58:05 PST
Comment on attachment 422134 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=422134&action=review > Source/WebCore/ChangeLog:8 > + It's a reland of r273435, which got reverted because it broken nit: s/broken/broke > Source/WebCore/rendering/RenderBox.cpp:2499 > + if (needsPreferredWidthsRecalculation() && shouldRecalculateMinMaxWidthsAffectedByAncestor(this) && parent()->preferredLogicalWidthsDirty()) { I think we should have a check here for parent(); I believe it's not guaranteed that it's not null.
Oriol Brufau
Comment 16 2021-03-04 06:38:50 PST
Comment on attachment 422134 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=422134&action=review >> Source/WebCore/rendering/RenderBox.cpp:2499 >> + if (needsPreferredWidthsRecalculation() && shouldRecalculateMinMaxWidthsAffectedByAncestor(this) && parent()->preferredLogicalWidthsDirty()) { > > I think we should have a check here for parent(); I believe it's not guaranteed that it's not null. Why does WebKit need parent()->preferredLogicalWidthsDirty() if Chromium doesn't have it? And maybe the condition should be moved into shouldRecalculateMinMaxWidthsAffectedByAncestor() ?
zsun
Comment 17 2021-03-04 10:24:00 PST
Sergio Villar Senin
Comment 18 2021-03-05 09:37:41 PST
Comment on attachment 422253 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=422253&action=review What I don't exactly understand is which cases fix this and why the setPreferredLogicalWidthsDirty() is not invoked in the specific subclass RenderFlexibleBox, RenderGrid... etc > Source/WebCore/rendering/RenderBox.cpp:2490 > + } You can write this in a more compact way using some C++ fancyness if (const RenderBox* cb = box->containingBlock(); !cb->preferredLogicalWidthsDirty()) return false; Also I guess this function is only meant to be used from updateLogicalWidth(). If that's indeed the case it'd be better to move it to a lambda inside that method.
Sergio Villar Senin
Comment 19 2021-03-05 09:37:43 PST
Comment on attachment 422253 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=422253&action=review What I don't exactly understand is which cases fix this and why the setPreferredLogicalWidthsDirty() is not invoked in the specific subclass RenderFlexibleBox, RenderGrid... etc > Source/WebCore/rendering/RenderBox.cpp:2490 > + } You can write this in a more compact way using some C++ fancyness if (const RenderBox* cb = box->containingBlock(); !cb->preferredLogicalWidthsDirty()) return false; Also I guess this function is only meant to be used from updateLogicalWidth(). If that's indeed the case it'd be better to move it to a lambda inside that method.
zsun
Comment 20 2021-04-02 03:11:02 PDT
zsun
Comment 21 2021-04-03 03:25:19 PDT
Javier Fernandez
Comment 22 2021-04-07 06:50:29 PDT
Comment on attachment 425089 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=425089&action=review r=me > Source/WebCore/rendering/RenderBlock.cpp:-639 > - Please, remove these empty lines
zsun
Comment 23 2021-04-07 08:16:39 PDT
zsun
Comment 24 2021-04-08 07:44:13 PDT
EWS
Comment 25 2021-04-09 02:18:04 PDT
Committed r275754 (236332@main): <https://commits.webkit.org/236332@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 425506 [details].
alan
Comment 26 2021-08-26 15:34:48 PDT
This patch has been reverted in r281662. See https://bugs.webkit.org/show_bug.cgi?id=229586#c0 for more info.
Note You need to log in before you can comment on or make changes to this bug.