Skip to content

Commit bdefa54

Browse files
committed
[css-values-5][editorial] Move 'Random Simplification' chapter to the correct place.
1 parent 69702af commit bdefa54

1 file changed

Lines changed: 73 additions & 73 deletions

File tree

css-values-5/Overview.bs

Lines changed: 73 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -2392,79 +2392,6 @@ Generating a Random Numeric Value: the ''random()'' function</h3>
23922392
</div>
23932393

23942394

2395-
<h4 id=random-simplify>
2396-
Simplification</h4>
2397-
2398-
At parse time,
2399-
certain transformations are performed on the <<random-cache-key>> of a [=random function=]:
2400-
2401-
* If the <<random-cache-key>> is ''auto'' (or omitted),
2402-
it's turned into ''element-scoped property-index-scoped''.
2403-
(And then subject to the below transformations.)
2404-
* If the <<random-cache-key>> contains ''property-scoped'' or ''property-index-scoped'',
2405-
that keyword is replaced by a <<random-ua-ident>>:
2406-
either <css>ua-PROPERTY</css> with PROPERTY being the property the value was parsed as,
2407-
or <css>ua-PROPERTY-INDEX</css> with PROPERTY as the previous
2408-
and INDEX being the 1-indexed integer index of this [=random function=]
2409-
among all [=random functions=] being used in the property.
2410-
2411-
The INDEX value is based on the ordering in the parsed value,
2412-
before any canonicalization/reordering might occur
2413-
that could shuffle the values around.
2414-
2415-
If the <<random-cache-key>> contains a <<random-ua-ident>>,
2416-
this must not be omitted in the serialization of the value,
2417-
even if this would normally be valid per the
2418-
[=serialize a CSS value|"shortest serialization principle"=].
2419-
2420-
<div class=example>
2421-
For example,
2422-
specifying ''margin: random(10px, 20px) random(10px, 20px)''
2423-
will cause the top and bottom margins to be one random value,
2424-
and the left and right margins to be another random value.
2425-
The omitted <<random-cache-key>>s get rewritten at parse-time
2426-
to ''element-scoped ua-margin-1'' and ''element-scoped ua-margin-2'',
2427-
respectively,
2428-
before they expand into the 'margin' longhands.
2429-
2430-
This way, the 'margin-top' and 'margin-bottom' longhands
2431-
will both contain the key ''element-scoped ua-margin-1'',
2432-
ensuring that the two values remain linked
2433-
even if you read and then set the value back.
2434-
</div>
2435-
2436-
The [=random base value=] of a [=random function=] is known at [=specified value=] time,
2437-
at the latest,
2438-
once it's known which element the function is being applied to.
2439-
As a [=math function=], a ''random()'' function can be [=simplify a calculation tree|simplified=]
2440-
as soon as its argument [=calculations=]
2441-
can be simplified to compatible numeric values.
2442-
If a ''random()'' function can't be fully [=simplify a calculation tree|simplified=]
2443-
by [=computed value=] time,
2444-
then its arguments are maximally simplified,
2445-
and its <<random-cache-key>>
2446-
is replaced with ''fixed BASE'',
2447-
where <css>BASE</css> is the function's [=random base value=].
2448-
2449-
Note: As an [=arbitrary substitution function=],
2450-
''random-item()'' is always replaced at [=computed value=] time.
2451-
2452-
<div class=example>
2453-
For example, given the declaration ''width: random(100px, 100%)'',
2454-
the calculations can't be simplified at [=computed value=] time
2455-
because the percentage depend on [=used value=] information
2456-
(the size of the element's [=containing block=],
2457-
to resolve the ''100%'' against).
2458-
2459-
So, the [=computed value=] of the property
2460-
becomes something like ''width: random(fixed .1234, 100px, 100%)''.
2461-
Once the ''100%'' is resolved to a length
2462-
(say, ''500px''),
2463-
the function will be able to fully simplify
2464-
(to ''149.36px'').
2465-
</div>
2466-
2467-
24682395
<h4 id=random-infinities>
24692396
Argument Ranges</h4>
24702397

@@ -3042,6 +2969,79 @@ Sharing (Or Not) Random Values: the <<random-cache-key>> value</h3>
30422969
</div>
30432970

30442971

2972+
<h4 id=random-simplify>
2973+
Simplification</h4>
2974+
2975+
At parse time,
2976+
certain transformations are performed on the <<random-cache-key>> of a [=random function=]:
2977+
2978+
* If the <<random-cache-key>> is ''auto'' (or omitted),
2979+
it's turned into ''element-scoped property-index-scoped''.
2980+
(And then subject to the below transformations.)
2981+
* If the <<random-cache-key>> contains ''property-scoped'' or ''property-index-scoped'',
2982+
that keyword is replaced by a <<random-ua-ident>>:
2983+
either <css>ua-PROPERTY</css> with PROPERTY being the property the value was parsed as,
2984+
or <css>ua-PROPERTY-INDEX</css> with PROPERTY as the previous
2985+
and INDEX being the 1-indexed integer index of this [=random function=]
2986+
among all [=random functions=] being used in the property.
2987+
2988+
The INDEX value is based on the ordering in the parsed value,
2989+
before any canonicalization/reordering might occur
2990+
that could shuffle the values around.
2991+
2992+
If the <<random-cache-key>> contains a <<random-ua-ident>>,
2993+
this must not be omitted in the serialization of the value,
2994+
even if this would normally be valid per the
2995+
[=serialize a CSS value|"shortest serialization principle"=].
2996+
2997+
<div class=example>
2998+
For example,
2999+
specifying ''margin: random(10px, 20px) random(10px, 20px)''
3000+
will cause the top and bottom margins to be one random value,
3001+
and the left and right margins to be another random value.
3002+
The omitted <<random-cache-key>>s get rewritten at parse-time
3003+
to ''element-scoped ua-margin-1'' and ''element-scoped ua-margin-2'',
3004+
respectively,
3005+
before they expand into the 'margin' longhands.
3006+
3007+
This way, the 'margin-top' and 'margin-bottom' longhands
3008+
will both contain the key ''element-scoped ua-margin-1'',
3009+
ensuring that the two values remain linked
3010+
even if you read and then set the value back.
3011+
</div>
3012+
3013+
The [=random base value=] of a [=random function=] is known at [=specified value=] time,
3014+
at the latest,
3015+
once it's known which element the function is being applied to.
3016+
As a [=math function=], a ''random()'' function can be [=simplify a calculation tree|simplified=]
3017+
as soon as its argument [=calculations=]
3018+
can be simplified to compatible numeric values.
3019+
If a ''random()'' function can't be fully [=simplify a calculation tree|simplified=]
3020+
by [=computed value=] time,
3021+
then its arguments are maximally simplified,
3022+
and its <<random-cache-key>>
3023+
is replaced with ''fixed BASE'',
3024+
where <css>BASE</css> is the function's [=random base value=].
3025+
3026+
Note: As an [=arbitrary substitution function=],
3027+
''random-item()'' is always replaced at [=computed value=] time.
3028+
3029+
<div class=example>
3030+
For example, given the declaration ''width: random(100px, 100%)'',
3031+
the calculations can't be simplified at [=computed value=] time
3032+
because the percentage depend on [=used value=] information
3033+
(the size of the element's [=containing block=],
3034+
to resolve the ''100%'' against).
3035+
3036+
So, the [=computed value=] of the property
3037+
becomes something like ''width: random(fixed .1234, 100px, 100%)''.
3038+
Once the ''100%'' is resolved to a length
3039+
(say, ''500px''),
3040+
the function will be able to fully simplify
3041+
(to ''149.36px'').
3042+
</div>
3043+
3044+
30453045
<!-- Big Text: counting
30463046

30473047
███▌ ███▌ █▌ █▌ █ █▌ █████▌ ████ █ █▌ ███▌

0 commit comments

Comments
 (0)