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-values-4] Clarify minimum calculation terms #8258

Closed
cdoublev opened this issue Dec 26, 2022 · 7 comments
Closed

[css-values-4] Clarify minimum calculation terms #8258

cdoublev opened this issue Dec 26, 2022 · 7 comments
Labels
Closed as Question Answered Used when the issue is more of a question than a problem, and it's been answered. css-values-4 Current Work

Comments

@cdoublev
Copy link
Collaborator

cdoublev commented Dec 26, 2022

UAs must support calculations of at least 32 <calc-value> terms and at least 32 levels of nesting (parentheses and/or functions)

Considering the above requirement, does calc(calc(1 + 2) + calc(1)) include 2, 3, or 5 <calc-value>s?

I would be fine with closing this issue as "question answered" with 32 <calc-value> terms without considering nesting, because that is what it means to me in the absence of any other precision. It would mean that there is 5 terms in my example.

@cdoublev
Copy link
Collaborator Author

cdoublev commented Jan 3, 2023

I re-open this issue because I think the current definition is inapplicable: if you have to support 32 levels of nesting, you have to support 33 <calc-value> terms.

(1) matches two <calc-value>: the first for the parens, the second for 1.

@cdoublev cdoublev reopened this Jan 3, 2023
@Loirooriol
Copy link
Contributor

Note those are minimums, not maximums.

@cdoublev
Copy link
Collaborator Author

cdoublev commented Jan 3, 2023

The title of this issue was incorrect, indeed.

But I wonder if it should be a maximum, actually. Chrome and Firefox do not limit terms and my laptop froze for 5 minutes when I tested this limit (doh) minimum in both browsers at the same time..

@cdoublev cdoublev changed the title [css-values-4] Clarify maximum calculation terms [css-values-4] Clarify minimum calculation terms Jan 3, 2023
@Loirooriol
Copy link
Contributor

How many terms did your test have? Maybe file issues in https://crbug.com and https://bugzil.la so that they add implementation limits. But I don't think the spec should impose maximums.

@cdoublev
Copy link
Collaborator Author

cdoublev commented Jan 3, 2023

I think it was a 6 or 7 digits number but I think it depends on the device resources.

You are probably right: the limit should be defined on the browser side. It seems that I cannot write anything good for today, and I am not thrilled with the idea of crashing my laptop again, but I will file an issue tomorrow after carefull testing.

@fantasai fantasai added the css-values-4 Current Work label Jun 1, 2023
@tabatkins
Copy link
Member

While parsing calc(calc(1 + 2) + calc(1)) you match against <calc-value> 5 times - twice at the top level, and three more times nested inside the calcs. So that's the answer for the purposes of this limit. ^_^

@tabatkins tabatkins added the Closed as Question Answered Used when the issue is more of a question than a problem, and it's been answered. label Oct 23, 2023
@cdoublev
Copy link
Collaborator Author

Ok, thanks. I am fine with the current definition since it is an unimportant detail. I understand that the purpose is to avoid processing variadic math functions with each argument defined with 32*32**32 calc values.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closed as Question Answered Used when the issue is more of a question than a problem, and it's been answered. css-values-4 Current Work
Projects
None yet
Development

No branches or pull requests

4 participants