[css-variables] Add User Agent properties and constant() #1817
@tabatkins I expect you'll have a lot of comments on this. For one, do you want to use the term global variables?
Also, if you want to allow the user to set their own --global-property, then I'd appreciate help on how that should be done. I assume it should only be allowed in one place, e.g :root?
How about just using "Constants" as the name everywhere, instead of "User Agent Properties" but then the syntax is
This would also imply changing
3a) Alternately, make the JS API hang off of individual stylesheets, and have it be just a shorthand for adding/removing/mutating the rules directly. Then precedence is automatic - you're just adding a rule to a given stylesheet, and the standard "later stylesheets win" rule comes into effect. This is less convenient for authors, tho - you need to figure out which stylesheet a given constant is coming from if you want to manipulate it.
How would this work for UA predefined constants? Would they be expected to have an @global rule in a stylesheet at UA precedence level, which gets updated if the value changes?
I'm asking because from our perspective, UA predefined constants are the main kind we care about, and author-defined constants are at most a tangential side benefit.
Also, I really think this concept should have a single name in syntax. Either
There is. Couldn't global variables / constants change after page open? e.g. in case of iPhone X, what would happen if user rotates the phone or split the screen? If we substitute them during parsing, we would never be able to change it dynamically.
It would require a reparse, yes.
The UA stylesheet is unobservable, so this doesn't matter. The only observable part would be the JS API, which would I suppose have readonly entries in the map that could be listened to for changes.
Oh, yes, certainly. All the discussion of "global variables" just led my fingers to type
Depends on how we answer my (3)! Global is easier for authors, I think, but per-stylesheet has simpler semantics.
One reasonable answer is both: we have a global map hanging off of the
That way the actual
The map-like just throws on attempted sets/deletes/clears for those keys.