Skip to content

Commit 21327d9

Browse files
zcorpansvgeesus
authored andcommitted
Use an abstract operation to create DOMMatrix[ReadOnly]. Fix 2d/3d logic. Fixes https://www.w3.org/Bugs/Public/show_bug.cgi?id=27426
1 parent 32cb78c commit 21327d9

File tree

1 file changed

+34
-41
lines changed

1 file changed

+34
-41
lines changed

geometry/Overview.bs

Lines changed: 34 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -616,27 +616,35 @@ To <dfn>set the dictionary members</dfn> <var>a</var> and <var>b</var> of a {{DO
616616
<li>Otherwise, set <var>a</var> and <var>b</var> dictionary members to <var>fallback</var>.
617617
</ol>
618618

619+
<h3 id='dommatrix-create'>Creating DOMMatrixReadOnly and DOMMatrix objects</h3>
620+
621+
To <dfn>create a 2d matrix</dfn> of type <var>type</var> being either {{DOMMatrixReadOnly}} or {{DOMMatrix}},
622+
with a sequence <var>numberSequence</var> of 6 elements, follow these steps:
623+
624+
1. Let <var>matrix</var> be a new instance of <var>type</var>.
625+
1. Set <a>m11 element</a>, <a>m12 element</a>, <a>m21 element</a>, <a>m22 element</a>, <a>m41 element</a> and <a>m42 element</a> to the values of <var>numberSequence</var> in order starting with the first value.
626+
1. Set <a>m31 element</a>, <a>m32 element</a>, <a>m13 element</a>, <a>m23 element</a>, <a>m43 element</a>, <a>m14 element</a>, <a>m24 element</a> and <a>m34 element</a> to ''0''.
627+
1. Set <a>m33 element</a> and <a>m44 element</a> to ''1''.
628+
1. Set <a>is2D</a> to <code>true</code>.
629+
1. Return <var>matrix</var>
630+
631+
To <dfn>create a 3d matrix</dfn> with <var>type</var> being either {{DOMMatrixReadOnly}} or {{DOMMatrix}},
632+
with a sequence <var>numberSequence</var> of 16 elements, follow these steps:
633+
634+
1. Let <var>matrix</var> be a new instance of <var>type</var>.
635+
1. Set <a>m11 element</a> to <a>m44 element</a> to the values of <var>numberSequence</var> in column-major order.
636+
1. Set <a>is2D</a> to <code>false</code>.
637+
1. Return <var>matrix</var>
638+
619639
<h3 id='dommatrixreadonly-constructors'>DOMMatrixReadOnly constructor</h3>
620640

621641
The <dfn dfn-type=constructor dfn-for=DOMMatrixReadOnly><code>DOMMatrixReadOnly(<var>numberSequence</var>)</code></dfn> constructor, when invoked, must run the following steps:
622642

623643
<dl class=switch>
624644
<dt>If <var>numberSequence</var> has 6 elements</dt>
625-
<dd>
626-
<ol>
627-
<li>Set <a>m11 element</a>, <a>m12 element</a>, <a>m21 element</a>, <a>m22 element</a>, <a>m41 element</a>, <a>m42 element</a> to the values of <var>numberSequence</var> in order starting with the first value. Furthermore, set <a>m31 element</a>, <a>m32 element</a>, <a>m13 element</a>, <a>m23 element</a>, <a>m43 element</a>, <a>m14 element</a>, <a>m24 element</a>, <a>m34 element</a> to ''0'' and <a>m33 element</a>, <a>m44 element</a> to ''1''.</li>
628-
<li>Set <a>is2D</a> to <code>true</code>.</li>
629-
<li>Return the new <a interface>DOMMatrixReadOnly</a> object.</li>
630-
</ol>
631-
</dd>
645+
<dd>Return the result of invoking <a>create a 2d matrix</a> of type {{DOMMatrixReadOnly}} with the sequence <var>numberSequence</var>.</dd>
632646
<dt>If <var>numberSequence</var> has 16 elements</dt>
633-
<dd>
634-
<ol>
635-
<li>Set <a>m11 element</a> to <a>m44 element</a> to the values of <var>numberSequence</var> in column-major order.</li>
636-
<li>Set <a>is2D</a> to <code>false</code>.</li>
637-
<li>Return the new <a interface>DOMMatrixReadOnly</a> object.</li>
638-
</ol>
639-
</dd>
647+
<dd>Return the result of invoking <a>create a 3d matrix</a> of type {{DOMMatrixReadOnly}} with the sequence <var>numberSequence</var>.</dd>
640648
<dt>Otherwise</dt>
641649
<dd>Throw a <code>TypeError</code> exception.</dd>
642650
</dl>
@@ -648,13 +656,9 @@ The <dfn dfn-type=constructor dfn-for=DOMMatrix><code>DOMMatrix(<var>numberSeque
648656

649657
<dl class=switch>
650658
<dt>If <var>numberSequence</var> has 6 elements</dt>
659+
<dd>Return the result of invoking <a>create a 2d matrix</a> of type {{DOMMatrix}} with the sequence <var>numberSequence</var>.</dd>
651660
<dt>If <var>numberSequence</var> has 16 elements</dt>
652-
<dd>
653-
<ol>
654-
<li>Call the constructor of <a interface>DOMMatrixReadOnly</a> with <var>numberSequence</var> as argument.</li>
655-
<li>Return the new <a interface>DOMMatrix</a> object.</li>
656-
</ol>
657-
</dd>
661+
<dd>Return the result of invoking <a>create a 3d matrix</a> of type {{DOMMatrix}} with the sequence <var>numberSequence</var>.</dd>
658662
<dt>Otherwise</dt>
659663
<dd>Throw a <code>TypeError</code> exception.</dd>
660664
</dl>
@@ -667,13 +671,11 @@ The <dfn dfn-for=DOMMatrix id=dom-dommatrix-frommatrix><code>fromMatrix(<var>oth
667671
<li>
668672
<dl class=switch>
669673
<dt>If the {{DOMMatrixInit/is2D}} dictionary member of <var>other</var> is <code>true</code></dt>
670-
<dd>Call the constructor of <a interface>DOMMatrixReadOnly</a> with a sequence of numbers, the values being the 16 elements {{DOMMatrixInit/m11}}, {{DOMMatrixInit/m12}}, {{DOMMatrixInit/m13}}, ..., {{DOMMatrixInit/m44}} of <var>other</var> in the given order.</dd>
674+
<dd>Return the result of invoking <a>create a 2d matrix</a> of type {{DOMMatrix}} with a sequence of numbers, the values being the 6 elements {{DOMMatrixInit/m11}}, {{DOMMatrixInit/m12}}, {{DOMMatrixInit/m21}}, {{DOMMatrixInit/m22}}, {{DOMMatrixInit/m41}} and {{DOMMatrixInit/m42}} of <var>other</var> in the given order.</dd>
671675
<dt>Otherwise</dt>
672-
<dd>Call the constructor of <a interface>DOMMatrixReadOnly</a> with a sequence of numbers, the values being the 6 elements {{DOMMatrixInit/m11}}, {{DOMMatrixInit/m12}}, {{DOMMatrixInit/m21}}, {{DOMMatrixInit/m22}}, {{DOMMatrixInit/m41}} and {{DOMMatrixInit/m42}} of <var>other</var> in the given order.</dd>
676+
<dd>Return the result of invoking <a>create a 3d matrix</a> of type {{DOMMatrix}} with a sequence of numbers, the values being the 16 elements {{DOMMatrixInit/m11}}, {{DOMMatrixInit/m12}}, {{DOMMatrixInit/m13}}, ..., {{DOMMatrixInit/m44}} of <var>other</var> in the given order.</dd>
673677
</dl>
674678
</li>
675-
676-
<li>Return the new {{DOMMatrix}} object.</li>
677679
</ol>
678680

679681
The <dfn dfn-for=DOMMatrix><code>fromString(<var>transformList</var>)</code></dfn> static method on {{DOMMatrix}} must follow these steps:
@@ -690,28 +692,23 @@ The <dfn dfn-for=DOMMatrix><code>fromString(<var>transformList</var>)</code></df
690692
</li>
691693
<li>Transform all <<transform-function>>s to 4x4 matrices by following the “<a href=http://www.w3.org/TR/css-transforms-1/#mathematical-description>Mathematical Description of Transform Functions</a>[[!CSS3-TRANSFORMS]].</li>
692694
<li>Let <var>matrix</var> be a 4x4 matrix as shown in the initial figure of this section. Post-multiply all matrices from left to right and set <var>matrix</var> to this product.</li>
693-
<li>Call the constructor of <a interface>DOMMatrixReadOnly</a> as follows
695+
<li>
694696
<dl class=switch>
695697
<dt>If <var>2dTransform</var> is set to <code>true</code></dt>
696-
<dd>Call the constructor of <a interface>DOMMatrixReadOnly</a> with a sequence of numbers, the values being the 16 elements of <var>matrix</var>.</dd>
698+
<dd>Return the result of invoking <a>create a 2d matrix</a> of type {{DOMMatrix}} with a sequence of numbers, the values being the elements <var>m11</var>, <var>m12</var>, <var>21</var>, <var>m22</var>, <var>m41</var> and <var>m42</var> of <var>matrix</var> of <var>matrix</var>.</dd>
697699
<dt>If <var>2dTransform</var> is set to <code>false</code></dt>
698-
<dd>Call the constructor of <a interface>DOMMatrixReadOnly</a> with a sequence of numbers, the values being the elements <var>m11</var>, <var>m12</var>, <var>21</var>, <var>m22</var>, <var>m41</var> and <var>m42</var> of <var>matrix</var> of <var>matrix</var>.</dd>
700+
<dd>Return the result of invoking <a>create a 3d matrix</a> of type {{DOMMatrix}} with a sequence of numbers, the values being the 16 elements of <var>matrix</var>.</dd>
699701
</dl>
700702
</li>
701-
<li>Return the new <a interface>DOMMatrix</a> object.</li>
702703
</ol>
703704

704705
The <dfn dfn-for=DOMMatrix><code>fromFloat32Array(<var>array32</var>)</code></dfn> static method on {{DOMMatrix}} must follow these steps:
705706

706707
<dl class=switch>
707708
<dt>If <var>array32</var> has 6 elements</dt>
709+
<dd>Return the result of invoking <a>create a 2d matrix</a> of type {{DOMMatrix}} with a sequence of numbers taking the values from <var>array32</var> in the provided order.</dd>
708710
<dt>If <var>array32</var> has 16 elements</dt>
709-
<dd>
710-
<ol>
711-
<li>Call the constructor of <a interface>DOMMatrixReadOnly</a> with a sequence of numbers taking the values from <var>array32</var> in the provided order.</li>
712-
<li>Return the new <a interface>DOMMatrix</a> object.</li>
713-
</ol>
714-
</dd>
711+
<dd>Return the result of invoking <a>create a 3d matrix</a> of type {{DOMMatrix}} with a sequence of numbers taking the values from <var>array32</var> in the provided order.</dd>
715712
<dt>Otherwise</dt>
716713
<dd>Throw a <code>TypeError</code> exception.</dd>
717714
</dl>
@@ -720,13 +717,9 @@ The <dfn dfn-for=DOMMatrix><code>fromFloat64Array(<var>array64</var>)</code></df
720717

721718
<dl class=switch>
722719
<dt>If <var>array64</var> has 6 elements</dt>
723-
<dt>If <var>array64</var> has 16 elements</dt>
724-
<dd>
725-
<ol>
726-
<li>Call the constructor of <a interface>DOMMatrixReadOnly</a> with sequence of numbers taking the values from <var>array64</var> in the provided order.</li>
727-
<li>Return the new <a interface>DOMMatrix</a> object.</li>
728-
</ol>
729-
</dd>
720+
<dd>Return the result of invoking <a>create a 2d matrix</a> of type {{DOMMatrix}} with a sequence of numbers taking the values from <var>array64</var> in the provided order.</dd>
721+
<dt>If <var>array32</var> has 16 elements</dt>
722+
<dd>Return the result of invoking <a>create a 3d matrix</a> of type {{DOMMatrix}} with a sequence of numbers taking the values from <var>array64</var> in the provided order.</dd>
730723
<dt>Otherwise</dt>
731724
<dd>Throw a <code>TypeError</code> exception.</dd>
732725
</dl>

0 commit comments

Comments
 (0)