Skip to content

[css-values-5] Do not make the type of *-progress() consistent with its input calculations? #10840

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

Closed
cdoublev opened this issue Sep 6, 2024 · 3 comments

Comments

@cdoublev
Copy link
Collaborator

cdoublev commented Sep 6, 2024

(Follow-up on this #10770 (comment))

For container-progress() and media-progress():

The two input calculations but must have a consistent type or else the function is invalid. The result will be a <number>, made consistent with the consistent type of the arguments.

There is no size/media feature accepting percentages, but if there was one, say hypothetical-length-percentage-feature, I think opacity: media-progress(hypothetical-length-percentage-feature from 0% to 100px) should be valid.

cdoublev added a commit to cdoublev/css that referenced this issue Sep 10, 2024
The result type should not be made consistent with its calculations (cf.
w3c/csswg-drafts#10840).
@tabatkins
Copy link
Member

I disagree. The % in the calculations needs to have a consistent source for resolving itself, and the clear answer in general is to take it from the property context (so you can do useful things with the box's size in 'width', for example).

So, your example would be invalid - the 0% is typed as {percent -> 1} since it resolves against <number>, but that can be added to the {length -> 1} from 100px. The function's type is thus {} and a percent hint of "length", which fails to match 'opacity's <number> grammar, since it has a non-null percent hint. This is good, since the % in this instance is not intended to be resolved against lengths.

(Hm, I should really capture that fact explicitly; the tip-toeing I do around percentages sometimes would be a little better if the percent hint could be non-null when it resolves against number or just as itself, so it'll fail earlier, at type-addition time, rather than later when matching the type against a grammar.)

There is certainly a potential for an MQ to accept a non-trivial percentage, such that you'd actually want its value. In that case, we'll have to create some clear way to obtain it. But there's no examples of this so far.

@tabatkins
Copy link
Member

Actually, hm, I think I'm wrong. I need to check with @fantasai, but I suspect the intention is to evaluate the calculations entirely in the context of the MQ itself (or the CQ).

If that's the case, then indeed, the types shouldn't be made consistent, as they're self-contained. (progress() still needs to be consistent, as its calculations are evaluated in the outer context.)

@tabatkins tabatkins reopened this Oct 7, 2024
@tabatkins
Copy link
Member

Okay yup, fixed in 4da8f9f. (accidentally mistagged the issue)

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

2 participants