Closed Bug 1690423 Opened 3 years ago Closed 3 years ago

Incorrect calculation of block content contribution because we skip aspect-ratio when measuring reflow in Grid layout

Categories

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

defect

Tracking

()

RESOLVED FIXED
89 Branch
Tracking Status
firefox89 --- fixed

People

(Reporter: boris, Assigned: boris)

References

()

Details

Attachments

(4 files, 1 obsolete file)

When using aspect-ratio on grid items, we should use the current intrinsic inline size and the aspect-ratio property to calculate the block size of the grid tracks.

For example:
https://codepen.io/jensimmons/pen/JjRZVwg?editors=1100

The content contribution of each grid item doesn't take the aspect-ratio into account, so the actual block size of these grid tracks is incorrect. It seems we shouldn't skip aspect-ratio when measuring reflow.

Status: NEW → ASSIGNED

For grid layout, we set UseAutoBSize flag during measuring reflow to
resolve the grid track sizing. We still have to respect aspect ratio
for the calculation of the content contribution.

Attachment #9202796 - Attachment is obsolete: true

I was trying to unified the nsLayoutUtils::IsAutoBSize usage with the flag ComputeSizeFlag::UseAutoBSize with the patch in comment 2, but I got one subgrid test failure testing/web-platform/tests/css/css-grid/subgrid/orthogonal-writing-mode-003.html. https://treeherder.mozilla.org/jobs?repo=try&revision=cec564abaa37b3f39c7145883cd7fe8a17a2373d

I believe the patch should be a reasonable approach going forward because it give us a foundation to replace the flag with StyleSizeOverrides. I'm replacing UseAutoISize flag in https://phabricator.services.mozilla.com/D103438.

I'm not familiar with subgrid, and probably don't have time to investigate further. If anyone have cycles to investigate, please feel free.

(In reply to Ting-Yu Lin [:TYLin] (UTC-8) from comment #4)

I was trying to unified the nsLayoutUtils::IsAutoBSize usage with the flag ComputeSizeFlag::UseAutoBSize with the patch in comment 2, but I got one subgrid test failure testing/web-platform/tests/css/css-grid/subgrid/orthogonal-writing-mode-003.html. https://treeherder.mozilla.org/jobs?repo=try&revision=cec564abaa37b3f39c7145883cd7fe8a17a2373d

I believe the patch should be a reasonable approach going forward because it give us a foundation to replace the flag with StyleSizeOverrides. I'm replacing UseAutoISize flag in https://phabricator.services.mozilla.com/D103438.

I'm not familiar with subgrid, and probably don't have time to investigate further. If anyone have cycles to investigate, please feel free.

Thanks, TYLin. It makes more sense to use the way you provide.

Based on https://drafts.csswg.org/css-grid/#grid-item-sizing, the grid
items should igonre aspect-ratio if it's stretched in that axis.

  1. If the alignment value is stretch: don't apply aspect ratio.
  2. If the alignment value is normal: apply aspect ratio if we have one.
  3. Other values: apply aspect ratio if we have one.
Attachment #9202751 - Attachment description: Bug 1690423 - Take aspect-ratio into account when measuring reflow. → Bug 1690423 - Unified auto block-size behavior with UseAutoBSize flag in nsIFrame::ComputeSize().
Blocks: 1672073, aspect-ratio
No longer blocks: 1646098
Attachment #9203000 - Attachment description: Bug 1690423 - Fix stretched grid items with aspect-ratio. → Bug 1690423 - Part 1: Fix stretched grid items with aspect-ratio.
Attachment #9202751 - Attachment description: Bug 1690423 - Unified auto block-size behavior with UseAutoBSize flag in nsIFrame::ComputeSize(). → Bug 1690423 - Part 2: Unified auto block-size behavior with UseAutoBSize flag in nsIFrame::ComputeSize().

The spec says: the content-based minimum size for a grid item in a given
dimension is its specified size suggestion if it exists, otherwise its
transferred size suggestion if that exists and the element is replaced, else
its content size suggestion. So for non-replaced elements, we don't have
to take transferred size suggestion into account.

Add some tests when using the preferred size with percentage value and
min-size:auto in grid items, and a test for overflow:auto.

Pushed by bchiou@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/49ed09f9753a
Part 1: Fix stretched grid items with aspect-ratio. r=mats
https://hg.mozilla.org/integration/autoland/rev/8c8b2e32217e
Part 2: Unified auto block-size behavior with UseAutoBSize flag in nsIFrame::ComputeSize(). r=mats
https://hg.mozilla.org/integration/autoland/rev/1a498df37bd5
Part 3: No need to handle transferred size suggestion for the minimum contribution on non-replaced elements. r=mats
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/28448 for changes under testing/web-platform/tests
Upstream PR merged by moz-wptsync-bot
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 89 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: