[css-flex][css-grid] Fix synthesized baseline
authorrego@igalia.com <rego@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Apr 2019 12:04:20 +0000 (12:04 +0000)
committerrego@igalia.com <rego@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Apr 2019 12:04:20 +0000 (12:04 +0000)
commit3eaf4e796df4cece50b1eb46f4bbc848eb9d4d46
tree1787f16759e0b23a4c9b35b04294f6180020400e
parentc70ae6d7438f3be79763d6d3e76fcc8d547bf62b
[css-flex][css-grid] Fix synthesized baseline
https://bugs.webkit.org/show_bug.cgi?id=196312

Reviewed by Javier Fernandez.

LayoutTests/imported/w3c:

Imported some tests from WPT css-align test suite that are fixed with this patch.

* resources/import-expectations.json:
* web-platform-tests/css/css-align/baseline-rules/synthesized-baseline-flexbox-001-expected.txt: Added.
* web-platform-tests/css/css-align/baseline-rules/synthesized-baseline-flexbox-001.html: Added.
* web-platform-tests/css/css-align/baseline-rules/synthesized-baseline-grid-001-expected.txt: Added.
* web-platform-tests/css/css-align/baseline-rules/synthesized-baseline-grid-001.html: Added.
* web-platform-tests/css/css-align/baseline-rules/synthesized-baseline-inline-block-001-expected.txt: Added.
* web-platform-tests/css/css-align/baseline-rules/synthesized-baseline-inline-block-001.html: Added.
* web-platform-tests/css/css-align/baseline-rules/w3c-import.log: Added.

Source/WebCore:

When a flex or grid container has no baseline,
its baseline should be synthesized from the border edges.
The same happens for flex and grid items.

Right now we were using the content box in some cases
and even using the margin box in a particular scenario.
The patch fixes this.

At the same time this is also fixing the baseline for
inline flex/grid containers to make it interoperable with Firefox.
Inline blocks have a special behavior per legacy reasons,
which applies to inline flex/grid containers when they have no items;
otherwise the items should be used to compute its baseline.
See more at: https://github.com/w3c/csswg-drafts/issues/3416

Note that we need to keep current behavior for buttons,
as the flexbox spec doesn't apply to them.

Tests: css3/flexbox/flexbox-baseline-margins.html
       fast/css-grid-layout/grid-baseline-margins-1.html
       fast/css-grid-layout/grid-baseline-margins-2.html
       imported/w3c/web-platform-tests/css/css-align/baseline-rules/synthesized-baseline-flexbox-001.html
       imported/w3c/web-platform-tests/css/css-align/baseline-rules/synthesized-baseline-grid-001.html
       imported/w3c/web-platform-tests/css/css-align/baseline-rules/synthesized-baseline-inline-block-001.html

* rendering/RenderButton.cpp:
(WebCore::synthesizedBaselineFromContentBox):
(WebCore::RenderButton::baselinePosition const):
* rendering/RenderButton.h:
* rendering/RenderFlexibleBox.cpp:
(WebCore::synthesizedBaselineFromBorderBox):
(WebCore::RenderFlexibleBox::baselinePosition const):
(WebCore::RenderFlexibleBox::firstLineBaseline const):
(WebCore::RenderFlexibleBox::inlineBlockBaseline const):
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::baselinePosition const):
(WebCore::RenderGrid::inlineBlockBaseline const):

LayoutTests:

Some of the tests were not checking the right behavior changed them to test the expected one.
We need new rebaselines for some tests.

* TestExpectations:
* css3/flexbox/flexbox-baseline-margins.html:
* fast/css-grid-layout/grid-baseline-expected.html:
* fast/css-grid-layout/grid-baseline-margins-1-expected.html: Renamed from LayoutTests/fast/css-grid-layout/grid-baseline-margins-expected.html.
* fast/css-grid-layout/grid-baseline-margins-1.html: Renamed from LayoutTests/fast/css-grid-layout/grid-baseline-margins.html.
* fast/css-grid-layout/grid-baseline-margins-2-expected.html: Added.
* fast/css-grid-layout/grid-baseline-margins-2.html: Added.
* fast/css-grid-layout/grid-baseline.html: This test is modified and split in two parts as it doesn't fit in the viewport.
* platform/gtk/css3/flexbox/flexbox-baseline-margins-expected.png:
* platform/gtk/css3/flexbox/flexbox-baseline-margins-expected.txt:
* platform/ios/css3/flexbox/flexbox-baseline-margins-expected.png: Added.
* platform/ios/css3/flexbox/flexbox-baseline-margins-expected.txt:
* platform/mac/css3/flexbox/flexbox-baseline-margins-expected.png: Added.
* platform/mac/css3/flexbox/flexbox-baseline-margins-expected.txt:
* platform/win/css3/flexbox/flexbox-baseline-margins-expected.png: Added.
* platform/win/css3/flexbox/flexbox-baseline-margins-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244213 268f45cc-cd09-0410-ab3c-d52691b4dbfc
31 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/css3/flexbox/flexbox-baseline-margins.html
LayoutTests/fast/css-grid-layout/grid-baseline-expected.html
LayoutTests/fast/css-grid-layout/grid-baseline-margins-1-expected.html [moved from LayoutTests/fast/css-grid-layout/grid-baseline-margins-expected.html with 66% similarity]
LayoutTests/fast/css-grid-layout/grid-baseline-margins-1.html [moved from LayoutTests/fast/css-grid-layout/grid-baseline-margins.html with 64% similarity]
LayoutTests/fast/css-grid-layout/grid-baseline-margins-2-expected.html [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-baseline-margins-2.html [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/grid-baseline.html
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/resources/import-expectations.json
LayoutTests/imported/w3c/web-platform-tests/css/css-align/baseline-rules/synthesized-baseline-flexbox-001-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/css/css-align/baseline-rules/synthesized-baseline-flexbox-001.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/css/css-align/baseline-rules/synthesized-baseline-grid-001-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/css/css-align/baseline-rules/synthesized-baseline-grid-001.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/css/css-align/baseline-rules/synthesized-baseline-inline-block-001-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/css/css-align/baseline-rules/synthesized-baseline-inline-block-001.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/css/css-align/baseline-rules/w3c-import.log [new file with mode: 0644]
LayoutTests/platform/gtk/css3/flexbox/flexbox-baseline-margins-expected.png
LayoutTests/platform/gtk/css3/flexbox/flexbox-baseline-margins-expected.txt
LayoutTests/platform/ios/css3/flexbox/flexbox-baseline-margins-expected.png [new file with mode: 0644]
LayoutTests/platform/ios/css3/flexbox/flexbox-baseline-margins-expected.txt
LayoutTests/platform/mac/css3/flexbox/flexbox-baseline-margins-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/css3/flexbox/flexbox-baseline-margins-expected.txt
LayoutTests/platform/win/css3/flexbox/flexbox-baseline-margins-expected.png [new file with mode: 0644]
LayoutTests/platform/win/css3/flexbox/flexbox-baseline-margins-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderButton.cpp
Source/WebCore/rendering/RenderButton.h
Source/WebCore/rendering/RenderFlexibleBox.cpp
Source/WebCore/rendering/RenderGrid.cpp