-
Notifications
You must be signed in to change notification settings - Fork 717
[css-flexbox-1] Should Flex Container Intrinsic Main Size algorithm really use _scaled_ flex shrink factor? #6909
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
Comments
In my recollection, I can't take credit for developing the spec's current intrinsic sizing algorithm (and we haven't actually implemented it in Firefox yet), though I think I did offer feedback when it was being written. As I recall: at a high level the algorithm here is just trying to reverse-engineer what the flexbox layout algorithm actually does, in order to produce an intrinsic size that lets each flex item achieve its own max-content size. So the correct wording here would be whatever achieves that result. (And given that the flexbox layout algorithm primarily uses the |
That is helpful. I didn't know the goal.
Maybe, but it doesn't work technically here. We end up doing nonsensical calculations, as described above. As is, the algorithm is unimplementable. |
Glad that helps! Grounding it in some spec text and making it more concrete, the spec does in fact define it as-such here: And then the algorithm that follows is attempting to define how to compute that size (perhaps with flaws right now).
This isn't what I was intending to say in #6909 (comment). Rather, I was just saying that the suggestion from your initial comment here (swapping in
Sounds like we do need some fix to how the scaled flex-shrink factor is used, then. |
Heh, I'd never understood that sentence, but do now :) |
Ok, I figured out what the algorithm was trying to say, and indeed we should continue to use scaled flex shrink factor. (The algorithm does specify to compare values of different units, which is undefined, but I see what the spec authors were getting at, and checked my understanding against EdgeHTML) Thanks for your help. Closing. |
This seems pretty bad. Can you share what you figured out "the algorithm was trying to say", so that the spec can stop doing undefined things? |
Here's the context from https://drafts.csswg.org/css-flexbox/#intrinsic-main-sizes
As described in comment 0, step 1 produces max-content flex fractions with different units for different flex items. The units hinge on the result of the first subtraction being positive or negative. Step 3 imposes an ordering on the max-content flex fractions of varied units, which is the undefined part. I interpret step 3 as doing this:
That description ignores forced line breaks and items with min/max main sizes. In step 3, the current spec amalgamates selecting which mode to be in with calculating how much to add to or subtract from the flex base sizes. |
Ah, I suppose it is technically undefined how to compare a flex fraction derived from the positive flex grow factor (units of "length") and a negative scaled flex shrink factor (units of "number"), but when we wrote it we figured it since the first case is always non-negative and the second case was always non-positive it was clear enough; magnitudes didn't need to be compared between the two cases, just the sign. The sign of the chosen fraction determines which of the factors to use, which correctly unifies the result's unit back to "length" so it can be meaningfully added to the base szie. |
Uh oh!
There was an error while loading. Please reload this page.
https://drafts.csswg.org/css-flexbox-1/#intrinsic-main-sizes says
For each flex item, subtract its outer
flex base size
from itsmax-content contribution size
.If that result is positive, divide by its
flex grow factor
floored at 1if negative, divide by its
scaled flex shrink factor
having floored theflex shrink factor
at 1.This result has no units because scaled flex shrink factor has pixel units. scaled flex shrink factor is equal to flex shrink factor * inner flex base size (https://drafts.csswg.org/css-flexbox-1/#scaled-flex-shrink-factor).
Put another way and expanding some terms:
(
flex base size
-max-content contribution size
) / (inner flex base size
* max(1,flex shrink factor
))Numerator and denominator both have pixel units so the result is unitless.
This is the item’s
max-content flex fraction
So items in the same flexbox can have
max-content flex fractions
of different units depending on if the result of the first step is positive or negative. That doesn't seem right. Maybeshould be the following?
/cc @fantasai and @dholbert who appear to have developed this algorithm originally
The text was updated successfully, but these errors were encountered: