Skip to content

Commit 68c036a

Browse files
zcorpansvgeesus
authored andcommitted
Introduce fromX static methods on DOMMatrixReadOnly. Fixes https://www.w3.org/Bugs/Public/show_bug.cgi?id=27493
1 parent 21327d9 commit 68c036a

File tree

1 file changed

+25
-31
lines changed

1 file changed

+25
-31
lines changed

geometry/Overview.bs

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,11 @@ In the following sections, terms have the following meaning:
395395
[Constructor(sequence<unrestricted double> numberSequence),
396396
Exposed=(Window,Worker)]
397397
interface DOMMatrixReadOnly {
398+
[NewObject] static DOMMatrixReadOnly fromMatrix(optional DOMMatrixInit other);
399+
[NewObject] static DOMMatrixReadOnly fromString(DOMString transformList);
400+
[NewObject] static DOMMatrixReadOnly fromFloat32Array(Float32Array array32);
401+
[NewObject] static DOMMatrixReadOnly fromFloat64Array(Float64Array array64);
402+
398403
// These attributes are simple aliases for certain elements of the 4x4 matrix
399404
readonly attribute unrestricted double a;
400405
readonly attribute unrestricted double b;
@@ -636,49 +641,36 @@ with a sequence <var>numberSequence</var> of 16 elements, follow these steps:
636641
1. Set <a>is2D</a> to <code>false</code>.
637642
1. Return <var>matrix</var>
638643

639-
<h3 id='dommatrixreadonly-constructors'>DOMMatrixReadOnly constructor</h3>
640-
641-
The <dfn dfn-type=constructor dfn-for=DOMMatrixReadOnly><code>DOMMatrixReadOnly(<var>numberSequence</var>)</code></dfn> constructor, when invoked, must run the following steps:
642-
643-
<dl class=switch>
644-
<dt>If <var>numberSequence</var> has 6 elements</dt>
645-
<dd>Return the result of invoking <a>create a 2d matrix</a> of type {{DOMMatrixReadOnly}} with the sequence <var>numberSequence</var>.</dd>
646-
<dt>If <var>numberSequence</var> has 16 elements</dt>
647-
<dd>Return the result of invoking <a>create a 3d matrix</a> of type {{DOMMatrixReadOnly}} with the sequence <var>numberSequence</var>.</dd>
648-
<dt>Otherwise</dt>
649-
<dd>Throw a <code>TypeError</code> exception.</dd>
650-
</dl>
651-
652-
653-
<h3 id='dommatrix-constructors'>DOMMatrix constructors</h3>
654-
655-
The <dfn dfn-type=constructor dfn-for=DOMMatrix><code>DOMMatrix(<var>numberSequence</var>)</code></dfn> constructor, when invoked, must run the following steps:
644+
The <dfn dfn-type=constructor dfn-for=DOMMatrixReadOnly><code>DOMMatrixReadOnly(<var>numberSequence</var>)</code></dfn> and
645+
the <dfn dfn-type=constructor dfn-for=DOMMatrix><code>DOMMatrix(<var>numberSequence</var>)</code></dfn> constructors, when invoked, must run the following steps:
656646

657647
<dl class=switch>
658648
<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>
649+
<dd>Return the result of invoking <a>create a 2d matrix</a> of type {{DOMMatrixReadOnly}} or {{DOMMatrix}} as appropriate, with the sequence <var>numberSequence</var>.</dd>
660650
<dt>If <var>numberSequence</var> has 16 elements</dt>
661-
<dd>Return the result of invoking <a>create a 3d matrix</a> of type {{DOMMatrix}} with the sequence <var>numberSequence</var>.</dd>
651+
<dd>Return the result of invoking <a>create a 3d matrix</a> of type {{DOMMatrixReadOnly}} or {{DOMMatrix}} as appropriate, with the sequence <var>numberSequence</var>.</dd>
662652
<dt>Otherwise</dt>
663653
<dd>Throw a <code>TypeError</code> exception.</dd>
664654
</dl>
665655

666-
The <dfn dfn-for=DOMMatrix id=dom-dommatrix-frommatrix><code>fromMatrix(<var>other</var>)</code></dfn> static method on {{DOMMatrix}} must follow these steps:
656+
The <dfn dfn-for=DOMMatrixReadOnly id=dom-dommatrixreadonly-frommatrix><code>fromMatrix(<var>other</var>)</code></dfn> static method on {{DOMMatrixReadOnly}} and
657+
the <dfn dfn-for=DOMMatrix id=dom-dommatrix-frommatrix><code>fromMatrix(<var>other</var>)</code></dfn> static method on {{DOMMatrix}} must follow these steps:
667658

668659
<ol>
669660
<li><a>Validate and fixup</a> <var>other</var>.</li>
670661

671662
<li>
672663
<dl class=switch>
673664
<dt>If the {{DOMMatrixInit/is2D}} dictionary member of <var>other</var> is <code>true</code></dt>
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>
665+
<dd>Return the result of invoking <a>create a 2d matrix</a> of type {{DOMMatrixReadOnly}} or {{DOMMatrix}} as appropriate, 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>
675666
<dt>Otherwise</dt>
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>
667+
<dd>Return the result of invoking <a>create a 3d matrix</a> of type {{DOMMatrixReadOnly}} or {{DOMMatrix}} as appropriate, 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>
677668
</dl>
678669
</li>
679670
</ol>
680671

681-
The <dfn dfn-for=DOMMatrix><code>fromString(<var>transformList</var>)</code></dfn> static method on {{DOMMatrix}} must follow these steps:
672+
The <dfn dfn-for=DOMMatrixReadOnly><code>fromString(<var>transformList</var>)</code></dfn> static method on {{DOMMatrixReadOnly}} and
673+
the <dfn dfn-for=DOMMatrix><code>fromString(<var>transformList</var>)</code></dfn> static method on {{DOMMatrix}} must follow these steps:
682674

683675
<ol>
684676
<li>Parse <var>transformList</var> by following the syntax description in “<a href=http://www.w3.org/TR/css-transforms-1/#svg-syntax>Syntax of the SVG ‘transform’ attribute</a>[[!CSS3-TRANSFORMS]] to a <<transform-list>>. If parsing is not successful or any <<transform-function>> has <<length>> values without <a spec='css-values'>absolute length</a> units<!--For WD: <a spec='css-values-3'>absolute length units</a>-->, throw a {{SyntaxError}} exception.</li>
@@ -695,31 +687,33 @@ The <dfn dfn-for=DOMMatrix><code>fromString(<var>transformList</var>)</code></df
695687
<li>
696688
<dl class=switch>
697689
<dt>If <var>2dTransform</var> is set to <code>true</code></dt>
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>
690+
<dd>Return the result of invoking <a>create a 2d matrix</a> of type {{DOMMatrixReadOnly}} or {{DOMMatrix}} as appropriate, 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>
699691
<dt>If <var>2dTransform</var> is set to <code>false</code></dt>
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>
692+
<dd>Return the result of invoking <a>create a 3d matrix</a> of type {{DOMMatrixReadOnly}} or {{DOMMatrix}} as appropriate, with a sequence of numbers, the values being the 16 elements of <var>matrix</var>.</dd>
701693
</dl>
702694
</li>
703695
</ol>
704696

705-
The <dfn dfn-for=DOMMatrix><code>fromFloat32Array(<var>array32</var>)</code></dfn> static method on {{DOMMatrix}} must follow these steps:
697+
The <dfn dfn-for=DOMMatrixReadOnly><code>fromFloat32Array(<var>array32</var>)</code></dfn> static method on {{DOMMatrixReadOnly}} and
698+
the <dfn dfn-for=DOMMatrix><code>fromFloat32Array(<var>array32</var>)</code></dfn> static method on {{DOMMatrix}} must follow these steps:
706699

707700
<dl class=switch>
708701
<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>
702+
<dd>Return the result of invoking <a>create a 2d matrix</a> of type {{DOMMatrixReadOnly}} or {{DOMMatrix}} as appropriate, with a sequence of numbers taking the values from <var>array32</var> in the provided order.</dd>
710703
<dt>If <var>array32</var> has 16 elements</dt>
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>
704+
<dd>Return the result of invoking <a>create a 3d matrix</a> of type {{DOMMatrixReadOnly}} or {{DOMMatrix}} as appropriate, with a sequence of numbers taking the values from <var>array32</var> in the provided order.</dd>
712705
<dt>Otherwise</dt>
713706
<dd>Throw a <code>TypeError</code> exception.</dd>
714707
</dl>
715708

716-
The <dfn dfn-for=DOMMatrix><code>fromFloat64Array(<var>array64</var>)</code></dfn> static method on {{DOMMatrix}} must follow these steps:
709+
The <dfn dfn-for=DOMMatrixReadOnly><code>fromFloat64Array(<var>array64</var>)</code></dfn> static method on {{DOMMatrixReadOnly}} and
710+
the <dfn dfn-for=DOMMatrix><code>fromFloat64Array(<var>array64</var>)</code></dfn> static method on {{DOMMatrix}} must follow these steps:
717711

718712
<dl class=switch>
719713
<dt>If <var>array64</var> has 6 elements</dt>
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>
714+
<dd>Return the result of invoking <a>create a 2d matrix</a> of type {{DOMMatrixReadOnly}} or {{DOMMatrix}} as appropriate, with a sequence of numbers taking the values from <var>array64</var> in the provided order.</dd>
721715
<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>
716+
<dd>Return the result of invoking <a>create a 3d matrix</a> of type {{DOMMatrixReadOnly}} or {{DOMMatrix}} as appropriate, with a sequence of numbers taking the values from <var>array64</var> in the provided order.</dd>
723717
<dt>Otherwise</dt>
724718
<dd>Throw a <code>TypeError</code> exception.</dd>
725719
</dl>

0 commit comments

Comments
 (0)