[CSS Grid Layout] inline margins not honored when not using stretch in row-axis alignment
https://bugs.webkit.org/show_bug.cgi?id=151323

Reviewed by Sergio Villar Senin.

Source/WebCore:

There are some situations where we avoid to compute the inline-axis
margins when computing the logical width of a box. One of those situations
is when we have set an override width; this only affects for now to flex
and grid items. We also follow this approach when setting the logical
width based on the restrictions of 'auto' value in the 'min-width'
property.

This behavior is not correct, since there is no reason to avoid
computing this margins, in the general case. I think this logic was
designed as an optimization for flexbox, which was already computing
the margins by its own, but it's not applicable in the general case, so
grid needs these margins to be computed properly.

For the shrink-to-fit behavior we can add some grid related logic to the
already defined RenderBox function "sizesLogicalWidthToFitContent",
so we avoid the override width.

Tests: fast/css-grid-layout/grid-item-auto-sized-align-justify-margin-border-padding.html
       fast/css-grid-layout/min-width-height-auto-and-margins.html

* rendering/RenderBox.cpp:
(WebCore::RenderBox::computeLogicalWidthInRegion):
(WebCore::RenderBox::sizesLogicalWidthToFitContent):
* rendering/RenderGrid.cpp:
(WebCore::defaultAlignmentChangedFromStretchInRowAxis):
(WebCore::selfAlignmentChangedFromStretchInRowAxis):
(WebCore::RenderGrid::styleDidChange):
(WebCore::RenderGrid::applyStretchAlignmentToChildIfNeeded):
(WebCore::selfAlignmentChangedFromStretchInColumnAxis): Deleted.
(WebCore::RenderGrid::computeMarginLogicalHeightForChild): Deleted.
(WebCore::RenderGrid::availableAlignmentSpaceForChildBeforeStretching): Deleted.

LayoutTests:

Tests to verify that margins are computed properly on grid items
using an alignment value different than stretch or when min-width
is auto.

* fast/css-grid-layout/grid-item-auto-sized-align-justify-margin-border-padding-expected.txt: Added.
* fast/css-grid-layout/grid-item-auto-sized-align-justify-margin-border-padding.html: Added.
* fast/css-grid-layout/min-width-height-auto-and-margins-expected.txt: Added.
* fast/css-grid-layout/min-width-height-auto-and-margins.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@192573 268f45cc-cd09-0410-ab3c-d52691b4dbfc
9 files changed