Skip to content

Commit 765f86f

Browse files
zcorpansvgeesus
authored andcommitted
Treat 0 and -0 as equal throughout
This is consistent with other APIs such as JS's Map, Set, and Array.prototype.includes. Fixes w3c#152. Tests for DOMMatrixInit: web-platform-tests/wpt#5896
1 parent a9f65cd commit 765f86f

File tree

1 file changed

+57
-60
lines changed

1 file changed

+57
-60
lines changed

geometry/Overview.bs

Lines changed: 57 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Default Highlight: javascript
3434
type: exception; text: SyntaxError; url: https://html.spec.whatwg.org/multipage/infrastructure.html#js-syntaxerror
3535
urlPrefix: https://tc39.github.io/ecma262/; spec: ECMA-262
3636
type: dfn
37+
text: SameValueZero; url: sec-samevaluezero
3738
text: ToString; url: sec-tostring
3839
text: !; url: sec-algorithm-conventions
3940
</pre>
@@ -459,20 +460,20 @@ a <code>DOMRectInit</code> dictionary</dfn> <var>other</var>, follow these steps
459460

460461
<li><p>Let <var>point1</var> be a new {{DOMPoint}} object with <a for=point>x coordinate</a> set to
461462
<var>x</var>, <a for=point>y coordinate</a> set to <var>y</var>, <a for=point>z coordinate</a> set
462-
to zero and <a for=point>w perspective</a> set to one.
463+
to ''0'' and <a for=point>w perspective</a> set to ''1''.
463464

464465
<li><p>Let <var>point2</var> be a new {{DOMPoint}} object with <a for=point>x coordinate</a> set to
465466
<var>x</var> + <var>width</var>, <a for=point>y coordinate</a> set to <var>y</var>, <a for=point>z
466-
coordinate</a> set to zero and <a for=point>w perspective</a> set to one.
467+
coordinate</a> set to ''0'' and <a for=point>w perspective</a> set to ''1''.
467468

468469
<li><p>Let <var>point3</var> be a new {{DOMPoint}} object with <a for=point>x coordinate</a> set to
469470
<var>x</var> + <var>width</var>, <a for=point>y coordinate</a> set to <var>y</var> +
470-
<var>height</var>, <a for=point>z coordinate</a> set to zero and <a for=point>w perspective</a> set
471-
to one.
471+
<var>height</var>, <a for=point>z coordinate</a> set to ''0'' and <a for=point>w perspective</a>
472+
set to ''1''.
472473

473474
<li><p>Let <var>point4</var> be a new {{DOMPoint}} object with <a for=point>x coordinate</a> set to
474475
<var>x</var>, <a for=point>y coordinate</a> set to <var>y</var> + <var>height</var>, <a for=point>z
475-
coordinate</a> set to zero and <a for=point>w perspective</a> set to one.
476+
coordinate</a> set to ''0'' and <a for=point>w perspective</a> set to ''1''.
476477

477478
<li><p>Return a new {{DOMQuad}} with <a for=quadrilateral>point 1</a> set to <var>point1</var>, <a
478479
for=quadrilateral>point 2</a> set to <var>point2</var>, <a for=quadrilateral>point 3</a> set to
@@ -825,29 +826,29 @@ run the following steps:
825826
{{TypeError}} exception and abort these steps.
826827

827828
<ul>
828-
<li><p>{{DOMMatrixInit/a}} and {{DOMMatrixInit/m11}} are both present and their values are not
829-
the <a for="WebIDL unrestricted double">same</a>.
829+
<li><p>{{DOMMatrixInit/a}} and {{DOMMatrixInit/m11}} are both present and
830+
[=SameValueZero=]({{DOMMatrixInit/a}}, {{DOMMatrixInit/m11}}) is <code>false</code>.
830831

831-
<li><p>{{DOMMatrixInit/b}} and {{DOMMatrixInit/m12}} are both present and their values are not
832-
the <a for="WebIDL unrestricted double">same</a>.
832+
<li><p>{{DOMMatrixInit/b}} and {{DOMMatrixInit/m12}} are both present and
833+
[=SameValueZero=]({{DOMMatrixInit/b}}, {{DOMMatrixInit/m12}}) is <code>false</code>.
833834

