Bug 232987

Summary: [css-grid] Transfer size for grid item with an aspect-ratio and stretch alignment against the definite row
Product: WebKit Reporter: zsun
Component: CSSAssignee: zsun
Status: RESOLVED FIXED    
Severity: Normal CC: changseok, esprehn+autocc, ews-watchlist, glenn, jfernandez, kondapallykalyan, pdr, rego, svillar, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch none

Description zsun 2021-11-11 01:45:33 PST
This is similar to bug 231802. Instead of having a percentage of the definite row, the grid item stretches in the block-axis.

Affected test -

imported/w3c/web-platform-tests/css/css-grid/grid-items/aspect-ratio-004.html
Comment 1 zsun 2021-11-11 02:05:15 PST
Created attachment 443923 [details]
Patch
Comment 2 zsun 2021-11-11 05:06:00 PST
Created attachment 443938 [details]
Patch
Comment 3 Javier Fernandez 2021-11-12 06:19:19 PST
Comment on attachment 443938 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=443938&action=review

> Source/WebCore/rendering/RenderGrid.cpp:965
> +        if (autoGridItem->hasStretchedLogicalHeight())

I think a comment here, explaining why we need to apply the stretch alignment, and how it affects the aspect-ratio, would be a good idea.

> Source/WebCore/rendering/RenderReplaced.cpp:805
> +    return (hasRelativeLogicalHeight() || (isGridItem() && hasStretchedLogicalHeight())) && style().logicalWidth().isAuto();

Do we need to check for isGridItem() ? wouldn't this be relevant for flexbox (the other layout model applying stretch alignment) as well ?
Comment 4 zsun 2021-11-16 03:43:51 PST
Created attachment 444370 [details]
Patch
Comment 5 zsun 2021-11-16 04:53:00 PST
(In reply to Javier Fernandez from comment #3)
> Comment on attachment 443938 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=443938&action=review
> 
> > Source/WebCore/rendering/RenderGrid.cpp:965
> > +        if (autoGridItem->hasStretchedLogicalHeight())
> 
> I think a comment here, explaining why we need to apply the stretch
> alignment, and how it affects the aspect-ratio, would be a good idea.
> 

Comments added.

> > Source/WebCore/rendering/RenderReplaced.cpp:805
> > +    return (hasRelativeLogicalHeight() || (isGridItem() && hasStretchedLogicalHeight())) && style().logicalWidth().isAuto();
> 
> Do we need to check for isGridItem() ? wouldn't this be relevant for flexbox
> (the other layout model applying stretch alignment) as well ?

Yes, I think we do need to check for isGridItem(). I have seen a couple of table related tests failures without this check. Tried running WPT flexbox tests with the check (e.g. add (isGridItem() || isFlexItem()) but couldn't see it makes any difference on the test result for flexibox tests.
Comment 6 Javier Fernandez 2021-11-17 15:08:10 PST
Comment on attachment 444370 [details]
Patch

r=me
Comment 7 EWS 2021-11-18 01:12:59 PST
Committed r285987 (244384@main): <https://commits.webkit.org/244384@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 444370 [details].
Comment 8 Radar WebKit Bug Importer 2021-11-18 01:13:25 PST
<rdar://problem/85540225>