[html5] r7972 - [e] (0) Integrate ArrayBuffer structured cloning Fixing https://www.w3.org/Bugs/ [...]

whatwg at whatwg.org whatwg at whatwg.org
Wed Jun 12 16:46:50 PDT 2013


Author: ianh
Date: 2013-06-12 16:46:48 -0700 (Wed, 12 Jun 2013)
New Revision: 7972

Modified:
   complete.html
   index
   source
Log:
[e] (0) Integrate ArrayBuffer structured cloning
Fixing https://www.w3.org/Bugs/Public/show_bug.cgi?id=13800
Affected topics: Canvas, DOM APIs, Workers

Modified: complete.html
===================================================================
--- complete.html	2013-06-12 23:00:57 UTC (rev 7971)
+++ complete.html	2013-06-12 23:46:48 UTC (rev 7972)
@@ -7974,11 +7974,21 @@
   particular to transfer ownership of unsharable or expensive
   resources across worker boundaries.</p>
 
+  <p>The following <code><a href=#transferable>Transferable</a></code> types exist:</p>
+
+  <ul class=brief><li><code><a href=#arraybuffer>ArrayBuffer</a></code> <a href=#refsTYPEDARRAY>[TYPEDARRAY]</a>
+   <li><code><a href=#canvasproxy>CanvasProxy</a></code> (defined in this specification)
+   <li><code><a href=#messageport>MessagePort</a></code> (defined in this specification)
+  </ul><div class=impl>
+
+  <p>The following IDL block formalizes this:</p>
+
   <pre class=idl>[NoInterfaceObject]
-interface <dfn id=transferable>Transferable</dfn> { };</pre>
+interface <dfn id=transferable>Transferable</dfn> { };
+<a href=#arraybuffer>ArrayBuffer</a> implements <a href=#transferable>Transferable</a>;
+<a href=#canvasproxy>CanvasProxy</a> implements <a href=#transferable>Transferable</a>;
+<a href=#messageport>MessagePort</a> implements <a href=#transferable>Transferable</a>;</pre>
 
-  <div class=impl>
-
   <p>To <dfn id=transfer-a-transferable-object>transfer a <code>Transferable</code> object</dfn> to a
   new owner, the user agent must run the steps defined for the type of
   object in question. The steps will return a new object of the same
@@ -7987,14 +7997,20 @@
   an object has been transferred, it cannot be transferred, or indeed
   used, again.)</p>
 
+  <p id=transferArrayBuffer>To <a href=#transfer-a-transferable-object title="transfer a Transferable object">transfer</a> an
+  <code><a href=#arraybuffer>ArrayBuffer</a></code> object <var title="">old</var> to a new owner <var title="">owner</var>,
+  a user agent must create a new <code><a href=#arraybuffer>ArrayBuffer</a></code> object pointing at the same underlying
+  data as <var title="">old</var>, thus obtaining <var title="">new</var>, must <a href=#concept-transferable-neutered title=concept-Transferable-neutered>neuter</a> the <var title="">old</var> object, and must
+  finally return <var title="">new</var>. <a href=#refsTYPEDARRAY>[TYPEDARRAY]</a></p>
+
+  <p class=note>Rules for how to <a href=#transferCanvasProxy>transfer a
+  <code>CanvasProxy</code> object</a> and how to <a href=#transferMessagePort>transfer a
+  <code>MessagePort</code> object</a> are given in the relevant sections of this specification.</p>
+
   </div>
 
-  <p>The following <code><a href=#transferable>Transferable</a></code> types exist:</p>
 
-  <ul class=brief><li><code><a href=#messageport>MessagePort</a></code>
-   <li><code><a href=#arraybuffer>ArrayBuffer</a></code> <a href=#refsTYPEDARRAY>[TYPEDARRAY]</a>
-   <li><code><a href=#canvasproxy>CanvasProxy</a></code>
-  </ul><div class=impl>
+  <div class=impl>
 
   <h4 id=safe-passing-of-structured-data><span class=secno>2.7.6 </span>Safe passing of structured data</h4>
 
