Skip to content

Commit 1849f8e

Browse files
zcorpansvgeesus
authored andcommitted
Add a DOMMatrix2dInit dictionary type
This is needed for CanvasRenderingContext2D's setTransform(). Fixes #210. Tests: web-platform-tests/wpt#7007
1 parent 1f039dc commit 1849f8e

File tree

1 file changed

+51
-43
lines changed

1 file changed

+51
-43
lines changed

geometry/Overview.bs

Lines changed: 51 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ interface DOMMatrix : DOMMatrixReadOnly {
817817
[Exposed=Window] DOMMatrix setMatrixValue(DOMString transformList);
818818
};
819819

820-
dictionary DOMMatrixInit {
820+
dictionary DOMMatrix2DInit {
821821
unrestricted double a;
822822
unrestricted double b;
823823
unrestricted double c;
@@ -826,18 +826,21 @@ dictionary DOMMatrixInit {
826826
unrestricted double f;
827827
unrestricted double m11;
828828
unrestricted double m12;
829-
unrestricted double m13 = 0;
830-
unrestricted double m14 = 0;
831829
unrestricted double m21;
832830
unrestricted double m22;
831+
unrestricted double m41;
832+
unrestricted double m42;
833+
};
834+
835+
dictionary DOMMatrixInit : DOMMatrix2DInit {
836+
unrestricted double m13 = 0;
837+
unrestricted double m14 = 0;
833838
unrestricted double m23 = 0;
834839
unrestricted double m24 = 0;
835840
unrestricted double m31 = 0;
836841
unrestricted double m32 = 0;
837842
unrestricted double m33 = 1;
838843
unrestricted double m34 = 0;
839-
unrestricted double m41;
840-
unrestricted double m42;
841844
unrestricted double m43 = 0;
842845
unrestricted double m44 = 1;
843846
boolean is2D;
@@ -865,59 +868,62 @@ prose.
865868
interface from SVG. [[SVG11]]
866869

867870

868-
<h3 id=dommatrixinit-dictionary>DOMMatrixInit dictionary</h3>
871+
<h3 id=dommatrixinit-dictionary>DOMMatrix2DInit and DOMMatrixInit dictionaries</h3>
869872

870-
<p>To <dfn dfn-for=matrix>validate and fixup</dfn> a {{DOMMatrixInit}} dictionary <var>dict</var>,
871-
run the following steps:
873+
<p>To <dfn dfn-for=matrix>validate and fixup</dfn> a {{DOMMatrix2DInit}} or {{DOMMatrixInit}}
874+
dictionary <var>dict</var>, given a boolean <var>ignore3D</var> (<code>false</code> if not
875+
provided), run the following steps:
872876

873877
<ol>
874878
<li>
875879
<p>If if at least one of the following conditions are true for <var>dict</var>, throw a
876880
{{TypeError}} exception and abort these steps.
877881

878882
<ul>
879-
<li><p>{{DOMMatrixInit/a}} and {{DOMMatrixInit/m11}} are both present and
880-
[=SameValueZero=]({{DOMMatrixInit/a}}, {{DOMMatrixInit/m11}}) is <code>false</code>.
883+
<li><p>{{DOMMatrix2DInit/a}} and {{DOMMatrix2DInit/m11}} are both present and
884+
[=SameValueZero=]({{DOMMatrix2DInit/a}}, {{DOMMatrix2DInit/m11}}) is <code>false</code>.
881885

882-
<li><p>{{DOMMatrixInit/b}} and {{DOMMatrixInit/m12}} are both present and
883-
[=SameValueZero=]({{DOMMatrixInit/b}}, {{DOMMatrixInit/m12}}) is <code>false</code>.
886+
<li><p>{{DOMMatrix2DInit/b}} and {{DOMMatrix2DInit/m12}} are both present and
887+
[=SameValueZero=]({{DOMMatrix2DInit/b}}, {{DOMMatrix2DInit/m12}}) is <code>false</code>.
884888

885-
<li><p>{{DOMMatrixInit/c}} and {{DOMMatrixInit/m21}} are both present and
886-
[=SameValueZero=]({{DOMMatrixInit/c}}, {{DOMMatrixInit/m21}}) is <code>false</code>.
889+
<li><p>{{DOMMatrix2DInit/c}} and {{DOMMatrix2DInit/m21}} are both present and
890+
[=SameValueZero=]({{DOMMatrix2DInit/c}}, {{DOMMatrix2DInit/m21}}) is <code>false</code>.
887891

888-
<li><p>{{DOMMatrixInit/d}} and {{DOMMatrixInit/m22}} are both present and
889-
[=SameValueZero=]({{DOMMatrixInit/d}}, {{DOMMatrixInit/m22}}) is <code>false</code>.
892+
<li><p>{{DOMMatrix2DInit/d}} and {{DOMMatrix2DInit/m22}} are both present and
893+
[=SameValueZero=]({{DOMMatrix2DInit/d}}, {{DOMMatrix2DInit/m22}}) is <code>false</code>.
890894

891-
<li><p>{{DOMMatrixInit/e}} and {{DOMMatrixInit/m41}} are both present and
892-
[=SameValueZero=]({{DOMMatrixInit/e}}, {{DOMMatrixInit/m41}}) is <code>false</code>.
895+
<li><p>{{DOMMatrix2DInit/e}} and {{DOMMatrix2DInit/m41}} are both present and
896+
[=SameValueZero=]({{DOMMatrix2DInit/e}}, {{DOMMatrix2DInit/m41}}) is <code>false</code>.
893897

894-
<li><p>{{DOMMatrixInit/f}} and {{DOMMatrixInit/m42}} are both present and
895-
[=SameValueZero=]({{DOMMatrixInit/f}}, {{DOMMatrixInit/m42}}) is <code>false</code>.
898+
<li><p>{{DOMMatrix2DInit/f}} and {{DOMMatrix2DInit/m42}} are both present and
899+
[=SameValueZero=]({{DOMMatrix2DInit/f}}, {{DOMMatrix2DInit/m42}}) is <code>false</code>.
896900

897-
<li><p>{{DOMMatrixInit/is2D}} is <code>true</code> and at least one of {{DOMMatrixInit/m13}},
898-
{{DOMMatrixInit/m14}}, {{DOMMatrixInit/m23}}, {{DOMMatrixInit/m24}}, {{DOMMatrixInit/m31}},
899-
{{DOMMatrixInit/m32}}, {{DOMMatrixInit/m34}}, {{DOMMatrixInit/m43}} are present with a value
900-
other than ''0'' or ''-0'', or at least one of {{DOMMatrixInit/m33}}, {{DOMMatrixInit/m44}} are
901-
present with a value other than ''1''.
901+
<li><p><var>ignore3D</var> is <code>false</code> and {{DOMMatrixInit/is2D}} is <code>true</code>
902+
and: at least one of {{DOMMatrixInit/m13}}, {{DOMMatrixInit/m14}}, {{DOMMatrixInit/m23}},
903+
{{DOMMatrixInit/m24}}, {{DOMMatrixInit/m31}}, {{DOMMatrixInit/m32}}, {{DOMMatrixInit/m34}},
904+
{{DOMMatrixInit/m43}} are present with a value other than ''0'' or ''-0'', or at least one of
905+
{{DOMMatrixInit/m33}}, {{DOMMatrixInit/m44}} are present with a value other than ''1''.
902906
</ul>
903907

904-
<li><p>If {{DOMMatrixInit/m11}} is not present then set it to the value of member
905-
{{DOMMatrixInit/a}}, or value ''1'' if {{DOMMatrixInit/a}} is also not present.
908+
<li><p>If {{DOMMatrix2DInit/m11}} is not present then set it to the value of member
909+
{{DOMMatrix2DInit/a}}, or value ''1'' if {{DOMMatrix2DInit/a}} is also not present.
910+
911+
<li><p>If {{DOMMatrix2DInit/m12}} is not present then set it to the value of member
912+
{{DOMMatrix2DInit/b}}, or value ''0'' if {{DOMMatrix2DInit/b}} is also not present.
906913

907-
<li><p>If {{DOMMatrixInit/m12}} is not present then set it to the value of member
908-
{{DOMMatrixInit/b}}, or value ''0'' if {{DOMMatrixInit/b}} is also not present.
914+
<li><p>If {{DOMMatrix2DInit/m21}} is not present then set it to the value of member
915+
{{DOMMatrix2DInit/c}}, or value ''0'' if {{DOMMatrix2DInit/c}} is also not present.
909916

910-
<li><p>If {{DOMMatrixInit/m21}} is not present then set it to the value of member
911-
{{DOMMatrixInit/c}}, or value ''0'' if {{DOMMatrixInit/c}} is also not present.
917+
<li><p>If {{DOMMatrix2DInit/m22}} is not present then set it to the value of member
918+
{{DOMMatrix2DInit/d}}, or value ''1'' if {{DOMMatrix2DInit/d}} is also not present.
912919

913-
<li><p>If {{DOMMatrixInit/m22}} is not present then set it to the value of member
914-
{{DOMMatrixInit/d}}, or value ''1'' if {{DOMMatrixInit/d}} is also not present.
920+
<li><p>If {{DOMMatrix2DInit/m41}} is not present then set it to the value of member
921+
{{DOMMatrix2DInit/e}}, or value ''0'' if {{DOMMatrix2DInit/e}} is also not present.
915922

916-
<li><p>If {{DOMMatrixInit/m41}} is not present then set it to the value of member
917-
{{DOMMatrixInit/e}}, or value ''0'' if {{DOMMatrixInit/e}} is also not present.
923+
<li><p>If {{DOMMatrix2DInit/m42}} is not present then set it to the value of member
924+
{{DOMMatrix2DInit/f}}, or value ''0'' if {{DOMMatrix2DInit/f}} is also not present.
918925

919-
<li><p>If {{DOMMatrixInit/m42}} is not present then set it to the value of member
920-
{{DOMMatrixInit/f}}, or value ''0'' if {{DOMMatrixInit/f}} is also not present.
926+
<li><p>If <var>ignore3D</var> is <code>true</code>, then return.
921927

922928
<li><p>If {{DOMMatrixInit/is2D}} is not present and at least one of {{DOMMatrixInit/m13}},
923929
{{DOMMatrixInit/m14}}, {{DOMMatrixInit/m23}}, {{DOMMatrixInit/m24}}, {{DOMMatrixInit/m31}},
@@ -1074,23 +1080,25 @@ id=dom-dommatrix-frommatrix><code>fromMatrix(<var>other</var>)</code></dfn> stat
10741080
<p>To <dfn lt="create a DOMMatrixReadOnly from the dictionary">create a
10751081
<code>DOMMatrixReadOnly</code> from a dictionary</dfn> <var>other</var> or to <dfn lt="create a
10761082
DOMMatrix from the dictionary">create a <code>DOMMatrix</code> from a dictionary</dfn>
1077-
<var>other</var>, follow these steps:
1083+
<var>other</var>, given a boolean <var>ignore3D</var> (<code>false</code> if not provided), follow
1084+
these steps:
10781085

10791086
<ol>
1080-
<li><a for=matrix>Validate and fixup</a> <var>other</var>.
1087+
<li><a for=matrix>Validate and fixup</a> <var>other</var>, given <var>ignore3D</var>.
10811088

10821089
<li>
10831090
<dl class=switch>
1084-
<dt>If the {{DOMMatrixInit/is2D}} dictionary member of <var>other</var> is <code>true</code>
1091+
<dt>If <var>ignore3D</var> is <code>true</code> or if the {{DOMMatrixInit/is2D}} dictionary
1092+
member of <var>other</var> is <code>true</code>
10851093
<dd><p>Return the result of invoking <a>create a 2d matrix</a> of type {{DOMMatrixReadOnly}} or
10861094
{{DOMMatrix}} as appropriate, with a sequence of numbers, the values being the 6 elements
1087-
{{DOMMatrixInit/m11}}, {{DOMMatrixInit/m12}}, {{DOMMatrixInit/m21}}, {{DOMMatrixInit/m22}},
1088-
{{DOMMatrixInit/m41}} and {{DOMMatrixInit/m42}} of <var>other</var> in the given order.
1095+
{{DOMMatrix2DInit/m11}}, {{DOMMatrix2DInit/m12}}, {{DOMMatrix2DInit/m21}}, {{DOMMatrix2DInit/m22}},
1096+
{{DOMMatrix2DInit/m41}} and {{DOMMatrix2DInit/m42}} of <var>other</var> in the given order.
10891097

10901098
<dt>Otherwise
10911099
<dd><p>Return the result of invoking <a>create a 3d matrix</a> of type {{DOMMatrixReadOnly}} or
10921100
{{DOMMatrix}} as appropriate, with a sequence of numbers, the values being the 16 elements
1093-
{{DOMMatrixInit/m11}}, {{DOMMatrixInit/m12}}, {{DOMMatrixInit/m13}}, ..., {{DOMMatrixInit/m44}}
1101+
{{DOMMatrix2DInit/m11}}, {{DOMMatrix2DInit/m12}}, {{DOMMatrixInit/m13}}, ..., {{DOMMatrixInit/m44}}
10941102
of <var>other</var> in the given order.
10951103
</dl>
10961104
</ol>

0 commit comments

Comments
 (0)