-
Notifications
You must be signed in to change notification settings - Fork 719
[css-values] Computed value of a negative calc unit that doesn't allow negative lengths. #434
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
Comments
cc @SimonSapin |
For the record, Firefox does follow the spec correctly, but clamps the value in |
For properties where the computed value is a length (i.e., calc()s are computed at computed value time) like I think the spec is still wrong for properties that accept calc() but where calc() is not part of the computed value space since it can be fully computed by computed value time (e.g., |
Yeah, and WebKit (and Blink) also clamp (edit: lengths, of course) at computed value time, see https://github.com/WebKit/webkit/blob/e999a05729f1c284fd6e734b88e81a2b078ed80f/Source/WebCore/css/CSSCalculationValue.cpp#L195 |
Note that getComputedStyle() returns the used value for a number of length-using properties, so that pollutes the data quite a bit here. WebKit/Blink doesn't actually have a separate notion of "computed value" in the engine. |
The CSS Working Group just discussed The full IRC log of that discussion |
Current text is:
I propose we change this to:
|
Okay, so there are two interpretations of what dbaron said:
For example,
The latter seems slightly simpler, but since it means that a property only clamps exactly one time, a property that currently only has computed-value units and then later adds used-value units would change behavior in an author-observable way. The wording for each of these options would be different, so we need the WG to resolve on which one. |
The CSS Working Group just discussed The full IRC log of that discussion |
Need to see more testing results before this goes on the agenda again. |
I've written these tests that check whether an animated negative calc value is clamped at computed value time (and thus a range of negative values aren't present in the animation) or used value time (where a range of negative values will be present in clamped form for a duration in the animation) astearns/web-platform-tests@da5892f The results I'm seeing are all over the place. Pass means clamping is happening at used value time (mostly). Fail means it's clamping at computed value time. width and padding-left have the same results width-up width-down opacity-up opacity-down font-size up font-size down |
Alan, which version of FF did you test? The results may not differ but our animation code has changed significantly from version 57 onwards. |
I'm on Mac nightly, so 58-ish? - I'll edit in the exact version number when I get back to the office tomorrow |
That's recent enough--thank you! |
It may also be worth testing Firefox 56, though, since that's the code currently shipping. |
FWIW, I'd note that the Firefox results make sense to me: the properties where calc() can be handled at computed value time "fail", and the properties where it needs to be deferred to used value time "pass". |
Agenda+ because we have test results (above) and a proposal (#434 (comment)) and this is blocking CR update of Values and Units for months now so it would be really nice to resolve and republish. |
@dbaron That has the forward-compatibility problems noted by @fantasai in #434 (comment) - if a property initially accepts only computed-value-time units, it would be clamped at computed-value time, but if it later starts accepting used-value-time units, we'd have to move it to clamping at used-value time, which is observably different. Thus the proposal to clamp at both spots - computed value clamping if possible, used-value clamping otherwise. That way a |
The Working Group just discussed The full IRC log of that discussion |
In the discussion above we talked about (but did not resolve) on what happens to calc() expressions when the value is clamped. I believe there was consensus on the call to simplify the calc() expression in that case, as the clamping changes the value significantly from what the expression might appear to be. We've had discussions in the past about preserving calc() expressions for tooling. It might be weird to have a "calc(50px)" value maintain the expression for a computed value, but a "calc(-50px)" value get simplified to "0px" upon clamping at computed value time. But it might be useful to represent the clamping in this edge case. Do you have an opinion, @therealglazou? |
I am fine with the resolution from confcall 20171213. |
The Working Group just discussed
The full IRC log of that discussion |
Ok, I've checked in the following changes:
@emilio @tabatkins Can you let me know if that seems adequate? |
👍 |
Looks good to me, thanks! Maybe noting explicitly that clamping should not be done at specified value time is worth it? WebKit / Blink are buggy here wrt numbers / integers IIRC. Haven't checked if it's something mentioned in other places of the spec. |
@emilio OK, added parenthetical about specified values.
|
Closing out per @emilio’s verification over IRC. |
…lues. Linkify different types of values. #434
In the CSS values spec, section 8.1.4. Range Checking:
Note that the used value is expected to be clamped, but not the computed value. Both Blink and Firefox (at least, probably other engines too) clamp the value at computed value time, as can be seen running the following test, where all the properties that don't accept negative lengths (like
font-size
,padding-xxx
, etc.) report a computed value of0px
instead of the expected-1px
.The text was updated successfully, but these errors were encountered: