Skip to content

Commit a7951fd

Browse files
committed
[css-color-5] Define edge cases of color-mix() with calc, by WG resolution. Fix #10772
1 parent 6afaf7f commit a7951fd

File tree

1 file changed

+34
-6
lines changed

1 file changed

+34
-6
lines changed

css-color-5/Overview.bs

+34-6
Original file line numberDiff line numberDiff line change
@@ -2854,16 +2854,44 @@ followed by the specified <<color-space>> in all-lowercase,
28542854
followed by ", ",
28552855
followed by the first specified color,
28562856
followed by a space,
2857-
followed by the specified (un-normalized) first percentage (unless both percentages are 50%),
2857+
followed by the serialization of the first percentage (see below)
28582858
followed by ", ",
28592859
followed by the second specified color,
2860-
followed by the specified (un-normalized) second percentage
2861-
(unless the two specified percentages add to 100%),
2860+
followed by the serialization of the second percentage (see below),
28622861
followed by ")".
28632862

2864-
Following the principle of shortest serialization,
2865-
the second percentage is typically omitted,
2866-
even if explicitly specified.
2863+
The serialization of the <strong>first</strong> percentage of a declared value of a ''color-mix()'' function is defined as:
2864+
2865+
- If BOTH the first percentage |p1| and second percentage |p2| are specified:
2866+
- if both |p1| equals 50% and |p2| equals 50%, nothing is serialized. <!-- (a) -->
2867+
- else, |p1| is serialized as is. <!-- (b) -->
2868+
- else if ONLY the first percentage |p1| is specified:
2869+
- if |p1| is equal to 50%, nothing is serialized. <!-- (c) -->
2870+
- else, |p1| is serialized as is. <!-- (d) -->
2871+
- else if ONLY the second percentage |p2| is specified:
2872+
- if |p2| equals 50%, nothing is serialized. <!-- (e) -->
2873+
- if |p2| is not ''calc()'', the value of 100% - |p2| is serialized. <!-- (f)-->
2874+
- else, nothing is serialized. <!-- (g) -->
2875+
- else if NEITHER is specified:
2876+
- nothing is serialized. <!-- (h) -->
2877+
2878+
The serialization of the <strong>second</strong> percentage of a declared value of a ''color-mix()'' function is defined as:
2879+
2880+
- If BOTH the first percentage p1 and second percentages p2 are specified:
2881+
- if neither p1 nor p2 is calc(), and p1 + p2 equals 100%, nothing is serialized. <!-- (i) -->
2882+
- else, p2 is serialized as is. <!-- (j) -->
2883+
- else if ONLY the first percentage p1 is specified:
2884+
- nothing is serialized. <!-- (k) -->
2885+
- else if ONLY the second percentage p2 is specified:
2886+
- if p2 equals 50%, nothing is serialized. <!-- (l) -->
2887+
- if p2 is not calc(), nothing is serialized. <!-- (m) -->
2888+
- else, p2 is serialized as is. <!-- (n) -->
2889+
- else if NEITHER is specified:
2890+
- nothing is serialized. <!-- (o) -->
2891+
2892+
Note: ''calc()'' values are consider to be unknown,
2893+
so are <strong>never</strong> equal 50%,
2894+
and never sum with something else to equal 100%.
28672895

28682896
<div class="example" id="ex-serial-specified-mix">
28692897
For example, the serialized declared value of

0 commit comments

Comments
 (0)