Content-Length: 245869 | pFad | http://github.com/w3c/csswg-drafts/issues/9616

6B [css-values-4] Allow more simplification of operator nodes · Issue #9616 · w3c/csswg-drafts · GitHub
Skip to content

[css-values-4] Allow more simplification of operator nodes #9616

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 Nov 20, 2023 · 2 comments · Fixed by #9630
Closed

[css-values-4] Allow more simplification of operator nodes #9616

cdoublev opened this issue Nov 20, 2023 · 2 comments · Fixed by #9630
Labels
css-values-4 Current Work

Comments

@cdoublev
Copy link
Collaborator

Maybe returning a result in its canonical unit should not be mandatory?

  1. If root is an operator node that’s not one of the calc-operator nodes, and all of its calculation children are numeric values with enough information to compute the operation root represents, return the result of running root’s operation using its children, expressed in the result’s canonical unit.

https://drafts.csswg.org/css-values-4/#simplify-a-calculation-tree

It prevents simplifying min(1em) as calc(1em) (related: #9559), clamp(0em, 2em, 1em) as calc(1em), round(1.1em, 1em) as calc(1em), etc.

Chrome/FF currently simplify min(max(1%, -1%)) as max(1%, -1%). There does not seem to be any corresponding WPT tests. Support for other math functions is still low so I have not tested them.

@cdoublev cdoublev added the css-values-4 Current Work label Nov 20, 2023
@cdoublev cdoublev changed the title [css-values-4] Advanced simplification of calc-operator nodes [css-values-4] Allow more simplification of calc-operator nodes Nov 20, 2023
@cdoublev cdoublev changed the title [css-values-4] Allow more simplification of calc-operator nodes [css-values-4] Allow more simplification of operator nodes Nov 20, 2023
@tabatkins
Copy link
Member

In general, I have no particular opinion on how the simplification rules should work, so long as they're consistent and reasonable. I'm happy to match browsers if they're in agreement and the result makes sense.

min(1em) as calc(1em)

I'll leave this to #9559.

clamp(0em, 2em, 1em) as calc(1em), round(1.1em, 1em) as calc(1em)

It doesn't seem particularly useful to me to require this work, versus just waiting until they can actually finish the answer. (And in the clamp case, you can't do that simplification if the arguments are %s.) Are browsers currently doing so?

Chrome/FF currently simplify min(max(1%, -1%)) as max(1%, -1%)

This looks like it's probably #9559 too.

@cdoublev
Copy link
Collaborator Author

Fwiw, I do not understand why the shortest serialization principle exists for specified values. But I have read that implementers prefer to avoid preserving as many of the calculation nodes as possible, probably to save memory (and the UX), I guess.

And in the clamp case, you can't do that simplification if the arguments are %s. Are browsers currently doing so?

No. I guess I cannot simplify them when one but not all have a negative value, right.

So it seems that everything is already well specified! Sorry. =)

noamr added a commit to noamr/csswg-drafts that referenced this issue Nov 23, 2023
noamr added a commit that referenced this issue Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css-values-4 Current Work
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/w3c/csswg-drafts/issues/9616

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy