Incorrect calculation of block content contribution because we skip aspect-ratio when measuring reflow in Grid layout
Categories
(Core :: Layout: Grid, defect, P2)
Tracking
()
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.
Assignee | ||
Updated•3 years ago
|
Assignee | ||
Comment 1•3 years ago
|
||
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.
Comment 2•3 years ago
|
||
Comment 3•3 years ago
|
||
Updated•3 years ago
|
Comment 4•3 years ago
|
||
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.
Assignee | ||
Comment 5•3 years ago
|
||
(In reply to Ting-Yu Lin [:TYLin] (UTC-8) from comment #4)
I was trying to unified the
nsLayoutUtils::IsAutoBSize
usage with the flagComputeSizeFlag::UseAutoBSize
with the patch in comment 2, but I got one subgrid test failuretesting/web-platform/tests/css/css-grid/subgrid/orthogonal-writing-mode-003.html
. https://treeherder.mozilla.org/jobs?repo=try&revision=cec564abaa37b3f39c7145883cd7fe8a17a2373dI believe the patch should be a reasonable approach going forward because it give us a foundation to replace the flag with
StyleSizeOverrides
. I'm replacingUseAutoISize
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.
Assignee | ||
Comment 6•3 years ago
|
||
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.
- If the alignment value is stretch: don't apply aspect ratio.
- If the alignment value is normal: apply aspect ratio if we have one.
- Other values: apply aspect ratio if we have one.
Updated•3 years ago
|
Assignee | ||
Updated•3 years ago
|
Assignee | ||
Updated•3 years ago
|
Updated•3 years ago
|
Updated•3 years ago
|
Assignee | ||
Comment 7•3 years ago
|
||
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
Comment 11•3 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/49ed09f9753a
https://hg.mozilla.org/mozilla-central/rev/8c8b2e32217e
https://hg.mozilla.org/mozilla-central/rev/1a498df37bd5
Description
•