Skip to content

Commit 33682af

Browse files
committed
[css-values-5][editorial] Rename random grammar productions for clarity
1 parent c39efe8 commit 33682af

File tree

1 file changed

+34
-32
lines changed

1 file changed

+34
-32
lines changed

css-values-5/Overview.bs

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ Commas in Function Arguments</h4>
163163
For example, the grammar of the ''random-item()'' function is:
164164

165165
<pre>
166-
random-item( <<random-cache-key>>, [<<declaration-value>>?]# )
166+
random-item( <<random-key>>, [<<declaration-value>>?]# )
167167
</pre>
168168

169169
The ''#'' indicates comma-separated repetitions,
@@ -2286,20 +2286,20 @@ Generating a Random Numeric Value: the ''random()'' function</h3>
22862286
optionally limiting the possible values to a step between those limits:
22872287

22882288
<pre class=prod>
2289-
&lt;random()> = random( <<random-cache-key>>? , <<calc-sum>>, <<calc-sum>>, <<calc-sum>>? )
2289+
&lt;random()> = random( <<random-key>>? , <<calc-sum>>, <<calc-sum>>, <<calc-sum>>? )
22902290
</pre>
22912291

22922292
See [[#random-evaluation]] and [[#random-caching]]
22932293
for details on how the function is evaluated.
22942294
Its arguments are:
22952295

22962296
<dl>
2297-
: <<random-cache-key>>
2298-
:: The optional <<random-cache-key>>
2297+
: <<random-key>>
2298+
:: The optional <<random-key>>
22992299
controls which [=random functions=] in the document
23002300
will share a [=random base value=]
23012301
and which will get distinct values.
2302-
If <<random-cache-key>> is omitted,
2302+
If <<random-key>> is omitted,
23032303
it behaves as ''random()/auto''.
23042304

23052305
See [[#random-caching]] for a full description of this value.
@@ -2426,7 +2426,7 @@ Picking a Random Item From a List: the ''random-item()'' function</h3>
24262426
from among its list of items.
24272427

24282428
<pre class=prod>
2429-
&lt;random-item()> = random-item( <<random-cache-key>> , [ <<declaration-value>>? ]# )
2429+
&lt;random-item()> = random-item( <<random-key>> , [ <<declaration-value>>? ]# )
24302430
</pre>
24312431

24322432
The ''random-item()'' function's [=argument grammar=] is:
@@ -2438,11 +2438,11 @@ Picking a Random Item From a List: the ''random-item()'' function</h3>
24382438
See [[#random-evaluation]] and [[#random-caching]]
24392439
for details on how the function is evaluated.
24402440

2441-
The <em>required</em> <<random-cache-key>>
2441+
The <em>required</em> <<random-key>>
24422442
is interpreted identically to ''random()''.
24432443
(See [[#random-caching]] for details.)
24442444

2445-
Note: The <<random-cache-key>> argument is required in ''random-item()'',
2445+
Note: The <<random-key>> argument is required in ''random-item()'',
24462446
but optional in ''random()'',
24472447
for parsing reasons
24482448
(it's impossible to tell whether ''random-item(--foo, --bar, --baz)''
@@ -2478,7 +2478,7 @@ Picking a Random Item From a List: the ''random-item()'' function</h3>
24782478
and |options| be a list of the remaining <<declaration-value>>? options.
24792479

24802480
2. [=Substitute arbitrary substitution functions=] in |value sharing|,
2481-
then [=CSS/parse=] it as <<random-cache-key>>.
2481+
then [=CSS/parse=] it as <<random-key>>.
24822482
If parsing returns failure,
24832483
return the [=guaranteed-invalid value=];
24842484
otherwise set |value sharing| to the result.
@@ -2572,7 +2572,7 @@ Evaluating Random Values</h3>
25722572

25732573

25742574
<h3 id=random-caching>
2575-
Sharing (Or Not) Random Values: the <<random-cache-key>> value</h3>
2575+
Sharing (Or Not) Random Values: the <<random-key>> value</h3>
25762576

25772577
CSS is a declarative language,
25782578
so functions don't have a specific “time” when they're evaluated;
@@ -2590,18 +2590,18 @@ Sharing (Or Not) Random Values: the <<random-cache-key>> value</h3>
25902590
will return <em>different</em> [=random base value=] from each other
25912591
(unless they are, randomly, the same).
25922592

2593-
The <<random-cache-key>> value controls this behavior,
2593+
The <<random-key>> value controls this behavior,
25942594
and defaults to ''random()/auto'' when omitted.
25952595
It's syntax is as follows, and interpreted as described below:
25962596

25972597
<pre class=prod>
2598-
<dfn><<random-cache-key>></dfn> = auto | <<random-name>> | fixed <<number [0,1]>>
2599-
<dfn><<random-name>></dfn> = <<dashed-ident>> || element-scoped
2598+
<dfn><<random-key>></dfn> = auto | <<random-name>> | fixed <<number [0,1]>>
2599+
<dfn><<random-cache-key>></dfn> = <<dashed-ident>> || element-scoped
26002600
|| [ property-scoped | property-index-scoped | <<random-ua-ident>> ]
26012601
<dfn><<random-ua-ident>></dfn> = <<custom-ident>>
26022602
</pre>
26032603

2604-
<dl dfn-type=value dfn-for="random(),random-item(),<random-cache-key>">
2604+
<dl dfn-type=value dfn-for="random(),random-item(),<random-key>">
26052605
: <dfn>auto</dfn>
26062606
:: The [=random function=] is roughly “as random as possible”:
26072607
the [=random cache name=], and thus the result,
@@ -2612,31 +2612,33 @@ Sharing (Or Not) Random Values: the <<random-cache-key>> value</h3>
26122612
This is equivalent to specifying ''element-scoped property-index-scoped'',
26132613
and simplifies in exactly the same way.
26142614

2615-
: <dfn><<random-name>></dfn>
2616-
:: The <<random-name>> specifies the [=random cache name=],
2615+
: <dfn><<random-cache-key>></dfn>
2616+
:: The <<random-cache-key>> specifies the [=random cache name=],
26172617
allowing it to be explicitly shared (or not)
26182618
with other uses of [=random functions=].
26192619
Every [=random function=] using the same [=random cache name=]
26202620
will get the same random value;
26212621
every one using a <em>different</em> [=random cache name=]
26222622
will get unrelated random values.
26232623

2624-
* The <<dashed-ident>> gives the value an explicit name.
2624+
<ul dfn-for="random(),random-item(),<random-key>,<random-cache-key>">
2625+
<li>The <<dashed-ident>> gives the value an explicit name.
26252626
If omitted, this part of the name is null.
2626-
* <dfn>element-scoped</dfn> adds an element-specific identifier
2627+
<li><dfn>element-scoped</dfn> adds an element-specific identifier
26272628
to the [=random cache name=],
26282629
so different elements will get different random values.
2629-
* <dfn>property-scoped</dfn> adds the property name the [=random function=] is being used on
2630+
<li><dfn>property-scoped</dfn> adds the property name the [=random function=] is being used on
26302631
to the [=random cache name=],
26312632
so different properties will get different random values.
26322633
Note that shorthand declarations will apply the [=shorthand property=]'s name.
2633-
* <dfn>property-index-scoped</dfn>
2634+
<li><dfn>property-index-scoped</dfn>
26342635
adds the property name <em>and</em> the index of the random function
26352636
among all the random functions used in the same property value
26362637
to the [=random cache name=],
26372638
so multiple instances of a [=random function=] in the same declaration
26382639
will each get different [=random cache names=].
26392640
Note this index is assigned <em>before</em> [=shorthand=] expansion.
2641+
</ul>
26402642

26412643
See [[#random-simplify]] for how these values resolve.
26422644

@@ -2683,7 +2685,7 @@ Sharing (Or Not) Random Values: the <<random-cache-key>> value</h3>
26832685
}
26842686
</pre>
26852687

2686-
Depending on what <<random-cache-key>> you provide
2688+
Depending on what <<random-key>> you provide
26872689
in place of the ''???'',
26882690
you'll get significantly different behavior for the elements:
26892691

@@ -2768,7 +2770,7 @@ Sharing (Or Not) Random Values: the <<random-cache-key>> value</h3>
27682770
If you want the values to be completely uncorrelated,
27692771
give them distinct names (''--foo'' vs ''--bar'')
27702772
or mix in additional information that will uniquify their [=random cache names=]
2771-
(specifying ''--foo property-scoped'', or omitting the <<random-cache-key>> argument entirely)
2773+
(specifying ''--foo property-scoped'', or omitting the <<random-key>> argument entirely)
27722774
</div>
27732775

27742776
<details class=note id=auto-naming-details>
@@ -2830,7 +2832,7 @@ Sharing (Or Not) Random Values: the <<random-cache-key>> value</h3>
28302832
* Each instance of a [=random function=] in styles
28312833
has an associated <dfn>random base value</dfn>.
28322834

2833-
If the [=random function's=] <<random-cache-key>> is ''fixed <<number>>'',
2835+
If the [=random function's=] <<random-key>> is ''fixed <<number>>'',
28342836
the [=random base value=] is that number.
28352837

28362838
Otherwise, the [=random base value=] is a pseudo-random real number
@@ -2935,13 +2937,13 @@ Sharing (Or Not) Random Values: the <<random-cache-key>> value</h3>
29352937
the ''random()'' function isn't evaluated
29362938
(or even recognized *as* a ''random()'' function)
29372939
in ''--size'',
2938-
so the default rules for an omitted <<random-cache-key>> aren't applied.
2940+
so the default rules for an omitted <<random-key>> aren't applied.
29392941
Instead, it's evaluated when it's substituted into 'width' and 'height',
29402942
so each gets a distinct [=random cache name=],
29412943
and this ends up defining a random <em>rectangle</em>,
29422944
rather than a square.
29432945

2944-
Similarly, ''random()/element-scoped'' in the <<random-cache-key>>
2946+
Similarly, ''random()/element-scoped'' in the <<random-key>>
29452947
won't cause the function to determine its "element identifier"
29462948
until substitution actually happens--
29472949
which might be <em>after</em> '--size' has inherited through multiple elements--
@@ -2964,15 +2966,15 @@ Sharing (Or Not) Random Values: the <<random-cache-key>> value</h3>
29642966

29652967

29662968
<h4 id=random-simplify>
2967-
Random Simplification</h4>
2969+
Simplification of <<random-key>></h4>
29682970

29692971
At parse time,
2970-
certain transformations are performed on the <<random-cache-key>> of a [=random function=]:
2972+
certain transformations are performed on the <<random-key>> of a [=random function=]:
29712973

2972-
* If the <<random-cache-key>> is ''auto'' (or omitted),
2974+
* If the <<random-key>> is ''auto'' (or omitted),
29732975
it's turned into ''element-scoped property-index-scoped''.
29742976
(And then subject to the below transformations.)
2975-
* If the <<random-cache-key>> contains ''property-scoped'' or ''property-index-scoped'',
2977+
* If the <<random-key>> contains ''property-scoped'' or ''property-index-scoped'',
29762978
that keyword is replaced by a <<random-ua-ident>>:
29772979
either <css>ua-PROPERTY</css> with PROPERTY being the property the value was parsed as,
29782980
or <css>ua-PROPERTY-INDEX</css> with PROPERTY as the previous
@@ -2983,7 +2985,7 @@ Random Simplification</h4>
29832985
before any canonicalization/reordering might occur
29842986
that could shuffle the values around.
29852987

2986-
If the <<random-cache-key>> contains a <<random-ua-ident>>,
2988+
If the <<random-key>> contains a <<random-ua-ident>>,
29872989
this must not be omitted in the serialization of the value,
29882990
even if this would normally be valid per the
29892991
[=serialize a CSS value|"shortest serialization principle"=].
@@ -2993,7 +2995,7 @@ Random Simplification</h4>
29932995
specifying ''margin: random(10px, 20px) random(10px, 20px)''
29942996
will cause the top and bottom margins to be one random value,
29952997
and the left and right margins to be another random value.
2996-
The omitted <<random-cache-key>>s get rewritten at parse-time
2998+
The omitted <<random-key>>s get rewritten at parse-time
29972999
to ''element-scoped ua-margin-1'' and ''element-scoped ua-margin-2'',
29983000
respectively,
29993001
before they expand into the 'margin' longhands.
@@ -3013,7 +3015,7 @@ Random Simplification</h4>
30133015
If a ''random()'' function can't be fully [=simplify a calculation tree|simplified=]
30143016
by [=computed value=] time,
30153017
then its arguments are maximally simplified,
3016-
and its <<random-cache-key>>
3018+
and its specified <<random-key>>
30173019
is replaced with ''fixed BASE'',
30183020
where <css>BASE</css> is the function's [=random base value=].
30193021

0 commit comments

Comments
 (0)