834-
<li><p>{{DOMMatrixInit/c}} and {{DOMMatrixInit/m21}} are both present and their values are not
835-
the <a for="WebIDL unrestricted double">same</a>.
835+
<li><p>{{DOMMatrixInit/c}} and {{DOMMatrixInit/m21}} are both present and
836+
[=SameValueZero=]({{DOMMatrixInit/c}}, {{DOMMatrixInit/m21}}) is <code>false</code>.
836837

837-
<li><p>{{DOMMatrixInit/d}} and {{DOMMatrixInit/m22}} are both present and their values are not
838-
the <a for="WebIDL unrestricted double">same</a>.
838+
<li><p>{{DOMMatrixInit/d}} and {{DOMMatrixInit/m22}} are both present and
839+
[=SameValueZero=]({{DOMMatrixInit/d}}, {{DOMMatrixInit/m22}}) is <code>false</code>.
839840

840-
<li><p>{{DOMMatrixInit/e}} and {{DOMMatrixInit/m41}} are both present and their values are not
841-
the <a for="WebIDL unrestricted double">same</a>.
841+
<li><p>{{DOMMatrixInit/e}} and {{DOMMatrixInit/m41}} are both present and
842+
[=SameValueZero=]({{DOMMatrixInit/e}}, {{DOMMatrixInit/m41}}) is <code>false</code>.
842843

843-
<li><p>{{DOMMatrixInit/f}} and {{DOMMatrixInit/m42}} are both present and their values are not
844-
the <a for="WebIDL unrestricted double">same</a>.
844+
<li><p>{{DOMMatrixInit/f}} and {{DOMMatrixInit/m42}} are both present and
845+
[=SameValueZero=]({{DOMMatrixInit/f}}, {{DOMMatrixInit/m42}}) is <code>false</code>.
845846

846847
<li><p>{{DOMMatrixInit/is2D}} is <code>true</code> and at least one of {{DOMMatrixInit/m13}},
847848
{{DOMMatrixInit/m14}}, {{DOMMatrixInit/m23}}, {{DOMMatrixInit/m24}}, {{DOMMatrixInit/m31}},
848849
{{DOMMatrixInit/m32}}, {{DOMMatrixInit/m34}}, {{DOMMatrixInit/m43}} are present with a value
849-
other than ''0'', or at least one of {{DOMMatrixInit/m33}}, {{DOMMatrixInit/m44}} are present
850-
with a value other than ''1''.
850+
other than ''0'' or ''-0'', or at least one of {{DOMMatrixInit/m33}}, {{DOMMatrixInit/m44}} are
851+
present with a value other than ''1''.
851852
</ul>
852853

853854
<li><p>If {{DOMMatrixInit/m11}} is not present then set it to the value of member
@@ -871,18 +872,14 @@ run the following steps:
871872
<li><p>If {{DOMMatrixInit/is2D}} is not present and at least one of {{DOMMatrixInit/m13}},
872873
{{DOMMatrixInit/m14}}, {{DOMMatrixInit/m23}}, {{DOMMatrixInit/m24}}, {{DOMMatrixInit/m31}},
873874
{{DOMMatrixInit/m32}}, {{DOMMatrixInit/m34}}, {{DOMMatrixInit/m43}} are present with a value other
874-
than ''0'', or at least one of {{DOMMatrixInit/m33}}, {{DOMMatrixInit/m44}} are present with a
875-
value other than ''1'', set {{DOMMatrixInit/is2D}} to <code>false</code>.
875+
than ''0'' or ''-0'', or at least one of {{DOMMatrixInit/m33}}, {{DOMMatrixInit/m44}} are present
876+
with a value other than ''1'', set {{DOMMatrixInit/is2D}} to <code>false</code>.
876877

877878
<li><p>If {{DOMMatrixInit/is2D}} is still not present, set it to <code>true</code>.
878879
</ol>
879880

880-
<p>For the purpose of the algorithm above, two WebIDL unrestricted double values are the <dfn
881-
for="WebIDL unrestricted double">same</dfn> if they have identical IEEE 754 double-precision bit
882-
patterns.
883-
884-
<p class=note>This means that two ''NaN'' values are the <a for="WebIDL unrestricted
885-
double">same</a>, but ''0'' and ''-0'' are not the <a for="WebIDL unrestricted double">same</a>.
881+
<p class=note>The [=SameValueZero=] comparison algorithm returns <code>true</code> for two ''NaN''
882+
values, and also for ''0'' and ''-0''. [[!ECMA-262]]
886883

887884

