Open SebastianZ opened 2 years ago
Added Agenda+ as @dbaron, @emilio, and @tabatkins already started the discussion on this in a previous call and it is required for making progress on https://github.com/w3c/csswg-drafts/issues/4431 and other linked list-valued properties.
Sebastian
For what it's worth, this also applies to fill-image
and its related list-valued properties.
Sebastian
I think clarifying and having a central definition might be useful, but in general if there isn't any kind of specific computation specified the computed value mirrors the specified value, so I think per-spec that's what's required. Whether we want to change that is a different question that might be worth discussing.
The CSS Working Group just discussed [css-values][css-backgrounds][css-animations][css-transitions][fill-stroke] How to handle linked list-valued properties?
.
I've created three fiddles now to check the current behavior of computed values again. One with longhand properties where the length-controlling properties have longer lists than the controlled ones, one with longhand properties where the length-controlling properties have shorter lists than the controlled ones, and one with shorthand properties.
Testing with those fiddles, my initial comment on that seems to be slightly incorrect because in Gecko background-*
longhands are treated special when it comes to the computed value.
Here are my observations regarding the list lengths of computed and used values in tabular form. I don't have access to MacOS/Safari, so maybe someone else can check the test cases there.
https://jsfiddle.net/SebastianZ/wyupok0h/
Chrome | Firefox | |
---|---|---|
background-size |
computed and used: repeated to match controlling property | computed and used: repeated to match controlling property |
transition-duration |
computed: as authored, used: repeated to match controlling property | computed: as authored, used: repeated to match controlling property |
animation-duration |
computed: as authored, used: repeated to match controlling property | computed: as authored, used: repeated to match controlling property |
https://jsfiddle.net/SebastianZ/bxj4y3ar/
Chrome | Firefox | |
---|---|---|
background-size |
computed and used: truncated to match controlling property | computed: as authored, used: repeated to match controlling property |
transition-duration |
computed: as authored, used: truncated to match controlling property | computed: as authored, used: truncated to match controlling property |
animation-duration |
computed: as authored, used: truncated to match controlling property | computed: as authored, used: truncated to match controlling property |
https://jsfiddle.net/SebastianZ/wmeLxhtf/
Chrome | Firefox | |
---|---|---|
background-size |
computed and used: padded with initial value to match controlling property | computed and used: padded with initial value to match controlling property |
transition-duration |
computed and used: padded with initial value to match controlling property | computed and used: padded with initial value to match controlling property |
animation-duration |
computed and used: padded with initial value to match controlling property | computed and used: padded with initial value to match controlling property |
"Repeated" refers to the spec. text, which currently reads like this:
The lists are matched up from the first value: excess values at the end are not used. If a property doesn’t have enough comma-separated values to match the number of layers, the UA must calculate its used value by repeating the list of values until there are enough.
Both Chromium and Gecko special-case the background-*
longhands by repeating them for the computed value in case they are shorter than background-image
. When background-image
is shorter than the longhands, Chromium truncates the longhands while Gecko keeps them as authored.
All other list-valued longhands are kept as authored for the computed value in both engines.
@LeaVerou mentioned on the last call, from an author's perspective, it may be a little easier to understand what's happening if computed and used values were the same. That means, repeating when the controlling property list is longer and truncating if it is shorter. I agree with her on that.
@emilio, @tabatkins, @nt1m Could you please check back with your teams regarding the current implementations, the complications, and what would make implementations actually easier?
Sebastian
The CSS Working Group just discussed list-valued properties
, and agreed to the following:
RESOLVED: Keep list-valued property definition as-is (as specified in B&B). Genericize definition and move to V&U.
Edits for Values and Units L4 done: #linked-properties
We'll need updates for all the remaining tagged specs. Dropping css-backgrounds-3 in favor of css-backgrounds-4 because L3 is practically a REC already.
4431 requests to turn
box-shadow
into a shorthand. During the discussion of this change @dbaron mentioned that there is a general issue in handling list-valued longhand properties.According to him and @emilio dealing with such values is complicated as the properties can have differently long lists. And this seems especially true for
background-*
longhands.As @tabatkins summarized it, they'd prefer if the computed value lists would be aligned with the used value lists, i.e. expanded or truncated depending on the length of the length-controlling property.
Having a deeper look at that, I realized that there are currently differences in handling such properties across browser engines but also within one browser engine. E.g. in Blink, the computed value list length of
background-size
is controlled by the length of the list inbackground-image
, whiletransition-duration
's computed value is not bound to the one oftransition-property
and rather corresponds to the authored value. In Gecko, all the values correspond to the authored value.Looking at the specifications, they seem to only clearly define the used values but the computed value is underdefined. CSS Backgrounds 3 defines how different lengths of authored values are handled and mentions that "the UA must calculate its used value by repeating the list of values until there are enough" (emphasizing by me). It doesn't seem to specify how computed values are actually generated. CSS Animations 1 refers to this specification as well as CSS Transitions 1 does. There might also be more specifications for such list-valued properties that need clarification.
This issue is meant to clarify how such linked list-valued properties should be handled. Maybe the definition for this handling should be moved to a central place (maybe in CSS Values?).
Sebastian