@@ -8093,16 +8109,29 @@
      <dd><p>Let <var title="">output</var> be a newly constructed <code><a href=#imagebitmap>ImageBitmap</a></code> object
      whose bitmap data is a copy of <var title="">input</var>'s bitmap data.</dd>
 
-<!--(when we add this, make sure to throw DataCloneError if these objects are already closed)
-     <dt>If <var title="">input</var> is an <code>ArrayBuffer</code> object</dt>
+     <dt>If <var title="">input</var> is an <code><a href=#arraybuffer>ArrayBuffer</a></code> object</dt>
 
-     <dd><p>...</p></dd>
+     <dd><p>If <var title="">input</var> has been <a href=#concept-transferable-neutered title=concept-Transferable-neutered>neutered</a>, throw a <code><a href=#datacloneerror>DataCloneError</a></code>
+     exception and abort the overall <a href=#structured-clone>structured clone</a> algorithm. Otherwise, let <var title="">output</var> be a newly constructed <code><a href=#arraybuffer>ArrayBuffer</a></code> object whose contents are
+     a copy of <var title="">input</var>'s contents, with the same length.</dd>
 
-     <dt>If <var title="">input</var> is an <code>ArrayBufferView</code> object</dt>
+     <dt>If <var title="">input</var> is an <code><a href=#arraybufferview>ArrayBufferView</a></code> object</dt>
 
-     <dd><p>...</p></dd>
--->
+     <dd>
 
+     <dd>
+
+      <p>Let <var title="">output</var> be a newly constructed object of the same class as <var title="">input</var>, with each IDL attribute defined for that class being set to the value
+      obtained from invoking the <a href=#internal-structured-cloning-algorithm>internal structured cloning algorithm</a> recursively with
+      the value of the attribute on <var title="">input</var> as the new "<var title="">input</var>"
+      argument and <var title="">memory</var> as the new "<var title="">memory</var>" argument.</p>
+
+      <p class=note>Only IDL attributes defined on the class (including the
+      <code><a href=#arraybufferview>ArrayBufferView</a></code> attributes) are cloned. Properties added by a script, for
+      example, are not cloned.</p>
+
+     </dd>
+
      <dt>If <var title="">input</var> is an <code>Array</code> object</dt>
 
      <dd>
@@ -33076,7 +33105,7 @@
   <pre class=idl>interface <dfn id=canvasproxy>CanvasProxy</dfn> {
   void <a href=#dom-canvasproxy-setcontext title=dom-CanvasProxy-setContext>setContext</a>(<a href=#renderingcontext>RenderingContext</a> context);
 };
-<a href=#canvasproxy>CanvasProxy</a> implements <a href=#transferable>Transferable</a>;</pre>
+// <a href=#canvasproxy>CanvasProxy</a> implements <a href=#transferable>Transferable</a>;</pre>
 
   <dl class=domintro><dt><var title="">canvasProxy</var> = <var title="">canvas</var> . <code title=dom-canvas-transferControlToProxy><a href=#dom-canvas-transfercontroltoproxy>transferControlToProxy</a></code>()</dt>
 
@@ -82525,7 +82554,7 @@
   // event handlers
            attribute <a href=#eventhandler>EventHandler</a> <a href=#handler-messageport-onmessage title=handler-MessagePort-onmessage>onmessage</a>;
 };
-<a href=#messageport>MessagePort</a> implements <a href=#transferable>Transferable</a>;</pre>
+// <a href=#messageport>MessagePort</a> implements <a href=#transferable>Transferable</a>;</pre>
 
   <dl class=domintro><!-- v2-onclose
    <dt><var title="">port</var> . <code title="dom-MessagePort-active">active</code></dt>

Modified: index
===================================================================
--- index	2013-06-12 23:00:57 UTC (rev 7971)
+++ index	2013-06-12 23:46:48 UTC (rev 7972)
@@ -7974,11 +7974,21 @@
   particular to transfer ownership of unsharable or expensive
   resources across worker boundaries.</p>
 
