Closed Bug 1593796 Opened 1 year ago Closed 1 year ago

[css-grid] Wrong sizes for implicit tracks when multiple values are provided (grid-auto-columns/rows)

Categories

(Core :: Layout: Grid, defect, P2)

defect

Tracking

()

RESOLVED FIXED
mozilla72
Tracking Status
firefox72 --- fixed

People

(Reporter: Oriol, Assigned: boris)

References

Details

(Keywords: testcase)

Attachments

(2 files)

Attached file grid-auto-tracks.htm

Load attached testcase.

There is a symmetrical grid with

grid-template: 200px / 200px;
grid-auto-columns: 100px 400px;
grid-auto-rows: 100px 400px;

The grid has 3 tracks:

  • 1 leading implicit track
  • 1 explicit track
  • 1 trailing implicit track

The explicit track is of course sized with 200px, the implicit tracks are sized with 100px 400px according to https://drafts.csswg.org/css-grid/#auto-tracks

If multiple track sizes are given, the pattern is repeated as necessary to find the size of the implicit tracks. The first implicit grid track after the explicit grid receives the first specified size, and so on forwards; and the last implicit grid track before the explicit grid receives the last specified size, and so on backwards.

Therefore, the 3rd track (trailing implicit) should be sized with 100px.
And the 1st track (leading implicit) should be sized with 400px.

So the track sizes should be 400px 200px 100px.

In Firefox they are 100px 200px 400px.

Chromium does it correctly.

Thanks for the detailed report!

Blocks: 1339672
Keywords: testcase
OS: Unspecified → All
Priority: -- → P2
Hardware: Unspecified → All
Summary: [css-grid] Wrong sizes for implicit tracks when multiple values are provided → [css-grid] Wrong sizes for implicit tracks when multiple values are provided (grid-auto-columns/rows)

This logic seems wrong: https://searchfox.org/mozilla-central/rev/3300072e993ae05d50d5c63d815260367eaf9179/layout/generic/nsGridContainerFrame.cpp#1157-1161

// If multiple track sizes are given, the pattern is repeated as necessary
// to find the size of the implicit tracks.
return mAutoSizing.IsEmpty()
           ? kAutoTrackSize
           : mAutoSizing.AsSpan()[aIndex % mAutoSizing.Length()];

I can take a look at this. :)

Assignee: nobody → boris.chiou
Status: NEW → ASSIGNED

Per the spec, if multiple track sizes are given, the pattern is repeated as
necessary to find the size of the implicit tracks:

  1. The first implicit grid track after the explicit grid receives the first
    specified size, and so on forwards.
  2. The last implicit grid track before the explicit grid receives the last
    specified size, and so on backwards.

We use a positive index of the auto track sizes for (1) and an negative index
for (2), so we can apply the correct specified implicit size.

Pushed by bchiou@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/4c34130cc58f
Apply the correct specified implicit size. r=mats
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/20225 for changes under testing/web-platform/tests
Upstream web-platform-tests status checks passed, PR will merge once commit reaches central.
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla72
Upstream PR merged by moz-wptsync-bot
You need to log in before you can comment on or make changes to this bug.