[css-grid] Implement alignment for absolute positioned grid items
authorjfernandez@igalia.com <jfernandez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Dec 2017 22:19:20 +0000 (22:19 +0000)
committerjfernandez@igalia.com <jfernandez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Dec 2017 22:19:20 +0000 (22:19 +0000)
commit98d96749e1e8705505818588106449da85f5dc8a
tree0274b7020475db7af8f9aa55ab86935f1e31e8d5
parenta8621d8acf57bf51cb41667a952f921be74c9a85
[css-grid] Implement alignment for absolute positioned grid items
https://bugs.webkit.org/show_bug.cgi?id=180632

Reviewed by Manuel Rego Casasnovas.

LayoutTests/imported/w3c:

These tests now pass and verify the alignment logic for positioned grid items.

* web-platform-tests/css/css-grid/alignment/grid-column-axis-alignment-positioned-items-002-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-column-axis-alignment-positioned-items-005-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-column-axis-alignment-positioned-items-007-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-column-axis-alignment-positioned-items-009-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-column-axis-alignment-positioned-items-011-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-column-axis-alignment-positioned-items-013-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-column-axis-alignment-positioned-items-014-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-column-axis-alignment-positioned-items-016-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-row-axis-alignment-positioned-items-002-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-row-axis-alignment-positioned-items-003-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-row-axis-alignment-positioned-items-004-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-row-axis-alignment-positioned-items-005-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-row-axis-alignment-positioned-items-007-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-row-axis-alignment-positioned-items-009-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-row-axis-alignment-positioned-items-010-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-row-axis-alignment-positioned-items-013-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-row-axis-alignment-positioned-items-014-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-row-axis-alignment-positioned-items-015-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-self-alignment-non-static-positioned-items-001-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-self-alignment-non-static-positioned-items-002-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-self-alignment-non-static-positioned-items-003-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-self-alignment-non-static-positioned-items-004-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-self-alignment-non-static-positioned-items-005-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-self-alignment-non-static-positioned-items-006-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-self-alignment-non-static-positioned-items-007-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-self-alignment-non-static-positioned-items-008-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-self-alignment-non-static-positioned-items-009-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-self-alignment-non-static-positioned-items-009.html:
* web-platform-tests/css/css-grid/alignment/grid-self-alignment-non-static-positioned-items-010-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-self-alignment-non-static-positioned-items-011-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-self-alignment-non-static-positioned-items-012-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-001-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-002-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-003-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-004-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-005-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-006-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-007-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-008-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-009-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-010-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-011-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-012-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-013-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-014-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-015-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-016-expected.txt:

Source/WebCore:

We are changing how we compute the grid area's size of positioned
items, trying to make the logic as independent as possible of the
grid container's direction.

The new way of placing absolute positioned elements in their grid area
is based on the previously computed area's size. This provide a
mechanism to place an item in its area respecting the offsets derived
from the Content Alignment CSS properties and, which is more important,
ignoring the grid container's direction.

Additionally, we use the already implemented alignment logic that's
used for regular grid items. This patch provides almost full alignment
capabilities for positioned objects, with the exception of 'stretch'.

It's worth mentioning that some of the test cases using vertical-rl
writing mode will fail because of the bug 180633.

Updated web-platform-tests results of the test cases that pass now.

* rendering/GridLayoutFunctions.cpp:
       (WebCore::GridLayoutFunctions::hasOverrideContainingBlockContentSizeForChild):
(WebCore::GridLayoutFunctions::overrideContainingBlockContentSizeForChild):
* rendering/GridLayoutFunctions.h:
* rendering/GridTrackSizingAlgorithm.cpp:
(WebCore::GridTrackSizingAlgorithmStrategy::updateOverrideContainingBlockContentSizeForChild const):
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::layoutBlock):
(WebCore::RenderGrid::gridItemOffset const):
(WebCore::RenderGrid::hasStaticPositionForChild const):
(WebCore::RenderGrid::layoutPositionedObject):
(WebCore::RenderGrid::applyStretchAlignmentToChildIfNeeded):
(WebCore::RenderGrid::columnAxisPositionForChild const):
(WebCore::RenderGrid::rowAxisPositionForChild const):
(WebCore::RenderGrid::columnAxisOffsetForChild const):
(WebCore::RenderGrid::rowAxisOffsetForChild const):
(WebCore::RenderGrid::gridPositionIsAutoForOutOfFlow const):
(WebCore::RenderGrid::resolveAutoStartGridPosition const):
(WebCore::RenderGrid::resolveAutoEndGridPosition const):
(WebCore::RenderGrid::gridAreaBreadthForOutOfFlowChild):
(WebCore::RenderGrid::logicalOffsetForChild const):
(WebCore::RenderGrid::gridAreaPositionForOutOfFlowChild const):
(WebCore::RenderGrid::gridAreaPositionForInFlowChild const):
(WebCore::RenderGrid::gridAreaPositionForChild const):
(WebCore::RenderGrid::translateOutOfFlowRTLCoordinate const):
(WebCore::RenderGrid::findChildLogicalPosition const):
* rendering/RenderGrid.h:
* rendering/style/GridPositionsResolver.cpp:
(WebCore::adjustGridPositionsFromStyle):
(WebCore::GridPositionsResolver::initialPositionSide):
(WebCore::GridPositionsResolver::finalPositionSide):
* rendering/style/GridPositionsResolver.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225805 268f45cc-cd09-0410-ab3c-d52691b4dbfc
55 files changed:
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-column-axis-alignment-positioned-items-002-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-column-axis-alignment-positioned-items-005-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-column-axis-alignment-positioned-items-007-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-column-axis-alignment-positioned-items-009-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-column-axis-alignment-positioned-items-011-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-column-axis-alignment-positioned-items-013-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-column-axis-alignment-positioned-items-014-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-column-axis-alignment-positioned-items-016-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-row-axis-alignment-positioned-items-002-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-row-axis-alignment-positioned-items-003-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-row-axis-alignment-positioned-items-004-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-row-axis-alignment-positioned-items-005-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-row-axis-alignment-positioned-items-007-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-row-axis-alignment-positioned-items-009-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-row-axis-alignment-positioned-items-010-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-row-axis-alignment-positioned-items-013-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-row-axis-alignment-positioned-items-014-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-row-axis-alignment-positioned-items-015-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-alignment-non-static-positioned-items-001-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-alignment-non-static-positioned-items-002-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-alignment-non-static-positioned-items-003-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-alignment-non-static-positioned-items-004-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-alignment-non-static-positioned-items-005-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-alignment-non-static-positioned-items-006-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-alignment-non-static-positioned-items-007-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-alignment-non-static-positioned-items-008-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-alignment-non-static-positioned-items-009-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-alignment-non-static-positioned-items-010-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-alignment-non-static-positioned-items-011-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-alignment-non-static-positioned-items-012-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-001-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-002-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-003-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-004-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-005-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-006-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-007-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-008-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-009-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-010-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-011-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-012-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-013-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-014-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-015-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-alignment-positioned-items-with-margin-border-padding-016-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/rendering/GridLayoutFunctions.cpp
Source/WebCore/rendering/GridLayoutFunctions.h
Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp
Source/WebCore/rendering/RenderGrid.cpp
Source/WebCore/rendering/RenderGrid.h
Source/WebCore/rendering/style/GridPositionsResolver.cpp
Source/WebCore/rendering/style/GridPositionsResolver.h