+  <p>The following <code><a href=#transferable>Transferable</a></code> types exist:</p>
+
+  <ul class=brief><li><code><a href=#arraybuffer>ArrayBuffer</a></code> <a href=#refsTYPEDARRAY>[TYPEDARRAY]</a>
+   <li><code><a href=#canvasproxy>CanvasProxy</a></code> (defined in this specification)
+   <li><code><a href=#messageport>MessagePort</a></code> (defined in this specification)
+  </ul><div class=impl>
+
+  <p>The following IDL block formalizes this:</p>
+
   <pre class=idl>[NoInterfaceObject]
-interface <dfn id=transferable>Transferable</dfn> { };</pre>
+interface <dfn id=transferable>Transferable</dfn> { };
+<a href=#arraybuffer>ArrayBuffer</a> implements <a href=#transferable>Transferable</a>;
+<a href=#canvasproxy>CanvasProxy</a> implements <a href=#transferable>Transferable</a>;
+<a href=#messageport>MessagePort</a> implements <a href=#transferable>Transferable</a>;</pre>
 
-  <div class=impl>
-
   <p>To <dfn id=transfer-a-transferable-object>transfer a <code>Transferable</code> object</dfn> to a
   new owner, the user agent must run the steps defined for the type of
   object in question. The steps will return a new object of the same
@@ -7987,14 +7997,20 @@
   an object has been transferred, it cannot be transferred, or indeed
   used, again.)</p>
 
+  <p id=transferArrayBuffer>To <a href=#transfer-a-transferable-object title="transfer a Transferable object">transfer</a> an
+  <code><a href=#arraybuffer>ArrayBuffer</a></code> object <var title="">old</var> to a new owner <var title="">owner</var>,
+  a user agent must create a new <code><a href=#arraybuffer>ArrayBuffer</a></code> object pointing at the same underlying
+  data as <var title="">old</var>, thus obtaining <var title="">new</var>, must <a href=#concept-transferable-neutered title=concept-Transferable-neutered>neuter</a> the <var title="">old</var> object, and must
+  finally return <var title="">new</var>. <a href=#refsTYPEDARRAY>[TYPEDARRAY]</a></p>
+
+  <p class=note>Rules for how to <a href=#transferCanvasProxy>transfer a
+  <code>CanvasProxy</code> object</a> and how to <a href=#transferMessagePort>transfer a
+  <code>MessagePort</code> object</a> are given in the relevant sections of this specification.</p>
+
   </div>
 
-  <p>The following <code><a href=#transferable>Transferable</a></code> types exist:</p>
 
-  <ul class=brief><li><code><a href=#messageport>MessagePort</a></code>
-   <li><code><a href=#arraybuffer>ArrayBuffer</a></code> <a href=#refsTYPEDARRAY>[TYPEDARRAY]</a>
-   <li><code><a href=#canvasproxy>CanvasProxy</a></code>
-  </ul><div class=impl>
+  <div class=impl>
 
   <h4 id=safe-passing-of-structured-data><span class=secno>2.7.6 </span>Safe passing of structured data</h4>
 
@@ -8093,16 +8109,29 @@
      <dd><p>Let <var title="">output</var> be a newly constructed <code><a href=#imagebitmap>ImageBitmap</a></code> object
      whose bitmap data is a copy of <var title="">input</var>'s bitmap data.</dd>
 
-<!--(when we add this, make sure to throw DataCloneError if these objects are already closed)
-     <dt>If <var title="">input</var> is an <code>ArrayBuffer</code> object</dt>
+     <dt>If <var title="">input</var> is an <code><a href=#arraybuffer>ArrayBuffer</a></code> object</dt>
 
-     <dd><p>...</p></dd>
+     <dd><p>If <var title="">input</var> has been <a href=#concept-transferable-neutered title=concept-Transferable-neutered>neutered</a>, throw a <code><a href=#datacloneerror>DataCloneError</a></code>
+     exception and abort the overall <a href=#structured-clone>structured clone</a> algorithm. Otherwise, let <var title="">output</var> be a newly constructed <code><a href=#arraybuffer>ArrayBuffer</a></code> object whose contents are
+     a copy of <var title="">input</var>'s contents, with the same length.</dd>
 
