[css-grid] Implement Baseline Alignment for grid items
authorjfernandez@igalia.com <jfernandez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Nov 2018 11:04:23 +0000 (11:04 +0000)
committerjfernandez@igalia.com <jfernandez@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 23 Nov 2018 11:04:23 +0000 (11:04 +0000)
commit18c8450cda5001e6ac122863f60f89205d0bbb36
tree66793a8528ea5d29dc762688063c1f4f20fa3827
parent47e2baee46f0f393dcc04180cc0c2862cd821e90
[css-grid] Implement Baseline Alignment for grid items
https://bugs.webkit.org/show_bug.cgi?id=145566

Reviewed by Manuel Rego Casasnovas.

LayoutTests/imported/w3c:

Updated test expectations of severla tests, that are now passing with the new code.

* resources/import-expectations.json:
* web-platform-tests/css/css-grid/alignment/grid-alignment-style-changes-001-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-alignment-style-changes-002-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-alignment-style-changes-003-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-alignment-style-changes-004-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-alignment-style-changes-005-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-alignment-style-changes-006-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-alignment-style-changes-007-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-alignment-style-changes-008-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-column-axis-self-baseline-synthesized-001-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-column-axis-self-baseline-synthesized-002-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-column-axis-self-baseline-synthesized-003-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-column-axis-self-baseline-synthesized-004-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-row-axis-self-baseline-synthesized-001-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-row-axis-self-baseline-synthesized-002-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-row-axis-self-baseline-synthesized-003-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-row-axis-self-baseline-synthesized-004-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-self-baseline-not-applied-if-sizing-cyclic-dependency-001-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-self-baseline-not-applied-if-sizing-cyclic-dependency-002-expected.txt:
* web-platform-tests/css/css-grid/alignment/grid-self-baseline-not-applied-if-sizing-cyclic-dependency-003-expected.txt:
* web-platform-tests/css/css-grid/alignment/self-baseline/grid-self-baseline-changes-grid-area-size-007.html:
* web-platform-tests/css/css-grid/alignment/self-baseline/grid-self-baseline-changes-grid-area-size-008.html:
* web-platform-tests/css/css-grid/alignment/self-baseline/grid-self-baseline-changes-grid-area-size-009.html:
* web-platform-tests/css/css-grid/alignment/self-baseline/grid-self-baseline-changes-grid-area-size-010.html:
* web-platform-tests/css/css-grid/alignment/self-baseline/grid-self-baseline-changes-grid-area-size-011.html:
* web-platform-tests/css/css-grid/alignment/self-baseline/grid-self-baseline-changes-grid-area-size-012.html:
* web-platform-tests/css/css-grid/grid-items/grid-items-percentage-margins-002-expected.txt:
* web-platform-tests/css/css-grid/grid-items/grid-items-percentage-margins-vertical-lr-002-expected.txt:
* web-platform-tests/css/css-grid/grid-items/grid-items-percentage-margins-vertical-rl-002-expected.txt:
* web-platform-tests/css/css-grid/grid-items/grid-items-percentage-paddings-002-expected.txt:
* web-platform-tests/css/css-grid/grid-items/grid-items-percentage-paddings-vertical-lr-002-expected.txt:
* web-platform-tests/css/css-grid/grid-items/grid-items-percentage-paddings-vertical-rl-002-expected.txt:

Source/WebCore:

This patch impements the Baseline Self-Alignment feature for grid items according to
the CSS Box Alignment specification [1].

This new layout logic is handled by the Self-Alignment (justify-self and align-self)
and Default-Alignment (justify-items and align-items) CSS properties.

This feature allows users to align the grid items sharing a Baseline Alignment Context,
either row or column contexts, based on their respective baselines.

[1] https://drafts.csswg.org/css-align-3/#baseline-align-self