888885
<h3 id=dommatrix-create>Creating DOMMatrixReadOnly and DOMMatrix objects</h3>
@@ -1093,13 +1090,13 @@ method on {{DOMMatrix}} must follow these steps:
10931090

10941091
<p>The <dfn><code>m13</code></dfn> attribute, on getting, must return the <a for=matrix>m13
10951092
element</a> value. For the {{DOMMatrix}} interface, setting the {{DOMMatrix/m13}} attribute must
1096-
set the <a for=matrix>m13 element</a> to the new value and, if the new value is not ''0'', set <a
1097-
for=matrix>is 2D</a> to <code>false</code>.
1093+
set the <a for=matrix>m13 element</a> to the new value and, if the new value is not ''0'' or
1094+
''-0'', set <a for=matrix>is 2D</a> to <code>false</code>.
10981095

10991096
<p>The <dfn><code>m14</code></dfn> attribute, on getting, must return the <a for=matrix>m14
11001097
element</a> value. For the {{DOMMatrix}} interface, setting the {{DOMMatrix/m14}} attribute must
1101-
set the <a for=matrix>m14 element</a> to the new value and, if the new value is not ''0'', set <a
1102-
for=matrix>is 2D</a> to <code>false</code>.
1098+
set the <a for=matrix>m14 element</a> to the new value and, if the new value is not ''0'' or
1099+
''-0'', set <a for=matrix>is 2D</a> to <code>false</code>.
11031100

11041101
<p>The <dfn><code>m21</code></dfn> and <dfn><code>c</code></dfn> attributes, on getting, must
11051102
return the <a for=matrix>m21 element</a> value. For the {{DOMMatrix}} interface, setting the
@@ -1113,23 +1110,23 @@ method on {{DOMMatrix}} must follow these steps:
11131110

11141111
<p>The <dfn><code>m23</code></dfn> attribute, on getting, must return the <a for=matrix>m23
11151112
element</a> value. For the {{DOMMatrix}} interface, setting the {{DOMMatrix/m23}} attribute must
1116-
set the <a for=matrix>m23 element</a> to the new value and, if the new value is not ''0'', set <a
1117-
for=matrix>is 2D</a> to <code>false</code>.
1113+
set the <a for=matrix>m23 element</a> to the new value and, if the new value is not ''0'' or
1114+
''-0'', set <a for=matrix>is 2D</a> to <code>false</code>.
11181115

11191116
<p>The <dfn><code>m24</code></dfn> attribute, on getting, must return the <a for=matrix>m24
11201117
element</a> value. For the {{DOMMatrix}} interface, setting the {{DOMMatrix/m24}} attribute must
1121-
set the <a for=matrix>m24 element</a> to the new value and, if the new value is not ''0'', set <a
1122-
for=matrix>is 2D</a> to <code>false</code>.
1118+
set the <a for=matrix>m24 element</a> to the new value and, if the new value is not ''0'' or
1119+
''-0'', set <a for=matrix>is 2D</a> to <code>false</code>.
11231120

11241121
<p>The <dfn><code>m31</code></dfn> attribute, on getting, must return the <a for=matrix>m31
11251122
element</a> value. For the {{DOMMatrix}} interface, setting the {{DOMMatrix/m31}} attribute must
1126-
set the <a for=matrix>m31 element</a> to the new value and, if the new value is not ''0'', set <a
1127-
for=matrix>is 2D</a> to <code>false</code>.
1123+
set the <a for=matrix>m31 element</a> to the new value and, if the new value is not ''0'' or
1124+
''-0'', set <a for=matrix>is 2D</a> to <code>false</code>.
11281125

11291126
<p>The <dfn><code>m32</code></dfn> attribute, on getting, must return the <a for=matrix>m32
11301127
element</a> value. For the {{DOMMatrix}} interface, setting the {{DOMMatrix/m32}} attribute must
1131-
set the <a for=matrix>m32 element</a> to the new value and, if the new value is not ''0'', set <a
1132-
for=matrix>is 2D</a> to <code>false</code>.
1128+
set the <a for=matrix>m32 element</a> to the new value and, if the new value is not ''0'' or
1129+
''-0'', set <a for=matrix>is 2D</a> to <code>false</code>.
11331130

11341131
<p>The <dfn><code>m33</code></dfn> attribute, on getting, must return the <a for=matrix>m33
11351132
element</a> value. For the {{DOMMatrix}} interface, setting the {{DOMMatrix/m33}} attribute must
@@ -1138,8 +1135,8 @@ method on {{DOMMatrix}} must follow these steps:
11381135

