[gw] (2) video: Use better terminology; make all invokations of the r…
…esource selection algorithm async; fix the problem whereby you could get that algorithm running twice on one element; add a missing loop step. (credit: cp)
git-svn-id: http://svn.whatwg.org/webapps@2873 340c8d12-0b0e-0410-8428-c7bf67bfef74
these must return a new <code><a href=#htmlaudioelement>HTMLAudioElement</a></code> object (a new
<code><a href=#audio>audio</a></code> element). If the <var title="">src</var> argument
is present, the object created must have its <code title=dom-media-src><a href=#dom-media-src>src</a></code> content attribute set to the
provided value, and the user agent must invoke the object's <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>load algorithm</a> before
returning.</p>
provided value, and the user agent must asynchronously invoke the
algorithm</a> defined below describes exactly when the <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> attribute changes
value and what events fire to indicate changes in this state.</p>
this element is already being invoked, then abort these
steps.</li>
<li><p>Abort any already-running instance of the <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>load algorithm</a> for this
element.</li>
<li><p>Abort any already-running instance of the <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection
algorithm</a> for this element.</li>
<li>
</ol></li>
<li><p>Asynchronously invoke the <a href=#media-element>media element</a>'s <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>load algorithm</a>.</li>
<li><p>Asynchronously invoke the <a href=#media-element>media element</a>'s <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection
algorithm</dfn> for a <a href=#media-element>media element</a> is as follows. This
algorithm is always invoked asynchronously, meaning that it runs in
the background with scripts and other <a href=#concept-task title=concept-task>tasks</a> running in parallel.</p>
<ol><li><p>While the <a href=#media-element>media element</a> has neither a <code title=attr-media-src><a href=#attr-media-src>src</a></code> attribute nor any
<code><a href=#the-source-element>source</a></code> element children, wait. (This steps might wait
forever.)</li>
<ol><li>
<p>If the <a href=#media-element>media element</a> has neither a <code title=attr-media-src><a href=#attr-media-src>src</a></code> attribute nor any
<code><a href=#the-source-element>source</a></code> element children, run these substeps:</p>
<ol><li><p>Set the <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> to <code title=dom-media-NETWORK_NO_SOURCE><a href=#dom-media-network_no_source>NETWORK_NO_SOURCE</a></code>.</li>
<li><p>While the <a href=#media-element>media element</a> has neither a <code title=attr-media-src><a href=#attr-media-src>src</a></code> attribute nor any
<code><a href=#the-source-element>source</a></code> element children, wait. (This steps might
wait forever.)</li>
</ol></li>
<li><p>Set the element's <a href=#delaying-the-load-event-flag>delaying-the-load-event flag</a>
to true. This <a href=#delay-the-load-event title="delay the load event">delays the load
<a href=#url>URL</a> given in that attribute, relative to the
<a href=#media-element>media element</a>.</p>
<li><p>If that is successful, then run the <a href=#concept-media-load-resource title=concept-media-load-resource>resource-load
<li><p>If that is successful, then run the <a href=#concept-media-load-resource title=concept-media-load-resource>resource fetch
algorithm</a> with the resulting <a href=#absolute-url>absolute URL</a>. If
that algorithm returns without aborting <em>this</em> one, then
the load failed.</li>
in case it was set to <code title=dom-media-NETWORK_NO_SOURCE><a href=#dom-media-network_no_source>NETWORK_NO_SOURCE</a></code>
above.</li>
<li><p>Run the <a href=#concept-media-load-resource title=concept-media-load-resource>resource-load
<li><p>Run the <a href=#concept-media-load-resource title=concept-media-load-resource>resource fetch
algorithm</a> with the <a href=#absolute-url>absolute URL</a> that resulted
from <a href=#resolve-a-url title="resolve a url">resolving</a> the
<a href=#url>URL</a> given by the <var title="">candidate</var>
event">delays the load event</a> again, in case it hasn't gone
been fired yet.</li>
<li><p>Jump back to the step labeled <i>search loop</i>.</li>
algorithm</dfn> for a <a href=#media-element>media element</a> and a given
<a href=#absolute-url>absolute URL</a> is as follows:</p>
<ol><li><p>The user agent should cancel the fetching
process.</li>
<li><p>Abort this subalgorithm, returning to the <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>load algorithm</a>.</p>
<li><p>Abort this subalgorithm, returning to the <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection
algorithm</a>.</p>
</ol></dd>
flag</a> to false. This stops <a href=#delay-the-load-event title="delay the load
event">delaying the load event</a>.</li>
<li><p>Abort the overall <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>load
<li><p>Abort the overall <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection
algorithm</a>.</li>
</ol></dd>
flag</a> to false. This stops <a href=#delay-the-load-event title="delay the load
event">delaying the load event</a>.</li>
<li><p>Abort the overall <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>load
<li><p>Abort the overall <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection
algorithm</a>.</li>
</ol></dd>
flag</a> to false. This stops <a href=#delay-the-load-event title="delay the load
event">delaying the load event</a>.</li>
<li><p>Abort the overall <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>load
<li><p>Abort the overall <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection
algorithm</a>.</li>
</ol></dd>
called <code title=event-load><a href=#event-load>load</a></code> at the
element.</li>
<li><p>Then, abort the overall <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>load
<li><p>Then, abort the overall <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection
algorithm</a>.</li>
</ol><p>If a <a href=#media-element>media element</a> whose <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> has the value
<code title=dom-media-NETWORK_EMPTY><a href=#dom-media-network_empty>NETWORK_EMPTY</a></code> is <a href=#insert-an-element-into-a-document title="insert an element into a document">inserted into a
document</a>, the user agent must asynchronously invoke the
attribute is a <a href=#boolean-attribute>boolean attribute</a>. Its presence hints to
<ol><li><p>If the <a href=#media-element>media element</a>'s <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> attribute has
the value <code title=dom-media-NETWORK_EMPTY><a href=#dom-media-network_empty>NETWORK_EMPTY</a></code>, then the user
agent must invoke the <a href=#media-element>media element</a>'s <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>load
agent must asynchronously invoke the <a href=#media-element>media element</a>'s
<ol><li><p>If the <a href=#media-element>media element</a>'s <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> attribute has
the value <code title=dom-media-NETWORK_EMPTY><a href=#dom-media-network_empty>NETWORK_EMPTY</a></code>, then the user
agent must invoke the <a href=#media-element>media element</a>'s <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>load
agent must asynchronously invoke the <a href=#media-element>media element</a>'s
<li><p>If the <a href=#media-element>media element</a>'s <code title=dom-media-paused><a href=#dom-media-paused>paused</a></code> attribute is false, it must
<td>The user agent begins looking for <a href=#media-data>media data</a>, as part of the <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>load algorithm</a>.
<td>The user agent begins looking for <a href=#media-data>media data</a>, as part of the <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection algorithm</a>.
<code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> equals either <code title=dom-media-NETWORK_EMPTY><a href=#dom-media-network_empty>NETWORK_EMPTY</a></code> or <code title=dom-media-NETWORK_LOADED><a href=#dom-media-network_loaded>NETWORK_LOADED</a></code>, depending on when the download was aborted.
<td>A <a href=#media-element>media element</a> whose <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> was previously not in the <code title=dom-media-NETWORK_EMPTY><a href=#dom-media-network_empty>NETWORK_EMPTY</a></code> state has just switched to that state (either because of a fatal error during load that's about to be reported, or because the <code title=dom-media-load><a href=#dom-media-load>load()</a></code> method was invoked while the <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>load algorithm</a> was already running, in which case it is fired synchronously during the <code title=dom-media-load><a href=#dom-media-load>load()</a></code> method call).
<td>A <a href=#media-element>media element</a> whose <code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> was previously not in the <code title=dom-media-NETWORK_EMPTY><a href=#dom-media-network_empty>NETWORK_EMPTY</a></code> state has just switched to that state (either because of a fatal error during load that's about to be reported, or because the <code title=dom-media-load><a href=#dom-media-load>load()</a></code> method was invoked while the <a href=#concept-media-load-algorithm title=concept-media-load-algorithm>resource selection algorithm</a> was already running, in which case it is fired synchronously during the <code title=dom-media-load><a href=#dom-media-load>load()</a></code> method call).
<td><code title=dom-media-networkState><a href=#dom-media-networkstate>networkState</a></code> is <code title=dom-media-NETWORK_EMPTY><a href=#dom-media-network_empty>NETWORK_EMPTY</a></code>; all the DOM attributes are in their initial states.