Re: [css-values] range-checking, calc(-5), and serialization

On 02/16/2016 06:53 PM, Tab Atkins Jr. wrote:
> On Tue, Feb 16, 2016 at 3:43 PM, fantasai <fantasai.lists@inkedblade.net> wrote:
>> The definition for calc() states:
>>
>> https://www.w3.org/TR/2015/CR-css-values-3-20150611/
>>   # The value resulting from an expression must be clamped to the
>>   # range allowed in the target context.
>>
>> There's a few issues with this...
>>
>> Issue 1:
>>    It doesn't state when this is clamped. Presumably the used value is
>> clamped.
>>    Assuming everyone agrees, I'll update the spec to say so.
>>
>> Issue 2:
>>    This presumably means that ''width: calc(-5px)'' is valid, and treated as
>> zero.
>>    However, the serialization rules recently added to the spec state that
>>      https://drafts.csswg.org/css-values-3/#calc-serialize
>>      # If the result is a single value, serialize as that value,
>>      # discarding the calc() wrapper.
>>    This means that some calc() values will not be round-trippable.
>
> Issue 2 is only an issue because of your suggested resolution for
> Issue 1.  If the clamping happens "as soon as possible", then the
> serialization rules would produce a "0" in that case.

The Serialization rules don't mention clamping, only simplifying arithmetic.
You could certainly add clamping as step 2 for serialization and still keep
issue 1 as "used values".

~fantasai

Received on Wednesday, 17 February 2016 00:02:35 UTC