Skip to content

Commit 86ab080

Browse files
zcorpansvgeesus
authored andcommitted
Define serialize/deserialize steps
Fixes #121.
1 parent 42e1706 commit 86ab080

File tree

1 file changed

+171
-18
lines changed

1 file changed

+171
-18
lines changed

geometry/Overview.bs

Lines changed: 171 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ Transforms. [[SVG11]] [[2DCONTEXT]] [[CSS3-TRANSFORMS]]
6767
<pre class=idl>
6868
[Constructor(optional unrestricted double x = 0, optional unrestricted double y = 0,
6969
optional unrestricted double z = 0, optional unrestricted double w = 1),
70-
Exposed=(Window,Worker)]
70+
Exposed=(Window,Worker),
71+
Serializable]
7172
interface DOMPointReadOnly {
7273
[NewObject] static DOMPointReadOnly fromPoint(optional DOMPointInit other);
7374

@@ -83,7 +84,8 @@ interface DOMPointReadOnly {
8384

8485
[Constructor(optional unrestricted double x = 0, optional unrestricted double y = 0,
8586
optional unrestricted double z = 0, optional unrestricted double w = 1),
86-
Exposed=(Window,Worker)]
87+
Exposed=(Window,Worker),
88+
Serializable]
8789
interface DOMPoint : DOMPointReadOnly {
8890
[NewObject] static DOMPoint fromPoint(optional DOMPointInit other);
8991

@@ -245,7 +247,8 @@ object.
245247
<pre class=idl>
246248
[Constructor(optional unrestricted double x = 0, optional unrestricted double y = 0,
247249
optional unrestricted double width = 0, optional unrestricted double height = 0),
248-
Exposed=(Window,Worker)]
250+
Exposed=(Window,Worker),
251+
Serializable]
249252
interface DOMRectReadOnly {
250253
[NewObject] static DOMRectReadOnly fromRect(optional DOMRectInit other);
251254

@@ -263,7 +266,8 @@ interface DOMRectReadOnly {
263266

264267
[Constructor(optional unrestricted double x = 0, optional unrestricted double y = 0,
265268
optional unrestricted double width = 0, optional unrestricted double height = 0),
266-
Exposed=(Window,Worker)]
269+
Exposed=(Window,Worker),
270+
Serializable]
267271
interface DOMRect : DOMRectReadOnly {
268272
[NewObject] static DOMRect fromRect(optional DOMRectInit other);
269273

@@ -377,7 +381,8 @@ non-enumerable property named <dfn dfn-type=interface><code>SVGRect</code></dfn>
377381
<pre class=idl>
378382
[Constructor(optional DOMPointInit p1, optional DOMPointInit p2,
379383
optional DOMPointInit p3, optional DOMPointInit p4),
380-
Exposed=(Window,Worker)]
384+
Exposed=(Window,Worker),
385+
Serializable]
381386
interface DOMQuad {
382387
[NewObject] static DOMQuad fromRect(optional DOMRectInit other);
383388
[NewObject] static DOMQuad fromQuad(optional DOMQuadInit other);
@@ -614,7 +619,8 @@ context. The following sections describe the details of the interface.
614619

615620
<pre class=idl>
616621
[Constructor(optional (DOMString or sequence&lt;unrestricted double>) init),
617-
Exposed=(Window,Worker)]
622+
Exposed=(Window,Worker),
623+
Serializable]
618624
interface DOMMatrixReadOnly {
619625
[NewObject] static DOMMatrixReadOnly fromMatrix(optional DOMMatrixInit other);
620626
[NewObject] static DOMMatrixReadOnly fromFloat32Array(Float32Array array32);
@@ -687,7 +693,8 @@ interface DOMMatrixReadOnly {
687693
};
688694

689695
[Constructor(optional (DOMString or sequence&lt;unrestricted double>) init),
690-
Exposed=(Window,Worker)]
696+
Exposed=(Window,Worker),
697+
Serializable]
691698
interface DOMMatrix : DOMMatrixReadOnly {
692699
[NewObject] static DOMMatrix fromMatrix(optional DOMMatrixInit other);
693700
[NewObject] static DOMMatrix fromFloat32Array(Float32Array array32);
@@ -1693,23 +1700,169 @@ user agents.
16931700
</dl>
16941701

16951702

1696-
<h2 id="cloning">Cloning</h2>
1703+
<h2 id="structured-serialization" oldids="cloning">Structured serialization</h2>
16971704

1698-
<p>When a user agent is asked to <b>clone</b> an {{DOMPointReadOnly}}, {{DOMPoint}},
1699-
{{DOMRectReadOnly}}, {{DOMRect}}, {{DOMQuad}}, {{DOMMatrixReadOnly}} or {{DOMMatrix}} object
1700-
<var>old</var>, it must run the following steps, which return a new object of same type. These steps
1701-
must be run atomically.
1705+
<p>{{DOMPointReadOnly}}, {{DOMPoint}}, {{DOMRectReadOnly}}, {{DOMRect}}, {{DOMQuad}},
1706+
{{DOMMatrixReadOnly}}, and {{DOMMatrix}} objects are <a>serializable objects</a>. [[!HTML]]
1707+
1708+
<p>The <a>serialization steps</a> for {{DOMPointReadOnly}} and {{DOMPoint}}, given |value| and
1709+
|serialized|, are:
1710+
1711+
<ol>
1712+
<li><p>Set |serialized|.\[[X]] to |value|'s <a for=point>x coordinate</a>.
1713+
1714+
<li><p>Set |serialized|.\[[Y]] to |value|'s <a for=point>y coordinate</a>.
1715+
1716+
<li><p>Set |serialized|.\[[Z]] to |value|'s <a for=point>z coordinate</a>.
1717+
1718+
<li><p>Set |serialized|.\[[W]] to |value|'s <a for=point>w perspective</a>.
1719+
</ol>
1720+
1721+
<p>Their <a>deserialization steps</a>, given |serialized| and |value|, are:
1722+
1723+
<ol>
1724+
<li>Set |value|'s <a for=point>x coordinate</a> to |serialized|.\[[X]].
1725+
1726+
<li>Set |value|'s <a for=point>y coordinate</a> to |serialized|.\[[Y]].
1727+
1728+
<li>Set |value|'s <a for=point>z coordinate</a> to |serialized|.\[[Z]].
1729+
1730+
<li>Set |value|'s <a for=point>w perspective</a> to |serialized|.\[[W]].
1731+
</ol>
1732+
1733+
<p>The <a>serialization steps</a> for {{DOMRectReadOnly}} and {{DOMRect}}, given |value| and
1734+
|serialized|, are:
17021735

17031736
<ol>
1704-
<li><p>Create a new object <var>new</var> of the same type as <var>old</var>. Copy all member
1705-
variable values from <var>old</var> to <var>new</var>.
1737+
<li><p>Set |serialized|.\[[X]] to |value|'s <a for=rectangle>x coordinate</a>.
17061738

1707-
<li><p>Return <var>new</var>. It is the clone.
1739+
<li><p>Set |serialized|.\[[Y]] to |value|'s <a for=rectangle>y coordinate</a>.
1740+
1741+
<li><p>Set |serialized|.\[[Width]] to |value|'s <a for=rectangle>width dimension</a>.
1742+
1743+
<li><p>Set |serialized|.\[[Height]] to |value|'s <a for=rectangle>height dimension</a>.
17081744
</ol>
17091745

1710-
<p>The above algorithm follows the <a
1711-
href="https://www.w3.org/TR/html5/infrastructure.html#safe-passing-of-structured-data">“safe passing
1712-
of structured data”</a> definitions. [[!HTML5]]
1746+
<p>Their <a>deserialization steps</a>, given |serialized| and |value|, are:
1747+
1748+
<ol>
1749+
<li>Set |value|'s <a for=rectangle>x coordinate</a> to |serialized|.\[[X]].
1750+
1751+
<li>Set |value|'s <a for=rectangle>y coordinate</a> to |serialized|.\[[Y]].
1752+
1753+
<li>Set |value|'s <a for=rectangle>width dimension</a> to |serialized|.\[[Width]].
1754+
1755+
<li>Set |value|'s <a for=rectangle>height dimension</a> to |serialized|.\[[Height]].
1756+
</ol>
1757+
1758+
<p>The <a>serialization steps</a> for {{DOMQuad}}, given |value| and |serialized|, are:
1759+
1760+
<ol>
1761+
<li><p>Set |serialized|.\[[P1]] to the <a>sub-serialization</a> of |value|'s <a
1762+
for=quadrilateral>point 1</a>.
1763+
1764+
<li><p>Set |serialized|.\[[P2]] to the <a>sub-serialization</a> of |value|'s <a
1765+
for=quadrilateral>point 2</a>.
1766+
1767+
<li><p>Set |serialized|.\[[P3]] to the <a>sub-serialization</a> of |value|'s <a
1768+
for=quadrilateral>point 3</a>.
1769+
1770+
<li><p>Set |serialized|.\[[P4]] to the <a>sub-serialization</a> of |value|'s <a
1771+
for=quadrilateral>point 4</a>.
1772+
</ol>
1773+
1774+
<p>Their <a>deserialization steps</a>, given |serialized| and |value|, are:
1775+
1776+
<ol>
1777+
<li><p>Set |value|'s <a for=quadrilateral>point 1</a> to the <a>sub-deserialization</a> of
1778+
|serialized|.\[[P1]].
1779+
1780+
<li><p>Set |value|'s <a for=quadrilateral>point 2</a> to the <a>sub-deserialization</a> of
1781+
|serialized|.\[[P2]].
1782+
1783+
<li><p>Set |value|'s <a for=quadrilateral>point 3</a> to the <a>sub-deserialization</a> of
1784+
|serialized|.\[[P3]].
1785+
1786+
<li><p>Set |value|'s <a for=quadrilateral>point 4</a> to the <a>sub-deserialization</a> of
1787+
|serialized|.\[[P4]].
1788+
</ol>
1789+
1790+
<p>The <a>serialization steps</a> for {{DOMMatrixReadOnly}} and {{DOMMatrix}}, given |value| and
1791+
|serialized|, are:
1792+
1793+
<ol>
1794+
<li><p>Set |serialized|.\[[M11]] to |value|'s <a for=matrix>m11 element</a>.
1795+
1796+
<li><p>Set |serialized|.\[[M12]] to |value|'s <a for=matrix>m12 element</a>.
1797+
1798+
<li><p>Set |serialized|.\[[M13]] to |value|'s <a for=matrix>m13 element</a>.
1799+
1800+
<li><p>Set |serialized|.\[[M14]] to |value|'s <a for=matrix>m14 element</a>.
1801+
1802+
<li><p>Set |serialized|.\[[M21]] to |value|'s <a for=matrix>m21 element</a>.
1803+
1804+
<li><p>Set |serialized|.\[[M22]] to |value|'s <a for=matrix>m22 element</a>.
1805+
1806+
<li><p>Set |serialized|.\[[M23]] to |value|'s <a for=matrix>m23 element</a>.
1807+
1808+
<li><p>Set |serialized|.\[[M24]] to |value|'s <a for=matrix>m24 element</a>.
1809+
1810+
<li><p>Set |serialized|.\[[M31]] to |value|'s <a for=matrix>m31 element</a>.
1811+
1812+
<li><p>Set |serialized|.\[[M32]] to |value|'s <a for=matrix>m32 element</a>.
1813+
1814+
<li><p>Set |serialized|.\[[M33]] to |value|'s <a for=matrix>m33 element</a>.
1815+
1816+
<li><p>Set |serialized|.\[[M34]] to |value|'s <a for=matrix>m34 element</a>.
1817+
1818+
<li><p>Set |serialized|.\[[M41]] to |value|'s <a for=matrix>m41 element</a>.
1819+
1820+
<li><p>Set |serialized|.\[[M42]] to |value|'s <a for=matrix>m42 element</a>.
1821+
1822+
<li><p>Set |serialized|.\[[M43]] to |value|'s <a for=matrix>m43 element</a>.
1823+
1824+
<li><p>Set |serialized|.\[[M44]] to |value|'s <a for=matrix>m44 element</a>.
1825+
1826+
<li><p>Set |serialized|.\[[Is2D]] to |value|'s <a for=matrix>is 2D</a>.
1827+
</ol>
1828+
1829+
<p>Their <a>deserialization steps</a>, given |serialized| and |value|, are:
1830+
1831+
<ol>
1832+
<li><p>Set |value|'s <a for=matrix>m11 element</a> to |serialized|.\[[M11]].
1833+
1834+
<li><p>Set |value|'s <a for=matrix>m12 element</a> to |serialized|.\[[M12]].
1835+
1836+
<li><p>Set |value|'s <a for=matrix>m13 element</a> to |serialized|.\[[M13]].
1837+
1838+
<li><p>Set |value|'s <a for=matrix>m14 element</a> to |serialized|.\[[M14]].
1839+
1840+
<li><p>Set |value|'s <a for=matrix>m21 element</a> to |serialized|.\[[M21]].
1841+
1842+
<li><p>Set |value|'s <a for=matrix>m22 element</a> to |serialized|.\[[M22]].
1843+
1844+
<li><p>Set |value|'s <a for=matrix>m23 element</a> to |serialized|.\[[M23]].
1845+
1846+
<li><p>Set |value|'s <a for=matrix>m24 element</a> to |serialized|.\[[M24]].
1847+
1848+
<li><p>Set |value|'s <a for=matrix>m31 element</a> to |serialized|.\[[M31]].
1849+
1850+
<li><p>Set |value|'s <a for=matrix>m32 element</a> to |serialized|.\[[M32]].
1851+
1852+
<li><p>Set |value|'s <a for=matrix>m33 element</a> to |serialized|.\[[M33]].
1853+
1854+
<li><p>Set |value|'s <a for=matrix>m34 element</a> to |serialized|.\[[M34]].
1855+
1856+
<li><p>Set |value|'s <a for=matrix>m41 element</a> to |serialized|.\[[M41]].
1857+
1858+
<li><p>Set |value|'s <a for=matrix>m42 element</a> to |serialized|.\[[M42]].
1859+
1860+
<li><p>Set |value|'s <a for=matrix>m43 element</a> to |serialized|.\[[M43]].
1861+
1862+
<li><p>Set |value|'s <a for=matrix>m44 element</a> to |serialized|.\[[M44]].
1863+
1864+
<li><p>Set |value|'s <a for=matrix>is 2D</a> to |serialized|.\[[Is2D]].
1865+
</ol>
17131866

17141867

17151868
<h2 id="priv-sec">Privacy and Security Considerations</h2>

0 commit comments

Comments
 (0)