[html5] r2074 - [] (0) Define event loops, task queues, etc; Make 'fetching' use this mechanism [...]

whatwg at whatwg.org whatwg at whatwg.org
Fri Aug 15 17:52:21 PDT 2008


Author: ianh
Date: 2008-08-15 17:52:20 -0700 (Fri, 15 Aug 2008)
New Revision: 2074

Modified:
   index
   source
Log:
[] (0) Define event loops, task queues, etc; Make 'fetching' use this mechanism (everything will in due course); Fix some cross-references around 'interactive content'.

/home/ianh/svn/webapps/hooks/commit-email.pl: `/usr/bin/svnlook diff /home/ianh/svn/webapps -r 2074' failed with this output:
Modified: index
===================================================================
--- index	2008-08-14 22:09:57 UTC (rev 2073)
+++ index	2008-08-16 00:52:20 UTC (rev 2074)
@@ -28,7 +28,7 @@
 
    <h1 id=html-5>HTML 5</h1>
 
-   <h2 class="no-num no-toc" id=draft>Draft Recommendation — 14 August
+   <h2 class="no-num no-toc" id=draft>Draft Recommendation — 16 August
     2008</h2>
 
    <p>You can take part in this work. <a
@@ -5474,23 +5474,34 @@
 
    <li>
     <p>Perform the remaining steps asynchronously.
-   </li>
-   <!-- XXX queue interaction -->
 
    <li>
     <p>If the resource identified by the resulting <a
      href="#absolute">absolute URL</a> is already being downloaded for other
-     reasons (e.g. another invocation of this algorithm), then the results of
-     that existing download process may be used for the purposes of this one,
-     in which case the following step must be skipped.
+     reasons (e.g. another invocation of this algorithm), and the resource is
+     to be obtained using a idempotent action (such as an HTTP GET or
+     equivalent), and the user agent is configured such that it is to reuse
+     the data from the existing download instead of initiating a new one,
+     then use the results of the existing download instead of starting a new
+     one.</p>
 
+    <p>Otherwise, at a time convenient to the user and the user agent,
+     download the resource, applying the semantics of the relevant
+     specifications (e.g. performing an HTTP GET or POST operation, or
+     reading the file from disk, following redirects, <a href="#dereferenced"
+     title=concept-js-deref>dereferencing <span title="javascript
+     protocol"><code title="">javascript:</code> URLs</span></a>, etc).</p>
+
    <li>
-    <p>At a time convenient to the user and the user agent, download the
-     resource, applying the semantics of the relevant specifications (e.g.
-     performing an HTTP GET or POST operation, or reading the file from disk,
-     following redirects, <a href="#dereferenced"
-     title=concept-js-deref>dereferencing <span title="javascript
-     protocol"><code title="">javascript:</code> URLs</span></a>, etc).
+    <p>When the resource is available, <a href="#queue">queue a task</a> that
+     uses the resource as appropriate. If the resource can be processed
+     incrementally, as, for instance, with a progressively interlaced JPEG or
+     an HTML file, multiple tasks may be queued to process the data as it is
+     downloaded. The <a href="#task-source">task source</a> for these tasks
+     is the <dfn id=networking>networking task source</dfn>.</p>
+    <!-- XXX make sure each use of 'fetch' defines what the appropriate
+   task is -->
+    
   </ol>
 
   <p class=note>The <span>offline application cache</span> processing model
@@ -7687,7 +7698,7 @@
            attribute DOMString <a href="#registrationmark0" title=dom-registrationMark>registrationMark</a>;
   readonly attribute DocumentFragment <a href="#originalcontent" title=dom-originalContent>originalContent</a>;
 
-  // <a href="#event5">event handler DOM attributes</a>
+  // <a href="#event6">event handler DOM attributes</a>
            attribute <span>EventListener</span> <a href="#onabort" title=handler-onabort>onabort</a>;
            attribute <span>EventListener</span> <a href="#onbeforeunload" title=handler-onbeforeunload>onbeforeunload</a>;
            attribute <span>EventListener</span> <a href="#onblur" title=handler-onblur>onblur</a>;
@@ -7771,7 +7782,7 @@
    <dd><code title=attr-title><a href="#title">title</a></code>
   </dl>
 
-  <p>In addition, the following <a href="#event4">event handler content
+  <p>In addition, the following <a href="#event5">event handler content
    attributes</a> may be specified on any <span>HTML element</span>:
 
   <dl class=element>
@@ -8547,9 +8558,6 @@
   <!-- XXX WF2: when this is merged into
   this spec, update xrefs -->
 
-  <p class=note>Most interactive elements have content models that disallow
-   nesting interactive elements.
-
   <h4 id=transparent><span class=secno>3.4.2 </span>Transparent content
    models</h4>
 
@@ -13128,9 +13136,10 @@
 
   <p class=note>One way that a user agent can enable users to follow
    hyperlinks is by allowing <code><a href="#a">a</a></code> elements to be
-   clicked, or focussed and activated by the keyboard. This <span
-   title="interactive elements">will cause</span> the aforementioned <a
-   href="#activation0">activation behavior</a> to be invoked.
+   clicked, or focussed and activated by the keyboard. This <a
+   href="#interactive1" title="interactive content">will cause</a> the
+   aforementioned <a href="#activation0">activation behavior</a> to be
+   invoked.
 
   <p>The DOM attributes <dfn id=href3
    title=dom-a-href><code>href</code></dfn>, <dfn id=ping0
@@ -13151,7 +13160,7 @@
   <div class=example>
    <p>The <code><a href="#a">a</a></code> element may be wrapped around
     entire paragraphs, lists, tables, and so forth, even entire sections, so
-    long as there are no interactive elements within (e.g. buttons or other
+    long as there is no interactive content within (e.g. buttons or other
     links). This example shows how this can be used to make an entire
     advertising block into a link:</p>
 
@@ -18239,7 +18248,6 @@
 
   <hr>
   <!-- XXX
-   make it an interactive element
    default activation behavior is to do the play() if paused, pause()
    otherwise
   -->
@@ -23884,9 +23892,10 @@
 
   <p class=note>One way that a user agent can enable users to follow
    hyperlinks is by allowing <code><a href="#area">area</a></code> elements
-   to be clicked, or focussed and activated by the keyboard. This <span
-   title="interactive elements">will cause</span> the aforementioned <a
-   href="#activation0">activation behavior</a> to be invoked.
+   to be clicked, or focussed and activated by the keyboard. This <a
+   href="#interactive1" title="interactive content">will cause</a> the
+   aforementioned <a href="#activation0">activation behavior</a> to be
+   invoked.
 
   <p>The DOM attributes <dfn id=alt3
    title=dom-area-alt><code>alt</code></dfn>, <dfn id=coords0
@@ -27132,7 +27141,7 @@
 
    <dd><a href="#flow-content0">Flow content</a>.
 
-   <dd><span>Interactive element</span>.
+   <dd><a href="#interactive1">Interactive content</a>.
 
    <dd><a href="#sectioning1">Sectioning root</a>.
 
@@ -31685,9 +31694,10 @@
    <li>
     <p>If the <a href="#parent">parent browsing context</a>'s <a
      href="#active">active document</a> does not have the <span>same</span>
-     <span>effective origin</span> as the script that is accessing the <code
-     title=dom-frameElement><a href="#frameelement">frameElement</a></code>
-     attribute, then throw a <a href="#security10">security exception</a>.
+     <a href="#effective3">effective script origin</a> as the script that is
+     accessing the <code title=dom-frameElement><a
+     href="#frameelement">frameElement</a></code> attribute, then throw a <a
+     href="#security10">security exception</a>.
 
    <li>
     <p>Otherwise, return the <a href="#browsing2">browsing context
@@ -31790,6 +31800,16 @@
    reachable browsing contexts</a> forms a <dfn id=unit-of>unit of related
    browsing contexts</dfn>.
 
+  <p>Each <a href="#unit-of">unit of related browsing contexts</a> is then
+   further divided into the smallest number of groups such that every member
+   of each group has an <a href="#effective3">effective script origin</a>
+   that, through appropriate manipulation of the <code
+   title=dom-document-domain><a href="#domain">document.domain</a></code>
+   attribute, could be made to be the same as other members of the group, but
+   could not be made the same as members of any other group. Each such group
+   is a <dfn id=unit-of0>unit of related similar-origin browsing
+   contexts</dfn>.
+
   <h4 id=browsing><span class=secno>5.1.6 </span>Browsing context names</h4>
 
   <p>Browsing contexts can have a <dfn id=browsing3>browsing context
@@ -31958,7 +31978,7 @@
   void <a href="#postmessage0" title=dom-window-postMessage-2>postMessage</a>(in DOMString message, in DOMString targetOrigin);
   void <a href="#postmessage1" title=dom-window-postMessage-3>postMessage</a>(in DOMString message, in <a href="#messageport0">MessagePort</a> messagePort, in DOMString targetOrigin);
 
-  // <a href="#event5">event handler DOM attributes</a>
+  // <a href="#event6">event handler DOM attributes</a>
            attribute <span>EventListener</span> <a href="#onabort" title=handler-onabort>onabort</a>;
            attribute <span>EventListener</span> <a href="#onbeforeunload" title=handler-onbeforeunload>onbeforeunload</a>;
            attribute <span>EventListener</span> <a href="#onblur" title=handler-onblur>onblur</a>;
@@ -32246,7 +32266,7 @@
      <dd>The owner is the <code>Document</code> to which the <code><a
       href="#script1">script</a></code> element belongs.
 
-     <dt>If a script is in an <a href="#event4" title="event handler content
+     <dt>If a script is in an <a href="#event5" title="event handler content
       attributes">event handler content attribute</a>
 
      <dd>The owner is the <code>Document</code> to which the attribute node
@@ -32591,8 +32611,8 @@
     rule in a CSS <code><a href="#style1">style</a></code> element block).
 
    <li>Event handlers, whether registered through the DOM using <code
-    title="">addEventListener()</code>, by explicit <a href="#event4">event
-    handler content attributes</a>, by <a href="#event5">event handler DOM
+    title="">addEventListener()</code>, by explicit <a href="#event5">event
+    handler content attributes</a>, by <a href="#event6">event handler DOM
     attributes</a>, or otherwise.
 
    <li>Processing of technologies like XBL or SVG that have their own
@@ -32684,9 +32704,95 @@
 
   <h4 id=event><span class=secno>5.4.2 </span>Event loops</h4>
 
-  <p class=big-issue>...</p>
-  <!-- XXXqueue-->
+  <p>To coordinate events, user interaction, scripts, rendering, networking,
+   and so forth, user agents must use <dfn id=event3 title="event loop">event
+   loops</dfn> as described in this section.
 
+  <p>There must be at least one <a href="#event3">event loop</a> per user
+   agent, and at most one <a href="#event3">event loop</a> per <a
+   href="#unit-of0">unit of related similar-origin browsing contexts</a>.
+
+  <p>An <a href="#event3">event loop</a> always has at least one <a
+   href="#browsing1">browsing context</a>. If an <a href="#event3">event
+   loop</a>'s <a href="#browsing1" title="browsing context">browsing
+   contexts</a> all go away, then the <a href="#event3">event loop</a> goes
+   away as well. A <a href="#browsing1">browsing context</a> always has an <a
+   href="#event3">event loop</a> coordinating its activities.
+
+  <p>An <a href="#event3">event loop</a> has one or more <dfn id=task-queues
+   title="task queue">task queues</dfn>. A <a href="#task-queues">task
+   queue</a> is an ordered list of:
+
+  <dl>
+   <dt>Events
+
+   <dd>
+    <p>Asynchronously dispatching an <code>Event</code> object at a
+     particular <code>EventTarget</code> object is a task.</p>
+
+    <p class=note>Not all events are dispatched using the <a
+     href="#task-queues">task queue</a>, many are dispatched synchronously
+     during other tasks.</p>
+
+   <dt>Parsing
+
+   <dd>
+    <p>The <a href="#html-0">HTML parser</a> tokenising a single byte, and
+     then processing any resulting tokens, is a task.
+
+   <dt>Callbacks
+
+   <dd>
+    <p>Calling a callback asynchronously is a task.
+
+   <dt>Using a resource
+
+   <dd>
+    <p>When an algorithm <a href="#fetch" title=fetch>fetches</a> a resource,
+     if the fetching occurs asynchronously then the processing of the
+     resource once some or all of the resource is available is a task.
+  </dl>
+
+  <p>When a user agent is to <dfn id=queue>queue a task</dfn>, it must add
+   the given task to one of the <a href="#task-queues" title="task
+   queue">task queues</a> of the relevant <a href="#event3">event loop</a>.
+   All the tasks from one particular <dfn id=task-source>task source</dfn>
+   (e.g. the callbacks generated by timers, the events dispatched for mouse
+   movements, the tasks queued for the parser) must always be added to the
+   same <a href="#task-queues">task queue</a>, but tasks from different <a
+   href="#task-source" title="task source">task sources</a> may be placed in
+   different <a href="#task-queues" title="task queue">task queues</a>.
+
+  <p class=example>For example, a user agent could have one <a
+   href="#task-queues">task queue</a> for mouse and key events (the
+   <span>user interaction task source</span><!-- XXX xref -->), and another
+   for everything else. The user agent could then give keyboard and mouse
+   events preference over other tasks three quarters of the time, keeping the
+   interface responsive but not starving other task queues, and never
+   processing events from any one <a href="#task-source">task source</a> out
+   of order.
+
+  <p>An <a href="#event3">event loop</a> must continually run through the
+   following steps for as long as it exists:
+
+  <ol>
+   <li>
+    <p>Run the oldest task on one of the <a href="#event3">event loop</a>'s
+     <a href="#task-queues" title="task queue">task queues</a>. The user
+     agent may pick any <a href="#task-queues">task queue</a>.
+
+   <li>
+    <p>Remove that task from its <a href="#task-queues">task queue</a>.
+
+   <li>
+    <p>If necessary, update the rendering or user interface of any
+     <code>Document</code> or <a href="#browsing1">browsing context</a> to
+     reflect the current state.
+
+   <li>
+    <p>Return to the first step of the <a href="#event3">event loop</a>.
+  </ol>
+
   <h4 id=security4><span class=secno>5.4.3 </span>Security exceptions</h4>
 
   <p class=big-issue>Define <dfn id=security10>security exception</dfn>.</p>
@@ -32793,13 +32899,13 @@
    handler attributes</h5>
   <!-- http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E%0A...%3Cscript%3E%0Aw(a%3Ddocument.implementation.createDocument(null%2C%20null%2C%20null))%3B%0Aw(a.appendChild(a.createElementNS('http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml'%2C%20'html')))%3B%0Aw(b%3Da.firstChild.appendChild(a.createElementNS('http%3A%2F%2Fwww.w3.org%2F1999%2Fxhtml'%2C%20'body')))%3B%0Aw(b.test%20%3D%20w)%3B%0Aw(b.setAttribute('onclick'%2C%20'test(%22fire%3A%20%22%20%2B%20event)'))%3B%0Aw(b.onclick)%3B%0Aw(e%3Da.createEvent('Event'))%3B%0Aw(e.initEvent('click'%2C%20false%2C%20false))%3B%0Aw(b.dispatchEvent(e))%3B%0A%3C%2Fscript%3E -->
 
-  <p><a href="#html-elements">HTML elements</a> can have <dfn id=event3>event
+  <p><a href="#html-elements">HTML elements</a> can have <dfn id=event4>event
    handler attributes</dfn> specified. These act as bubbling event listeners
    for the element on which they are specified.
 
-  <p>Each event handler attribute has two parts, an <a href="#event4"
+  <p>Each event handler attribute has two parts, an <a href="#event5"
    title="event handler content attributes">event handler content
-   attribute</a> and an <a href="#event5" title="event handler DOM
+   attribute</a> and an <a href="#event6" title="event handler DOM
    attributes">event handler DOM attribute</a>. Event handler attributes must
    initially be set to null. When their value changes (through the changing
    of their event handler content attribute or their event handler DOM
@@ -32807,11 +32913,11 @@
    <code>EventListener</code> object assigned to them.
 
   <p>Objects other than <code>Element</code> objects, in particular <code><a
-   href="#window">Window</a></code>, only have <a href="#event5" title="event
+   href="#window">Window</a></code>, only have <a href="#event6" title="event
    handler DOM attributes">event handler DOM attribute</a> (since they have
    no content attributes).
 
-  <p><dfn id=event4>Event handler content attributes</dfn>, when specified,
+  <p><dfn id=event5>Event handler content attributes</dfn>, when specified,
    must contain valid ECMAScript code matching the ECMAScript <code
    title="">FunctionBody</code> production. <a
    href="#refsECMA262">[ECMA262]</a></p>
@@ -32849,7 +32955,7 @@
 
   <p class=big-issue>How do we allow non-JS event handlers?
 
-  <p><dfn id=event5>Event handler DOM attributes</dfn>, on setting, must set
+  <p><dfn id=event6>Event handler DOM attributes</dfn>, on setting, must set
    the corresponding event handler attribute to their new value, and on
    getting, must return whatever the current value of the corresponding event
    handler attribute is (possibly null).
@@ -35607,7 +35713,7 @@
      cache</var>.
   </ol>
 
-  <p>The following are the <a href="#event5">event handler DOM attributes</a>
+  <p>The following are the <a href="#event6">event handler DOM attributes</a>
    that must be supported by objects implementing the <code><a
    href="#applicationcache">ApplicationCache</a></code> interface:
 
@@ -43298,7 +43404,7 @@
 
   <hr>
 
-  <p>The following are the <a href="#event5">event handler DOM attributes</a>
+  <p>The following are the <a href="#event6">event handler DOM attributes</a>
    that must be supported by objects implementing the <code><a
    href="#websocket0">WebSocket</a></code> interface:
 
@@ -44634,7 +44740,7 @@
 
   <hr>
 
-  <p>The following are the <a href="#event5">event handler DOM attributes</a>
+  <p>The following are the <a href="#event6">event handler DOM attributes</a>
    that must be supported by objects implementing the <code><a
    href="#messageport0">MessagePort</a></code> interface:
 

Modified: source
===================================================================



More information about the Commit-Watchers mailing list