Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css-flexbox] Should definite cross size be used to compute flex item's transferred size suggestion? #5663

Closed
aethanyc opened this issue Oct 26, 2020 · 8 comments

Comments

@aethanyc
Copy link

As @davidsgrogan noticed in this comment, for transferred size, the spec says:

If the item has a preferred aspect ratio and its computed cross size property is definite

In 9.8, the definite rule says:

the outer cross size of any stretched flex items ... is considered definite.

Should the stretched definite cross size be used in computing transferred size? Or in other words, should the transferred size defined as If the item has a preferred aspect ratio and a definite cross size, then ...? (similar to the flex algo 3B where a definite cross size is used to compute flex base size)

Consider the following example:

<div style="display:flex; width:0; height: 50px;">
  <img style="" src="https://placehold.it/300x100" >
</div>

It's obvious that the image has no specified size suggestion and the content size suggestion is 300px. Currently Firefox Nightly gives the image 150px width as it does use definite cross size and aspect-ratio to compute to transferred size. Chrome and Safari gives the image 300px width. (I guess both implementations think the image has no transferred size.)

cc @tabatkins @dholbert

@davidsgrogan
Copy link
Member

I think Chrome matches the spec here[1] but firefox's behavior is better[2], so we should change the wording of transferred size suggestion from

If the item has a preferred aspect ratio and its computed cross size property is definite

to something like

If the item has a preferred aspect ratio and its outer cross size is definite

Which matches the wording in 9.8 and makes clear that items with definite sizes imposed by the 9.8 rule qualify for the transferred size suggestion.

[1] The computed cross size property in the example above is not definite, which means there is no transferred size suggestion.

[2] Because Chrome's behavior in https://jsfiddle.net/dgrogan/jd76er1y/ is gross. One image has its aspect ratio respected but the other confusingly doesn't. In Firefox both images have their aspect ratio respected.

@tabatkins
Copy link
Member

Okay, 0c1a35d fixes up the terminology to hopefully make this clearer; at the time we wrote the min-auto section of the spec, we didn't have terminology like "preferred size" defined, so we had to refer directly to the properties; I recall us finding that awkward but not having a better option at the time.

Is it clear that if one of the preferred sizes for a box is definite, the rest are too, so long as they're calculated by fixed values? Like if the outer size is definite, and margin/border/padding are all definite values, that the inner size will be definite as well?

@tabatkins
Copy link
Member

(We aligned Grid with this same terminology as well, and took some time to make sure the two texts were as parallel as possible; some tiny discrepancies had come in accidentally.)

@tabatkins
Copy link
Member

(Posting on behalf of @fantasai, whose internet just broke)

I'm pretty sure our intent was that Firefox's behavior is correct. The difference in terminology is largely because we didn't have such specific sizing terms at the time Flexbox was drafted. :) We've checked in changes to align the terminology. Let us know if this seems to resolve the issue, or if there's more to sort out.
[Agenda+ to confirm changes with the CSSWG.]

@davidsgrogan
Copy link
Member

Thanks, this all looks good, I'd call it resolved.

Is it clear that if one of the preferred sizes for a box is definite, the rest are too, so long as they're calculated by fixed values? Like if the outer size is definite, and margin/border/padding are all definite values, that the inner size will be definite as well?

Yep, that makes sense.

@aethanyc
Copy link
Author

aethanyc commented Nov 5, 2020

The edited spec looks good to me.

@css-meeting-bot
Copy link
Member

The CSS Working Group just discussed [css-flexbox] Should definite cross size be used to compute flex item's transferred size suggestion?, and agreed to the following:

  • RESOLVED: close this issue as an editorial change
The full IRC log of that discussion <dael> Topic: [css-flexbox] Should definite cross size be used to compute flex item's transferred size suggestion?
<dael> github: https://github.com//issues/5663
<dael> TabAtkins: There's a question about terms we're using in 2 parts of spec. In 9.8 where we define etra ways for lengths to get def we talk about outer cross size. In earlier sections for min size one of the conditions was stated as relying on cross size being defininte. Unclear if one being definite was meant to apply to other term.
<dael> TabAtkins: Edited spec for more consistent. Didn't have right terms and said "property" waht we want is preferred size. dgrogan confirmed it looked good. Unless other thoughts I think we can close with this fix
<dael> astearns: Original commentor just replied saying good
<dael> fantasai: I say we close as editorial
<dael> astearns: Prop is close this issue and an editorial change
<dael> astearns: Obj?
<dael> RESOLVED: close this issue as an editorial change
<dael> astearns: Thanks for the updates

@davidsgrogan
Copy link
Member

The wpt test landed for this in http://wpt.live/css/css-flexbox/flex-aspect-ratio-img-row-013.html. Tomorrow's chrome canary will pass it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants