[CSS Grid Layout] Grid item's auto-margins are not applied correctly
authorjfernandez@igalia.com <jfernandez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Jul 2015 17:53:55 +0000 (17:53 +0000)
committerjfernandez@igalia.com <jfernandez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Jul 2015 17:53:55 +0000 (17:53 +0000)
commit3e08daeec8e7b49a9b7aafb39eae17a54dbf95da
treed00588cd246799718de336001e1551539a79fd48
parent0199f83e2b00a3b6290ee3a383b600badaa0b161
[CSS Grid Layout] Grid item's auto-margins are not applied correctly
https://bugs.webkit.org/show_bug.cgi?id=146581

Reviewed by Darin Adler.

Source/WebCore:

Grid Layout specification states that auto-margins must prevent to apply
any Box Alignment property in that dimension. Instead, auto-margin is
applied as described in the spec.

http://dev.w3.org/csswg/css-grid/#auto-margins

Only Flexbox and Grid Layout implement vertical auto-margin alignment;
for other layout modes, auto-margin should compute as 0.

Tests: fast/css-grid-layout/grid-item-auto-margins-alignment-vertical-lr.html
       fast/css-grid-layout/grid-item-auto-margins-alignment-vertical-rl.html
       fast/css-grid-layout/grid-item-auto-margins-alignment.html

* rendering/RenderBox.cpp:
(WebCore::RenderBox::styleDidChange):
(WebCore::RenderBox::updateGridAlignmentAfterStyleChange):
* rendering/RenderBox.h:
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::layoutGridItems):
(WebCore::RenderGrid::hasAutoMarginsInColumnAxis):
(WebCore::RenderGrid::hasAutoMarginsInRowAxis):
(WebCore::RenderGrid::updateAutoMarginsInColumnAxisIfNeeded):
(WebCore::RenderGrid::rowPositionForChild):
(WebCore::RenderGrid::columnPositionForChild):
* rendering/RenderGrid.h:

LayoutTests:

Tests to verify auto-margins alignment works as expected with grid items.

* fast/css-grid-layout/grid-item-auto-margins-alignment-expected.txt: Added.
* fast/css-grid-layout/grid-item-auto-margins-alignment-vertical-lr-expected.txt: Added.
* fast/css-grid-layout/grid-item-auto-margins-alignment-vertical-lr.html: Added.
* fast/css-grid-layout/grid-item-auto-margins-alignment-vertical-rl-expected.txt: Added.
* fast/css-grid-layout/grid-item-auto-margins-alignment-vertical-rl.html: Added.
* fast/css-grid-layout/grid-item-auto-margins-alignment.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@186682 268f45cc-cd09-0410-ab3c-d52691b4dbfc
12 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css-grid-layout/grid-item-auto-margins-alignment-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-item-auto-margins-alignment-vertical-lr-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-item-auto-margins-alignment-vertical-lr.html [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-item-auto-margins-alignment-vertical-rl-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-item-auto-margins-alignment-vertical-rl.html [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-item-auto-margins-alignment.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBox.cpp
Source/WebCore/rendering/RenderBox.h
Source/WebCore/rendering/RenderGrid.cpp
Source/WebCore/rendering/RenderGrid.h