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] <angle> needs clamping details for degenerated values #6105

Closed
DevSDK opened this issue Mar 17, 2021 · 8 comments
Closed

[css-values-4] <angle> needs clamping details for degenerated values #6105

DevSDK opened this issue Mar 17, 2021 · 8 comments
Labels
Closed Accepted by Editor Discretion Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. css-values-4 Current Work

Comments

@DevSDK
Copy link

DevSDK commented Mar 17, 2021

https://www.w3.org/TR/css-values-4/#calc-range

Hello, CSSWG folks!

I'm currently implementing the infinity and NaN for 'calc()' function on chromium.

The step of implementation is now clamping to other components per each types e.g. <length>, <time> and etc.

Now I will work <angle> but the spec doesn't specify how to clamp for <angle> type for infinity and -infinity (also NaN).

According to the spec, the degenerated values must be clamped maximum and lowest values per the types.

However, I think if the <angle> is clamped to the maximum value (i.e., ≈3.35544e+0) seems like no make sense. Because the infinity degree is not specified how it looks like. (My minor opinion is the infinity degree is should look like 0 degrees)

Therefore, I think this might need a discussion about how to clamp 'infinity degree' and 'infinity rad' and so on.

@DevSDK
Copy link
Author

DevSDK commented Mar 17, 2021

@DevSDK DevSDK changed the title [css-values-4] <angle> need clamping details for degenerated values Mar 17, 2021
@fantasai
Copy link
Collaborator

Probably need to clarify that the actual value of a dimension is clamped to the implementable range, and for angles in particular this limit must be a multiple of 360deg.

Treating infinity as zero wouldn't make sense because for something that e.g. rotates between 0deg and 2000deg, if the implementable limit were 1024deg (say), clamping the second value to zero wouldn't make sense.

@fantasai fantasai added the css-values-4 Current Work label Mar 17, 2021
@DevSDK
Copy link
Author

DevSDK commented Mar 17, 2021

Oh, thanks for the detailed comment :)
I see, zero is no make sense.

So, As I understood, the infinity degree should be the nearest multiple of 360deg from the maximum value. Am I correct?

particular this limit must be a multiple of 360deg.

Was it already existed in the spec or needed update?

@tabatkins
Copy link
Member

That doesn't exist in the spec currently; we'd need to add it. I agree with it, tho - your intuition about treating it as 0deg was correct, it just needs to be equivalent to 0deg but with the correct distance from normal values.

@svgeesus
Copy link
Contributor

Now I will work but the spec doesn't specify how to clamp for type for infinity and -infinity (also NaN).

Angles with NaN should be left as-is. This is depended on by some specifications. For example in CSS Color 4, NaN may be used for indeterminate hue angles (colors which are super close to the neutral axis).

And CSS Color 4 also defines interpolation between hue angles, when one is NaN.

@tabatkins
Copy link
Member

Hmmmm, that's not workable per current spec; NaN only exists within a calculation and is censored otherwise (to infinity) as it escapes the calculation. If Color is currently depending on detecting a NaN that spec text will never fire.

I think what you want is that the hue is "missing", due to taking an achromatic color and interpolating it in a space with hue. Whether or not that ends up producing a hue angle of NaN when you run angle calculations in JS isn't necessarily relevant here.

Outside of that implicit missing-ness produced by converting between representations, a NaN angle is only produced by nonsensical calculations, and probably should be treated the same as an infinite angle.

@xiaochengh
Copy link
Contributor

If I understand correctly, #6107 is a separate non-blocking issue, and this one only needs some spec edits?

@tabatkins
Copy link
Member

Yep.

@tabatkins tabatkins added Closed Accepted by Editor Discretion Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. labels Mar 19, 2021
webkit-commit-queue pushed a commit to WebKit/WebKit that referenced this issue Mar 29, 2022
https://bugs.webkit.org/show_bug.cgi?id=238401

Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

* web-platform-tests/css/css-values/calc-infinity-nan-computed-expected.txt:

Source/WebCore:

Clamp nan, infinity and -infinity to zero for <angle>. Issue discussing this:
w3c/csswg-drafts#6105.

* css/calc/CSSCalcValue.cpp:
(WebCore::CSSCalcValue::clampToPermittedRange const):



Canonical link: https://commits.webkit.org/248962@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@292018 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closed Accepted by Editor Discretion Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. css-values-4 Current Work
5 participants