@@ -5066,8 +5066,6 @@ Range Checking</h3>
5066
5066
<h3 id='calc-serialize'>
5067
5067
Serialization</h3>
5068
5068
5069
- Issue: This section is still <a href="https://lists.w3.org/Archives/Member/w3c-css-wg/2016AprJun/0239.html">under discussion</a> .
5070
-
5071
5069
<div algorithm>
5072
5070
To <dfn export>serialize a math function</dfn> |fn|:
5073
5071
@@ -5094,7 +5092,7 @@ Serialization</h3>
5094
5092
with a value of 1.
5095
5093
Serialize this numeric value
5096
5094
and append it to |s|.
5097
- 3. Return |s|.
5095
+ 4. Append ")" to |s|, then return it .
5098
5096
5099
5097
3. If the [=calculation tree’s=] root node is a numeric value,
5100
5098
or a [=calc-operator node=] ,
@@ -5141,78 +5139,82 @@ Serialization</h3>
5141
5139
treating the node's children as the function's comma-separated [=calculation=] arguments,
5142
5140
and return the result.
5143
5141
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|.
5147
5149
5148
- [=serialize a calculation tree|Serialize=] |root|'s child ,
5149
- and append it to |s| .
5150
+ 3. Append ")" to |s| ,
5151
+ then return it.
5150
5152
5151
- Append ")" to |s|,
5152
- then return it.
5153
+ 5. If |root| is an Invert node:
5153
5154
5154
- 5. If |root| is an Invert node,
5155
- let |s| be a [=string=]
5155
+ 1. Let |s| be a [=string=]
5156
5156
initially containing "(1 / ".
5157
5157
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:
5160
5165
5161
- Append ")" to |s|,
5162
- then return it .
5166
+ 1. Let |s| be a [=string=]
5167
+ initially containing "(" .
5163
5168
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=] .
5167
5170
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|.
5169
5173
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:
5172
5175
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|.
5174
5180
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|.
5179
5185
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|.
5184
5190
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.
5189
5193
5190
- Finally, append ")" to |s|
5191
- and return it.
5194
+ 7. If |root| is a Product node:
5192
5195
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 "(".
5196
5198
5197
- [=sort a calculation's children|Sort root's children=] .
5199
+ 2. [=sort a calculation's children|Sort root's children=] .
5198
5200
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|.
5201
5203
5202
- [=list/For each=] |child| of |root| beyond the first:
5204
+ 4. [=list/For each=] |child| of |root| beyond the first:
5203
5205
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|.
5208
5210
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|.
5213
5215
5214
- Finally, append ")" to |s|
5215
- and return it.
5216
+ 5. Append ")" to |s|
5217
+ and return it.
5216
5218
</div>
5217
5219
5218
5220
<div algorithm>
0 commit comments