-     <dt>If <var title="">input</var> is an <code>ArrayBufferView</code> object</dt>
+     <dt>If <var title="">input</var> is an <code><a href=#arraybufferview>ArrayBufferView</a></code> object</dt>
 
-     <dd><p>...</p></dd>
--->
+     <dd>
 
+     <dd>
+
+      <p>Let <var title="">output</var> be a newly constructed object of the same class as <var title="">input</var>, with each IDL attribute defined for that class being set to the value
+      obtained from invoking the <a href=#internal-structured-cloning-algorithm>internal structured cloning algorithm</a> recursively with
+      the value of the attribute on <var title="">input</var> as the new "<var title="">input</var>"
+      argument and <var title="">memory</var> as the new "<var title="">memory</var>" argument.</p>
+
+      <p class=note>Only IDL attributes defined on the class (including the
+      <code><a href=#arraybufferview>ArrayBufferView</a></code> attributes) are cloned. Properties added by a script, for
+      example, are not cloned.</p>
+
+     </dd>
+
      <dt>If <var title="">input</var> is an <code>Array</code> object</dt>
 
      <dd>
@@ -33076,7 +33105,7 @@
   <pre class=idl>interface <dfn id=canvasproxy>CanvasProxy</dfn> {
   void <a href=#dom-canvasproxy-setcontext title=dom-CanvasProxy-setContext>setContext</a>(<a href=#renderingcontext>RenderingContext</a> context);
 };
-<a href=#canvasproxy>CanvasProxy</a> implements <a href=#transferable>Transferable</a>;</pre>
+// <a href=#canvasproxy>CanvasProxy</a> implements <a href=#transferable>Transferable</a>;</pre>
 
   <dl class=domintro><dt><var title="">canvasProxy</var> = <var title="">canvas</var> . <code title=dom-canvas-transferControlToProxy><a href=#dom-canvas-transfercontroltoproxy>transferControlToProxy</a></code>()</dt>
 
@@ -82525,7 +82554,7 @@
   // event handlers
            attribute <a href=#eventhandler>EventHandler</a> <a href=#handler-messageport-onmessage title=handler-MessagePort-onmessage>onmessage</a>;
 };
-<a href=#messageport>MessagePort</a> implements <a href=#transferable>Transferable</a>;</pre>
+// <a href=#messageport>MessagePort</a> implements <a href=#transferable>Transferable</a>;</pre>
 
   <dl class=domintro><!-- v2-onclose
    <dt><var title="">port</var> . <code title="dom-MessagePort-active">active</code></dt>

Modified: source
===================================================================
--- source	2013-06-12 23:00:57 UTC (rev 7971)
+++ source	2013-06-12 23:46:48 UTC (rev 7972)
@@ -7609,11 +7609,24 @@
   particular to transfer ownership of unsharable or expensive
   resources across worker boundaries.</p>
 
-  <pre class="idl">[NoInterfaceObject]
-interface <dfn>Transferable</dfn> { };</pre>
+  <p>The following <code>Transferable</code> types exist:</p>
 
+  <ul class="brief">
+   <li><code>ArrayBuffer</code> <a href="#refsTYPEDARRAY">[TYPEDARRAY]</a>
+   <li><code>CanvasProxy</code> (defined in this specification)
+   <li><code>MessagePort</code> (defined in this specification)
+  </ul>
+
   <div class="impl">
 
+  <p>The following IDL block formalizes this:</p>
+
+  <pre class="idl">[NoInterfaceObject]
+interface <dfn>Transferable</dfn> { };
+<span>ArrayBuffer</span> implements <span>Transferable</span>;
+<span>CanvasProxy</span> implements <span>Transferable</span>;
+<span>MessagePort</span> implements <span>Transferable</span>;</pre>
+
   <p>To <dfn>transfer a <code>Transferable</code> object</dfn> to a
   new owner, the user agent must run the steps defined for the type of
   object in question. The steps will return a new object of the same
