[CSS Grid Layout] Columns set in percentages collapse to auto width
authorrego@igalia.com <rego@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Apr 2015 04:59:09 +0000 (04:59 +0000)
committerrego@igalia.com <rego@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Apr 2015 04:59:09 +0000 (04:59 +0000)
commit9eb9d6d45e6c7ffe131e082aa589ca2c8841dcc7
treedebb9be77bf10c074ab0ce2951befc93c3e9d861
parent23615a663bbcb06b77e31fd41c84e7bcfaf6a316
[CSS Grid Layout] Columns set in percentages collapse to auto width
https://bugs.webkit.org/show_bug.cgi?id=141435

Reviewed by David Hyatt.

Source/WebCore:

Based on a patch by Sergio Villar Senin  <svillar@igalia.com>.

This patch adds 2 new new methods in RenderBox to determine if the grid
has a definite size or not.

RenderGrid::gridTrackSize() was not checking properly if the grid has or
not an indefinite size.
The condition was including auto which is not indefinite per se. For
example, auto is definite if the containing block is definite.
As the new method is more expensive, we just call it when it's really
needed to avoid performance regressions.

Finally we were setting the override logical width/height to -1 (no
possible resolution) for all the items regardless if they've a relative
width/height or a fixed one.
Added the condition, including not only items with percentage logical
width/height but also relative, to avoid overriding the value for items
with fixed width/height as it's not needed.

Tests: fast/css-grid-layout/grid-item-with-percent-height-in-auto-height-grid-resolution.html
       fast/css-grid-layout/percent-intrinsic-track-breadth.html
       fast/css-grid-layout/percent-track-breadths-regarding-container-size.html

* rendering/RenderBox.cpp:
(WebCore::logicalWidthIsResolvable):
(WebCore::RenderBox::hasDefiniteLogicalWidth):
(WebCore::RenderBox::percentageLogicalHeightIsResolvableFromBlock):
(WebCore::RenderBox::hasRelativeLogicalWidth):
* rendering/RenderBox.h:
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::hasDefiniteLogicalSize):
(WebCore::RenderGrid::gridTrackSize):
(WebCore::RenderGrid::logicalContentHeightForChild):
(WebCore::RenderGrid::minContentForChild):
(WebCore::RenderGrid::maxContentForChild):
* rendering/RenderGrid.h:

LayoutTests:

Added new tests to check that percentage track breadths are properly
calculated under different sizing conditions.
Modified one test to include relative sizes too.

* fast/css-grid-layout/grid-item-with-percent-height-in-auto-height-grid-resolution-expected.txt:
* fast/css-grid-layout/grid-item-with-percent-height-in-auto-height-grid-resolution.html:
* fast/css-grid-layout/percent-intrinsic-track-breadth-expected.txt: Added.
* fast/css-grid-layout/percent-intrinsic-track-breadth.html: Added.
* fast/css-grid-layout/percent-track-breadths-regarding-container-size-expected.txt: Added.
* fast/css-grid-layout/percent-track-breadths-regarding-container-size.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@182780 268f45cc-cd09-0410-ab3c-d52691b4dbfc
12 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css-grid-layout/grid-item-with-percent-height-in-auto-height-grid-resolution-expected.txt
LayoutTests/fast/css-grid-layout/grid-item-with-percent-height-in-auto-height-grid-resolution.html
LayoutTests/fast/css-grid-layout/percent-intrinsic-track-breadth-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/percent-intrinsic-track-breadth.html [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/percent-track-breadths-regarding-container-size-expected.txt [new file with mode: 0644]
LayoutTests/fast/css-grid-layout/percent-track-breadths-regarding-container-size.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