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-color-5] Allow using channel keywords in any calculation #10983

Open
cdoublev opened this issue Oct 1, 2024 · 5 comments
Open

[css-color-5] Allow using channel keywords in any calculation #10983

cdoublev opened this issue Oct 1, 2024 · 5 comments
Assignees
Labels
css-color-5 Color modification Needs Edits

Comments

@cdoublev
Copy link
Collaborator

cdoublev commented Oct 1, 2024

CSS Values 5 defines progress functions, which are not math functions, but take calculations (<calc-sum>) and resolve to <number>, like math functions (which are calculations).

I cannot think of a realistic use case but CSS Color 5 should probably extend the validity of channel keywords to calculations, rather than just math functions:

Math functions can also use these keywords to do dynamic modifications of the origin color’s channels.

@cdoublev cdoublev added the css-color-5 Color modification label Oct 1, 2024
@svgeesus svgeesus self-assigned this Oct 2, 2024
@svgeesus
Copy link
Contributor

svgeesus commented Oct 2, 2024

I too cannot think of a use case but agree that we should say that channel keywords can be used in calculations.

@tabatkins
Copy link
Member

Actually I think these just need to be defined as math functions. As it says in the spec, progress() is just syntax sugar for a calc(), and the other two progress functions are morally equivalent; they would just be syntax sugar if we instead had a function which just resolved to an MQ/CQ value.

@cdoublev
Copy link
Collaborator Author

cdoublev commented Oct 3, 2024

Ah, that also answers #10979 then.

I thought the distinction with math functions was intentional, for some reason, which I did not understand for progress().

I am more interested in clarifying the processing of these new "numeric substitution functions" than in semantic correctness of "math function". Specifically in this issue, in the validity of color channel keywords used as their terms.

That said, I also thought than generalizing with (functional) calculations could possibly be more correct and useful.

I think serializing calc(sibling-*()) as a component of a declared value, with or without calc(), currently depends on whether sibling-*() is a math function, which it probably is not.

I do not know why "naked" math operations (sum/product) are not allowed outside of math functions (except in calc-size()), but assuming they were, this generalization would cover rgb(from red r/2 0 0).

Anyway, I am ok if this issue is closed with no change, since color channels keywords in progress() has been clarified.

@tabatkins
Copy link
Member

whether sibling-*() is a math function, which it probably is not.

Correct, it's not, it's just a normal function.

I do not know why "naked" math operations (sum/product) are not allowed outside of math functions

Because, while the boundaries of a calculation with other values is grammatically unambiguous, it's hard to spot with the naked eye. 1 +2 would match <calc-sum> <number>, for instance, but it sure looks like it's the same thing as 1 + 2, which only matches <calc-sum>. To avoid this sort of confusion, we don't mix <calc-sum> with any other grammar terms, and this generally means it's not allowed nakedly at all, as that would limit how we could extend the grammar in the future. Wrapping it in a calc() is always clear and unambiguous.

@cdoublev
Copy link
Collaborator Author

cdoublev commented Oct 9, 2024

So now that progress() is defined as a math function, the question that remains is whether rgb(from red media-progress(width from r * 1px to 100%) 0 0) should be valid, whereas media-progress() are only morally math functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-color-5 Color modification Needs Edits
Projects
None yet
Development

No branches or pull requests

3 participants