[CSS Grid Layout] Fix positioning of grid items with margins
authorsvillar@igalia.com <svillar@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Nov 2013 08:43:07 +0000 (08:43 +0000)
committersvillar@igalia.com <svillar@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Nov 2013 08:43:07 +0000 (08:43 +0000)
commit4726aee4670727639e677c3d1991bb9f58d552ed
tree9d2568e791ea6186816024ab63fae38518f0af84
parentd93ea4040735a3f70a3d88185fc96d14553fe918
[CSS Grid Layout] Fix positioning of grid items with margins
https://bugs.webkit.org/show_bug.cgi?id=124345

Reviewed by David Hyatt.

From Blink r157925 and r158041 by <jchaffraix@chromium.org>

Source/WebCore:

Test: fast/css-grid-layout/grid-item-margin-resolution.html

Adds margin start/before to the positions of grid items (removing
several FIXME's in the current code). This means calling
findChildLogicalPosition() after the layout in order to have the
right values for the margins.

In order to match flexbox and author's intents we're also
including the margins of grid items in the intrinsic size of the
grid. That's why flexbox's marginLogicalPositionForChild() is
moved up to RenderBlock in order to share it with RenderGrid.

* rendering/RenderBlock.cpp:
(WebCore::RenderBlock::marginIntrinsicLogicalWidthForChild): Moved
from RenderFlexibleBox::marginLogicalWidthForChild().
* rendering/RenderBlock.h:
* rendering/RenderFlexibleBox.cpp:
(WebCore::RenderFlexibleBox::computeIntrinsicLogicalWidths):
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::computePreferredTrackWidth):
(WebCore::RenderGrid::layoutGridItems):
(WebCore::RenderGrid::findChildLogicalPosition):

LayoutTests:

New test case for grid items margin resolution. Extended the
preferred logical widths checks with grid items with margins.

* fast/css-grid-layout/grid-item-margin-resolution-expected.txt: Added.
* fast/css-grid-layout/grid-item-margin-resolution.html: Added.
* fast/css-grid-layout/grid-preferred-logical-widths-expected.txt:
* fast/css-grid-layout/grid-preferred-logical-widths.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@159809 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/css-grid-layout/grid-item-margin-resolution-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-item-margin-resolution.html [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-preferred-logical-widths-expected.txt
LayoutTests/fast/css-grid-layout/grid-preferred-logical-widths.html [changed mode: 0644->0755]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBlock.cpp
Source/WebCore/rendering/RenderBlock.h
Source/WebCore/rendering/RenderFlexibleBox.cpp
Source/WebCore/rendering/RenderGrid.cpp