Bug 163200

Summary: [css-grid] New expected behavior for stretch
Product: WebKit Reporter: Manuel Rego Casasnovas <rego>
Component: Layout and RenderingAssignee: Manuel Rego Casasnovas <rego>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, esprehn+autocc, glenn, jfernandez, kondapallykalyan, simon.fraser, svillar
Priority: P2 Keywords: BlinkMergeCandidate
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.chromium.org/p/chromium/issues/detail?id=653433
Bug Depends on:    
Bug Blocks: 60731, 169197    
Attachments:
Description Flags
Patch
none
Rebased patch none

Manuel Rego Casasnovas
Reported 2016-10-10 01:24:09 PDT
There were some discussion on GitHub about minimum size of grid items: https://github.com/w3c/csswg-drafts/issues/283 The spec has been modified so it now includes the following sentence (https://drafts.csswg.org/css-grid/#min-size-auto): "However, if the grid item spans only grid tracks that have a fixed max track sizing function, its automatic minimum size in that dimension is further clamped to less than or equal to the size necessary to fit its margin box within the resulting grid area (flooring at zero)." This has changed quite a lot the default behavior, so if a grid cell is very small the item should be shrunk to fit into that cell. This has been already fixed on Blink: https://codereview.chromium.org/2398043002
Attachments
Patch (9.38 KB, patch)
2016-10-10 01:26 PDT, Manuel Rego Casasnovas
no flags
Rebased patch (9.50 KB, patch)
2017-03-06 05:00 PST, Manuel Rego Casasnovas
no flags
Manuel Rego Casasnovas
Comment 1 2016-10-10 01:26:11 PDT
Sergio Villar Senin
Comment 2 2016-10-10 01:29:55 PDT
Comment on attachment 291076 [details] Patch Removing that code looks awesome to me, but I wonder where the "if the grid item spans only grid tracks that have a fixed max track sizing function" restriction is considered now. Shouldn't we keep the current behavior for the other cases? Shouldn't we add new test cases for these two possible situations?
Darin Adler
Comment 3 2016-10-10 01:34:44 PDT
Comment on attachment 291076 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=291076&action=review > Source/WebCore/rendering/RenderBox.cpp:2429 > if (treatAsReplaced) { > computedValues.m_extent = logicalWidthLength.value() + borderAndPaddingLogicalWidth(); > -#if ENABLE(CSS_GRID_LAYOUT) > - } else if (parent()->isRenderGrid() && style().logicalWidth().isAuto() && style().logicalMinWidth().isAuto() && style().overflowX() == OVISIBLE && containerWidthInInlineDirection < minPreferredLogicalWidth()) { > - // TODO (lajava) Move this logic to the LayoutGrid class. > - // Implied minimum size of Grid items. > - computedValues.m_extent = constrainLogicalWidthInRegionByMinMax(minPreferredLogicalWidth(), containerWidthInInlineDirection, cb); > -#endif > } else { WebKit coding style uses no braces for a one line if body. > Source/WebCore/rendering/RenderBox.cpp:2838 > )) { > - LayoutUnit contentHeight = overrideLogicalContentHeight(); > -#if ENABLE(CSS_GRID_LAYOUT) > - if (parent()->isRenderGrid() && style().logicalHeight().isAuto() && style().logicalMinHeight().isAuto() && style().overflowX() == OVISIBLE) { > - LayoutUnit intrinsicContentHeight = computedValues.m_extent - borderAndPaddingLogicalHeight(); > - if (auto minContentHeight = computeContentLogicalHeight(MinSize, Length(MinContent), intrinsicContentHeight)) > - contentHeight = std::max(contentHeight, constrainContentBoxLogicalHeightByMinMax(minContentHeight.value(), intrinsicContentHeight)); > - } > -#endif > - h = Length(contentHeight, Fixed); > + h = Length(overrideLogicalContentHeight(), Fixed); > } else if (treatAsReplaced) WebKit coding style uses no braces for a one line if body.
Manuel Rego Casasnovas
Comment 4 2016-10-10 06:09:09 PDT
(In reply to comment #2) > Removing that code looks awesome to me, but I wonder where the "if the grid > item spans only grid tracks that have a fixed max track sizing function" > restriction is considered now. Shouldn't we keep the current behavior for > the other cases? Shouldn't we add new test cases for these two possible > situations? Yes it's true we're not checking those cases. However I'm not 100% sure what would be the expected behavior, let me clarify it with the CSS WG before moving this forward: https://github.com/w3c/csswg-drafts/issues/283#issuecomment-252584331
Manuel Rego Casasnovas
Comment 5 2017-03-06 05:00:59 PST
Created attachment 303508 [details] Rebased patch
Manuel Rego Casasnovas
Comment 6 2017-03-06 05:05:46 PST
(In reply to comment #4) > (In reply to comment #2) > > Removing that code looks awesome to me, but I wonder where the "if the grid > > item spans only grid tracks that have a fixed max track sizing function" > > restriction is considered now. Shouldn't we keep the current behavior for > > the other cases? Shouldn't we add new test cases for these two possible > > situations? > > Yes it's true we're not checking those cases. > > However I'm not 100% sure what would be the expected behavior, let me > clarify it with the CSS WG before moving this forward: > https://github.com/w3c/csswg-drafts/issues/283#issuecomment-252584331 The issues have been clarified, and the expected behavior matches this patch implementation. There are tests on the W3C test suite checking the cases explained before, and I'm working on getting it imported (see bug #169196). @svillar would you be fine with landing this as is? That would move us closer to Blink implementation, and we can always add more tests cases later if needed. What do you think?
Sergio Villar Senin
Comment 7 2017-03-06 06:54:37 PST
(In reply to comment #6) > (In reply to comment #4) > > (In reply to comment #2) > > > Removing that code looks awesome to me, but I wonder where the "if the grid > > > item spans only grid tracks that have a fixed max track sizing function" > > > restriction is considered now. Shouldn't we keep the current behavior for > > > the other cases? Shouldn't we add new test cases for these two possible > > > situations? > > > > Yes it's true we're not checking those cases. > > > > However I'm not 100% sure what would be the expected behavior, let me > > clarify it with the CSS WG before moving this forward: > > https://github.com/w3c/csswg-drafts/issues/283#issuecomment-252584331 > > The issues have been clarified, and the expected behavior matches this patch > implementation. > > There are tests on the W3C test suite checking the cases explained before, > and I'm working on getting it imported (see bug #169196). > > @svillar would you be fine with landing this as is? > That would move us closer to Blink implementation, > and we can always add more tests cases later if needed. > What do you think? After carefully thinking about it, I think this patch addresses my concerns because it properly stretches items spanning tracks with fixed max track sizing functions. For the other cases (i.e. content sized functions) the tracks would be properly sized to the contents of the items, so they would never overflow. Anyway, it would be awesome to add more test cases for: a) items spanning only non fixed max track sizing functions b) items spanning none non fixed max track sizing functions c) items spanning both types of tracks and check how the same item with the same min-size behaves differently (actually cases b and c should implement the same behavior). I wouldn't block the landing of this patch due to the lack of those tests if you add then later.
Manuel Rego Casasnovas
Comment 8 2017-03-06 07:02:48 PST
Comment on attachment 303508 [details] Rebased patch (In reply to comment #7) > I wouldn't block the landing of this patch due to the lack of those tests if > you add then later. Ok, thanks for the new comment. Some of the cases you mentioned are already covered by the W3C Test Suite, and I'm planning to import it very soon. Then I could add there more tests if needed and get them imported.
WebKit Commit Bot
Comment 9 2017-03-06 07:30:37 PST
Comment on attachment 303508 [details] Rebased patch Clearing flags on attachment: 303508 Committed r213449: <http://trac.webkit.org/changeset/213449>
WebKit Commit Bot
Comment 10 2017-03-06 07:30:43 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.