Closed Bug 1683976 Opened 4 years ago Closed 4 years ago

Make flex item consider box-sizing when deriving its main size from aspect-ratio

Categories

(Core :: Layout: Flexbox, defect)

defect

Tracking

()

RESOLVED FIXED
86 Branch
Tracking Status
firefox86 --- fixed

People

(Reporter: TYLin, Assigned: TYLin)

References

Details

Attachments

(4 files)

Similar to bug 1683424, when we calculate a flex item's main size from its definite cross-size and aspect-ratio, and the aspect-ratio is from style aspect-ratio:<ratio> [1], the ratio should work with the dimensions of the box specified by box-sizing.

[1] https://drafts.csswg.org/css-sizing-4/#valdef-aspect-ratio-ratio

FlexItem::mIntrinsicRatio caches the AspectRatio from
nsIFrame::GetAspectRatio(), which can either be the natural aspect-ratio
of the element or the aspect-ratio set from style system. Rename it and
its accessors for accuracy.

The comments are revised to match the term "preferred aspect ratio" used
throughout the flexbox spec.

We are going to revise this method in the next part, so this patch
simply moves this method into FlexItem without doing any improvement.

Depends on D100369

Per aspect ratio spec [1], when specifying aspect-ratio:<ratio>, the
size calculations involving the aspect ratio work with the dimensions of
the box specified by box-sizing.

MainSizeFromAspectRatio() doesn't consider box-sizing, so we replace it
with AspectRatio::ComputeRatioDependentSize() which considers
box-sizing.

[1] https://drafts.csswg.org/css-sizing-4/#valdef-aspect-ratio-ratio

Depends on D100370

If the flex container overrides a flex item's block-size, we don't want
to apply aspect-ratio's automatic content-based minimum sizes
https://drafts.csswg.org/css-sizing-4/#aspect-ratio-minimum.

Depends on D100371

Pushed by aethanyc@gmail.com: https://hg.mozilla.org/integration/autoland/rev/7b3500bc99cd Part 1 - Rename intrinsic ratio to aspect ratio in nsFlexContainerFrame. r=dholbert,boris https://hg.mozilla.org/integration/autoland/rev/2c5d4838ecd8 Part 2 - Move ClampMainSizeViaCrossAxisConstraints() into FlexItem. r=dholbert https://hg.mozilla.org/integration/autoland/rev/d2a613ecea6b Part 3 - Make flex item work with box-sizing when its aspect-ratio is set from <ratio>. r=dholbert https://hg.mozilla.org/integration/autoland/rev/2ebcdae9c537 Part 4 - Reset ReflowInput's mBSizeIsSetByAspectRatio flag if we override flex item's block-size. r=dholbert
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/27057 for changes under testing/web-platform/tests
Upstream PR merged by moz-wptsync-bot
Regressions: 1730570
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: