html5/spec Overview.html,1.1257,1.1258

Update of /sources/public/html5/spec
In directory hutz:/tmp/cvs-serv29948

Modified Files:
	Overview.html 
Log Message:
Further work on the event loop front. (WebSockets, postMessage, MessagePorts, setTimeout) (whatwg r2085)

Index: Overview.html
===================================================================
RCS file: /sources/public/html5/spec/Overview.html,v
retrieving revision 1.1257
retrieving revision 1.1258
diff -u -d -r1.1257 -r1.1258
--- Overview.html	19 Aug 2008 09:00:33 -0000	1.1257
+++ Overview.html	19 Aug 2008 09:30:32 -0000	1.1258
@@ -30858,10 +30858,10 @@
   <h4 id=processing1><span class=secno>4.12.6 </span>Processing model</h4>
   <!-- ua side -->
 
-  <p>The <span>event source</span> for all <a href="#tasks"
+  <p>The <a href="#task-source">task source</a> for all <a href="#tasks"
    title=concept-task>tasks</a> <a href="#queue" title="queue a
    task">queued</a> by algorithms in this section and its subsections is the
-   <dfn id=template1>template event source</dfn>.
+   <dfn id=template1>template task source</dfn>.
 
   <h5 id=the-originalcontent><span class=secno>4.12.6.1. </span>The <code
    title=dom-originalContent><a
@@ -42883,6 +42883,17 @@
    title=dom-MessageEvent-messagePort><a
    href="#messageport">messagePort</a></code> attribute must be null.
 
+  <hr>
+
+  <p><a href="#tasks" title=concept-task>Tasks</a> in <a
+   href="#server-sent">server-sent events</a> and <a href="#web-sockets">Web
+   Sockets</a> use their own <a href="#task-source" title="task source">task
+   sources</a>, but the <a href="#task-source">task source</a> for the <a
+   href="#tasks" title=concept-task>tasks</a> in <a
+   href="#cross-document">cross-document messaging</a> and <a
+   href="#channel0">channel messaging</a> is the <dfn id=posted>posted
+   message task source</dfn>.
+
   <h3 id=server-sent-events><span class=secno>7.2 </span><dfn
    id=server-sent>Server-sent events</dfn></h3>
   <!-- eventsource -->
@@ -42950,8 +42961,9 @@
      href="#absolute">absolute URL</a>.</p>
 
     <p>As data is received, the <a href="#tasks" title=concept-task>tasks</a>
-     queued by the <span>networking event source</span> to handle the data
-     must consist of following the rules given in the following sections.</p>
+     queued by the <a href="#networking">networking task source</a> to handle
+     the data must consist of following the rules given in the following
+     sections.</p>
   </ol>
 
   <p>When an event source is removed from the list of event sources for an
@@ -43454,8 +43466,8 @@
    <dt><dfn id=open3 title=dom-WebSocket-OPEN><code>OPEN</code></dfn>
     (numeric value 1)
 
-   <dd>The <a href="#web-socket">Web Socket connection is established</a> and
-    communication is possible.
+   <dd>The <a href="#web-socket0">Web Socket connection is established</a>
+    and communication is possible.
 
    <dt><dfn id=closed title=dom-WebSocket-CLOSED><code>CLOSED</code></dfn>
     (numeric value 2)
@@ -43492,7 +43504,7 @@
   <h4 id=websocket><span class=secno>7.3.3 </span>WebSocket Events</h4>
 
   <p>The <dfn id=open4 title=event-WebSocket-open><code>open</code></dfn>
-   event is fired when the <a href="#web-socket">Web Socket connection is
+   event is fired when the <a href="#web-socket0">Web Socket connection is
    established</a>.
 
   <p>The <dfn id=close1 title=event-WebSocket-close><code>close</code></dfn>
@@ -43507,16 +43519,6 @@
   <p>The <code title=event-message><a href="#message2">message</a></code>
    event is fired when when data is received for a connection.
 
-  <p>Events that would be fired during script execution (e.g. between the
-   <code><a href="#websocket0">WebSocket</a></code> object being created
-   &mdash; and thus the connection being established &mdash; and the current
-   script completing; or, during the execution of a <code
-   title=event-message><a href="#message2">message</a></code> event handler)
-   must be buffered, and those events queued up and each one individually
-   fired after the script has completed.</p>
-  <!-- XXX make this more generic
-  -->
-
   <hr>
 
   <p>The following are the <a href="#event6">event handler DOM attributes</a>
@@ -43552,6 +43554,11 @@
 
   <h4 id=the-web><span class=secno>7.3.4 </span>The Web Socket protocol</h4>
 
+  <p>The <a href="#task-source">task source</a> for all <a href="#tasks"
+   title=concept-task>tasks</a> <a href="#queue" title="queue a
+   task">queued</a> by algorithms in this section and its subsections is the
+   <dfn id=web-socket>Web Socket task source</dfn>.
+
   <h5 id=client-side><span class=secno>7.3.4.1. </span>Client-side
    requirements</h5>
 
@@ -43912,13 +43919,14 @@
      title=dom-WebSocket-OPEN><a href="#open3">OPEN</a></code> (1).</p>
 
    <li>
-    <p><a href="#firing2">Fire a simple event</a> named <code
-     title=event-WebSocket-open><a href="#open4">open</a></code> at the
-     <code><a href="#websocket0">WebSocket</a></code> object.</p>
+    <p><a href="#queue">Queue a task</a> to <a href="#firing2">fire a simple
+     event</a> named <code title=event-WebSocket-open><a
+     href="#open4">open</a></code> at the <code><a
+     href="#websocket0">WebSocket</a></code> object.</p>
 
    <li>
-    <p>The <dfn id=web-socket>Web Socket connection is established</dfn>. Now
-     the user agent must send and receive to and from the connection as
+    <p>The <dfn id=web-socket0>Web Socket connection is established</dfn>.
+     Now the user agent must send and receive to and from the connection as
      described in the next section.</p>
   </ol>
 
@@ -43930,7 +43938,7 @@
 
   <h6 id=data-framing><span class=secno>7.3.4.1.2. </span>Data framing</h6>
 
-  <p>Once a <a href="#web-socket">Web Socket connection is established</a>,
+  <p>Once a <a href="#web-socket0">Web Socket connection is established</a>,
    the user agent must run through the following state machine for the bytes
    sent by the server.
 
@@ -43939,7 +43947,7 @@
     <p>Try to read a byte from the server. Let <var title="">frame type</var>
      be that byte.</p>
 
-    <p>If no byte could be read because the <a href="#web-socket0">Web Socket
+    <p>If no byte could be read because the <a href="#web-socket1">Web Socket
      connection is closed</a>, then abort.</p>
 
    <li>
@@ -43952,7 +43960,7 @@
 
      <dd>
       <p>Run these steps. If at any point during these steps a read is
-       attempted but fails because the <a href="#web-socket0">Web Socket
+       attempted but fails because the <a href="#web-socket1">Web Socket
        connection is closed</a>, then abort.</p>
 
       <ol>
@@ -43992,7 +44000,7 @@
 
      <dd>
       <p>Run these steps. If at any point during these steps a read is
-       attempted but fails because the <a href="#web-socket0">Web Socket
+       attempted but fails because the <a href="#web-socket1">Web Socket
        connection is closed</a>, then abort.</p>
 
       <ol>
@@ -44019,9 +44027,10 @@
          href="#message2">message</a></code>, which does not bubble, is
          cancelable, has no default action, and whose <code
          title=dom-MessageEvent-data><a href="#data4">data</a></code>
-         attribute is set to <var title="">data</var>, and dispatch it at the
-         <code><a href="#websocket0">WebSocket</a></code> object. Otherwise,
-         discard the data.
+         attribute is set to <var title="">data</var>, and <a
+         href="#queue">queue a task</a> to dispatch it at the <code><a
+         href="#websocket0">WebSocket</a></code> object. Otherwise, discard
+         the data.
       </ol>
     </dl>
 
@@ -44035,7 +44044,7 @@
 
   <hr>
 
-  <p>Once a <a href="#web-socket">Web Socket connection is established</a>,
+  <p>Once a <a href="#web-socket0">Web Socket connection is established</a>,
    the user agent must use the following steps to <dfn id=send->send <var
    title="">data</var> using the Web Socket</dfn>:
 
@@ -44220,7 +44229,7 @@
   <p>To <dfn id=close2>close the Web Socket connection</dfn>, either the user
    agent or the server closes the TCP/IP connection. There is no closing
    handshake. Whether the user agent or the server closes the connection, it
-   is said that the <dfn id=web-socket0>Web Socket connection is
+   is said that the <dfn id=web-socket1>Web Socket connection is
    closed</dfn>.
 
   <p>Servers may <a href="#close2">close the Web Socket connection</a>
@@ -44229,14 +44238,15 @@
   <p>User agents should not <a href="#close2">close the Web Socket
    connection</a> arbitrarily.
 
-  <p id=closeWebSocket>When the <a href="#web-socket0">Web Socket connection
+  <p id=closeWebSocket>When the <a href="#web-socket1">Web Socket connection
    is closed</a>, the <code title=dom-WebSocket-readyState><a
    href="#readystate1">readyState</a></code> attribute's value must be
    changed to <code title=dom-WebSocket-CLOSED><a
    href="#closed">CLOSED</a></code> (2), and the user agent must <a
-   href="#firing2">fire a simple event</a> named <code
-   title=event-WebSocket-close><a href="#close1">close</a></code> at the
-   <code><a href="#websocket0">WebSocket</a></code> object.
+   href="#queue">queue a task</a> to <a href="#firing2">fire a simple
+   event</a> named <code title=event-WebSocket-close><a
+   href="#close1">close</a></code> at the <code><a
+   href="#websocket0">WebSocket</a></code> object.
 
   <h3 id=crossDocumentMessages><span class=secno>7.4 </span><dfn
    id=cross-document>Cross-document messaging</dfn></h3>
@@ -44344,14 +44354,6 @@
      continue running these steps.</p>
 
    <li>
-    <p>Wait for all scripts in the <a href="#unit-of">unit of related
-     browsing contexts</a> to which the <code><a
-     href="#window">Window</a></code> object on which the method was invoked
-     belongs to have finished executing any pending scripts.</p>
-    <!-- XXX define this in terms of the
-    event queue -->
-
-   <li>
     <p>If the <var title="">targetOrigin</var> argument has a value other
      than a single literal U+002A ASTERISK character ("*"), and the <a
      href="#active">active document</a> of the <a href="#browsing1">browsing
@@ -44387,9 +44389,11 @@
     
 
    <li>
-    <p>Dispatch the event created in the previous step at the <code><a
-     href="#window">Window</a></code> object on which the method was invoked.</p>
-    <!-- XXX define this in terms of the event queue -->
+    <p><a href="#queue">Queue a task</a> to dispatch the event created in the
+     previous step at the <code><a href="#window">Window</a></code> object on
+     which the method was invoked. The <a href="#task-source">task source</a>
+     for this <a href="#tasks" title=concept-task>task</a> is the <a
+     href="#posted">posted message task source</a>.</p>
     <!-- XXX apply any body/window dispatch decisions here -->
   </ol>
 
@@ -44431,14 +44435,6 @@
      continue running these steps.</p>
 
    <li>
-    <p>Wait for all scripts in the <a href="#unit-of">unit of related
-     browsing contexts</a> to which the <code><a
-     href="#window">Window</a></code> object on which the method was invoked
-     belongs to have finished executing any pending scripts.</p>
-    <!-- XXX define this in terms of the
-    event queue -->
-
-   <li>
     <p>If the <var title="">targetOrigin</var> argument has a value other
      than a single literal U+002A ASTERISK character ("*"), and the <a
      href="#active">active document</a> of the <a href="#browsing1">browsing
@@ -44479,9 +44475,11 @@
      <var title="">new port</var>.</p>
 
    <li>
-    <p>Dispatch the event created in the previous step at the <code><a
-     href="#window">Window</a></code> object on which the method was invoked.</p>
-    <!-- XXX define this in terms of the event queue -->
+    <p><a href="#queue">Queue a task</a> to dispatch the event created in the
+     previous step at the <code><a href="#window">Window</a></code> object on
+     which the method was invoked. The <a href="#task-source">task source</a>
+     for this <a href="#tasks" title=concept-task>task</a> is the <a
+     href="#posted">posted message task source</a>.</p>
     <!-- XXX apply any body/window dispatch decisions here -->
   </ol>
 