11391136
<p>The <dfn><code>m34</code></dfn> attribute, on getting, must return the <a for=matrix>m34
11401137
element</a> value. For the {{DOMMatrix}} interface, setting the {{DOMMatrix/m34}} attribute must
1141-
set the <a for=matrix>m34 element</a> to the new value and, if the new value is not ''0'', set <a
1142-
for=matrix>is 2D</a> to <code>false</code>.
1138+
set the <a for=matrix>m34 element</a> to the new value and, if the new value is not ''0'' or
1139+
''-0'', set <a for=matrix>is 2D</a> to <code>false</code>.
11431140

11441141
<p>The <dfn><code>m41</code></dfn> and <dfn><code>e</code></dfn> attributes, on getting, must
11451142
return the <a for=matrix>m41 element</a> value. For the {{DOMMatrix}} interface, setting the
@@ -1153,8 +1150,8 @@ method on {{DOMMatrix}} must follow these steps:
11531150

11541151
<p>The <dfn><code>m43</code></dfn> attribute, on getting, must return the <a for=matrix>m43
11551152
element</a> value. For the {{DOMMatrix}} interface, setting the {{DOMMatrix/m43}} attribute must
1156-
set the <a for=matrix>m43 element</a> to the new value and, if the new value is not ''0'', set <a
1157-
for=matrix>is 2D</a> to <code>false</code>.
1153+
set the <a for=matrix>m43 element</a> to the new value and, if the new value is not ''0'' or
1154+
''-0'', set <a for=matrix>is 2D</a> to <code>false</code>.
11581155

11591156
<p>The <dfn><code>m44</code></dfn> attribute, on getting, must return the <a for=matrix>m44
11601157
element</a> value. For the {{DOMMatrix}} interface, setting the {{DOMMatrix/m44}} attribute must
@@ -1189,8 +1186,8 @@ method on {{DOMMatrix}} must follow these steps:
11891186
for=matrix>m21 element</a>, <a for=matrix>m23 element</a>, <a for=matrix>m24 element</a>, <a
11901187
for=matrix>m31 element</a>, <a for=matrix>m32 element</a>, <a for=matrix>m34 element</a>, <a
11911188
for=matrix>m41 element</a>, <a for=matrix>m42 element</a>, <a for=matrix>m43 element</a> are ''0''
1192-
and <a for=matrix>m11 element</a>, <a for=matrix>m22 element</a>, <a for=matrix>m33 element</a>, <a
1193-
for=matrix>m44 element</a> are ''1''. Otherwise it must return <code>false</code>.
1189+
or ''-0'' and <a for=matrix>m11 element</a>, <a for=matrix>m22 element</a>, <a for=matrix>m33
1190+
element</a>, <a for=matrix>m44 element</a> are ''1''. Otherwise it must return <code>false</code>.
11941191
</div>
11951192

11961193
<p>Every {{DOMMatrixReadOnly}} object must be flagged with a boolean <dfn for=matrix
@@ -1398,8 +1395,8 @@ export>is 2D</dfn>. This flag indicates that:
13981395

13991396
<p class=note>Even if {{DOMMatrixReadOnly/is2D}} of the current matrix returns <code>true</code>,
14001397
a 4x4 matrix multiplication will be performed if the {{DOMPointReadOnly/z}} attribute of
1401-
<var>point</var> is not ''0'' or the {{DOMPointReadOnly/w}} attribute of <var>point</var> is not
1402-
''1''.
1398+
<var>point</var> is not ''0'' or ''-0'' or the {{DOMPointReadOnly/w}} attribute of
1399+
<var>point</var> is not ''1''.
14031400

14041401
<dt><dfn>toFloat32Array()</dfn>
14051402
<dd><p>Returns the serialized 16 elements {{DOMMatrixReadOnly/m11}} to {{DOMMatrixReadOnly/m44}} of
@@ -1623,8 +1620,8 @@ user agents.
16231620
href="https://drafts.csswg.org/css-transforms-1/#Translate3dDefined">described</a> in CSS
16241621
Transforms. [[!CSS3-TRANSFORMS]]
16251622

1626-
<li><p>If <var>tz</var> is specified and not ''0'', set <a for=matrix>is 2D</a> of the current
1627-
matrix to <code>false</code>.
1623+
<li><p>If <var>tz</var> is specified and not ''0'' or ''-0'', set <a for=matrix>is 2D</a> of the
1624+
current matrix to <code>false</code>.
16281625

