Skip to content

Commit 56fb598

Browse files
committed
[css-values-4] Fix min()/max() partial simplification to not imply that %s will always block simplification, and add a Note making the % behavior more explicit. w3c#6298
1 parent 6509658 commit 56fb598

File tree

1 file changed

+37
-18
lines changed

1 file changed

+37
-18
lines changed

css-values-4/Overview.bs

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4189,11 +4189,47 @@ Simplification</h4>
41894189
3. If |root| is an [=operator node=]
41904190
that's not one of the [=calc-operator nodes=],
41914191
and all of its children are numeric values
4192-
with enough information to computed the operation |root| represents,
4192+
with enough information to compute the operation |root| represents,
41934193
return the result of running |root|'s operation
41944194
using its children,
41954195
expressed in the result's [=canonical unit=].
41964196

4197+
<div class=note>
4198+
4199+
If a percentage is left at this point,
4200+
it will <em>usually</em> block simplification of the node,
4201+
since it needs to be resolved against another value
4202+
using information not currently available.
4203+
(Otherwise, it would have been converted to a different value in an earlier step.)
4204+
This includes operations such as "min",
4205+
since percentages might resolve against a negative basis,
4206+
and thus end up with an opposite comparative relationship
4207+
than the raw percentage value would seem to indicate.
4208+
4209+
However, "raw" percentages--
4210+
ones which do not resolve against another value,
4211+
such as in 'opacity'--
4212+
might not block simplification.
4213+
</div>
4214+
4215+
4216+
8. If |root| is a Min or Max node,
4217+
attempt to <em>partially</em> simplify it:
4218+
4219+
1. [=list/For each=] node |child| of |root|’s children:
4220+
4221+
If |child| is a numeric value
4222+
with enough information to compare magnitudes with another child of the same unit
4223+
(see note in previous step),
4224+
and there are other children of |root|
4225+
that are numeric values with the same unit,
4226+
combine all such children
4227+
with the appropriate operator per |root|,
4228+
and replace |child| with the result,
4229+
removing all other child nodes involved.
4230+
4231+
2. Return |root|.
4232+
41974233
4. If |root| is a Negate node:
41984234

41994235
1. If |root|'s child is a numeric value,
@@ -4267,23 +4303,6 @@ Simplification</h4>
42674303

42684304
5. Return |root|.
42694305

4270-
8. If |root| is a Min or Max node:
4271-
4272-
1. [=list/For each=] node |child| of |root|’s children:
4273-
4274-
If |child| is a numeric value
4275-
with a unit other than "percent",
4276-
and there are other children of |root|
4277-
that are numeric values with the same unit,
4278-
combine all such children
4279-
with the appropriate operator per |root|,
4280-
and replace |child| with the result,
4281-
removing all other child nodes involved.
4282-
4283-
2. If |root| now has only a single child,
4284-
return that child.
4285-
Otherwise, return |root|.
4286-
42874306
</div>
42884307

42894308
<h3 id='calc-computed-value'>

0 commit comments

Comments
 (0)