Skip to content

Instantly share code, notes, and snippets.

Created April 7, 2015 11:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/a8931b3ebac8a418ca23 to your computer and use it in GitHub Desktop.
Save anonymous/a8931b3ebac8a418ca23 to your computer and use it in GitHub Desktop.
diff --git a/geometry/Overview.bs b/geometry/Overview.bs
index 4a4c40a..8c2ca9f 100644
--- a/geometry/Overview.bs
+++ b/geometry/Overview.bs
@@ -58,7 +58,7 @@ interface DOMPointReadOnly {
readonly attribute unrestricted double z;
readonly attribute unrestricted double w;
- DOMPoint matrixTransform(DOMMatrixReadOnly matrix);
+ DOMPoint matrixTransform(optional DOMMatrixInit matrix);
};
[Constructor(optional DOMPointInit point),
@@ -490,7 +490,7 @@ interface DOMMatrixReadOnly {
unrestricted double angle);
DOMMatrix skewX(unrestricted double sx);
DOMMatrix skewY(unrestricted double sy);
- DOMMatrix multiply(DOMMatrix other);
+ DOMMatrix multiply(optional DOMMatrixInit other);
DOMMatrix flipX();
DOMMatrix flipY();
DOMMatrix inverse();
@@ -501,9 +501,8 @@ interface DOMMatrixReadOnly {
stringifier;
};
-[Constructor,
- Constructor(DOMString transformList),
- Constructor(DOMMatrixReadOnly other),
+[Constructor(DOMString transformList),
+ Constructor(optional DOMMatrixInit other),
Constructor(Float32Array array32),
Constructor(Float64Array array64),
Constructor(sequence<unrestricted double> numberSequence),
@@ -535,8 +534,8 @@ interface DOMMatrix : DOMMatrixReadOnly {
inherit attribute unrestricted double m44;
// Mutable transform methods
- DOMMatrix multiplySelf(DOMMatrix other);
- DOMMatrix preMultiplySelf(DOMMatrix other);
+ DOMMatrix multiplySelf(optional DOMMatrixInit other);
+ DOMMatrix preMultiplySelf(optional DOMMatrixInit other);
DOMMatrix translateSelf(unrestricted double tx,
unrestricted double ty,
optional unrestricted double tz = 0);
@@ -568,6 +567,32 @@ interface DOMMatrix : DOMMatrixReadOnly {
DOMMatrix setMatrixValue(DOMString transformList);
};
+
+dictionary DOMMatrixInit {
+ unrestricted double a;
+ unrestricted double b;
+ unrestricted double c;
+ unrestricted double d;
+ unrestricted double e;
+ unrestricted double f;
+ unrestricted double m11;
+ unrestricted double m12;
+ unrestricted double m13 = 0;
+ unrestricted double m14 = 0;
+ unrestricted double m21;
+ unrestricted double m22;
+ unrestricted double m23 = 0;
+ unrestricted double m24 = 0;
+ unrestricted double m31 = 0;
+ unrestricted double m32 = 0;
+ unrestricted double m33 = 1;
+ unrestricted double m34 = 0;
+ unrestricted double m41;
+ unrestricted double m42;
+ unrestricted double m43 = 0;
+ unrestricted double m44 = 1;
+ boolean is2D;
+};
</pre>
The following algorithms assume that <a interface>DOMMatrixReadOnly</a> objects have the internal member variables <dfn dfn-for=matrix>m11 element</dfn>, <dfn dfn-for=matrix>m12 element</dfn>, <dfn dfn-for=matrix>m13 element</dfn>, <dfn dfn-for=matrix>m14 element</dfn>, <dfn dfn-for=matrix>m21 element</dfn>, <dfn dfn-for=matrix>m22 element</dfn>, <dfn dfn-for=matrix>m23 element</dfn>, <dfn dfn-for=matrix>m24 element</dfn>, <dfn dfn-for=matrix>m31 element</dfn>, <dfn dfn-for=matrix>m32 element</dfn>, <dfn dfn-for=matrix>m33 element</dfn>, <dfn dfn-for=matrix>m34 element</dfn>, <dfn dfn-for=matrix>m41 element</dfn>, <dfn dfn-for=matrix>m42 element</dfn>, <dfn dfn-for=matrix>m43 element</dfn>, <dfn dfn-for=matrix>m44 element</dfn> and <a>is2D</a>. <a interface>DOMMatrixReadOnly</a> as well as the inheriting interface <a interface>DOMMatrix</a> must be able to access and set the value of these variables.
@@ -580,6 +605,55 @@ The <a interface>DOMMatrix</a> and <a interface>DOMMatrixReadOnly</a> interfaces
For historical reasons, Window objects must also have a writable, configurable, non-enumerable property named <dfn dfn-type=interface>SVGMatrix</dfn> whose value is the <a interface>DOMMatrix</a> interface object.
+<h3 id='dommatrixinit-dictionary'>DOMMatrixInit dictionary</h3>
+
+To <dfn>validate and fixup</dfn> a {{DOMMatrixInit}} dictionary <var>dict</var>, run the following steps:
+
+<ol>
+ <li>If if at least one of the following conditions are true for <var>dict</var>, throw a <code>TypeError</code> exception and abort these steps.
+ <ul>
+ <li>{{DOMMatrixInit/a}} and {{DOMMatrixInit/m11}} are both present and their values are not the same.
+ <li>{{DOMMatrixInit/b}} and {{DOMMatrixInit/m12}} are both present and their values are not the same.
+ <li>{{DOMMatrixInit/c}} and {{DOMMatrixInit/m21}} are both present and their values are not the same.
+ <li>{{DOMMatrixInit/d}} and {{DOMMatrixInit/m22}} are both present and their values are not the same.
+ <li>{{DOMMatrixInit/e}} and {{DOMMatrixInit/m41}} are both present and their values are not the same.
+ <li>{{DOMMatrixInit/f}} and {{DOMMatrixInit/m42}} are both present and their values are not the same.
+ <li>{{DOMMatrixInit/is2D}} is <code>true</code> and at least one of
+ {{DOMMatrixInit/m31}}, {{DOMMatrixInit/m32}}, {{DOMMatrixInit/m13}}, {{DOMMatrixInit/m23}},
+ {{DOMMatrixInit/m43}}, {{DOMMatrixInit/m14}}, {{DOMMatrixInit/m24}}, {{DOMMatrixInit/m34}}
+ are present with a value other than ''0'',
+ or at least one of {{DOMMatrixInit/m33}}, {{DOMMatrixInit/m44}}
+ are present with a value other than ''1''.
+ </ul>
+ <li><a>Set the dictionary members</a> {{DOMMatrixInit/a}} and {{DOMMatrixInit/m11}} with fallback value ''1''.
+ <li><a>Set the dictionary members</a> {{DOMMatrixInit/b}} and {{DOMMatrixInit/m12}} with fallback value ''0''.
+ <li><a>Set the dictionary members</a> {{DOMMatrixInit/c}} and {{DOMMatrixInit/m21}} with fallback value ''0''.
+ <li><a>Set the dictionary members</a> {{DOMMatrixInit/d}} and {{DOMMatrixInit/m22}} with fallback value ''1''.
+ <li><a>Set the dictionary members</a> {{DOMMatrixInit/e}} and {{DOMMatrixInit/m41}} with fallback value ''0''.
+ <li><a>Set the dictionary members</a> {{DOMMatrixInit/f}} and {{DOMMatrixInit/m42}} with fallback value ''0''.
+ <li>If {{DOMMatrixInit/is2D}} is not present and at least one of
+ {{DOMMatrixInit/m31}}, {{DOMMatrixInit/m32}}, {{DOMMatrixInit/m13}}, {{DOMMatrixInit/m23}},
+ {{DOMMatrixInit/m43}}, {{DOMMatrixInit/m14}}, {{DOMMatrixInit/m24}}, {{DOMMatrixInit/m34}}
+ are present with a value other than ''0'',
+ or at least one of {{DOMMatrixInit/m33}}, {{DOMMatrixInit/m44}}
+ are present with a value other than ''1'',
+ set {{DOMMatrixInit/is2D}} to <code>false</code>.
+ <li>If {{DOMMatrixInit/is2D}} is still not present, set it to <code>true</code>.
+</ol>
+
+For the purpose of the algorithm above, two WebIDL unrestricted double values <var>a</var> and <var>b</var>
+are the same if they have identical IEEE 754 double-precision bit patterns.
+
+Note: This means that two ''NaN'' values are the same.
+
+To <dfn>set the dictionary members</dfn> <var>a</var> and <var>b</var> of a {{DOMMatrixInit}} dictionary, with a fallback value <var>fallback</var>, run the following steps:
+
+<ol>
+ <li>If <var>a</var> is present and <var>b</var> is not present, set the <var>b</var> dictionary member to the value of <var>a</var>.
+ <li>Otherwise, if <var>b</var> is present and <var>a</var> is not present, set the <var>a</var> dictionary member to the value of <var>b</var>.
+ <li>Otherwise, set <var>a</var> and <var>b</var> dictionary members to <var>fallback</var>.
+</ol>
+
<h3 id='dommatrixreadonly-constructors'>DOMMatrixReadOnly constructor</h3>
The <dfn dfn-type=constructor dfn-for=DOMMatrixReadOnly><code>DOMMatrixReadOnly(sequence&lt;unrestricted double> <var>numberSequence</var>)</code></dfn> constructor, when invoked, must run the following steps:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment