w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.48k stars 661 forks source link

[css-variables-1][css-values-5] Define "arbitrary substitution function" #10679

Open tabatkins opened 2 months ago

tabatkins commented 2 months ago

In Variables, we have a lot of text defining how to handle a function that can be replaced by an arbitrary token sequence. In Values 5, we're adding several more functions that act similarly. I ended up just referencing the (undefined) concept of an "arbitrary substitution function", and had an issue saying I needed to define it in Variables at some point. Mixins also needs to reference this concept, for custom functions.

Well, I've defined it (in the commit that'll be referenced from this issue in a moment). Please review?

Notably, the only actually new text is the algorithms for "resolve a var() function" and "substitute an arbitrary substitution function"; the rest of the commit is just rearranging text and rephrasing some things to refer to the new generic term rather than be var()-specific.

Assuming this looks good, I'll need to follow up with some edits to Values 5 and to Mixins, to define resolution algorithms.

(Because of the text movement, reviewing the diff might be difficult; I recommend just checking the live Variables spec.)

cdoublev commented 2 months ago

Arbitrary substitution functions can be used in place of any part of a value in any property on an element.

UAs (at least Chrome and FF) already accept var() and env() in descriptors of page and margin rules, including size, ie. a descriptor whose name and grammar do not match those of a property.

I suggest that:


(edit) Reference for the next comment: https://github.com/w3c/csswg-drafts/issues/5969#issuecomment-1216433727

andruud commented 2 months ago

@tabatkins I read through it, LGTM.

UAs (at least Chrome and FF) already accept var() and env() in descriptors of page and margin rules

@cdoublev Huh. Looking briefly at the Blink code (StyleResolver::StyleForPage), I think var() would resolve against the root element. I don't think that's per spec.

It's a separate issue, though.