@@ -44812,23 +44810,32 @@
    its port's <a href="#port-message">port message queue</a>, if it is not
    already open.
 
-  <p>When a port's <a href="#port-message">port message queue</a> is open and
-   contains an event, the user agent must, at the earliest opportunity, after
-   any scripts have finished executing<!-- XXX queue -->, dispatch the first
+  <p>When a port's <a href="#port-message">port message queue</a> is open,
+   contains an event, and its owner is <a href="#available" title="port owner
+   available">available</a>, the user agent must <a href="#queue">queue a
+   task</a> in the <a href="#event3">event loop</a> to dispatch the first
    event in the queue on the <code><a
    href="#messageport0">MessagePort</a></code> object, and remove the event
-   from the queue.
+   from the queue. The <a href="#task-source">task source</a> for this <a
+   href="#tasks" title=concept-task>task</a> is the <a href="#posted">posted
+   message task source</a>.
 
-  <p>If the <code><a href="#messageport0">MessagePort</a></code> is owned by
-   a <code><a href="#window">Window</a></code> object and the
+  <p>A <code><a href="#messageport0">MessagePort</a></code>'s owner is <dfn
+   id=available title="port owner available">available</dfn> if the <code><a
+   href="#messageport0">MessagePort</a></code> is owned by an object other
+   than a <code><a href="#window">Window</a></code> object, or if it is owned
+   by a <code><a href="#window">Window</a></code> object and the
    <code>Document</code> that was the <a href="#active">active document</a>
    in that <a href="#browsing1">browsing context</a> when the <code><a
-   href="#messageport0">MessagePort</a></code> was created is not <a
-   href="#fully">fully active</a>, then an opportunity doesn't exist &mdash;
-   events in such cases must only be dispatched once the
-   <code>Document</code> in question becomes <a href="#fully">fully
-   active</a>. If that doesn't happen before that <code>Document</code> is
-   discarded, then the events are lost.
+   href="#messageport0">MessagePort</a></code> was created is <a
+   href="#fully">fully active</a>. If that <code>Document</code> is discarded
+   before the port's owner becomes available, then the events are lost.</p>
+  <!-- XXX when we have sorted out the global object mess, if that
+  makes this easier to fix, then fix it better. (e.g. maybe just say
+  that callback tasks aren't processed if they involve firing a
+  callback that wouldn't fire because the code is swapped out? not
+  sure how you'd handle prioritisation, i guess you'd just pretend
+  those events weren't there for the time being) -->
 
   <hr>
 
@@ -44842,14 +44849,20 @@
     <p>Unentangle the two ports.
 
    <li>
-    <p>At the next available opportunity, after any scripts have finished
-     executing<!-- XXX queue -->, <a href="#firing2">fire a simple event</a>
-     called <code title=event-unload>unload</code> at each of the message
-     ports. If the two message ports are in the same <a href="#unit-of">unit
-     of related browsing contexts</a>, then the port on which the method was
-     called must receive the event first.
+    <p><a href="#queue">Queue a task</a> to <a href="#firing2">fire a simple
+     event</a> called <code title=event-unload>unload</code> at the port on
+     which the method was called.
+
+   <li>
+    <p><a href="#queue">Queue a task</a> to <a href="#firing2">fire a simple
+     event</a> called <code title=event-unload>unload</code> at the other
+     port.
   </ol>
 
+  <p>The <a href="#task-source">task source</a> for the two <a href="#tasks"
+   title=concept-task>tasks</a> above is the <a href="#posted">posted message
+   task source</a>.
+
   <p>If the method is called on a port that is not entangled, then the method
    must do nothing.
 
@@ -44919,10 +44932,11 @@
     <p>Unentangle the two ports.
 
    <li>
-    <p>At the next available opportunity, after any scripts have finished
-     executing<!-- XXX queue -->, <a href="#firing2">fire a simple event</a>
-     called <code title=event-unload>unload</code> at <var title="">surviving
-     port</var>.
+    <p><a href="#queue">Queue a task</a> to <a href="#firing2">fire a simple
+     event</a> called <code title=event-unload>unload</code> at <var
+     title="">surviving port</var>. The <a href="#task-source">task
+     source</a> for this <a href="#tasks" title=concept-task>task</a> is the
+     <a href="#posted">posted message task source</a>.
   </ol>
 
   <h5 id=ports0><span class=secno>7.5.3.2. </span>Ports and garbage
@@ -55469,8 +55483,9 @@
 
   <h3 id=timers><span class=secno>10.4 </span>Timers</h3>
 
-  <p class=big-issue>This section is expected to be moved to the Window
-   Object specification in due course.
+  <p class=big-issue>This section is expected to be moved to its own
+   specification in due course. It needs a lot of work to actually make it
+   into a semi-decent spec.
 
   <p>Objects that implement the <code><a href="#window">Window</a></code>
    interface must also implement the <code><a
@@ -55509,19 +55524,22 @@
    <code><a href="#timeouthandler">TimeoutHandler</a></code> object and a
    length of time in milliseconds. It must return a handle to the timeout
    created, and then asynchronously wait <var title="">timeout</var>
-   milliseconds and then invoke <code>handleEvent()</code> on the <var
-   title="">handler</var> object. If any <var title="">arguments...</var>
-   were provided, they must be passed to the <var title="">handler</var> as
-   arguments to the <code>handleEvent()</code> function.
+   milliseconds and then <a href="#queue">queue a task</a> to invoke
+   <code>handleEvent()</code> on the <var title="">handler</var> object. If
+   any <var title="">arguments...</var> were provided, they must be passed to
+   the <var title="">handler</var> as arguments to the
+   <code>handleEvent()</code> function.
 
   <p>Alternatively, <dfn id=settimeout0 title=""><code>setTimeout(<var
    title="">code</var>, <var title="">timeout</var>[, <var
    title="">language</var>])</code></dfn> may be used. This variant takes a
    string instead of a <code><a
-   href="#timeouthandler">TimeoutHandler</a></code> object. That string must
-   be parsed using the specified <var title="">language</var> (defaulting to
-   ECMAScript if the third argument is omitted) and executed in the scope of
-   the <a href="#browsing1">browsing context</a> associated with the <code><a
+   href="#timeouthandler">TimeoutHandler</a></code> object. <span
+   title=big-issue>define the actual requirements for this method, as with
+   the previous one.</span> That string must be parsed using the specified
+   <var title="">language</var> (defaulting to ECMAScript if the third
+   argument is omitted) and executed in the scope of the <a
+   href="#browsing1">browsing context</a> associated with the <code><a
    href="#window">Window</a></code> object on which the <code
    title=setTimeout>setTimeout()</code> method was invoked.
 
@@ -55531,9 +55549,10 @@
    title=dom-windowtimers-setInterval><code>setInterval(...)</code></dfn>
    variants must work in the same way as the <code>setTimeout</code> variants
    except that if <var title="">timeout</var> is a value greater than zero,
-   the <var title="">handler</var> or <code><a href="#code">code</a></code>
-   must be invoked again every <var title="">timeout</var> milliseconds, not
-   just the once.</p>
+   the <a href="#tasks" title=concept-task>task</a> that invokes the <var
+   title="">handler</var> or <code><a href="#code">code</a></code> must be <a
+   href="#queue" title="queue a task">queued</a> again every <var
+   title="">timeout</var> milliseconds, not just the once.</p>
   <!-- so
   setInterval(x) and setInterval(x, 0) are equivalent to setTimeout(x)
   and setTimeout(x, 0) respectively -->
@@ -55551,10 +55570,6 @@
    correspond to an active timeout or interval, the methods must return
    without doing anything.
 
-  <p>Timeouts must never fire while another script is executing. (Thus the
-   HTML scripting model is strictly single-threaded and not reentrant.)</p>
-  <!-- XXX queue -->
-
   <h2 class=no-num id=index>Index</h2>
 
   <p><em>This section is non-normative.</em>

Received on Tuesday, 19 August 2008 09:31:11 UTC