Browse files

[] (0) Define event loops, task queues, etc; Make 'fetching' use this…

… mechanism (everything will in due course); Fix some cross-references around 'interactive content'.

git-svn-id: http://svn.whatwg.org/webapps@2074 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information...
1 parent c9167ac commit 89751261a2d7b683c4356734c3a111f64aacecd5 @Hixie Hixie committed Aug 16, 2008
Showing with 287 additions and 68 deletions.
  1. +150 −44 index
  2. +137 −24 source
View
194 index
@@ -28,7 +28,7 @@
<h1 id=html-5>HTML 5</h1>
- <h2 class="no-num no-toc" id=draft>Draft Recommendation &mdash; 14 August
+ <h2 class="no-num no-toc" id=draft>Draft Recommendation &mdash; 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 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3E..
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 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20html%3E..
<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 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
<!-- 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 @@ first matching case):&lt;/p&gt;
<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 @@ first matching case):&lt;/p&gt;
<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 @@ href="?audio">audio&lt;/a> test instead.)&lt;/p></pre>
<hr>
<!-- XXX
- make it an interactive element
default activation behavior is to do the play() if paused, pause()
otherwise
-->
@@ -23884,9 +23892,10 @@ function AddCloud(data, x, y) { ... }</pre>
<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 @@ https://www.google.com/base/settings
<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 @@ never reset. This is nice and consistent.)
<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 @@ never reset. This is nice and consistent.)
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 @@ never reset. This is nice and consistent.)
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 @@ never reset. This is nice and consistent.)
<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 @@ never reset. This is nice and consistent.)
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,8 +32704,94 @@ never reset. This is nice and consistent.)
<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>
@@ -32793,25 +32899,25 @@ JSURL: http://ietfreport.isoc.org/all-ids/draft-hoehrmann-javascript-scheme-00.t
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
attribute), they will either be null, or have an
<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 @@ JSURL: http://ietfreport.isoc.org/all-ids/draft-hoehrmann-javascript-scheme-00.t
<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 @@ style/default.css</pre>
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 @@ interface <dfn id=websocket0>WebSocket</dfn> {
<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 @@ interface <dfn id=messagechannel>MessageChannel</dfn> {
<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:
View
161 source
@@ -3444,21 +3444,36 @@
and abort these steps.</p></li>
<li><p>Perform the remaining steps asynchronously.</p></li>
- <!-- XXX queue interaction -->
-
- <li><p>If the resource identified by the resulting <span>absolute
- URL</span> 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.</p></li>
-
- <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, <span
- title="concept-js-deref">dereferencing <span title="javascript
- protocol"><code title="">javascript:</code> URLs</span></span>,
- etc).</p></li>
+
+ <li>
+
+ <p>If the resource identified by the resulting <span>absolute
+ URL</span> is already being downloaded for other 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, <span
+ title="concept-js-deref">dereferencing <span title="javascript
+ protocol"><code title="">javascript:</code> URLs</span></span>,
+ etc).</p>
+
+ </li>
+
+ <li><p>When the resource is available, <span>queue a task</span>
+ 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 <span>task source</span>
+ for these tasks is the <dfn>networking task source</dfn>.</p>
+ <!-- XXX make sure each use of 'fetch' defines what the appropriate
+ task is -->
</ol>
@@ -6412,8 +6427,6 @@ http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C%21DOCTYPE%20HTML%3E%0
href="#refsWF2">[WF2]</a></p> <!-- 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.</p>
<h4>Transparent content models</h4>
@@ -10815,7 +10828,7 @@ first matching case):&lt;/p&gt;
<p class="note">One way that a user agent can enable users to follow
hyperlinks is by allowing <code>a</code> elements to be clicked, or
focussed and activated by the keyboard. This <span
- title="interactive elements">will cause</span> the aforementioned
+ title="interactive content">will cause</span> the aforementioned
<span>activation behavior</span> to be invoked.</p>
<p>The DOM attributes <dfn
@@ -10838,7 +10851,7 @@ first matching case):&lt;/p&gt;
<p>The <code>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
+ 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>
@@ -15798,7 +15811,6 @@ href="?audio">audio&lt;/a> test instead.)&lt;/p></pre>
<hr>
<!-- XXX
- make it an interactive element
default activation behavior is to do the play() if paused, pause()
otherwise
-->
@@ -21113,7 +21125,7 @@ function AddCloud(data, x, y) { ... }</pre>
<p class="note">One way that a user agent can enable users to follow
hyperlinks is by allowing <code>area</code> elements to be clicked,
or focussed and activated by the keyboard. This <span
- title="interactive elements">will cause</span> the aforementioned
+ title="interactive content">will cause</span> the aforementioned
<span>activation behavior</span> to be invoked.</p>
<p>The DOM attributes <dfn
@@ -24535,7 +24547,7 @@ https://www.google.com/base/settings
<dl class="element">
<dt>Categories</dt>
<dd><span>Flow content</span>.</dd>
- <dd><span>Interactive element</span>.</dd>
+ <dd><span>Interactive content</span>.</dd>
<dd><span>Sectioning root</span>.</dd>
<dt>Contexts in which this element may be used:</dt>
<dd>Where <span>flow content</span> is expected.</dd>
@@ -28891,7 +28903,7 @@ never reset. This is nice and consistent.)
<li><p>If the <span>parent browsing context</span>'s <span>active
document</span> does not have the <span>same</span> <span>effective
- origin</span> as the script that is accessing the <code
+ script origin</span> as the script that is accessing the <code
title="dom-frameElement">frameElement</code> attribute, then throw
a <span>security exception</span>.</p></li>
@@ -29001,6 +29013,15 @@ never reset. This is nice and consistent.)
browsing contexts</span> forms a <dfn>unit of related browsing
contexts</dfn>.</p>
+ <p>Each <span>unit of related browsing contexts</span> is then
+ further divided into the smallest number of groups such that every
+ member of each group has an <span>effective script origin</span>
+ that, through appropriate manipulation of the <code
+ title="dom-document-domain">document.domain</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>unit of related similar-origin browsing contexts</dfn>.</p>
+
<h4>Browsing context names</h4>
@@ -29969,7 +29990,99 @@ never reset. This is nice and consistent.)
<h4>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 title="event
+ loop">event loops</dfn> as described in this section.</p>
+
+ <p>There must be at least one <span>event loop</span> per user
+ agent, and at most one <span>event loop</span> per <span>unit of
+ related similar-origin browsing contexts</span>.</p>
+
+ <p>An <span>event loop</span> always has at least one <span>browsing
+ context</span>. If an <span>event loop</span>'s <span
+ title="browsing context">browsing contexts</span> all go away, then
+ the <span>event loop</span> goes away as well. A <span>browsing
+ context</span> always has an <span>event loop</span> coordinating
+ its activities.</p>
+
+ <p>An <span>event loop</span> has one or more <dfn title="task
+ queue">task queues</dfn>. A <span>task queue</span> is an ordered
+ list of:</p>
+
+ <dl>
+
+ <dt>Events</dt>
+
+ <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 <span>task
+ queue</span>, many are dispatched synchronously during other
+ tasks.</p>
+
+ </dd>
+
+
+ <dt>Parsing</dt>
+
+ <dd><p>The <span>HTML parser</span> tokenising a single byte, and
+ then processing any resulting tokens, is a task.</p></dd>
+
+
+ <dt>Callbacks</dt>
+
+ <dd><p>Calling a callback asynchronously is a task.</p></dd>
+
+
+ <dt>Using a resource</dt>
+
+ <dd><p>When an algorithm <span title="fetch">fetches</span> 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.</p></dd>
+
+ </dl>
+
+ <p>When a user agent is to <dfn>queue a task</dfn>, it must add the
+ given task to one of the <span title="task queue">task queues</span>
+ of the relevant <span>event loop</span>. All the tasks from one
+ particular <dfn>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 <span>task
+ queue</span>, but tasks from different <span title="task
+ source">task sources</span> may be placed in different <span
+ title="task queue">task queues</span>.</p>
+
+ <p class="example">For example, a user agent could have one
+ <span>task queue</span> 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 <span>task source</span>
+ out of order.</p>
+
+ <p>An <span>event loop</span> must continually run through the
+ following steps for as long as it exists:</p>
+
+ <ol>
+
+ <li><p>Run the oldest task on one of the <span>event loop</span>'s
+ <span title="task queue">task queues</span>. The user agent may
+ pick any <span>task queue</span>.</p></li>
+
+ <li><p>Remove that task from its <span>task queue</span>.</p></li>
+
+ <li><p>If necessary, update the rendering or user interface of any
+ <code>Document</code> or <span>browsing context</span> to reflect
+ the current state.</p></li>
+
+ <li><p>Return to the first step of the <span>event
+ loop</span>.</p></li>
+
+ </ol>

0 comments on commit 8975126

Please sign in to comment.