16291626
<li><p>Return the current matrix.
16301627
</ol>
@@ -1648,7 +1645,7 @@ user agents.
16481645
<li><p>Perform a {{DOMMatrix/translateSelf()}}</a> transformation on the current matrix with the
16491646
arguments <var>originX</var>, <var>originY</var>, <var>originZ</var>.
16501647

1651-
<li><p>If <var>scaleZ</var> is not ''1'' or <var>originZ</var> is not ''0'', set <a
1648+
<li><p>If <var>scaleZ</var> is not ''1'' or <var>originZ</var> is not ''0'' or ''-0'', set <a
16521649
for=matrix>is 2D</a> of the current matrix to <code>false</code>.
16531650

16541651
<li><p>Return the current matrix.
@@ -1680,14 +1677,14 @@ user agents.
16801677
<dd>
16811678
<ol>
16821679
<li><p>If <var>rotY</var> and <var>rotZ</var> are both missing, set <var>rotZ</var> to the value
1683-
of <var>rotX</var> and set <var>rotX</var> and <var>rotY</var> to zero.
1680+
of <var>rotX</var> and set <var>rotX</var> and <var>rotY</var> to ''0''.
16841681

1685-
<li><p>If <var>rotY</var> is still missing, set <var>rotY</var> to zero.
1682+
<li><p>If <var>rotY</var> is still missing, set <var>rotY</var> to ''0''.
16861683

1687-
<li><p>If <var>rotZ</var> is still missing, set <var>rotZ</var> to zero.
1684+
<li><p>If <var>rotZ</var> is still missing, set <var>rotZ</var> to ''0''.
16881685

1689-
<li><p>If <var>rotX</var> or <var>rotY</var> are non-zero, set <a for=matrix>is 2D</a> of the
1690-
current matrix to <code>false</code>.
1686+
<li><p>If <var>rotX</var> or <var>rotY</var> are not ''0'' or ''-0'', set <a for=matrix>is 2D</a>
1687+
of the current matrix to <code>false</code>.
16911688

16921689
<li><p><a>Post-multiply</a> a rotation transformation on the current matrix around the vector 0,
16931690
0, 1 by the specified rotation <var>rotZ</var> in degrees. The 3D rotation matrix is <a
@@ -1713,9 +1710,9 @@ user agents.
17131710
<li><p><a>Post-multiply</a> a rotation transformation on the current matrix. The rotation angle
17141711
is determined by the angle between the vector (1,0)<sup>T</sup> and
17151712
(<var>x</var>,<var>y</var>)<sup>T</sup> in the clockwise direction. If <var>x</var> and
1716-
<var>y</var> should both be zero, the angle is specified as zero. The 2D rotation matrix is <a
1717-
href="https://drafts.csswg.org/css-transforms-1/#RotateDefined">described</a> in CSS Transforms
1718-
where <code>alpha</code> is the angle between the vector (1,0)<sup>T</sup> and
1713+
<var>y</var> should both be ''0'' or ''-0'', the angle is specified as ''0''. The 2D rotation
1714+
matrix is <a href="https://drafts.csswg.org/css-transforms-1/#RotateDefined">described</a> in CSS
1715+
Transforms where <code>alpha</code> is the angle between the vector (1,0)<sup>T</sup> and
17191716
(<var>x</var>,<var>y</var>)<sup>T</sup> in degrees. [[!CSS3-TRANSFORMS]]
17201717

17211718
<li><p>Return the current matrix.
@@ -1730,8 +1727,8 @@ user agents.
17301727
href="https://drafts.csswg.org/css-transforms-1/#Rotate3dDefined">described</a> in CSS Transforms
17311728
with <var>alpha</var> = <var>angle</var> in degrees. [[!CSS3-TRANSFORMS]]
17321729

1733-
<li><p>If <var>x</var> or <var>y</var> are not ''0'', set <a for=matrix>is 2D</a> of the current
1734-
matrix to <code>false</code>.
1730+
<li><p>If <var>x</var> or <var>y</var> are not ''0'' or ''-0'', set <a for=matrix>is 2D</a> of
1731+
the current matrix to <code>false</code>.
17351732

17361733
<li><p>Return the current matrix.
17371734
</ol>

0 commit comments

Comments
 (0)