Tests: fast/css-grid-layout/grid-self-baseline-and-flex-tracks-with-indefinite-container-crash.html
       fast/css-grid-layout/grid-self-baseline-and-flexible-tracks-should-not-crash.html
       fast/css-grid-layout/grid-self-baseline-and-item-relayout-should-not-crash.html
       fast/css-grid-layout/grid-self-baseline-and-relative-sized-items-crash.html
       fast/css-grid-layout/grid-self-baseline-and-relative-sized-tracks-crash.html
       fast/css-grid-layout/grid-self-baseline-followed-by-item-style-change-should-not-crash.html

* Sources.txt:
* rendering/GridBaselineAlignment.cpp: Added.
(WebCore::GridBaselineAlignment::marginOverForChild const):
(WebCore::GridBaselineAlignment::marginUnderForChild const):
(WebCore::GridBaselineAlignment::logicalAscentForChild const):
(WebCore::GridBaselineAlignment::ascentForChild const):
(WebCore::GridBaselineAlignment::descentForChild const):
(WebCore::GridBaselineAlignment::isDescentBaselineForChild const):
(WebCore::GridBaselineAlignment::isHorizontalBaselineAxis const):
(WebCore::GridBaselineAlignment::isOrthogonalChildForBaseline const):
(WebCore::GridBaselineAlignment::isParallelToBaselineAxisForChild const):
(WebCore::GridBaselineAlignment::baselineGroupForChild const):
(WebCore::GridBaselineAlignment::updateBaselineAlignmentContext):
(WebCore::GridBaselineAlignment::baselineOffsetForChild const):
(WebCore::GridBaselineAlignment::clear):
(WebCore::BaselineGroup::BaselineGroup):
(WebCore::BaselineGroup::update):
(WebCore::BaselineGroup::isOppositeBlockFlow const):
(WebCore::BaselineGroup::isOrthogonalBlockFlow const):
(WebCore::BaselineGroup::isCompatible const):
(WebCore::BaselineContext::BaselineContext):
(WebCore::BaselineContext::sharedGroup const):
(WebCore::BaselineContext::updateSharedGroup):
(WebCore::BaselineContext::findCompatibleSharedGroup):
* rendering/GridBaselineAlignment.h: Added.
(WebCore::BaselineGroup::maxAscent const):
(WebCore::BaselineGroup::maxDescent const):
(WebCore::BaselineGroup::size const):
(WebCore::isBaselinePosition):
(WebCore::GridBaselineAlignment::setBlockFlow):
* rendering/GridLayoutFunctions.h:
* rendering/GridTrackSizingAlgorithm.cpp:
(WebCore::gridAxisForDirection):
(WebCore::gridDirectionForAxis):
(WebCore::GridTrackSizingAlgorithm::availableSpace const):
(WebCore::GridTrackSizingAlgorithm::isIntrinsicSizedGridArea const):
(WebCore::GridTrackSizingAlgorithmStrategy::logicalHeightForChild const):
(WebCore::GridTrackSizingAlgorithmStrategy::minContentForChild const):
(WebCore::GridTrackSizingAlgorithmStrategy::maxContentForChild const):
(WebCore::GridTrackSizingAlgorithmStrategy::minSizeForChild const):
(WebCore::GridTrackSizingAlgorithm::canParticipateInBaselineAlignment const):
(WebCore::GridTrackSizingAlgorithm::participateInBaselineAlignment const):
(WebCore::GridTrackSizingAlgorithm::updateBaselineAlignmentContext):
(WebCore::GridTrackSizingAlgorithm::baselineOffsetForChild const):
(WebCore::GridTrackSizingAlgorithm::clearBaselineItemsCache):
(WebCore::GridTrackSizingAlgorithm::cacheBaselineAlignedItem):
(WebCore::GridTrackSizingAlgorithm::copyBaselineItemsCache):
(WebCore::GridTrackSizingAlgorithm::setup):
(WebCore::GridTrackSizingAlgorithm::computeBaselineAlignmentContext):
* rendering/GridTrackSizingAlgorithm.h:
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::firstLineBaseline const):
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::layoutBlock):
(WebCore::RenderGrid::computeIntrinsicLogicalWidths const):
(WebCore::RenderGrid::placeItemsOnGrid const):
(WebCore::RenderGrid::performGridItemsPreLayout const):
(WebCore::synthesizedBaselineFromMarginBox):
(WebCore::RenderGrid::isBaselineAlignmentForChild const):
(WebCore::RenderGrid::baselinePosition const):
(WebCore::RenderGrid::firstLineBaseline const):
(WebCore::RenderGrid::inlineBlockBaseline const):
(WebCore::RenderGrid::columnAxisBaselineOffsetForChild const):
(WebCore::RenderGrid::rowAxisBaselineOffsetForChild const):
(WebCore::RenderGrid::columnAxisOffsetForChild const):
(WebCore::RenderGrid::rowAxisOffsetForChild const):
* rendering/RenderGrid.h:

LayoutTests:

Most of the baseline realated tests pass now; just a few still fail because of unrelated bugs.

* TestExpectations: Removed several entries, related to the baseline tests that are now passing.
* fast/css-grid-layout/grid-align-baseline-expected.txt:
* fast/css-grid-layout/grid-align-baseline-vertical-expected.txt:
* fast/css-grid-layout/grid-baseline-expected.html:
* fast/css-grid-layout/grid-baseline-margins-expected.html:
* fast/css-grid-layout/grid-baseline-margins.html:
* fast/css-grid-layout/grid-baseline-must-respect-grid-order-expected.txt:
* fast/css-grid-layout/grid-baseline-must-respect-grid-order.html:
* fast/css-grid-layout/grid-baseline.html:
* fast/css-grid-layout/grid-self-baseline-and-flex-tracks-with-indefinite-container-crash-expected.txt: Added.
* fast/css-grid-layout/grid-self-baseline-and-flex-tracks-with-indefinite-container-crash.html: Added.
* fast/css-grid-layout/grid-self-baseline-and-flexible-tracks-should-not-crash-expected.txt: Added.
* fast/css-grid-layout/grid-self-baseline-and-flexible-tracks-should-not-crash.html: Added.
* fast/css-grid-layout/grid-self-baseline-and-item-relayout-should-not-crash-expected.txt: Added.
* fast/css-grid-layout/grid-self-baseline-and-item-relayout-should-not-crash.html: Added.
* fast/css-grid-layout/grid-self-baseline-and-relative-sized-items-crash-expected.txt: Added.
* fast/css-grid-layout/grid-self-baseline-and-relative-sized-items-crash.html: Added.
* fast/css-grid-layout/grid-self-baseline-and-relative-sized-tracks-crash-expected.txt: Added.
* fast/css-grid-layout/grid-self-baseline-and-relative-sized-tracks-crash.html: Added.
* fast/css-grid-layout/grid-self-baseline-followed-by-item-style-change-should-not-crash-expected.txt: Added.
* fast/css-grid-layout/grid-self-baseline-followed-by-item-style-change-should-not-crash.html: Added.
* fast/css-grid-layout/grid-self-baseline-two-dimensional-expected.txt:
* fast/css-grid-layout/grid-self-baseline-two-dimensional.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238457 268f45cc-cd09-0410-ab3c-d52691b4dbfc
74 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/fast/css-grid-layout/grid-align-baseline-expected.txt
LayoutTests/fast/css-grid-layout/grid-align-baseline-vertical-expected.txt
LayoutTests/fast/css-grid-layout/grid-baseline-expected.html
LayoutTests/fast/css-grid-layout/grid-baseline-margins-expected.html
LayoutTests/fast/css-grid-layout/grid-baseline-margins.html
LayoutTests/fast/css-grid-layout/grid-baseline-must-respect-grid-order-expected.txt
LayoutTests/fast/css-grid-layout/grid-baseline-must-respect-grid-order.html
LayoutTests/fast/css-grid-layout/grid-baseline.html
LayoutTests/fast/css-grid-layout/grid-self-baseline-and-flex-tracks-with-indefinite-container-crash-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-self-baseline-and-flex-tracks-with-indefinite-container-crash.html [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-self-baseline-and-flexible-tracks-should-not-crash-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-self-baseline-and-flexible-tracks-should-not-crash.html [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-self-baseline-and-item-relayout-should-not-crash-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-self-baseline-and-item-relayout-should-not-crash.html [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-self-baseline-and-relative-sized-items-crash-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-self-baseline-and-relative-sized-items-crash.html [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-self-baseline-and-relative-sized-tracks-crash-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-self-baseline-and-relative-sized-tracks-crash.html [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-self-baseline-followed-by-item-style-change-should-not-crash-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-self-baseline-followed-by-item-style-change-should-not-crash.html [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-self-baseline-horiz-04-expected.html
LayoutTests/fast/css-grid-layout/grid-self-baseline-two-dimensional-expected.txt
LayoutTests/fast/css-grid-layout/grid-self-baseline-two-dimensional.html
LayoutTests/fast/css-grid-layout/grid-self-baseline-vertical-lr-04-expected.html
LayoutTests/fast/css-grid-layout/grid-self-baseline-vertical-lr-04.html
LayoutTests/fast/css-grid-layout/grid-self-baseline-vertical-rl-04-expected.html
LayoutTests/fast/css-grid-layout/grid-self-baseline-vertical-rl-04.html
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-alignment-style-changes-001-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-alignment-style-changes-002-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-alignment-style-changes-003-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-alignment-style-changes-004-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-alignment-style-changes-005-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-alignment-style-changes-006-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-alignment-style-changes-007-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-alignment-style-changes-008-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-column-axis-self-baseline-synthesized-001-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-column-axis-self-baseline-synthesized-002-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-column-axis-self-baseline-synthesized-003-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-column-axis-self-baseline-synthesized-004-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-row-axis-self-baseline-synthesized-001-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-row-axis-self-baseline-synthesized-002-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-row-axis-self-baseline-synthesized-003-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-row-axis-self-baseline-synthesized-004-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-baseline-not-applied-if-sizing-cyclic-dependency-001-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-baseline-not-applied-if-sizing-cyclic-dependency-002-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/grid-self-baseline-not-applied-if-sizing-cyclic-dependency-003-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/self-baseline/grid-self-baseline-changes-grid-area-size-002.html
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/self-baseline/grid-self-baseline-changes-grid-area-size-007.html
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/self-baseline/grid-self-baseline-changes-grid-area-size-008.html
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/self-baseline/grid-self-baseline-changes-grid-area-size-009.html
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/self-baseline/grid-self-baseline-changes-grid-area-size-010.html
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/self-baseline/grid-self-baseline-changes-grid-area-size-011.html
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/alignment/self-baseline/grid-self-baseline-changes-grid-area-size-012.html
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-items-percentage-margins-002-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-items-percentage-margins-vertical-lr-002-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-items-percentage-margins-vertical-rl-002-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-items-percentage-paddings-002-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-items-percentage-paddings-vertical-lr-002-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-grid/grid-items/grid-items-percentage-paddings-vertical-rl-002-expected.txt
LayoutTests/platform/ios-simulator/TestExpectations
LayoutTests/platform/mac/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/Sources.txt
Source/WebCore/rendering/GridBaselineAlignment.cpp [new file with mode: 0644]
Source/WebCore/rendering/GridBaselineAlignment.h [new file with mode: 0644]
Source/WebCore/rendering/GridLayoutFunctions.h
Source/WebCore/rendering/GridTrackSizingAlgorithm.cpp
Source/WebCore/rendering/GridTrackSizingAlgorithm.h
Source/WebCore/rendering/RenderBlockFlow.cpp
Source/WebCore/rendering/RenderGrid.cpp
Source/WebCore/rendering/RenderGrid.h