Skip to content

Commit 367e81a

Browse files
committed
Define the types of CSSMathValue classes, and use the right types terminology.
1 parent 89a8706 commit 367e81a

File tree

1 file changed

+40
-19
lines changed

1 file changed

+40
-19
lines changed

css-typed-om/Overview.bs

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,12 @@ For the purposes of [=matching=],
10341034
these cases should be treated as <<length-percentage>>.
10351035
Similarly for <<angle-percentage>>, etc.
10361036

1037+
Note: [=Types=] form a semi-group under both addition and multiplication,
1038+
meaning that they're associative and commutative.
1039+
Thus the spec can, for example,
1040+
[=add=] an unbounded number of types together unambiguously,
1041+
rather than having to manually [=add=] them pair-wise.
1042+
10371043

10381044

10391045
<!--
@@ -1268,32 +1274,26 @@ of all the "math" operations.
12681274
2. If |args| [=list/is empty=],
12691275
[=throw=] a {{SyntaxError}}.
12701276

1271-
3. Let |strongType| initially be null.
1272-
1273-
4. Let |values| be an initially empty [=list=].
1274-
1275-
5. [=list/For each=] |arg| of |args|:
1276-
1277-
1. If |arg| has a [=strong type=], and |strongType| is null,
1278-
let |strongType| by |arg|’s [=strong type=].
1279-
1280-
2. If |arg| has a [=strong type=],
1281-
and |strongType| is not equal to that type,
1282-
[=throw=] a {{TypeError}}.
1283-
1284-
3. [=list/Append=] |arg| to |values|.
1277+
3. Let |type| be the result of [=adding=] the [=types=] of all the [=list/items=] of |args|.
1278+
If |type| is failure,
1279+
[=throw=] a {{SyntaxError}}.
12851280

1286-
6. Return a new {{CSSMathSum}}
1281+
4. Return a new {{CSSMathSum}}
12871282
whose {{CSSMathSum/values}} internal slot
1288-
is set to |values|.
1283+
is set to |args|.
12891284

1290-
The <dfn constructor for="CSSMathProduct">CSSMathProduct(...|args|)</dfn>,
1291-
<dfn constructor for="CSSMathMin">CSSMathMin(...|args|)</dfn>,
1285+
The <dfn constructor for="CSSMathMin">CSSMathMin(...|args|)</dfn>
12921286
and <dfn constructor for="CSSMathMax">CSSMathMax(...|args|)</dfn> constructors
12931287
are defined identically to the above,
12941288
except that in the last step
1295-
they return a new {{CSSMathProduct}}, {{CSSMathMin}}, or {{CSSMathMax}} object,
1289+
they return a new {{CSSMathMin}} or {{CSSMathMax}} object,
12961290
respectively.
1291+
1292+
The <dfn constructor for="CSSMathProduct">CSSMathProduct(...|args|)</dfn> constructor
1293+
is defined identically to the above,
1294+
except that in step 3 it [=multiplies=] the types instead of [=adding=],
1295+
and in the last step
1296+
it returns a {{CSSMathProduct}}.
12971297
</div>
12981298

12991299
<div algorithm="CSSMathNegate(arg)">
@@ -1314,6 +1314,27 @@ of all the "math" operations.
13141314
it returns a new {{CSSMathInvert}} object.
13151315
</div>
13161316

1317+
<div algorithm>
1318+
The <dfn>[=type=] of a CSSMathValue</dfn>
1319+
depends on its class:
1320+
1321+
<dl class=switch>
1322+
: {{CSSMathSum}}
1323+
: {{CSSMathMin}}
1324+
: {{CSSMathMax}}
1325+
:: The [=type=] is the result of [=adding=] the [=types=]
1326+
of each of the [=list/items=] in its {{CSSMathSum/values}} internal slot.
1327+
1328+
: {{CSSMathProduct}}
1329+
:: The [=type=] is the result of [=multiplying=] the [=types=]
1330+
of each of the [=list/items=] in its {{CSSMathProduct/values}} internal slot.
1331+
1332+
: {{CSSMathNegate}}
1333+
: {{CSSMathInvert}}
1334+
:: The [=type=] is the same as the [=type=] of its {{CSSMathNegate/value}} internal slot,
1335+
but with all [=map/values=] negated.
1336+
</dl>
1337+
</div>
13171338

13181339

13191340
<!--

0 commit comments

Comments
 (0)