Skip to content

Commit 6bc3b59

Browse files
committed
[css-values-4] Further tweaks of math-function simplification, ensuring that old-style calc()s will fully simplify down to a sum of values.
1 parent aa27946 commit 6bc3b59

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

css-values-4/Overview.bs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3432,7 +3432,11 @@ Simplification</h4>
34323432

34333433
6. If |root| is a Sum node:
34343434

3435-
1. For each set of |root|'s children
3435+
1. For each of |root|'s children
3436+
that are Sum nodes,
3437+
replace them with their children.
3438+
3439+
2. For each set of |root|'s children
34363440
that are numeric values with identical units,
34373441
remove those children
34383442
and replace them with a single numeric value
@@ -3442,18 +3446,30 @@ Simplification</h4>
34423446
(E.g. combine numbers, combine percentages,
34433447
combine px values, etc.)
34443448

3445-
2. If |root| has only a single child at this point,
3449+
3. If |root| has only a single child at this point,
34463450
return the child.
34473451
Otherwise, return |root|.
34483452

34493453
7. If |root| is a Product node:
34503454

3451-
1. If |root| has multiple children that are numbers
3455+
1. For each of |root|'s children
3456+
that are Product nodes,
3457+
replace them with their children.
3458+
3459+
2. If |root| has multiple children that are numbers
34523460
(not percentages or dimensions),
34533461
remove them and replace them with a single number
34543462
containing the product of the removed nodes.
34553463

3456-
2. If |root| contains only numeric values
3464+
3. If |root| contains only two children,
3465+
one of which is a number
3466+
(not a percentage or dimension)
3467+
and the other of which is a Sum
3468+
whose children are all numeric values,
3469+
multiply all of the Sum's children by the number,
3470+
then return the Sum.
3471+
3472+
4. If |root| contains only numeric values
34573473
and/or Invert nodes containing numeric values,
34583474
and [=multiply two types|multiplying the types=]
34593475
of all the children
@@ -3466,7 +3482,7 @@ Simplification</h4>
34663482
is the reciprocal of its child's value),
34673483
expressed in the result's [=canonical unit=].
34683484

3469-
3. Return |root|.
3485+
5. Return |root|.
34703486
</div>
34713487

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

0 commit comments

Comments
 (0)