Skip to content

Commit d90c9c4

Browse files
AtkinsSJtabatkins
andauthored
[css-values-4] A small fix and some tweaks to calc serialization (#11782)
* [css-values-4] Remove outdated link to calc-serialization issue See #6506 (comment) * [css-values-4] Close parentheses in math-function serialization step 2.4 * [css-values-4] Number per-type steps of calculation tree serialization --------- Co-authored-by: Tab Atkins Jr. <jackalmage@gmail.com>
1 parent a4bc5c1 commit d90c9c4

File tree

1 file changed

+56
-54
lines changed

1 file changed

+56
-54
lines changed

css-values-4/Overview.bs

+56-54
Original file line numberDiff line numberDiff line change
@@ -5066,8 +5066,6 @@ Range Checking</h3>
50665066
<h3 id='calc-serialize'>
50675067
Serialization</h3>
50685068

5069-
Issue: This section is still <a href="https://lists.w3.org/Archives/Member/w3c-css-wg/2016AprJun/0239.html">under discussion</a>.
5070-
50715069
<div algorithm>
50725070
To <dfn export>serialize a math function</dfn> |fn|:
50735071

@@ -5094,7 +5092,7 @@ Serialization</h3>
50945092
with a value of 1.
50955093
Serialize this numeric value
50965094
and append it to |s|.
5097-
3. Return |s|.
5095+
4. Append ")" to |s|, then return it.
50985096

50995097
3. If the [=calculation tree’s=] root node is a numeric value,
51005098
or a [=calc-operator node=],
@@ -5141,78 +5139,82 @@ Serialization</h3>
51415139
treating the node's children as the function's comma-separated [=calculation=] arguments,
51425140
and return the result.
51435141

5144-
4. If |root| is a Negate node,
5145-
let |s| be a [=string=]
5146-
initially containing "(-1 * ".
5142+
4. If |root| is a Negate node:
5143+
5144+
1. Let |s| be a [=string=]
5145+
initially containing "(-1 * ".
5146+
5147+
2. [=serialize a calculation tree|Serialize=] |root|'s child,
5148+
and append it to |s|.
51475149

5148-
[=serialize a calculation tree|Serialize=] |root|'s child,
5149-
and append it to |s|.
5150+
3. Append ")" to |s|,
5151+
then return it.
51505152

5151-
Append ")" to |s|,
5152-
then return it.
5153+
5. If |root| is an Invert node:
51535154

5154-
5. If |root| is an Invert node,
5155-
let |s| be a [=string=]
5155+
1. Let |s| be a [=string=]
51565156
initially containing "(1 / ".
51575157

5158-
[=serialize a calculation tree|Serialize=] |root|'s child,
5159-
and append it to |s|.
5158+
2. [=serialize a calculation tree|Serialize=] |root|'s child,
5159+
and append it to |s|.
5160+
5161+
3. Append ")" to |s|,
5162+
then return it.
5163+
5164+
6. If |root| is a Sum node:
51605165

5161-
Append ")" to |s|,
5162-
then return it.
5166+
1. Let |s| be a [=string=]
5167+
initially containing "(".
51635168

5164-
6. If |root| is a Sum node,
5165-
let |s| be a [=string=]
5166-
initially containing "(".
5169+
2. [=sort a calculation's children|Sort root's children=].
51675170

5168-
[=sort a calculation's children|Sort root's children=].
5171+
3. [=serialize a calculation tree|Serialize=] |root|'s first child,
5172+
and append it to |s|.
51695173

5170-
[=serialize a calculation tree|Serialize=] |root|'s first child,
5171-
and append it to |s|.
5174+
4. [=list/For each=] |child| of |root| beyond the first:
51725175

5173-
[=list/For each=] |child| of |root| beyond the first:
5176+
1. If |child| is a Negate node,
5177+
append " - " to |s|,
5178+
then [=serialize a calculation tree|serialize=] the Negate's child
5179+
and append the result to |s|.
51745180

5175-
1. If |child| is a Negate node,
5176-
append " - " to |s|,
5177-
then [=serialize a calculation tree|serialize=] the Negate's child
5178-
and append the result to |s|.
5181+
2. If |child| is a negative numeric value,
5182+
append " - " to |s|,
5183+
then serialize the negation of |child| as normal
5184+
and append the result to |s|.
51795185

5180-
3. If |child| is a negative numeric value,
5181-
append " - " to |s|,
5182-
then serialize the negation of |child| as normal
5183-
and append the result to |s|.
5186+
3. Otherwise,
5187+
append " + " to |s|,
5188+
then [=serialize a calculation tree|serialize=] |child|
5189+
and append the result to |s|.
51845190

5185-
2. Otherwise,
5186-
append " + " to |s|,
5187-
then [=serialize a calculation tree|serialize=] |child|
5188-
and append the result to |s|.
5191+
5. Append ")" to |s|
5192+
and return it.
51895193

5190-
Finally, append ")" to |s|
5191-
and return it.
5194+
7. If |root| is a Product node:
51925195

5193-
7. If |root| is a Product node,
5194-
let |s| be a [=string=]
5195-
initially containing "(".
5196+
1. Let |s| be a [=string=]
5197+
initially containing "(".
51965198

5197-
[=sort a calculation's children|Sort root's children=].
5199+
2. [=sort a calculation's children|Sort root's children=].
51985200

5199-
[=serialize a calculation tree|Serialize=] |root|'s first child,
5200-
and append it to |s|.
5201+
3. [=serialize a calculation tree|Serialize=] |root|'s first child,
5202+
and append it to |s|.
52015203

5202-
[=list/For each=] |child| of |root| beyond the first:
5204+
4. [=list/For each=] |child| of |root| beyond the first:
52035205

5204-
1. If |child| is an Invert node,
5205-
append " / " to |s|,
5206-
then [=serialize a calculation tree|serialize=] the Invert's child
5207-
and append the result to |s|.
5206+
1. If |child| is an Invert node,
5207+
append " / " to |s|,
5208+
then [=serialize a calculation tree|serialize=] the Invert's child
5209+
and append the result to |s|.
52085210

5209-
2. Otherwise,
5210-
append " * " to |s|,
5211-
then [=serialize a calculation tree|serialize=] |child|
5212-
and append the result to |s|.
5211+
2. Otherwise,
5212+
append " * " to |s|,
5213+
then [=serialize a calculation tree|serialize=] |child|
5214+
and append the result to |s|.
52135215

5214-
Finally, append ")" to |s|
5215-
and return it.
5216+
5. Append ")" to |s|
5217+
and return it.
52165218
</div>
52175219

52185220
<div algorithm>

0 commit comments

Comments
 (0)