[CSS Grid Layout] inline margins not honored when not using stretch in row-axis alignment
authorjfernandez@igalia.com <jfernandez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Nov 2015 12:53:26 +0000 (12:53 +0000)
committerjfernandez@igalia.com <jfernandez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Nov 2015 12:53:26 +0000 (12:53 +0000)
commit80cf6d3967f659e51b25830c33eb4838cf283fe7
tree68407592bd1137af6f554322b127cb4fd5bba439
parenteb682feba9ea992fe2cbf01021d1c4f34d242028
[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: https://svn.webkit.org/repository/webkit/trunk@192573 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/css-grid-layout/grid-item-auto-sized-align-justify-margin-border-padding-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-item-auto-sized-align-justify-margin-border-padding.html [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/min-width-height-auto-and-margins-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/min-width-height-auto-and-margins.html [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/resources/grid-alignment.css
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBox.cpp
Source/WebCore/rendering/RenderGrid.cpp