- From: poot <cvsmail@w3.org>
- Date: Thu, 7 Oct 2010 07:41:56 +0900 (JST)
- To: public-html-diffs@w3.org
hixie: Make the structured clone algorithm support cycles. (whatwg r5587) http://dev.w3.org/cvsweb/html5/spec/Overview.html?r1=1.4464&r2=1.4465&f=h http://html5.org/tools/web-apps-tracker?from=5586&to=5587 =================================================================== RCS file: /sources/public/html5/spec/Overview.html,v retrieving revision 1.4464 retrieving revision 1.4465 diff -u -d -r1.4464 -r1.4465 --- Overview.html 6 Oct 2010 21:00:57 -0000 1.4464 +++ Overview.html 6 Oct 2010 22:41:27 -0000 1.4465 @@ -6633,8 +6633,11 @@ <ol><li><p>Let <var title="">input</var> be the object being cloned.</li> - <li><p>Let <var title="">memory</var> be a list of objects, - initially empty. (This is used to catch cycles.)</li> + <li><p>Let <var title="">memory</var> be an association list of + pairs of objects, initially empty. This is used to handle duplicate + references. In each pair of objects, one is called the + <em>source</em> object and the other the <em>destination</em> + object.</li> <li><p>Let <var title="">output</var> be the object resulting from calling the <a href="#internal-structured-cloning-algorithm">internal structured cloning algorithm</a> with @@ -6643,122 +6646,108 @@ <li><p>Return <var title="">output</var>.</li> </ol><p>The <dfn id="internal-structured-cloning-algorithm">internal structured cloning algorithm</dfn> is always - called with two arguments, <var title="">input</var> and <var title="">memory</var>, and its behavior depends on the type of <var title="">input</var>, as follows:</p> - - <dl class="switch"><dt>If <var title="">input</var> is the undefined value</dt> - - <dd><p>Return the undefined value.</dd> - - <dt>If <var title="">input</var> is the null value</dt> - - <dd><p>Return the null value.</dd> - - <dt>If <var title="">input</var> is the false value</dt> - - <dd><p>Return the false value.</dd> - - <dt>If <var title="">input</var> is the true value</dt> + called with two arguments, <var title="">input</var> and <var title="">memory</var>, and its behavior is as follows:</p> - <dd><p>Return the true value.</dd> + <ol><li><p>If <var title="">input</var> is the source object of a pair + of objects in <var title="">memory</var>, then return the + destination object in that pair of objects and abort these + steps.</li> - <dt>If <var title="">input</var> is a number</dt> + <li><p>If <var title="">input</var> is a primitive value, then + return that value and abort these steps.</li> - <dd><p>Return the same number.</dd> + <li> - <dt>If <var title="">input</var> is a string</dt> + <p>The <var title="">input</var> value is an object. Jump to the + appropriate step below:</p> - <dd><p>Return the same string.</dd> + <dl class="switch"><dt>If <var title="">input</var> is a Boolean object</dt> - <dt>If <var title="">input</var> is a Boolean object</dt> + <dd><p>Let <var title="">output</var> be a newly constructed Boolean object with the same value as <var title="">input</var>.</dd> - <dd><p>Return a newly constructed Boolean object with the same value as <var title="">input</var>.</dd> + <dt>If <var title="">input</var> is a Number object</dt> - <dt>If <var title="">input</var> is a Number object</dt> + <dd><p>Let <var title="">output</var> be a newly constructed Number object with the same value as <var title="">input</var>.</dd> - <dd><p>Return a newly constructed Number object with the same value as <var title="">input</var>.</dd> + <dt>If <var title="">input</var> is a String object</dt> - <dt>If <var title="">input</var> is a String object</dt> + <dd><p>Let <var title="">output</var> be a newly constructed String object with the same value as <var title="">input</var>.</dd> - <dd><p>Return a newly constructed String object with the same value as <var title="">input</var>.</dd> + <dt>If <var title="">input</var> is a <code>Date</code> object</dt> - <dt>If <var title="">input</var> is a <code>Date</code> object</dt> + <dd><p>Let <var title="">output</var> be a newly constructed <code>Date</code> object with the same value as <var title="">input</var>.</dd> - <dd><p>Return a newly constructed <code>Date</code> object with the same value as <var title="">input</var>.</dd> + <dt>If <var title="">input</var> is a <code>RegExp</code> object</dt> - <dt>If <var title="">input</var> is a <code>RegExp</code> object</dt> + <dd> - <dd> + <p>Let <var title="">output</var> be a newly constructed <code>RegExp</code> object with the same pattern and flags as <var title="">input</var>.</p> - <p>Return a newly constructed <code>RegExp</code> object with the same pattern and flags as <var title="">input</var>.</p> + <p class="note">The value of the <code title="">lastIndex</code> property is not copied.</p> - <p class="note">The value of the <code title="">lastIndex</code> property is not copied.</p> + </dd> - </dd> + <dt>If <var title="">input</var> is a <code>ImageData</code> object</dt> - <dt>If <var title="">input</var> is a <code>ImageData</code> object</dt> + <dd><p>Let <var title="">output</var> be a newly constructed <code>ImageData</code> object + with the same <code title="dom-imagedata-width">width</code> and + <code title="dom-imagedata-height">height</code> as <var title="">input</var>, and with a newly constructed + <code>CanvasPixelArray</code> for its <code title="dom-imagedata-data">data</code> attribute, with the same + <code title="dom-canvaspixelarray-length">length</code> and pixel + values as the <var title="">input</var>'s.</dd> - <dd><p>Return a newly constructed <code>ImageData</code> object - with the same <code title="dom-imagedata-width">width</code> and - <code title="dom-imagedata-height">height</code> as <var title="">input</var>, and with a newly constructed - <code>CanvasPixelArray</code> for its <code title="dom-imagedata-data">data</code> attribute, with the same - <code title="dom-canvaspixelarray-length">length</code> and pixel - values as the <var title="">input</var>'s.</dd> + <dt>If <var title="">input</var> is a <code>File</code> object</dt> - <dt>If <var title="">input</var> is a <code>File</code> object</dt> + <dd><p>Let <var title="">output</var> be a newly constructed <code>File</code> object corresponding to the same underlying data.</dd> - <dd><p>Return a newly constructed <code>File</code> object corresponding to the same underlying data.</dd> + <dt>If <var title="">input</var> is a <code>Blob</code> object</dt> - <dt>If <var title="">input</var> is a <code>Blob</code> object</dt> + <dd><p>Let <var title="">output</var> be a newly constructed <code>Blob</code> object corresponding to the same underlying data.</dd> - <dd><p>Return a newly constructed <code>Blob</code> object corresponding to the same underlying data.</dd> + <dt>If <var title="">input</var> is a <code>FileList</code> object</dt> - <dt>If <var title="">input</var> is a <code>FileList</code> object</dt> + <dd><p>Let <var title="">output</var> be a newly constructed <code>FileList</code> object containing a list of newly constructed <code>File</code> objects corresponding to the same underlying data as those in <var title="">input</var>, maintaining their relative order.</dd> - <dd><p>Return a newly constructed <code>FileList</code> object containing a list of newly constructed <code>File</code> objects corresponding to the same underlying data as those in <var title="">input</var>, maintaining their relative order.</dd> + <dt>If <var title="">input</var> is an Array object</dt> - <dt>If <var title="">input</var> is an Array object</dt> - <dt>If <var title="">input</var> is an Object object</dt> + <dd><p>Let <var title="">output</var> be a newly constructed empty <code>Array</code> object.</dd> - <dd> + <dt>If <var title="">input</var> is an Object object</dt> - <ol><li><p>If <var title="">input</var> is in <var title="">memory</var>, then throw a <code><a href="#data_clone_err">DATA_CLONE_ERR</a></code> - exception and abort the overall <a href="#structured-clone">structured clone</a> - algorithm.</li> + <dd><p>Let <var title="">output</var> be a newly constructed empty <code><a href="#the-object-element">Object</a></code> object.</dd> - <li><p>Otherwise, let <var title="">new memory</var> be a list - consisting of the items in <var title="">memory</var> with the - addition of <var title="">input</var>.</li> + <dt>If <var title="">input</var> is another native object type (e.g. <code>Error</code>, <code><a href="#function">Function</a></code>)</dt> + <dt>If <var title="">input</var> is a host object (e.g. a DOM node)</dt> - <li><p>Create a new object, <var title="">output</var>, of the - same type as <var title="">input</var>: either an Array or an - Object.</li> + <dd><p>Throw a <code><a href="#data_clone_err">DATA_CLONE_ERR</a></code> exception and abort + the overall <a href="#structured-clone">structured clone</a> algorithm.</dd> - <li> + </dl></li> - <p>For each enumerable property in <var title="">input</var>, - add a corresponding property to <var title="">output</var> - having the same name, and having a value created from invoking - the <a href="#internal-structured-cloning-algorithm">internal structured cloning algorithm</a> - recursively with the value of the property as the "<var title="">input</var>" argument and <var title="">new - memory</var> as the "<var title="">memory</var>" argument. The - order of the properties in the <var title="">input</var> and - <var title="">output</var> objects must be the same.</p> + <li><p>Add a mapping from <var title="">input</var> (the source + object) to <var title="">output</var> (the destination object) to + <var title="">memory</var>.</li> - <p class="note">This does not walk the prototype chain.</p> + <li> - </li> + <p>If <var title="">input</var> is an Array object or an Object + object, then, for each enumerable property in <var title="">input</var>, add a corresponding property to <var title="">output</var> having the same name, and having a value + created from invoking the <a href="#internal-structured-cloning-algorithm">internal structured cloning + algorithm</a> recursively with the value of the property as the + "<var title="">input</var>" argument and <var title="">memory</var> as the "<var title="">memory</var>" + argument. The order of the properties in the <var title="">input</var> and <var title="">output</var> objects must + be the same.</p> - <li><p>Return <var title="">output</var>.</li> + <p class="note">This does not walk the prototype chain.</p> - </ol></dd> + </li> - <dt>If <var title="">input</var> is another native object type (e.g. <code>Error</code>, <code><a href="#function">Function</a></code>)</dt> - <dt>If <var title="">input</var> is a host object (e.g. a DOM node)</dt> + <li><p>Return <var title="">output</var>.</li> - <dd><p>Throw a <code><a href="#data_clone_err">DATA_CLONE_ERR</a></code> exception and abort the - overall <a href="#structured-clone">structured clone</a> algorithm.</dd> + </ol><p class="note">This algorithm preserves cycles and preserves the + identity of duplicate objects in graphs.</p> - </dl></div><h4 id="domstringmap-0"><span class="secno">2.8.6 </span>DOMStringMap</h4><p>The <code><a href="#domstringmap">DOMStringMap</a></code> interface represents a set of + </div><h4 id="domstringmap-0"><span class="secno">2.8.6 </span>DOMStringMap</h4><p>The <code><a href="#domstringmap">DOMStringMap</a></code> interface represents a set of name-value pairs. It exposes these using the scripting language's native mechanisms for property access.<div class="impl">
Received on Wednesday, 6 October 2010 22:42:26 UTC