- From: Ian Hickson via cvs-syncmail <cvsmail@w3.org>
- Date: Fri, 20 Mar 2009 22:29:06 +0000
- To: public-html-commits@w3.org
Update of /sources/public/html5/workers In directory hutz:/tmp/cvs-serv22113 Modified Files: Overview.html Log Message: Define how to determine the character encoding of worker scripts. (whatwg r2888) Index: Overview.html =================================================================== RCS file: /sources/public/html5/workers/Overview.html,v retrieving revision 1.84 retrieving revision 1.85 diff -u -d -r1.84 -r1.85 --- Overview.html 20 Mar 2009 21:09:59 -0000 1.84 +++ Overview.html 20 Mar 2009 22:29:04 -0000 1.85 @@ -252,16 +252,17 @@ <li><a href=#dedicated-workers-and-the-dedicatedworkerglobalscope-interface><span class=secno>4.1.2 </span>Dedicated workers and the <code>DedicatedWorkerGlobalScope</code> interface</a></li> <li><a href=#shared-workers-and-the-sharedworkerglobalscope-inteface><span class=secno>4.1.3 </span>Shared workers and the <code>SharedWorkerGlobalScope</code> inteface</a></ol></li> <li><a href=#base-urls-and-origins-of-workers><span class=secno>4.2 </span>Base URLs and origins of workers</a></li> - <li><a href=#the-event-loop><span class=secno>4.3 </span>The event loop</a></li> - <li><a href=#the-worker-s-ports><span class=secno>4.4 </span>The worker's ports</a></li> - <li><a href=#processing-model><span class=secno>4.5 </span>Processing model</a> + <li><a href=#decoding-scripts><span class=secno>4.3 </span>Decoding scripts</a></li> + <li><a href=#the-event-loop><span class=secno>4.4 </span>The event loop</a></li> + <li><a href=#the-worker-s-ports><span class=secno>4.5 </span>The worker's ports</a></li> + <li><a href=#processing-model><span class=secno>4.6 </span>Processing model</a> <ol> - <li><a href=#runtime-script-errors><span class=secno>4.5.1 </span>Runtime script errors</a></ol></li> - <li><a href=#creating-workers><span class=secno>4.6 </span>Creating workers</a> + <li><a href=#runtime-script-errors><span class=secno>4.6.1 </span>Runtime script errors</a></ol></li> + <li><a href=#creating-workers><span class=secno>4.7 </span>Creating workers</a> <ol> - <li><a href=#the-abstractworker-abstract-interface><span class=secno>4.6.1 </span>The <code>AbstractWorker</code> abstract interface</a></li> - <li><a href=#dedicated-workers-and-the-worker-interface><span class=secno>4.6.2 </span>Dedicated workers and the <code>Worker</code> interface</a></li> - <li><a href=#shared-workers-and-the-sharedworker-interface><span class=secno>4.6.3 </span>Shared workers and the <code>SharedWorker</code> interface</a></ol></ol></li> + <li><a href=#the-abstractworker-abstract-interface><span class=secno>4.7.1 </span>The <code>AbstractWorker</code> abstract interface</a></li> + <li><a href=#dedicated-workers-and-the-worker-interface><span class=secno>4.7.2 </span>Dedicated workers and the <code>Worker</code> interface</a></li> + <li><a href=#shared-workers-and-the-sharedworker-interface><span class=secno>4.7.3 </span>Shared workers and the <code>SharedWorker</code> interface</a></ol></ol></li> <li><a href=#apis-available-to-workers><span class=secno>5 </span>APIs available to workers</a> <ol> <li><a href=#importing-scripts-and-libraries><span class=secno>5.1 </span>Importing scripts and libraries</a></li> @@ -1080,7 +1081,74 @@ origin</span> of scripts running in workers are the <span>origin</span> of the <span>absolute URL</span> given in that the worker's <code title=dom-WorkerGlobalScope-location><a href=#dom-workerglobalscope-location>location</a></code> attribute - represents.<h3 id=the-event-loop><span class=secno>4.3 </span>The event loop</h3><p>Each <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object is asssociated with a + represents.<h3 id=decoding-scripts><span class=secno>4.3 </span>Decoding scripts</h3><p>When a user agent is to <dfn id=decode-a-script-resource>decode a script resource</dfn> to + obtain its source in Unicode, it must run the following steps:<ol><li> + + <p>Let <var title="">character encoding</var> be <i title="">unknown</i>.</p> + + </li> + + <li> + + <p>For each of the rows in the following table, starting with the + first one and going down, if the resource has as many or more + bytes available than the number of bytes in the first column, and + the first bytes of the resource match the bytes given in the first + column, then let <var title="">character encoding</var> be the + encoding given in the cell in the second column of that row:</p> + + <!-- this table is present in several forms in this file; keep them in sync --> + <table><thead><tr><th>Bytes in Hexadecimal + <th>Encoding + <tbody><!-- nobody uses this + <tr> + <td>00 00 FE FF + <td>UTF-32BE + <tr> + <td>FF FE 00 00 + <td>UTF-32LE +--><tr><td>FE FF + <td>UTF-16BE + <tr><td>FF FE + <td>UTF-16LE + <tr><td>EF BB BF + <td>UTF-8 +<!-- nobody uses this + <tr> + <td>DD 73 66 73 + <td>UTF-EBCDIC +--> + </table><p class=note>This step looks for Unicode Byte Order Marks + (BOMs).</p> + + </li> + + <li> + + <p>If <var title="">character encoding</var> is still <i title="">unknown</i>, apply the <span>algorithm for extracting an + encoding from a Content-Type</span> to the resource's <span title=Content-Type>Content Type metadata</span>; if this returns + an encoding, and the user agent supports that encoding, then let + <var title="">character encoding</var> be that encoding.</p> + + </li> + + <li> + + <p>If <var title="">character encoding</var> is still <i title="">unknown</i>, then let <var title="">character + encoding</var> be UTF-8.</p> + + </li> + + <li> + + <p>Convert the resource to Unicode using the character encoding + given by <var title="">character encoding</var>.</p> + + <p>Return the text that is so obtained.</p> + + </li> + + </ol><h3 id=the-event-loop><span class=secno>4.4 </span>The event loop</h3><p>Each <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object is asssociated with a <span>event loop</span>. This <span>event loop</span> has no associated <span>browsing context</span>, and its <span title="task queue">task queues</span> only have events, callbacks, and @@ -1095,7 +1163,7 @@ already on the queue are unaffected unless otherwise specified). Effectively, once the <a href=#dom-workerglobalscope-closing title=dom-WorkerGlobalScope-closing>closing</a> flag is true, timers stop firing, notifications for all pending asynchronous - operations are dropped, etc.<h3 id=the-worker-s-ports><span class=secno>4.4 </span>The worker's ports</h3><p>Workers communicate with other workers and with <span title="browsing context">browsing contexts</span> through <span title="channel messaging">message channels</span> and their + operations are dropped, etc.<h3 id=the-worker-s-ports><span class=secno>4.5 </span>The worker's ports</h3><p>Workers communicate with other workers and with <span title="browsing context">browsing contexts</span> through <span title="channel messaging">message channels</span> and their <code>MessagePort</code> objects.<p>Each <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> <var title="">worker global scope</var> has a list of <dfn id=the-worker-s-ports-0>the worker's ports</dfn>, which consists of all the <code>MessagePort</code> objects that are @@ -1155,7 +1223,7 @@ <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> object that is itself a <span>needed worker</span>.</li> - </ul><h3 id=processing-model><span class=secno>4.5 </span>Processing model</h3><p>When a user agent is to <dfn id=run-a-worker>run a worker</dfn> for a script with + </ul><h3 id=processing-model><span class=secno>4.6 </span>Processing model</h3><p>When a user agent is to <dfn id=run-a-worker>run a worker</dfn> for a script with <span>URL</span> <var title="">url</var>, a browsing context <var title="">owner browsing context</var>, and with global scope <var title="">worker global scope</var>, it must run the following steps:<ol><li> @@ -1174,9 +1242,8 @@ <span>fire a simple event</span> called <code title=event-error>error</code> at that object. Abort these steps.</p> - <p>If the attempt succeeds, then let <var title="">source</var> be - the text of the resource that was obtained.</p><!-- XXX do we need - to define character encoding decoding here? --> + <p>If the attempt succeeds, then <a href=#decode-a-script-resource title="decode a script + resource">decode the script resource</a> to obtain its <var title="">source</var>.</p> <p>Let <var title="">language</var> be JavaScript.</p> @@ -1367,7 +1434,7 @@ queue</span> of the port that the worker's implicit port is entangled with.</li> - </ol><h4 id=runtime-script-errors><span class=secno>4.5.1 </span>Runtime script errors</h4><p>Whenever a runtime script error occurs in one of the worker's + </ol><h4 id=runtime-script-errors><span class=secno>4.6.1 </span>Runtime script errors</h4><p>Whenever a runtime script error occurs in one of the worker's scripts, if the error did not occur while handling a previous script error, the user agent must <span>queue a task</span> to <a href=#fire-an-error-event>fire an error event</a> at the the <code><a href=#workerglobalscope>WorkerGlobalScope</a></code> @@ -1401,7 +1468,7 @@ attribute represents the <span>absolute URL</span> of the script in which the error originally occured.<p>The <dfn id=dom-errorevent-lineno title=dom-ErrorEvent-lineno><code>lineno</code></dfn> attribute represents the line number where the error occured in the - script.<h3 id=creating-workers><span class=secno>4.6 </span>Creating workers</h3><h4 id=the-abstractworker-abstract-interface><span class=secno>4.6.1 </span>The <code><a href=#abstractworker>AbstractWorker</a></code> abstract interface</h4><pre class=idl>interface <dfn id=abstractworker>AbstractWorker</dfn> { + script.<h3 id=creating-workers><span class=secno>4.7 </span>Creating workers</h3><h4 id=the-abstractworker-abstract-interface><span class=secno>4.7.1 </span>The <code><a href=#abstractworker>AbstractWorker</a></code> abstract interface</h4><pre class=idl>interface <dfn id=abstractworker>AbstractWorker</dfn> { attribute <span>EventListener</span> <a href=#handler-abstractworker-onerror title=handler-AbstractWorker-onerror>onerror</a>; attribute <span>EventListener</span> <a href=#handler-abstractworker-onclose title=handler-AbstractWorker-onclose>onclose</a>; };</pre><p>Objects implementing the <code><a href=#abstractworker>AbstractWorker</a></code> interface @@ -1417,7 +1484,7 @@ <dd><p>Must be invoked whenever an <code title=event-close>close</code> event is targeted at or bubbles through the <code><a href=#abstractworker>AbstractWorker</a></code> object.</dd> - </dl><h4 id=dedicated-workers-and-the-worker-interface><span class=secno>4.6.2 </span>Dedicated workers and the <code><a href=#worker>Worker</a></code> interface</h4><pre class=idl>[<a href=#dom-worker title=dom-Worker>Constructor</a>(in DOMString scriptURL)] + </dl><h4 id=dedicated-workers-and-the-worker-interface><span class=secno>4.7.2 </span>Dedicated workers and the <code><a href=#worker>Worker</a></code> interface</h4><pre class=idl>[<a href=#dom-worker title=dom-Worker>Constructor</a>(in DOMString scriptURL)] interface <dfn id=worker>Worker</dfn> : <a href=#abstractworker>AbstractWorker</a> { void <a href=#dom-worker-terminate title=dom-Worker-terminate>terminate</a>(); @@ -1497,7 +1564,7 @@ </li> - </ol><h4 id=shared-workers-and-the-sharedworker-interface><span class=secno>4.6.3 </span>Shared workers and the <code><a href=#sharedworker>SharedWorker</a></code> interface</h4><pre class=idl>[<a href=#dom-sharedworker title=dom-SharedWorker>Constructor</a>(in DOMString scriptURL, in DOMString name)] + </ol><h4 id=shared-workers-and-the-sharedworker-interface><span class=secno>4.7.3 </span>Shared workers and the <code><a href=#sharedworker>SharedWorker</a></code> interface</h4><pre class=idl>[<a href=#dom-sharedworker title=dom-SharedWorker>Constructor</a>(in DOMString scriptURL, in DOMString name)] interface <dfn id=sharedworker>SharedWorker</dfn> : <a href=#abstractworker>AbstractWorker</a> { readonly attribute <span>MessagePort</span> <a href=#dom-sharedworker-port title=dom-SharedWorker-port>port</a>; };</pre><p>The <dfn id=dom-sharedworker-port title=dom-SharedWorker-port><code>port</code></dfn> @@ -1664,9 +1731,10 @@ <code>NETWORK_ERR</code> exception and abort all these steps.</p> - <p>If the fetching attempt succeeded, then let <var title="">source</var> be the text of the resource that was - obtained, and let <var title="">language</var> be - JavaScript.</p> + <p>If the attempt succeeds, then <a href=#decode-a-script-resource title="decode a script + resource">decode the script resource</a> to obtain its <var title="">source</var>.</p> + + <p>Let <var title="">language</var> be JavaScript.</p> <p class=note>As with the worker's script, the script here is always assumed to be JavaScript, regardless of the MIME
Received on Friday, 20 March 2009 22:29:21 UTC