@@ -7623,15 +7636,18 @@
   an object has been transferred, it cannot be transferred, or indeed
   used, again.)</p>
 
-  </div>
+  <p id="transferArrayBuffer">To <span title="transfer a Transferable object">transfer</span> an
+  <code>ArrayBuffer</code> object <var title="">old</var> to a new owner <var title="">owner</var>,
+  a user agent must create a new <code>ArrayBuffer</code> object pointing at the same underlying
+  data as <var title="">old</var>, thus obtaining <var title="">new</var>, must <span
+  title="concept-Transferable-neutered">neuter</span> the <var title="">old</var> object, and must
+  finally return <var title="">new</var>. <a href="#refsTYPEDARRAY">[TYPEDARRAY]</a></p>
 
-  <p>The following <code>Transferable</code> types exist:</p>
+  <p class="note">Rules for how to <a href="#transferCanvasProxy">transfer a
+  <code>CanvasProxy</code> object</a> and how to <a href="#transferMessagePort">transfer a
+  <code>MessagePort</code> object</a> are given in the relevant sections of this specification.</p>
 
-  <ul class="brief">
-   <li><code>MessagePort</code>
-   <li><code>ArrayBuffer</code> <a href="#refsTYPEDARRAY">[TYPEDARRAY]</a>
-   <li><code>CanvasProxy</code>
-  </ul>
+  </div>
 
 
   <div class="impl">
@@ -7751,16 +7767,32 @@
      <dd><p>Let <var title="">output</var> be a newly constructed <code>ImageBitmap</code> object
      whose bitmap data is a copy of <var title="">input</var>'s bitmap data.</p></dd>
 
-<!--(when we add this, make sure to throw DataCloneError if these objects are already closed)
      <dt>If <var title="">input</var> is an <code>ArrayBuffer</code> object</dt>
 
-     <dd><p>...</p></dd>
+     <dd><p>If <var title="">input</var> has been <span
+     title="concept-Transferable-neutered">neutered</span>, throw a <code>DataCloneError</code>
+     exception and abort the overall <span>structured clone</span> algorithm. Otherwise, let <var
+     title="">output</var> be a newly constructed <code>ArrayBuffer</code> object whose contents are
+     a copy of <var title="">input</var>'s contents, with the same length.</p></dd>
 
      <dt>If <var title="">input</var> is an <code>ArrayBufferView</code> object</dt>
 
-     <dd><p>...</p></dd>
--->
+     <dd>
 
+     <dd>
+
+      <p>Let <var title="">output</var> be a newly constructed object of the same class as <var
+      title="">input</var>, with each IDL attribute defined for that class being set to the value
+      obtained from invoking the <span>internal structured cloning algorithm</span> recursively with
+      the value of the attribute on <var title="">input</var> as the new "<var title="">input</var>"
+      argument and <var title="">memory</var> as the new "<var title="">memory</var>" argument.</p>
+
+      <p class="note">Only IDL attributes defined on the class (including the
+      <code>ArrayBufferView</code> attributes) are cloned. Properties added by a script, for
+      example, are not cloned.</p>
+
+     </dd>
+
      <dt>If <var title="">input</var> is an <code>Array</code> object</dt>
 
      <dd>
@@ -35712,7 +35744,7 @@
   <pre class="idl">interface <dfn>CanvasProxy</dfn> {
   void <span title="dom-CanvasProxy-setContext">setContext</span>(<span>RenderingContext</span> context);
 };
-<span>CanvasProxy</span> implements <span>Transferable</span>;</pre>
+// <span>CanvasProxy</span> implements <span>Transferable</span>;</pre>
 
   <dl class="domintro">
 
@@ -92053,7 +92085,7 @@
   // event handlers
            attribute <span>EventHandler</span> <span title="handler-MessagePort-onmessage">onmessage</span>;
 };
-<span>MessagePort</span> implements <span>Transferable</span>;</pre>
+// <span>MessagePort</span> implements <span>Transferable</span>;</pre>
 
   <dl class="domintro">
 <!-- v2-onclose




More information about the Commit-Watchers mailing list