[Webkit-unassigned] [Bug 199648] CSS Grid `align-items: baseline; ` with scaled images results in excessive top whitespace

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Aug 25 13:38:32 PDT 2020


https://bugs.webkit.org/show_bug.cgi?id=199648

--- Comment #3 from Oriol Brufau <obrufau at igalia.com> ---
Created attachment 407225

  --> https://bugs.webkit.org/attachment.cgi?id=407225&action=review

Simpler testcase

OK, so the problem is that the track sizing algorithm takes baseline alignment into account, so when we calculate that baseline alignment we still don't know the final grid area sizes.

In RenderGrid::performGridItemsPreLayout, there is

```cpp
if (isBaselineAlignmentForChild(*child)) {
    updateGridAreaLogicalSize(*child, algorithm.estimatedGridAreaBreadthForChild(*child));
```

The estimated area is 200px wide and undefined tall for the 1st item.
But the 2nd item has a 50px wide X, so the estimated area is 250px wide.
Then we think that the image will be 250px wide, and therefore 250px tall via the aspect ratio.
So we add a 50px shim, which increases the row size by 50px, thinking that this will provide proper baseline alignment.
However, the 2ns column ends up being 200px, not 250px, so the above was wrong.

The problem is in GridTrackSizingAlgorithm::estimatedGridAreaBreadthForChild.
Since `isRelativeGridLengthAsAuto(maxTrackSize, direction)` is true, it returns the maxPreferredLogicalWidth.
However, while the grid track sizing function for the column is a percentage, it is actually definite due to `width: 400px`.
So isRelativeGridLengthAsAuto should return false!
But it returns true because the availableSpace has not been set yet, so it thinks that the grid is sized under a min/max-content constraint.

Chromium is also affected.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20200825/de18b789/attachment.htm>


More information about the webkit-unassigned mailing list