[html5] r4103 - [giow] (2) Define how <script> gets blocked while <style>@import</style>, and a [...]
whatwg at whatwg.org
whatwg at whatwg.org
Sun Oct 11 01:02:02 PDT 2009
Author: ianh
Date: 2009-10-11 01:02:00 -0700 (Sun, 11 Oct 2009)
New Revision: 4103
Modified:
complete.html
index
source
Log:
[giow] (2) Define how <script> gets blocked while <style>@import</style>, and a general rewrite of how <script>s are executed and interact with the parsers.
Modified: complete.html
===================================================================
--- complete.html 2009-10-09 10:49:21 UTC (rev 4102)
+++ complete.html 2009-10-11 08:02:00 UTC (rev 4103)
@@ -110,7 +110,7 @@
<header class=head><p><a class=logo href=http://www.whatwg.org/ rel=home><img alt=WHATWG src=/images/logo></a></p>
<hgroup><h1>Web Applications 1.0</h1>
- <h2 class="no-num no-toc">Draft Standard — 9 October 2009</h2>
+ <h2 class="no-num no-toc">Draft Standard — 11 October 2009</h2>
</hgroup><p>You can take part in this work. <a href=http://www.whatwg.org/mailing-list>Join the working group's discussion list.</a></p>
<p><strong>Web designers!</strong> We have a <a href=http://blog.whatwg.org/faq/>FAQ</a>, a <a href=http://forums.whatwg.org/>forum</a>, and a <a href=http://www.whatwg.org/mailing-list#help>help mailing list</a> for you!</p>
<!--<p class="impl"><strong>Implementors!</strong> We have a <a href="http://www.whatwg.org/mailing-list#implementors">mailing list</a> for you too!</p>-->
@@ -9945,7 +9945,7 @@
<li>
- <p>If there is a <a href=#pending-external-script>pending external script</a>, then the
+ <p>If there is a <a href=#pending-parsing-blocking-script>pending parsing-blocking script</a>, then the
method must now return without further processing of the
<a href=#the-input-stream>input stream</a>.</p>
@@ -10767,22 +10767,15 @@
followed and 404 responses must cause the external resource to not
be applied.)</p>
- <!-- similar text in various places -->
- <p>Fetching external resources must <a href=#delay-the-load-event>delay the load
- event</a> of the element's document until the <a href=#concept-task title=concept-task>task</a> that is <a href=#queue-a-task title="queue a
- task">queued</a> by the <a href=#networking-task-source>networking task source</a> once
- the resource has been <a href=#fetch title=fetch>fetched</a> (defined
- below) has been run.</p>
-
- <!-- the next paragraph is similar to text in the <style> section -->
- <p>The <a href=#concept-task title=concept-task>task</a> that is <a href=#queue-a-task title="queue a task">queued</a> by the <a href=#networking-task-source>networking task
- source</a> once the resource has been <a href=#fetch title=fetch>fetched</a> must, if the loads were successful,
- <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named
- <code title=event-load>load</code> at the <code><a href=#the-link-element>link</a></code>
- element; otherwise, if the resource or one of its subresources
- failed to completely load for any reason (e.g. DNS error, HTTP 404
- response, a connection being prematurely closed, unsupported
- Content-Type), it must instead <a href=#queue-a-task>queue a task</a> to
+ <!-- the next few paragraph are similar to text in the <style> section -->
+ <p>Once the attempts to obtain the resource and its critical
+ subresources are complete, the user agent must, if the loads were
+ successful, <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple
+ event</a> named <code title=event-load>load</code> at the
+ <code><a href=#the-link-element>link</a></code> element, or, if the resource or one of its
+ critical subresources failed to completely load for any reason
+ (e.g. DNS error, HTTP 404 response, a connection being prematurely
+ closed, unsupported Content-Type), <a href=#queue-a-task>queue a task</a> to
<a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-error>error</code> at the <code><a href=#the-link-element>link</a></code>
element. Non-network errors in processing the resource or its
subresources (e.g. CSS parse errors, PNG decoding errors) are not
@@ -10791,6 +10784,14 @@
<p>The <a href=#task-source>task source</a> for these <a href=#concept-task title=concept-task>tasks</a> is the <a href=#dom-manipulation-task-source>DOM manipulation
task source</a>.</p>
+ <p>The element must <a href=#delay-the-load-event>delay the load event</a> of the
+ element's document until all the attempts to obtain the resource and
+ its critical subresources are complete.</p>
+
+ <p>Which resources are considered critical or not is defind by the
+ relevant specification. For CSS resources, only <code title="">@import</code> rules introduce critical subresources; other
+ resources, e.g. fonts or backgrounds, are not.</p>
+
<hr><p id=linkui>Interactive user agents may provide users with a
means to <a href=#following-hyperlinks title="following hyperlinks">follow the
hyperlinks</a> created using the <code><a href=#the-link-element>link</a></code> element,
@@ -10903,8 +10904,8 @@
resource link type has a default type defined, then the user agent
must assume that the resource is of that type.</p>
- <p class=note>The <code title=link-type-stylesheet>stylesheet</code> link type defines
- rules for processing the resource's <a href=#content-type title=Content-Type>Content-Type metadata</a>.</p>
+ <p class=note>The <code title=rel-stylesheet><a href=#link-type-stylesheet>stylesheet</a></code>
+ link type defines rules for processing the resource's <a href=#content-type title=Content-Type>Content-Type metadata</a>.</p>
<p>Once the user agent has established the type of the resource, the
user agent must apply the resource if it is of a supported type and
@@ -11891,10 +11892,6 @@
</div>
- <p>However, if the link is an <a href=#external-resource-link>external resource link</a>,
- then the <code title=attr-link-media><a href=#attr-link-media>media</a></code> attribute is
- prescriptive.
-
<p>The <dfn id=attr-style-media title=attr-style-media><code>media</code></dfn>
attribute says which media the styles apply to. The value must be a
<a href=#valid-media-query>valid media query</a>. <span class=impl>The user agent
@@ -11964,24 +11961,33 @@
when the processor is invoked.<!-- so dynamic changes to the base
URL don't affect the CSS --></p>
- <!-- the next paragraph is similar to text in the <link> section -->
- <p>Once the element has been evaluated, if it had no subresources or
- once all the subresources it uses have been <a href=#fetch title=fetch>fetched</a>, the user agent must <a href=#queue-a-task>queue a
- task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-load>load</code> at the <code><a href=#the-style-element>style</a></code> element. If
- the resource has a subresource that fails to completely load for any
- reason (e.g. DNS error, HTTP 404 response, the connection being
- prematurely closed, unsupported Content-Type), the user agent must
- instead <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple
- event</a> named <code title=event-error>error</code> at the
- <code><a href=#the-style-element>style</a></code> element. Non-network errors in the processing of
- the element's contents or its subresources (e.g. CSS parse errors)
- are not failures for the purposes of this paragraph. The
- <code><a href=#the-style-element>style</a></code> element must <a href=#delay-the-load-event>delay the load event</a> of
- the element's document until one of these <a href=#concept-task title=concept-task>tasks</a> has been queued.</p>
+ <!-- the next few paragraph are similar to text in the <style> section -->
+ <p>Once the attempts to obtain the style sheet's critical
+ subresources, if any, are complete, or, if the style sheet has no
+ critical subresources, once the style sheet has been parsed and
+ processed, the user agent must, if the loads were successful or
+ there were none, <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple
+ event</a> named <code title=event-load>load</code> at the
+ <code><a href=#the-style-element>style</a></code> element, or, if one of the style sheet's critical
+ subresources failed to completely load for any reason (e.g. DNS
+ error, HTTP 404 response, a connection being prematurely closed,
+ unsupported Content-Type), <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a
+ simple event</a> named <code title=event-error>error</code> at
+ the <code><a href=#the-style-element>style</a></code> element. Non-network errors in processing the
+ style sheet or its subresources (e.g. CSS parse errors, PNG decoding
+ errors) are not failures for the purposes of this paragraph.</p>
- <p>The <a href=#task-source>task source</a> for these <a href=#concept-task title=concept-task>tasks</a> is the <a href=#dom-manipulation-task-source>DOM manipulation
- task source</a>.</p>
+ <p>The <a href=#task-source>task source</a> for these <a href=#concept-task title=concept-task>tasks</a> is the <a href=#dom-manipulation-task-source>DOM manipulation task
+ source</a>.</p>
+ <p>The element must <a href=#delay-the-load-event>delay the load event</a> of the
+ element's document until all the attempts to obtain the style
+ sheet's critical subresources, if any, are complete.</p>
+
+ <p>Which resources are considered critical or not is defind by the
+ relevant specification. For CSS resources, only <code title="">@import</code> rules introduce critical subresources; other
+ resources, e.g. fonts or backgrounds, are not.</p>
+
</div>
<p class=note>This specification does not specify a style system,
@@ -12120,11 +12126,39 @@
<p id=alternate-style-sheets>The rules for handling alternative
style sheets are defined in the CSS object model specification. <a href=#refsCSSOM>[CSSOM]</a></p>
+ <hr><p>Style sheets, whether added by a <code><a href=#the-link-element>link</a></code> element, a
+ <code><a href=#the-style-element>style</a></code> element, an <code><?xml-stylesheet></code> PI,
+ an HTTP <code title=http-link>Link:</code> header, or some other
+ mechanism, have a <dfn id=style-sheet-ready>style sheet ready</dfn> flag, which is
+ initially unset.</p>
+
+ <p>When a style sheet is ready to be applied, its <a href=#style-sheet-ready>style sheet
+ ready</a> flag must be set. If the style sheet referenced no
+ other resources (e.g. it was an internal style sheet given by a
+ <code><a href=#the-style-element>style</a></code> element with no <code title="">@import</code>
+ rules), then the style rules must be synchronously made available to
+ script; otherwise, the style rules must only be made available to
+ script once the <a href=#event-loop>event loop</a> reaches its "update the
+ rendering" step.</p>
+
+ <p>A style sheet in the context of the <code>Document</code> of an
+ <a href=#html-parser>HTML parser</a> or <a href=#xml-parser>XML parser</a> is said to be
+ <dfn id=a-style-sheet-blocking-scripts>a style sheet blocking scripts</dfn> if the element was created
+ by that <code>Document</code>'s parser, and the element is either a
+ <code><a href=#the-style-element>style</a></code> element or a <code><a href=#the-link-element>link</a></code> element that was
+ an <a href=#link-type-stylesheet title=rel-stylesheet>external resource link that
+ contributes to the styling processing model</a> when the element
+ was created by the parser, and the element's style sheet was enabled
+ when the element was created by the parser, and the element's
+ <a href=#style-sheet-ready>style sheet ready</a> flag is not yet set, and, the last
+ time the <a href=#event-loop>event loop</a> reached step 1, the element was
+ <a href=#in-a-document title="in a document">in that
+ <code>Document</code></a>.</p>
+
</div>
-
<h3 id=scripting-1><span class=secno>4.3 </span>Scripting</h3>
<p>Scripts allow authors to add interactivity to their documents.</p>
@@ -12255,26 +12289,38 @@
<div class=impl>
- <p><code><a href=#script>script</a></code> elements have four associated pieces of
- metadata. The first is a flag indicating whether or not the script
- block has been <dfn id=already-executed>"already executed"</dfn>. Initially,
+ <p>A <code><a href=#script>script</a></code> element has several associated pieces of
+ state.</p>
+
+ <p>The first is a flag indicating whether or not the script block
+ has been <dfn id=already-started>"already started"</dfn>. Initially,
<code><a href=#script>script</a></code> elements must have this flag unset (script
- blocks, when created, are not "already executed"). When a
- <code><a href=#script>script</a></code> element is cloned, the "already executed" flag,
- if set, must be propagated to the clone when it is created. The
- second is a flag indicating whether the element was
+ blocks, when created, are not "already started"). When a
+ <code><a href=#script>script</a></code> element is cloned, the "already started" flag,
+ if set, must be propagated to the clone when it is created.</p>
+
+ <p>The second is a flag indicating whether the element was
<dfn id=parser-inserted>"parser-inserted"</dfn>. This flag is set by the <a href=#html-parser>HTML
- parser</a> and is used to handle <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> calls. The third
- and fourth pieces of metadata are <dfn id="the-script-block's-type"><var>the script block's
- type</var></dfn> and <dfn id="the-script-block's-character-encoding"><var>the script block's character
+ parser</a> and is used to handle <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> calls.</p>
+
+ <p>The third is a flag indicating whether or not the script block is
+ <dfn id=ready-to-be-parser-executed>"ready to be parser-executed"</dfn>. Initially,
+ <code><a href=#script>script</a></code> elements must have this flag unset (script
+ blocks, when created, are not "ready to be parser-executed"). This
+ flag is used only for elements that are also
+ <a href=#parser-inserted>"parser-inserted"</a>, to let the parser know when to
+ execute the script.</p>
+
+ <p>The fourth and fifth pieces of state are <dfn id="the-script-block's-type"><var>the script
+ block's type</var></dfn> and <dfn id="the-script-block's-character-encoding"><var>the script block's character
encoding</var></dfn>. They are determined when the script is run,
based on the attributes on the element at that time.</p>
<p>When a <code><a href=#script>script</a></code> element that is neither marked as
- having <a href=#already-executed>"already executed"</a> nor marked as being
+ having <a href=#already-started>"already started"</a> nor marked as being
<a href=#parser-inserted>"parser-inserted"</a> experiences one of the events listed
- in the following list, the user agent must <a href=#running-a-script title="running a
- script">run</a> the <code><a href=#script>script</a></code> element:</p>
+ in the following list, the user agent must synchronously <a href=#running-a-script title="running a script">run</a> the <code><a href=#script>script</a></code>
+ element:</p>
<ul><li>The <code><a href=#script>script</a></code> element gets <a href=#insert-an-element-into-a-document title="insert an
element into a document">inserted into a document</a>.</li>
@@ -12355,8 +12401,8 @@
<li>
- <p>The user agent must set the element's <a href=#already-executed>"already
- executed"</a> flag.</p>
+ <p>The user agent must set the element's <a href=#already-started>"already
+ started"</a> flag.</p>
</li>
@@ -12382,13 +12428,6 @@
user agent supports that encoding, then let <var><a href="#the-script-block's-character-encoding">the script
block's character encoding</a></var> be that encoding.</p>
- <p>Once the fetching process has completed, and the script has
- <dfn id=completed-loading>completed loading</dfn>, the user agent will have to complete
- <a href=#when-a-script-completes-loading title="when a script completes loading">the steps described
- below</a>. (If the parser is still active at that time, those
- steps defer to the parser to handle the execution of pending
- scripts.)</p>
-
<p>For performance reasons, user agents may start fetching the
script as soon as the attribute is set, instead, in the hope that
the element will be inserted into the document. Either way, once
@@ -12412,112 +12451,94 @@
has been flagged as <a href=#parser-inserted>"parser-inserted"</a>, and the
element does not have an <code title=attr-script-async><a href=#attr-script-async>async</a></code> attribute</dt>
- <dd>The element must be added to the end of the <a href=#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of
- scripts that will execute when the document has finished
- parsing</a>.</dd>
+ <dd>
+ <p>The element must be added to the end of the <dfn id=list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of
+ scripts that will execute when the document has finished
+ parsing</dfn>.</p>
- <dt>If the element has a <code title=attr-script-src><a href=#attr-script-src>src</a></code>
- attribute, and the element has been flagged as
- <a href=#parser-inserted>"parser-inserted"</a>, and the element does not have an
- <code title=attr-script-async><a href=#attr-script-async>async</a></code> attribute</dt>
+ <p>The <a href=#concept-task title=concept-task>task</a> that the
+ <a href=#networking-task-source>networking task source</a> places on the <a href=#task-queue>task
+ queue</a> once the <a href=#fetch title=fetch>fetching
+ algorithm</a> has completed must set the element's
+ <a href=#ready-to-be-parser-executed>"ready to be parser-executed"</a> flag. The parser will
+ handle executing the script.</p>
- <dd>The element is the <dfn id=pending-external-script>pending external script</dfn>. (There
- can only be one such script at a time.)</dd>
+ </dd>
<dt>If the element has a <code title=attr-script-src><a href=#attr-script-src>src</a></code>
- attribute</dt>
+ attribute, and the element has been flagged as
+ <a href=#parser-inserted>"parser-inserted"</a>, and the element does not have an
+ <code title=attr-script-async><a href=#attr-script-async>async</a></code> attribute, or</dt>
- <dd>The element must be added to the end of the <a href=#list-of-scripts-that-will-execute-as-soon-as-possible>list of
- scripts that will execute as soon as possible</a>.</dd>
+ <dd>
+ <p>The element is the <a href=#pending-parsing-blocking-script>pending parsing-blocking
+ script</a>. (There can only be one such script at a
+ time.)</p>
- <dt>Otherwise</dt>
+ <p>The <a href=#concept-task title=concept-task>task</a> that the
+ <a href=#networking-task-source>networking task source</a> places on the <a href=#task-queue>task
+ queue</a> once the <a href=#fetch title=fetch>fetching
+ algorithm</a> has completed must set the element's
+ <a href=#ready-to-be-parser-executed>"ready to be parser-executed"</a> flag. The parser will
+ handle executing the script.</p>
- <dd>The user agent must immediately <a href=#executing-a-script-block title="executing a
- script block">execute the script block</a>, even if other
- scripts are already executing.</dd>
+ </dd>
- </dl></li>
- </ol><!-- similar text in various places --><p>Fetching an external script must <a href=#delay-the-load-event>delay the load
- event</a> of the element's document until the <a href=#concept-task title=concept-task>task</a> that is <a href=#queue-a-task title="queue a
- task">queued</a> by the <a href=#networking-task-source>networking task source</a> once
- the resource has been <a href=#fetch title=fetch>fetched</a> (defined
- below) has been run.</p>
+ <dt>If the element does not have a <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute, but there is
+ <a href=#a-style-sheet-blocking-scripts>a style sheet blocking scripts</a>, and the element has
+ been flagged as <a href=#parser-inserted>"parser-inserted"</a></dt>
- <p><dfn id=when-a-script-completes-loading>When a script completes loading</dfn>: The UA must run the
- following steps as the <a href=#concept-task title=concept-task>task</a> that
- the <a href=#networking-task-source>networking task source</a> places on the <a href=#task-queue>task
- queue</a>:</p>
+ <dd>
- <dl class=switch><dt>If the <code><a href=#script>script</a></code> element was added to the <dfn id=list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list
- of scripts that will execute when the document has finished
- parsing</dfn>:</dt>
+ <p>The element is the <a href=#pending-parsing-blocking-script>pending parsing-blocking
+ script</a>. (There can only be one such script at a
+ time.)</p>
- <dd>
+ <p>Set the element's <a href=#ready-to-be-parser-executed>"ready to be parser-executed"</a>
+ flag. The parser will handle executing the script.</p>
- <ol><li>
+ </dd>
- <p>If the script's <code>Document</code> is still being parsed,
- then the parser handles it. Abort these steps.</p>
- </li>
+ <dt>If the element has a <code title=attr-script-src><a href=#attr-script-src>src</a></code>
+ attribute</dt>
- <li>
+ <dd>
- <p>If the <code><a href=#script>script</a></code> element is not the first element
- in the list, then do nothing yet. Stop going through these
- steps.</p>
+ <p>The element must be added to the end of the <dfn id=list-of-scripts-that-will-execute-as-soon-as-possible>list of
+ scripts that will execute as soon as possible</dfn>.</p>
- </li>
+ <p>The <a href=#concept-task title=concept-task>task</a> that the
+ <a href=#networking-task-source>networking task source</a> places on the <a href=#task-queue>task
+ queue</a> once the <a href=#fetch title=fetch>fetching
+ algorithm</a> has completed must <a href=#executing-a-script-block title="executing a
+ script block">execute the script block</a>.
- <li>
+ </dd>
- <p>Otherwise, <a href=#executing-a-script-block title="executing a script block">execute the
- script block</a> (the first element in the list).</p>
- </li>
+ <dt>Otherwise</dt>
- <li>
+ <dd>The user agent must immediately <a href=#executing-a-script-block title="executing a
+ script block">execute the script block</a>, even if other
+ scripts are already executing.</dd>
- <p>Remove the <code><a href=#script>script</a></code> element from the list
- (i.e. shift out the first entry in the list).</p>
+ </dl></li>
- </li>
+ </ol><!-- similar text in various places --><p>Fetching an external script must <a href=#delay-the-load-event>delay the load
+ event</a> of the element's document until the <a href=#concept-task title=concept-task>task</a> that is <a href=#queue-a-task title="queue a
+ task">queued</a> by the <a href=#networking-task-source>networking task source</a> once
+ the resource has been <a href=#fetch title=fetch>fetched</a> (defined
+ above) has been run.</p>
- <li>
+ <p>The <dfn id=pending-parsing-blocking-script>pending parsing-blocking script</dfn> is used by the
+ parser.</p>
- <p>If there are any more entries in the list, and if the script
- associated with the element that is now the first in the list is
- already loaded, then jump back to step 2 to execute it.</p>
-
- </li>
-
- </ol></dd>
-
- <dt>If the <code><a href=#script>script</a></code> element was added to the <dfn id=list-of-scripts-that-will-execute-as-soon-as-possible>list
- of scripts that will execute as soon as possible</dfn>:</dt>
-
- <dd>
-
- <ol><li>
-
- <p><a href=#executing-a-script-block title="executing a script block">Execute the
- script block</a>.</p>
-
- </li>
-
- <li>
-
- <p>Remove the <code><a href=#script>script</a></code> element from the list.</p>
-
- </li>
-
- </ol></dd>
-
- </dl><p><dfn id=executing-a-script-block title="executing a script block">Executing a script
+ <p><dfn id=executing-a-script-block title="executing a script block">Executing a script
block</dfn>: When the steps above require that the script block be
executed, the user agent must act as follows:</p>
@@ -50490,6 +50511,27 @@
<li><p>Return to the first step of the <a href=#event-loop>event
loop</a>.</li>
+ </ol><hr><p>When an algorithm says to <dfn id=spin-the-event-loop>spin the event loop</dfn> until
+ a condition <var title="">goal</var> is met, the user agent must run
+ the following steps:</p>
+
+ <ol><li><p>Let <var title="">task source</var> be the <a href=#task-source>task
+ source</a> of the currently running <a href=#concept-task title=concept-task>task</a>.</li>
+
+ <li><p>Stop the currently running <a href=#concept-task title=concept-task>task</a>, allowing the <a href=#event-loop>event
+ loop</a> to resume, but continue these steps
+ asynchronously.</li>
+
+ <li><p>Wait until the condition <var title="">goal</var> is
+ met.</li>
+
+ <li><p><a href=#queue-a-task>Queue a task</a> to continue running these steps,
+ using the <a href=#task-source>task source</a> <var title="">task
+ source</var>. Wait until this task runs before continuing these
+ steps.</li>
+
+ <li><p>Return to the caller.</li>
+
</ol><hr><p>Some of the algorithms in this specification, for historical
reasons, require the user agent to <dfn id=pause>pause</dfn> while running a
<a href=#concept-task title=concept-task>task</a> until some condition has been
@@ -72257,8 +72299,8 @@
<li><p>If the parser was originally created for the <a href=#html-fragment-parsing-algorithm>HTML
fragment parsing algorithm</a>, then mark the
- <code><a href=#script>script</a></code> element as <a href=#already-executed>"already
- executed"</a>. (<a href=#fragment-case>fragment case</a>)</li>
+ <code><a href=#script>script</a></code> element as <a href=#already-started>"already
+ started"</a>. (<a href=#fragment-case>fragment case</a>)</li>
<li><p>Append the new element to the <a href=#current-node>current node</a>
and push it onto the <a href=#stack-of-open-elements>stack of open
@@ -73691,8 +73733,8 @@
<p><a href=#parse-error>Parse error</a>.</p>
<p>If the <a href=#current-node>current node</a> is a <code><a href=#script>script</a></code>
- element, mark the <code><a href=#script>script</a></code> element as <a href=#already-executed>"already
- executed"</a>.</p>
+ element, mark the <code><a href=#script>script</a></code> element as <a href=#already-started>"already
+ started"</a>.</p>
<p>Pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open
elements</a>.</p>
@@ -73736,7 +73778,7 @@
might be the "undefined" value.)</p>
<p id=scriptTagParserResumes>At this stage, if there is a
- <a href=#pending-external-script>pending external script</a>, then:</p>
+ <a href=#pending-parsing-blocking-script>pending parsing-blocking script</a>, then:</p>
<dl class=switch><dt>If the <a href=#script-nesting-level>script nesting level</a> is not zero:</dt>
@@ -73760,13 +73802,23 @@
<p>Follow these steps:</p>
- <ol><li><p>Let <var title="">the script</var> be the <a href=#pending-external-script>pending
- external script</a>. There is no longer a <a href=#pending-external-script>pending
- external script</a>.</li>
+ <ol><li><p>Let <var title="">the script</var> be the <a href=#pending-parsing-blocking-script>pending
+ parsing-blocking script</a>. There is no longer a <a href=#pending-parsing-blocking-script>pending
+ parsing-blocking script</a>.</li>
- <li><p><a href=#pause>Pause</a> until the script has <a href=#completed-loading>completed
- loading</a>.</li>
+ <li><p>Block the <a href=#tokenization title=tokenization>tokenizer</a>
+ for this instance of the <a href=#html-parser>HTML parser</a>, such that
+ the <a href=#event-loop>event loop</a> will not run <a href=#concept-task title=concept-task>tasks</a> that invoke the <a href=#tokenization title=tokenization>tokenizer</a>.</li>
+ <li><p><a href=#spin-the-event-loop>Spin the event loop</a> until there is no <a href=#a-style-sheet-blocking-scripts title="a style sheet blocking scripts">style sheet blocking
+ scripts</a> and <var title="">the script</var>'s
+ <a href=#ready-to-be-parser-executed>"ready to be parser-executed"</a> flag is set.</li>
+
+ <li><p>Unblock the <a href=#tokenization title=tokenization>tokenizer</a>
+ for this instance of the <a href=#html-parser>HTML parser</a>, such that
+ <a href=#concept-task title=concept-task>tasks</a> that invoke the <a href=#tokenization title=tokenization>tokenizer</a> can again be
+ run.</li>
+
<li><p>Let the <a href=#insertion-point>insertion point</a> be just before the
<a href=#next-input-character>next input character</a>.</li>
@@ -73774,8 +73826,8 @@
by one (it should be zero before this step, so this sets it to
one).</li>
- <li><p><a href=#executing-a-script-block title="executing a script block">Execute the
- script</a>.</li>
+ <li><p><a href=#executing-a-script-block title="executing a script block">Execute</a>
+ <var title="">the script</var>.</li>
<li><p>Decrement the parser's <a href=#script-nesting-level>script nesting level</a>
by one. If the parser's <a href=#script-nesting-level>script nesting level</a> is
@@ -73785,7 +73837,7 @@
<li><p>Let the <a href=#insertion-point>insertion point</a> be undefined
again.</li>
- <li><p>If there is once again a <a href=#pending-external-script>pending external
+ <li><p>If there is once again a <a href=#pending-parsing-blocking-script>pending parsing-blocking
script</a>, then repeat these steps from step 1.</li>
</ol></dd>
@@ -75095,53 +75147,55 @@
<h4 id=the-end><span class=secno>10.2.6 </span>The end</h4>
<p>Once the user agent <dfn id=stop-parsing title="stop parsing">stops parsing</dfn>
- the document, the user agent must follow the steps in this
- section.</p>
+ the document, the user agent must run the following steps:</p>
- <!-- this happens as part of one of the tasks that runs the parser -->
+ <ol><!-- this happens as part of one of the tasks that runs the parser --><li><p>Set the <a href=#current-document-readiness>current document readiness</a> to
+ "interactive" <!-- this also synchronously fires an event --> and
+ the <a href=#insertion-point>insertion point</a> to undefined.</li>
- <p>First, the user agent must set the <a href=#current-document-readiness>current document
- readiness</a> to "interactive" and the <a href=#insertion-point>insertion
- point</a> to undefined.</p> <!-- this also synchronously fires an
- event -->
+ <li><p>If the <a href=#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of scripts that will execute when the
+ document has finished parsing</a> is not empty, run these
+ substeps:</p>
- <p>Then, the user agent must then make a list of all the scripts
- that are in the <a href=#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of scripts that will execute when the
- document has finished parsing</a> and the <a href=#list-of-scripts-that-will-execute-as-soon-as-possible>list of scripts
- that will execute as soon as possible</a>. This is the <dfn id=list-of-scripts-pending-after-the-parser-stopped>list
- of scripts pending after the parser stopped</dfn>.</p>
+ <ol><li><p><a href=#spin-the-event-loop>Spin the event loop</a> until the first
+ <code><a href=#script>script</a></code> in the <a href=#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of scripts that will
+ execute when the document has finished parsing</a> has its
+ <a href=#ready-to-be-parser-executed>"ready to be parser-executed"</a> flag set <em>and</em> there
+ is no <a href=#a-style-sheet-blocking-scripts title="a style sheet blocking scripts">style sheet
+ blocking scripts</a>.</li>
- <p>The document is no longer being parsed, so the rules for
- <a href=#when-a-script-completes-loading>when a script completes loading</a> for the <a href=#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of
- scripts that will execute when the document has finished
- parsing</a> start applying (script execution for that list is no
- longer managed by the parser).</p>
+ <li><p><a href=#executing-a-script-block title="executing a script block">Execute</a> the
+ first <code><a href=#script>script</a></code> in the <a href=#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of scripts that will
+ execute when the document has finished parsing</a>.</li>
- <p>If the <a href=#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of scripts that will execute when the document
- has finished parsing</a> is not empty, and the first item in this
- list has already <a href=#completed-loading>completed loading</a>, then the user agent
- must act as if that script just finished loading.</p>
+ <li><p>Remove the first <code><a href=#script>script</a></code> element from the
+ <a href=#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of scripts that will execute when the document has
+ finished parsing</a> (i.e. shift out the first entry in the
+ list).</li>
+
+ <li><p>If the <a href=#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of scripts that will execute when the
+ document has finished parsing</a> is still not empty, repeat
+ these substeps again from substep 1.</p>
- <p class=note>By this point, there will be no scripts that have
- loaded but have not yet been executed.</p>
+ </ol></li>
- <hr><!-- async --><p>Once all the scripts on the <a href=#list-of-scripts-pending-after-the-parser-stopped>list of scripts pending after
- the parser stopped</a> have <a href=#completed-loading>completed loading</a> and
- been <a href=#executing-a-script-block title="executing a script block">executed</a>, the
- user agent must <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple
- event</a> named <code title=event-DOMContentLoaded>DOMContentLoaded</code> at the
- <code>Document</code>. (If the list is empty, this happens
- immediately.)</p>
+ <li><p><a href=#spin-the-event-loop>Spin the event loop</a> until the the <a href=#list-of-scripts-that-will-execute-as-soon-as-possible>list of
+ scripts that will execute as soon as possible</a> is
+ empty.</li>
- <hr><!-- async --><p>Once everything that <dfn id=delay-the-load-event title="delay the load event">delays the
- load event</dfn> of the document has completed, the user agent must
- run the following steps:</p>
+ <li><p><a href=#queue-a-task>Queue a task</a> to <a href=#fire-a-simple-event>fire a simple
+ event</a> named <code title=event-DOMContentLoaded>DOMContentLoaded</code> at the
+ <code>Document</code>.</li>
- <ol><li><a href=#queue-a-task>Queue a task</a> to set the <a href=#current-document-readiness>current document
- readiness</a> to "complete".</li> <!-- this also fires an event
- synchronously during the task -->
+ <li><p><a href=#spin-the-event-loop>Spin the event loop</a> until there is nothing that
+ <dfn id=delay-the-load-event title="delay the load event">delays the load event</dfn> in
+ the <code>Document</code>.</li>
- <li>If the <code>Document</code> is in a <a href=#browsing-context>browsing
+ <li><p><a href=#queue-a-task>Queue a task</a> to set the <a href=#current-document-readiness>current document
+ readiness</a> to "complete". <!-- this also fires an event
+ synchronously during the task --></li>
+
+ <li><p>If the <code>Document</code> is in a <a href=#browsing-context>browsing
context</a>, then <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a
simple event</a> named <code title=event-load>load</code> at
the <code>Document</code>'s <code><a href=#window>Window</a></code> object, but with
@@ -75149,15 +75203,16 @@
<code>Document</code> object (and the <code title=dom-event-currentTarget>currentTarget</code> set to the
<code><a href=#window>Window</a></code> object).</li>
- <li>If the <code>Document</code> has a <a href=#pending-state-object>pending state
+ <li><p>If the <code>Document</code> has a <a href=#pending-state-object>pending state
object</a>, then <a href=#queue-a-task>queue a task</a> to fire a <code title=event-popstate><a href=#event-popstate>popstate</a></code> event in no namespace on the
<code>Document</code>'s <code><a href=#window>Window</a></code> object using the
<code><a href=#popstateevent>PopStateEvent</a></code> interface, with the <code title=dom-PopStateEvent-state><a href=#dom-popstateevent-state>state</a></code> attribute set to the
current value of the <a href=#pending-state-object>pending state object</a>. This event
- must bubble but not be cancelable and has no default action.</li>
+ must bubble but not be cancelable and has no default
+ action.</li>
- </ol><p>The <a href=#task-source>task source</a> for these <a href=#concept-task title=concept-task>tasks</a> is the <a href=#dom-manipulation-task-source>DOM manipulation
- task source</a>.</p>
+ </ol><p>The <a href=#task-source>task source</a> for the <a href=#concept-task title=concept-task>tasks</a> mentioned in this section is the
+ <a href=#dom-manipulation-task-source>DOM manipulation task source</a>.</p>
</div>
@@ -78099,15 +78154,31 @@
element, it must be marked as being <a href=#parser-inserted>"parser-inserted"</a>.
If the parser was originally created for the <a href=#xml-fragment-parsing-algorithm>XML fragment
parsing algorithm</a>, then the element must be marked as
- <a href=#already-executed>"already executed"</a> also. When the element's end tag is
+ <a href=#already-started>"already started"</a> also. When the element's end tag is
parsed, the user agent must <a href=#running-a-script title="running a
script">run</a> the <code><a href=#script>script</a></code> element. If this causes
- there to be a <a href=#pending-external-script>pending external script</a>, then the user
- agent must <a href=#pause>pause</a> until that script has <a href=#completed-loading>completed
- loading</a>, and then <a href=#executing-a-script-block title="executing a script
- block">execute it</a>.</p>
+ there to be a <a href=#pending-parsing-blocking-script>pending parsing-blocking script</a>, then the
+ user agent must run the following steps:</p>
- <p class=note>Since the <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> API is not
+ <ol><li><p>Block this instance of the <a href=#xml-parser>XML parser</a>, such
+ that the <a href=#event-loop>event loop</a> will not run <a href=#concept-task title=concept-task>tasks</a> that invoke it.</li>
+
+ <li><p><a href=#spin-the-event-loop>Spin the event loop</a> until there is no <a href=#a-style-sheet-blocking-scripts title="a style sheet blocking scripts">style sheet blocking
+ scripts</a> and the <a href=#pending-parsing-blocking-script>pending parsing-blocking
+ script</a>'s <a href=#ready-to-be-parser-executed>"ready to be parser-executed"</a> flag is
+ set.</li>
+
+ <li><p>Unblock this instance of the <a href=#xml-parser>XML parser</a>, such
+ that <a href=#concept-task title=concept-task>tasks</a> that invoke it can
+ again be run.</li>
+
+ <li><p><a href=#executing-a-script-block title="executing a script block">Execute</a> the
+ <a href=#pending-parsing-blocking-script>pending parsing-blocking script</a>.</li>
+
+ <li><p>There is no longer a <a href=#pending-parsing-blocking-script>pending parsing-blocking
+ script</a>.</li>
+
+ </ol><p class=note>Since the <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> API is not
available for <a href=#xml-documents>XML documents</a>, much of the complexity in
the <a href=#html-parser>HTML parser</a> is not needed in the <a href=#xml-parser>XML
parser</a>.</p>
Modified: index
===================================================================
--- index 2009-10-09 10:49:21 UTC (rev 4102)
+++ index 2009-10-11 08:02:00 UTC (rev 4103)
@@ -111,7 +111,7 @@
<header class=head><p><a class=logo href=http://www.whatwg.org/ rel=home><img alt=WHATWG src=/images/logo></a></p>
<hgroup><h1>HTML5</h1>
- <h2 class="no-num no-toc">Draft Standard — 9 October 2009</h2>
+ <h2 class="no-num no-toc">Draft Standard — 11 October 2009</h2>
</hgroup><p>You can take part in this work. <a href=http://www.whatwg.org/mailing-list>Join the working group's discussion list.</a></p>
<p><strong>Web designers!</strong> We have a <a href=http://blog.whatwg.org/faq/>FAQ</a>, a <a href=http://forums.whatwg.org/>forum</a>, and a <a href=http://www.whatwg.org/mailing-list#help>help mailing list</a> for you!</p>
<!--<p class="impl"><strong>Implementors!</strong> We have a <a href="http://www.whatwg.org/mailing-list#implementors">mailing list</a> for you too!</p>-->
@@ -9781,7 +9781,7 @@
<li>
- <p>If there is a <a href=#pending-external-script>pending external script</a>, then the
+ <p>If there is a <a href=#pending-parsing-blocking-script>pending parsing-blocking script</a>, then the
method must now return without further processing of the
<a href=#the-input-stream>input stream</a>.</p>
@@ -10603,22 +10603,15 @@
followed and 404 responses must cause the external resource to not
be applied.)</p>
- <!-- similar text in various places -->
- <p>Fetching external resources must <a href=#delay-the-load-event>delay the load
- event</a> of the element's document until the <a href=#concept-task title=concept-task>task</a> that is <a href=#queue-a-task title="queue a
- task">queued</a> by the <a href=#networking-task-source>networking task source</a> once
- the resource has been <a href=#fetch title=fetch>fetched</a> (defined
- below) has been run.</p>
-
- <!-- the next paragraph is similar to text in the <style> section -->
- <p>The <a href=#concept-task title=concept-task>task</a> that is <a href=#queue-a-task title="queue a task">queued</a> by the <a href=#networking-task-source>networking task
- source</a> once the resource has been <a href=#fetch title=fetch>fetched</a> must, if the loads were successful,
- <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named
- <code title=event-load>load</code> at the <code><a href=#the-link-element>link</a></code>
- element; otherwise, if the resource or one of its subresources
- failed to completely load for any reason (e.g. DNS error, HTTP 404
- response, a connection being prematurely closed, unsupported
- Content-Type), it must instead <a href=#queue-a-task>queue a task</a> to
+ <!-- the next few paragraph are similar to text in the <style> section -->
+ <p>Once the attempts to obtain the resource and its critical
+ subresources are complete, the user agent must, if the loads were
+ successful, <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple
+ event</a> named <code title=event-load>load</code> at the
+ <code><a href=#the-link-element>link</a></code> element, or, if the resource or one of its
+ critical subresources failed to completely load for any reason
+ (e.g. DNS error, HTTP 404 response, a connection being prematurely
+ closed, unsupported Content-Type), <a href=#queue-a-task>queue a task</a> to
<a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-error>error</code> at the <code><a href=#the-link-element>link</a></code>
element. Non-network errors in processing the resource or its
subresources (e.g. CSS parse errors, PNG decoding errors) are not
@@ -10627,6 +10620,14 @@
<p>The <a href=#task-source>task source</a> for these <a href=#concept-task title=concept-task>tasks</a> is the <a href=#dom-manipulation-task-source>DOM manipulation
task source</a>.</p>
+ <p>The element must <a href=#delay-the-load-event>delay the load event</a> of the
+ element's document until all the attempts to obtain the resource and
+ its critical subresources are complete.</p>
+
+ <p>Which resources are considered critical or not is defind by the
+ relevant specification. For CSS resources, only <code title="">@import</code> rules introduce critical subresources; other
+ resources, e.g. fonts or backgrounds, are not.</p>
+
<hr><p id=linkui>Interactive user agents may provide users with a
means to <a href=#following-hyperlinks title="following hyperlinks">follow the
hyperlinks</a> created using the <code><a href=#the-link-element>link</a></code> element,
@@ -10739,8 +10740,8 @@
resource link type has a default type defined, then the user agent
must assume that the resource is of that type.</p>
- <p class=note>The <code title=link-type-stylesheet>stylesheet</code> link type defines
- rules for processing the resource's <a href=#content-type title=Content-Type>Content-Type metadata</a>.</p>
+ <p class=note>The <code title=rel-stylesheet><a href=#link-type-stylesheet>stylesheet</a></code>
+ link type defines rules for processing the resource's <a href=#content-type title=Content-Type>Content-Type metadata</a>.</p>
<p>Once the user agent has established the type of the resource, the
user agent must apply the resource if it is of a supported type and
@@ -11727,10 +11728,6 @@
</div>
- <p>However, if the link is an <a href=#external-resource-link>external resource link</a>,
- then the <code title=attr-link-media><a href=#attr-link-media>media</a></code> attribute is
- prescriptive.
-
<p>The <dfn id=attr-style-media title=attr-style-media><code>media</code></dfn>
attribute says which media the styles apply to. The value must be a
<a href=#valid-media-query>valid media query</a>. <span class=impl>The user agent
@@ -11800,24 +11797,33 @@
when the processor is invoked.<!-- so dynamic changes to the base
URL don't affect the CSS --></p>
- <!-- the next paragraph is similar to text in the <link> section -->
- <p>Once the element has been evaluated, if it had no subresources or
- once all the subresources it uses have been <a href=#fetch title=fetch>fetched</a>, the user agent must <a href=#queue-a-task>queue a
- task</a> to <a href=#fire-a-simple-event>fire a simple event</a> named <code title=event-load>load</code> at the <code><a href=#the-style-element>style</a></code> element. If
- the resource has a subresource that fails to completely load for any
- reason (e.g. DNS error, HTTP 404 response, the connection being
- prematurely closed, unsupported Content-Type), the user agent must
- instead <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple
- event</a> named <code title=event-error>error</code> at the
- <code><a href=#the-style-element>style</a></code> element. Non-network errors in the processing of
- the element's contents or its subresources (e.g. CSS parse errors)
- are not failures for the purposes of this paragraph. The
- <code><a href=#the-style-element>style</a></code> element must <a href=#delay-the-load-event>delay the load event</a> of
- the element's document until one of these <a href=#concept-task title=concept-task>tasks</a> has been queued.</p>
+ <!-- the next few paragraph are similar to text in the <style> section -->
+ <p>Once the attempts to obtain the style sheet's critical
+ subresources, if any, are complete, or, if the style sheet has no
+ critical subresources, once the style sheet has been parsed and
+ processed, the user agent must, if the loads were successful or
+ there were none, <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple
+ event</a> named <code title=event-load>load</code> at the
+ <code><a href=#the-style-element>style</a></code> element, or, if one of the style sheet's critical
+ subresources failed to completely load for any reason (e.g. DNS
+ error, HTTP 404 response, a connection being prematurely closed,
+ unsupported Content-Type), <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a
+ simple event</a> named <code title=event-error>error</code> at
+ the <code><a href=#the-style-element>style</a></code> element. Non-network errors in processing the
+ style sheet or its subresources (e.g. CSS parse errors, PNG decoding
+ errors) are not failures for the purposes of this paragraph.</p>
- <p>The <a href=#task-source>task source</a> for these <a href=#concept-task title=concept-task>tasks</a> is the <a href=#dom-manipulation-task-source>DOM manipulation
- task source</a>.</p>
+ <p>The <a href=#task-source>task source</a> for these <a href=#concept-task title=concept-task>tasks</a> is the <a href=#dom-manipulation-task-source>DOM manipulation task
+ source</a>.</p>
+ <p>The element must <a href=#delay-the-load-event>delay the load event</a> of the
+ element's document until all the attempts to obtain the style
+ sheet's critical subresources, if any, are complete.</p>
+
+ <p>Which resources are considered critical or not is defind by the
+ relevant specification. For CSS resources, only <code title="">@import</code> rules introduce critical subresources; other
+ resources, e.g. fonts or backgrounds, are not.</p>
+
</div>
<p class=note>This specification does not specify a style system,
@@ -11956,11 +11962,39 @@
<p id=alternate-style-sheets>The rules for handling alternative
style sheets are defined in the CSS object model specification. <a href=#refsCSSOM>[CSSOM]</a></p>
+ <hr><p>Style sheets, whether added by a <code><a href=#the-link-element>link</a></code> element, a
+ <code><a href=#the-style-element>style</a></code> element, an <code><?xml-stylesheet></code> PI,
+ an HTTP <code title=http-link>Link:</code> header, or some other
+ mechanism, have a <dfn id=style-sheet-ready>style sheet ready</dfn> flag, which is
+ initially unset.</p>
+
+ <p>When a style sheet is ready to be applied, its <a href=#style-sheet-ready>style sheet
+ ready</a> flag must be set. If the style sheet referenced no
+ other resources (e.g. it was an internal style sheet given by a
+ <code><a href=#the-style-element>style</a></code> element with no <code title="">@import</code>
+ rules), then the style rules must be synchronously made available to
+ script; otherwise, the style rules must only be made available to
+ script once the <a href=#event-loop>event loop</a> reaches its "update the
+ rendering" step.</p>
+
+ <p>A style sheet in the context of the <code>Document</code> of an
+ <a href=#html-parser>HTML parser</a> or <a href=#xml-parser>XML parser</a> is said to be
+ <dfn id=a-style-sheet-blocking-scripts>a style sheet blocking scripts</dfn> if the element was created
+ by that <code>Document</code>'s parser, and the element is either a
+ <code><a href=#the-style-element>style</a></code> element or a <code><a href=#the-link-element>link</a></code> element that was
+ an <a href=#link-type-stylesheet title=rel-stylesheet>external resource link that
+ contributes to the styling processing model</a> when the element
+ was created by the parser, and the element's style sheet was enabled
+ when the element was created by the parser, and the element's
+ <a href=#style-sheet-ready>style sheet ready</a> flag is not yet set, and, the last
+ time the <a href=#event-loop>event loop</a> reached step 1, the element was
+ <a href=#in-a-document title="in a document">in that
+ <code>Document</code></a>.</p>
+
</div>
-
<h3 id=scripting-1><span class=secno>4.3 </span>Scripting</h3>
<p>Scripts allow authors to add interactivity to their documents.</p>
@@ -12091,26 +12125,38 @@
<div class=impl>
- <p><code><a href=#script>script</a></code> elements have four associated pieces of
- metadata. The first is a flag indicating whether or not the script
- block has been <dfn id=already-executed>"already executed"</dfn>. Initially,
+ <p>A <code><a href=#script>script</a></code> element has several associated pieces of
+ state.</p>
+
+ <p>The first is a flag indicating whether or not the script block
+ has been <dfn id=already-started>"already started"</dfn>. Initially,
<code><a href=#script>script</a></code> elements must have this flag unset (script
- blocks, when created, are not "already executed"). When a
- <code><a href=#script>script</a></code> element is cloned, the "already executed" flag,
- if set, must be propagated to the clone when it is created. The
- second is a flag indicating whether the element was
+ blocks, when created, are not "already started"). When a
+ <code><a href=#script>script</a></code> element is cloned, the "already started" flag,
+ if set, must be propagated to the clone when it is created.</p>
+
+ <p>The second is a flag indicating whether the element was
<dfn id=parser-inserted>"parser-inserted"</dfn>. This flag is set by the <a href=#html-parser>HTML
- parser</a> and is used to handle <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> calls. The third
- and fourth pieces of metadata are <dfn id="the-script-block's-type"><var>the script block's
- type</var></dfn> and <dfn id="the-script-block's-character-encoding"><var>the script block's character
+ parser</a> and is used to handle <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> calls.</p>
+
+ <p>The third is a flag indicating whether or not the script block is
+ <dfn id=ready-to-be-parser-executed>"ready to be parser-executed"</dfn>. Initially,
+ <code><a href=#script>script</a></code> elements must have this flag unset (script
+ blocks, when created, are not "ready to be parser-executed"). This
+ flag is used only for elements that are also
+ <a href=#parser-inserted>"parser-inserted"</a>, to let the parser know when to
+ execute the script.</p>
+
+ <p>The fourth and fifth pieces of state are <dfn id="the-script-block's-type"><var>the script
+ block's type</var></dfn> and <dfn id="the-script-block's-character-encoding"><var>the script block's character
encoding</var></dfn>. They are determined when the script is run,
based on the attributes on the element at that time.</p>
<p>When a <code><a href=#script>script</a></code> element that is neither marked as
- having <a href=#already-executed>"already executed"</a> nor marked as being
+ having <a href=#already-started>"already started"</a> nor marked as being
<a href=#parser-inserted>"parser-inserted"</a> experiences one of the events listed
- in the following list, the user agent must <a href=#running-a-script title="running a
- script">run</a> the <code><a href=#script>script</a></code> element:</p>
+ in the following list, the user agent must synchronously <a href=#running-a-script title="running a script">run</a> the <code><a href=#script>script</a></code>
+ element:</p>
<ul><li>The <code><a href=#script>script</a></code> element gets <a href=#insert-an-element-into-a-document title="insert an
element into a document">inserted into a document</a>.</li>
@@ -12191,8 +12237,8 @@
<li>
- <p>The user agent must set the element's <a href=#already-executed>"already
- executed"</a> flag.</p>
+ <p>The user agent must set the element's <a href=#already-started>"already
+ started"</a> flag.</p>
</li>
@@ -12218,13 +12264,6 @@
user agent supports that encoding, then let <var><a href="#the-script-block's-character-encoding">the script
block's character encoding</a></var> be that encoding.</p>
- <p>Once the fetching process has completed, and the script has
- <dfn id=completed-loading>completed loading</dfn>, the user agent will have to complete
- <a href=#when-a-script-completes-loading title="when a script completes loading">the steps described
- below</a>. (If the parser is still active at that time, those
- steps defer to the parser to handle the execution of pending
- scripts.)</p>
-
<p>For performance reasons, user agents may start fetching the
script as soon as the attribute is set, instead, in the hope that
the element will be inserted into the document. Either way, once
@@ -12248,112 +12287,94 @@
has been flagged as <a href=#parser-inserted>"parser-inserted"</a>, and the
element does not have an <code title=attr-script-async><a href=#attr-script-async>async</a></code> attribute</dt>
- <dd>The element must be added to the end of the <a href=#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of
- scripts that will execute when the document has finished
- parsing</a>.</dd>
+ <dd>
+ <p>The element must be added to the end of the <dfn id=list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of
+ scripts that will execute when the document has finished
+ parsing</dfn>.</p>
- <dt>If the element has a <code title=attr-script-src><a href=#attr-script-src>src</a></code>
- attribute, and the element has been flagged as
- <a href=#parser-inserted>"parser-inserted"</a>, and the element does not have an
- <code title=attr-script-async><a href=#attr-script-async>async</a></code> attribute</dt>
+ <p>The <a href=#concept-task title=concept-task>task</a> that the
+ <a href=#networking-task-source>networking task source</a> places on the <a href=#task-queue>task
+ queue</a> once the <a href=#fetch title=fetch>fetching
+ algorithm</a> has completed must set the element's
+ <a href=#ready-to-be-parser-executed>"ready to be parser-executed"</a> flag. The parser will
+ handle executing the script.</p>
- <dd>The element is the <dfn id=pending-external-script>pending external script</dfn>. (There
- can only be one such script at a time.)</dd>
+ </dd>
<dt>If the element has a <code title=attr-script-src><a href=#attr-script-src>src</a></code>
- attribute</dt>
+ attribute, and the element has been flagged as
+ <a href=#parser-inserted>"parser-inserted"</a>, and the element does not have an
+ <code title=attr-script-async><a href=#attr-script-async>async</a></code> attribute, or</dt>
- <dd>The element must be added to the end of the <a href=#list-of-scripts-that-will-execute-as-soon-as-possible>list of
- scripts that will execute as soon as possible</a>.</dd>
+ <dd>
+ <p>The element is the <a href=#pending-parsing-blocking-script>pending parsing-blocking
+ script</a>. (There can only be one such script at a
+ time.)</p>
- <dt>Otherwise</dt>
+ <p>The <a href=#concept-task title=concept-task>task</a> that the
+ <a href=#networking-task-source>networking task source</a> places on the <a href=#task-queue>task
+ queue</a> once the <a href=#fetch title=fetch>fetching
+ algorithm</a> has completed must set the element's
+ <a href=#ready-to-be-parser-executed>"ready to be parser-executed"</a> flag. The parser will
+ handle executing the script.</p>
- <dd>The user agent must immediately <a href=#executing-a-script-block title="executing a
- script block">execute the script block</a>, even if other
- scripts are already executing.</dd>
+ </dd>
- </dl></li>
- </ol><!-- similar text in various places --><p>Fetching an external script must <a href=#delay-the-load-event>delay the load
- event</a> of the element's document until the <a href=#concept-task title=concept-task>task</a> that is <a href=#queue-a-task title="queue a
- task">queued</a> by the <a href=#networking-task-source>networking task source</a> once
- the resource has been <a href=#fetch title=fetch>fetched</a> (defined
- below) has been run.</p>
+ <dt>If the element does not have a <code title=attr-script-src><a href=#attr-script-src>src</a></code> attribute, but there is
+ <a href=#a-style-sheet-blocking-scripts>a style sheet blocking scripts</a>, and the element has
+ been flagged as <a href=#parser-inserted>"parser-inserted"</a></dt>
- <p><dfn id=when-a-script-completes-loading>When a script completes loading</dfn>: The UA must run the
- following steps as the <a href=#concept-task title=concept-task>task</a> that
- the <a href=#networking-task-source>networking task source</a> places on the <a href=#task-queue>task
- queue</a>:</p>
+ <dd>
- <dl class=switch><dt>If the <code><a href=#script>script</a></code> element was added to the <dfn id=list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list
- of scripts that will execute when the document has finished
- parsing</dfn>:</dt>
+ <p>The element is the <a href=#pending-parsing-blocking-script>pending parsing-blocking
+ script</a>. (There can only be one such script at a
+ time.)</p>
- <dd>
+ <p>Set the element's <a href=#ready-to-be-parser-executed>"ready to be parser-executed"</a>
+ flag. The parser will handle executing the script.</p>
- <ol><li>
+ </dd>
- <p>If the script's <code>Document</code> is still being parsed,
- then the parser handles it. Abort these steps.</p>
- </li>
+ <dt>If the element has a <code title=attr-script-src><a href=#attr-script-src>src</a></code>
+ attribute</dt>
- <li>
+ <dd>
- <p>If the <code><a href=#script>script</a></code> element is not the first element
- in the list, then do nothing yet. Stop going through these
- steps.</p>
+ <p>The element must be added to the end of the <dfn id=list-of-scripts-that-will-execute-as-soon-as-possible>list of
+ scripts that will execute as soon as possible</dfn>.</p>
- </li>
+ <p>The <a href=#concept-task title=concept-task>task</a> that the
+ <a href=#networking-task-source>networking task source</a> places on the <a href=#task-queue>task
+ queue</a> once the <a href=#fetch title=fetch>fetching
+ algorithm</a> has completed must <a href=#executing-a-script-block title="executing a
+ script block">execute the script block</a>.
- <li>
+ </dd>
- <p>Otherwise, <a href=#executing-a-script-block title="executing a script block">execute the
- script block</a> (the first element in the list).</p>
- </li>
+ <dt>Otherwise</dt>
- <li>
+ <dd>The user agent must immediately <a href=#executing-a-script-block title="executing a
+ script block">execute the script block</a>, even if other
+ scripts are already executing.</dd>
- <p>Remove the <code><a href=#script>script</a></code> element from the list
- (i.e. shift out the first entry in the list).</p>
+ </dl></li>
- </li>
+ </ol><!-- similar text in various places --><p>Fetching an external script must <a href=#delay-the-load-event>delay the load
+ event</a> of the element's document until the <a href=#concept-task title=concept-task>task</a> that is <a href=#queue-a-task title="queue a
+ task">queued</a> by the <a href=#networking-task-source>networking task source</a> once
+ the resource has been <a href=#fetch title=fetch>fetched</a> (defined
+ above) has been run.</p>
- <li>
+ <p>The <dfn id=pending-parsing-blocking-script>pending parsing-blocking script</dfn> is used by the
+ parser.</p>
- <p>If there are any more entries in the list, and if the script
- associated with the element that is now the first in the list is
- already loaded, then jump back to step 2 to execute it.</p>
-
- </li>
-
- </ol></dd>
-
- <dt>If the <code><a href=#script>script</a></code> element was added to the <dfn id=list-of-scripts-that-will-execute-as-soon-as-possible>list
- of scripts that will execute as soon as possible</dfn>:</dt>
-
- <dd>
-
- <ol><li>
-
- <p><a href=#executing-a-script-block title="executing a script block">Execute the
- script block</a>.</p>
-
- </li>
-
- <li>
-
- <p>Remove the <code><a href=#script>script</a></code> element from the list.</p>
-
- </li>
-
- </ol></dd>
-
- </dl><p><dfn id=executing-a-script-block title="executing a script block">Executing a script
+ <p><dfn id=executing-a-script-block title="executing a script block">Executing a script
block</dfn>: When the steps above require that the script block be
executed, the user agent must act as follows:</p>
@@ -47656,6 +47677,27 @@
<li><p>Return to the first step of the <a href=#event-loop>event
loop</a>.</li>
+ </ol><hr><p>When an algorithm says to <dfn id=spin-the-event-loop>spin the event loop</dfn> until
+ a condition <var title="">goal</var> is met, the user agent must run
+ the following steps:</p>
+
+ <ol><li><p>Let <var title="">task source</var> be the <a href=#task-source>task
+ source</a> of the currently running <a href=#concept-task title=concept-task>task</a>.</li>
+
+ <li><p>Stop the currently running <a href=#concept-task title=concept-task>task</a>, allowing the <a href=#event-loop>event
+ loop</a> to resume, but continue these steps
+ asynchronously.</li>
+
+ <li><p>Wait until the condition <var title="">goal</var> is
+ met.</li>
+
+ <li><p><a href=#queue-a-task>Queue a task</a> to continue running these steps,
+ using the <a href=#task-source>task source</a> <var title="">task
+ source</var>. Wait until this task runs before continuing these
+ steps.</li>
+
+ <li><p>Return to the caller.</li>
+
</ol><hr><p>Some of the algorithms in this specification, for historical
reasons, require the user agent to <dfn id=pause>pause</dfn> while running a
<a href=#concept-task title=concept-task>task</a> until some condition has been
@@ -63307,8 +63349,8 @@
<li><p>If the parser was originally created for the <a href=#html-fragment-parsing-algorithm>HTML
fragment parsing algorithm</a>, then mark the
- <code><a href=#script>script</a></code> element as <a href=#already-executed>"already
- executed"</a>. (<a href=#fragment-case>fragment case</a>)</li>
+ <code><a href=#script>script</a></code> element as <a href=#already-started>"already
+ started"</a>. (<a href=#fragment-case>fragment case</a>)</li>
<li><p>Append the new element to the <a href=#current-node>current node</a>
and push it onto the <a href=#stack-of-open-elements>stack of open
@@ -64741,8 +64783,8 @@
<p><a href=#parse-error>Parse error</a>.</p>
<p>If the <a href=#current-node>current node</a> is a <code><a href=#script>script</a></code>
- element, mark the <code><a href=#script>script</a></code> element as <a href=#already-executed>"already
- executed"</a>.</p>
+ element, mark the <code><a href=#script>script</a></code> element as <a href=#already-started>"already
+ started"</a>.</p>
<p>Pop the <a href=#current-node>current node</a> off the <a href=#stack-of-open-elements>stack of open
elements</a>.</p>
@@ -64786,7 +64828,7 @@
might be the "undefined" value.)</p>
<p id=scriptTagParserResumes>At this stage, if there is a
- <a href=#pending-external-script>pending external script</a>, then:</p>
+ <a href=#pending-parsing-blocking-script>pending parsing-blocking script</a>, then:</p>
<dl class=switch><dt>If the <a href=#script-nesting-level>script nesting level</a> is not zero:</dt>
@@ -64810,13 +64852,23 @@
<p>Follow these steps:</p>
- <ol><li><p>Let <var title="">the script</var> be the <a href=#pending-external-script>pending
- external script</a>. There is no longer a <a href=#pending-external-script>pending
- external script</a>.</li>
+ <ol><li><p>Let <var title="">the script</var> be the <a href=#pending-parsing-blocking-script>pending
+ parsing-blocking script</a>. There is no longer a <a href=#pending-parsing-blocking-script>pending
+ parsing-blocking script</a>.</li>
- <li><p><a href=#pause>Pause</a> until the script has <a href=#completed-loading>completed
- loading</a>.</li>
+ <li><p>Block the <a href=#tokenization title=tokenization>tokenizer</a>
+ for this instance of the <a href=#html-parser>HTML parser</a>, such that
+ the <a href=#event-loop>event loop</a> will not run <a href=#concept-task title=concept-task>tasks</a> that invoke the <a href=#tokenization title=tokenization>tokenizer</a>.</li>
+ <li><p><a href=#spin-the-event-loop>Spin the event loop</a> until there is no <a href=#a-style-sheet-blocking-scripts title="a style sheet blocking scripts">style sheet blocking
+ scripts</a> and <var title="">the script</var>'s
+ <a href=#ready-to-be-parser-executed>"ready to be parser-executed"</a> flag is set.</li>
+
+ <li><p>Unblock the <a href=#tokenization title=tokenization>tokenizer</a>
+ for this instance of the <a href=#html-parser>HTML parser</a>, such that
+ <a href=#concept-task title=concept-task>tasks</a> that invoke the <a href=#tokenization title=tokenization>tokenizer</a> can again be
+ run.</li>
+
<li><p>Let the <a href=#insertion-point>insertion point</a> be just before the
<a href=#next-input-character>next input character</a>.</li>
@@ -64824,8 +64876,8 @@
by one (it should be zero before this step, so this sets it to
one).</li>
- <li><p><a href=#executing-a-script-block title="executing a script block">Execute the
- script</a>.</li>
+ <li><p><a href=#executing-a-script-block title="executing a script block">Execute</a>
+ <var title="">the script</var>.</li>
<li><p>Decrement the parser's <a href=#script-nesting-level>script nesting level</a>
by one. If the parser's <a href=#script-nesting-level>script nesting level</a> is
@@ -64835,7 +64887,7 @@
<li><p>Let the <a href=#insertion-point>insertion point</a> be undefined
again.</li>
- <li><p>If there is once again a <a href=#pending-external-script>pending external
+ <li><p>If there is once again a <a href=#pending-parsing-blocking-script>pending parsing-blocking
script</a>, then repeat these steps from step 1.</li>
</ol></dd>
@@ -66145,53 +66197,55 @@
<h4 id=the-end><span class=secno>9.2.6 </span>The end</h4>
<p>Once the user agent <dfn id=stop-parsing title="stop parsing">stops parsing</dfn>
- the document, the user agent must follow the steps in this
- section.</p>
+ the document, the user agent must run the following steps:</p>
- <!-- this happens as part of one of the tasks that runs the parser -->
+ <ol><!-- this happens as part of one of the tasks that runs the parser --><li><p>Set the <a href=#current-document-readiness>current document readiness</a> to
+ "interactive" <!-- this also synchronously fires an event --> and
+ the <a href=#insertion-point>insertion point</a> to undefined.</li>
- <p>First, the user agent must set the <a href=#current-document-readiness>current document
- readiness</a> to "interactive" and the <a href=#insertion-point>insertion
- point</a> to undefined.</p> <!-- this also synchronously fires an
- event -->
+ <li><p>If the <a href=#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of scripts that will execute when the
+ document has finished parsing</a> is not empty, run these
+ substeps:</p>
- <p>Then, the user agent must then make a list of all the scripts
- that are in the <a href=#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of scripts that will execute when the
- document has finished parsing</a> and the <a href=#list-of-scripts-that-will-execute-as-soon-as-possible>list of scripts
- that will execute as soon as possible</a>. This is the <dfn id=list-of-scripts-pending-after-the-parser-stopped>list
- of scripts pending after the parser stopped</dfn>.</p>
+ <ol><li><p><a href=#spin-the-event-loop>Spin the event loop</a> until the first
+ <code><a href=#script>script</a></code> in the <a href=#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of scripts that will
+ execute when the document has finished parsing</a> has its
+ <a href=#ready-to-be-parser-executed>"ready to be parser-executed"</a> flag set <em>and</em> there
+ is no <a href=#a-style-sheet-blocking-scripts title="a style sheet blocking scripts">style sheet
+ blocking scripts</a>.</li>
- <p>The document is no longer being parsed, so the rules for
- <a href=#when-a-script-completes-loading>when a script completes loading</a> for the <a href=#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of
- scripts that will execute when the document has finished
- parsing</a> start applying (script execution for that list is no
- longer managed by the parser).</p>
+ <li><p><a href=#executing-a-script-block title="executing a script block">Execute</a> the
+ first <code><a href=#script>script</a></code> in the <a href=#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of scripts that will
+ execute when the document has finished parsing</a>.</li>
- <p>If the <a href=#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of scripts that will execute when the document
- has finished parsing</a> is not empty, and the first item in this
- list has already <a href=#completed-loading>completed loading</a>, then the user agent
- must act as if that script just finished loading.</p>
+ <li><p>Remove the first <code><a href=#script>script</a></code> element from the
+ <a href=#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of scripts that will execute when the document has
+ finished parsing</a> (i.e. shift out the first entry in the
+ list).</li>
+
+ <li><p>If the <a href=#list-of-scripts-that-will-execute-when-the-document-has-finished-parsing>list of scripts that will execute when the
+ document has finished parsing</a> is still not empty, repeat
+ these substeps again from substep 1.</p>
- <p class=note>By this point, there will be no scripts that have
- loaded but have not yet been executed.</p>
+ </ol></li>
- <hr><!-- async --><p>Once all the scripts on the <a href=#list-of-scripts-pending-after-the-parser-stopped>list of scripts pending after
- the parser stopped</a> have <a href=#completed-loading>completed loading</a> and
- been <a href=#executing-a-script-block title="executing a script block">executed</a>, the
- user agent must <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a simple
- event</a> named <code title=event-DOMContentLoaded>DOMContentLoaded</code> at the
- <code>Document</code>. (If the list is empty, this happens
- immediately.)</p>
+ <li><p><a href=#spin-the-event-loop>Spin the event loop</a> until the the <a href=#list-of-scripts-that-will-execute-as-soon-as-possible>list of
+ scripts that will execute as soon as possible</a> is
+ empty.</li>
- <hr><!-- async --><p>Once everything that <dfn id=delay-the-load-event title="delay the load event">delays the
- load event</dfn> of the document has completed, the user agent must
- run the following steps:</p>
+ <li><p><a href=#queue-a-task>Queue a task</a> to <a href=#fire-a-simple-event>fire a simple
+ event</a> named <code title=event-DOMContentLoaded>DOMContentLoaded</code> at the
+ <code>Document</code>.</li>
- <ol><li><a href=#queue-a-task>Queue a task</a> to set the <a href=#current-document-readiness>current document
- readiness</a> to "complete".</li> <!-- this also fires an event
- synchronously during the task -->
+ <li><p><a href=#spin-the-event-loop>Spin the event loop</a> until there is nothing that
+ <dfn id=delay-the-load-event title="delay the load event">delays the load event</dfn> in
+ the <code>Document</code>.</li>
- <li>If the <code>Document</code> is in a <a href=#browsing-context>browsing
+ <li><p><a href=#queue-a-task>Queue a task</a> to set the <a href=#current-document-readiness>current document
+ readiness</a> to "complete". <!-- this also fires an event
+ synchronously during the task --></li>
+
+ <li><p>If the <code>Document</code> is in a <a href=#browsing-context>browsing
context</a>, then <a href=#queue-a-task>queue a task</a> to <a href=#fire-a-simple-event>fire a
simple event</a> named <code title=event-load>load</code> at
the <code>Document</code>'s <code><a href=#window>Window</a></code> object, but with
@@ -66199,15 +66253,16 @@
<code>Document</code> object (and the <code title=dom-event-currentTarget>currentTarget</code> set to the
<code><a href=#window>Window</a></code> object).</li>
- <li>If the <code>Document</code> has a <a href=#pending-state-object>pending state
+ <li><p>If the <code>Document</code> has a <a href=#pending-state-object>pending state
object</a>, then <a href=#queue-a-task>queue a task</a> to fire a <code title=event-popstate><a href=#event-popstate>popstate</a></code> event in no namespace on the
<code>Document</code>'s <code><a href=#window>Window</a></code> object using the
<code><a href=#popstateevent>PopStateEvent</a></code> interface, with the <code title=dom-PopStateEvent-state><a href=#dom-popstateevent-state>state</a></code> attribute set to the
current value of the <a href=#pending-state-object>pending state object</a>. This event
- must bubble but not be cancelable and has no default action.</li>
+ must bubble but not be cancelable and has no default
+ action.</li>
- </ol><p>The <a href=#task-source>task source</a> for these <a href=#concept-task title=concept-task>tasks</a> is the <a href=#dom-manipulation-task-source>DOM manipulation
- task source</a>.</p>
+ </ol><p>The <a href=#task-source>task source</a> for the <a href=#concept-task title=concept-task>tasks</a> mentioned in this section is the
+ <a href=#dom-manipulation-task-source>DOM manipulation task source</a>.</p>
</div>
@@ -69149,15 +69204,31 @@
element, it must be marked as being <a href=#parser-inserted>"parser-inserted"</a>.
If the parser was originally created for the <a href=#xml-fragment-parsing-algorithm>XML fragment
parsing algorithm</a>, then the element must be marked as
- <a href=#already-executed>"already executed"</a> also. When the element's end tag is
+ <a href=#already-started>"already started"</a> also. When the element's end tag is
parsed, the user agent must <a href=#running-a-script title="running a
script">run</a> the <code><a href=#script>script</a></code> element. If this causes
- there to be a <a href=#pending-external-script>pending external script</a>, then the user
- agent must <a href=#pause>pause</a> until that script has <a href=#completed-loading>completed
- loading</a>, and then <a href=#executing-a-script-block title="executing a script
- block">execute it</a>.</p>
+ there to be a <a href=#pending-parsing-blocking-script>pending parsing-blocking script</a>, then the
+ user agent must run the following steps:</p>
- <p class=note>Since the <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> API is not
+ <ol><li><p>Block this instance of the <a href=#xml-parser>XML parser</a>, such
+ that the <a href=#event-loop>event loop</a> will not run <a href=#concept-task title=concept-task>tasks</a> that invoke it.</li>
+
+ <li><p><a href=#spin-the-event-loop>Spin the event loop</a> until there is no <a href=#a-style-sheet-blocking-scripts title="a style sheet blocking scripts">style sheet blocking
+ scripts</a> and the <a href=#pending-parsing-blocking-script>pending parsing-blocking
+ script</a>'s <a href=#ready-to-be-parser-executed>"ready to be parser-executed"</a> flag is
+ set.</li>
+
+ <li><p>Unblock this instance of the <a href=#xml-parser>XML parser</a>, such
+ that <a href=#concept-task title=concept-task>tasks</a> that invoke it can
+ again be run.</li>
+
+ <li><p><a href=#executing-a-script-block title="executing a script block">Execute</a> the
+ <a href=#pending-parsing-blocking-script>pending parsing-blocking script</a>.</li>
+
+ <li><p>There is no longer a <a href=#pending-parsing-blocking-script>pending parsing-blocking
+ script</a>.</li>
+
+ </ol><p class=note>Since the <code title=dom-document-write><a href=#dom-document-write>document.write()</a></code> API is not
available for <a href=#xml-documents>XML documents</a>, much of the complexity in
the <a href=#html-parser>HTML parser</a> is not needed in the <a href=#xml-parser>XML
parser</a>.</p>
Modified: source
===================================================================
--- source 2009-10-09 10:49:21 UTC (rev 4102)
+++ source 2009-10-11 08:02:00 UTC (rev 4103)
@@ -10173,7 +10173,7 @@
<li>
- <p>If there is a <span>pending external script</span>, then the
+ <p>If there is a <span>pending parsing-blocking script</span>, then the
method must now return without further processing of the
<span>input stream</span>.</p>
@@ -11099,25 +11099,15 @@
followed and 404 responses must cause the external resource to not
be applied.)</p>
- <!-- similar text in various places -->
- <p>Fetching external resources must <span>delay the load
- event</span> of the element's document until the <span
- title="concept-task">task</span> that is <span title="queue a
- task">queued</span> by the <span>networking task source</span> once
- the resource has been <span title="fetch">fetched</span> (defined
- below) has been run.</p>
-
- <!-- the next paragraph is similar to text in the <style> section -->
- <p>The <span title="concept-task">task</span> that is <span
- title="queue a task">queued</span> by the <span>networking task
- source</span> once the resource has been <span
- title="fetch">fetched</span> must, if the loads were successful,
- <span>queue a task</span> to <span>fire a simple event</span> named
- <code title="event-load">load</code> at the <code>link</code>
- element; otherwise, if the resource or one of its subresources
- failed to completely load for any reason (e.g. DNS error, HTTP 404
- response, a connection being prematurely closed, unsupported
- Content-Type), it must instead <span>queue a task</span> to
+ <!-- the next few paragraph are similar to text in the <style> section -->
+ <p>Once the attempts to obtain the resource and its critical
+ subresources are complete, the user agent must, if the loads were
+ successful, <span>queue a task</span> to <span>fire a simple
+ event</span> named <code title="event-load">load</code> at the
+ <code>link</code> element, or, if the resource or one of its
+ critical subresources failed to completely load for any reason
+ (e.g. DNS error, HTTP 404 response, a connection being prematurely
+ closed, unsupported Content-Type), <span>queue a task</span> to
<span>fire a simple event</span> named <code
title="event-error">error</code> at the <code>link</code>
element. Non-network errors in processing the resource or its
@@ -11128,6 +11118,15 @@
title="concept-task">tasks</span> is the <span>DOM manipulation
task source</span>.</p>
+ <p>The element must <span>delay the load event</span> of the
+ element's document until all the attempts to obtain the resource and
+ its critical subresources are complete.</p>
+
+ <p>Which resources are considered critical or not is defind by the
+ relevant specification. For CSS resources, only <code
+ title="">@import</code> rules introduce critical subresources; other
+ resources, e.g. fonts or backgrounds, are not.</p>
+
<hr>
<p id="linkui">Interactive user agents may provide users with a
@@ -11265,9 +11264,8 @@
resource link type has a default type defined, then the user agent
must assume that the resource is of that type.</p>
- <p class="note">The <code
- title="link-type-stylesheet">stylesheet</code> link type defines
- rules for processing the resource's <span
+ <p class="note">The <code title="rel-stylesheet">stylesheet</code>
+ link type defines rules for processing the resource's <span
title="Content-Type">Content-Type metadata</span>.</p>
<p>Once the user agent has established the type of the resource, the
@@ -12390,10 +12388,6 @@
</div>
- <p>However, if the link is an <span>external resource link</span>,
- then the <code title="attr-link-media">media</code> attribute is
- prescriptive.
-
<p>The <dfn title="attr-style-media"><code>media</code></dfn>
attribute says which media the styles apply to. The value must be a
<span>valid media query</span>. <span class="impl">The user agent
@@ -12470,28 +12464,35 @@
when the processor is invoked.<!-- so dynamic changes to the base
URL don't affect the CSS --></p>
- <!-- the next paragraph is similar to text in the <link> section -->
- <p>Once the element has been evaluated, if it had no subresources or
- once all the subresources it uses have been <span
- title="fetch">fetched</span>, the user agent must <span>queue a
- task</span> to <span>fire a simple event</span> named <code
- title="event-load">load</code> at the <code>style</code> element. If
- the resource has a subresource that fails to completely load for any
- reason (e.g. DNS error, HTTP 404 response, the connection being
- prematurely closed, unsupported Content-Type), the user agent must
- instead <span>queue a task</span> to <span>fire a simple
- event</span> named <code title="event-error">error</code> at the
- <code>style</code> element. Non-network errors in the processing of
- the element's contents or its subresources (e.g. CSS parse errors)
- are not failures for the purposes of this paragraph. The
- <code>style</code> element must <span>delay the load event</span> of
- the element's document until one of these <span
- title="concept-task">tasks</span> has been queued.</p>
+ <!-- the next few paragraph are similar to text in the <style> section -->
+ <p>Once the attempts to obtain the style sheet's critical
+ subresources, if any, are complete, or, if the style sheet has no
+ critical subresources, once the style sheet has been parsed and
+ processed, the user agent must, if the loads were successful or
+ there were none, <span>queue a task</span> to <span>fire a simple
+ event</span> named <code title="event-load">load</code> at the
+ <code>style</code> element, or, if one of the style sheet's critical
+ subresources failed to completely load for any reason (e.g. DNS
+ error, HTTP 404 response, a connection being prematurely closed,
+ unsupported Content-Type), <span>queue a task</span> to <span>fire a
+ simple event</span> named <code title="event-error">error</code> at
+ the <code>style</code> element. Non-network errors in processing the
+ style sheet or its subresources (e.g. CSS parse errors, PNG decoding
+ errors) are not failures for the purposes of this paragraph.</p>
<p>The <span>task source</span> for these <span
- title="concept-task">tasks</span> is the <span>DOM manipulation
- task source</span>.</p>
+ title="concept-task">tasks</span> is the <span>DOM manipulation task
+ source</span>.</p>
+ <p>The element must <span>delay the load event</span> of the
+ element's document until all the attempts to obtain the style
+ sheet's critical subresources, if any, are complete.</p>
+
+ <p>Which resources are considered critical or not is defind by the
+ relevant specification. For CSS resources, only <code
+ title="">@import</code> rules introduce critical subresources; other
+ resources, e.g. fonts or backgrounds, are not.</p>
+
</div>
<p class="note">This specification does not specify a style system,
@@ -12652,11 +12653,41 @@
style sheets are defined in the CSS object model specification. <a
href="#refsCSSOM">[CSSOM]</a></p>
+ <hr>
+
+ <p>Style sheets, whether added by a <code>link</code> element, a
+ <code>style</code> element, an <code><?xml-stylesheet></code> PI,
+ an HTTP <code title="http-link">Link:</code> header, or some other
+ mechanism, have a <dfn>style sheet ready</dfn> flag, which is
+ initially unset.</p>
+
+ <p>When a style sheet is ready to be applied, its <span>style sheet
+ ready</span> flag must be set. If the style sheet referenced no
+ other resources (e.g. it was an internal style sheet given by a
+ <code>style</code> element with no <code title="">@import</code>
+ rules), then the style rules must be synchronously made available to
+ script; otherwise, the style rules must only be made available to
+ script once the <span>event loop</span> reaches its "update the
+ rendering" step.</p>
+
+ <p>A style sheet in the context of the <code>Document</code> of an
+ <span>HTML parser</span> or <span>XML parser</span> is said to be
+ <dfn>a style sheet blocking scripts</dfn> if the element was created
+ by that <code>Document</code>'s parser, and the element is either a
+ <code>style</code> element or a <code>link</code> element that was
+ an <span title="rel-stylesheet">external resource link that
+ contributes to the styling processing model</span> when the element
+ was created by the parser, and the element's style sheet was enabled
+ when the element was created by the parser, and the element's
+ <span>style sheet ready</span> flag is not yet set, and, the last
+ time the <span>event loop</span> reached step 1, the element was
+ <span title="in a document">in that
+ <code>Document</code></span>.</p>
+
</div>
-
<h3>Scripting</h3>
<p>Scripts allow authors to add interactivity to their documents.</p>
@@ -12807,27 +12838,40 @@
<div class="impl">
- <p><code>script</code> elements have four associated pieces of
- metadata. The first is a flag indicating whether or not the script
- block has been <dfn>"already executed"</dfn>. Initially,
+ <p>A <code>script</code> element has several associated pieces of
+ state.</p>
+
+ <p>The first is a flag indicating whether or not the script block
+ has been <dfn>"already started"</dfn>. Initially,
<code>script</code> elements must have this flag unset (script
- blocks, when created, are not "already executed"). When a
- <code>script</code> element is cloned, the "already executed" flag,
- if set, must be propagated to the clone when it is created. The
- second is a flag indicating whether the element was
+ blocks, when created, are not "already started"). When a
+ <code>script</code> element is cloned, the "already started" flag,
+ if set, must be propagated to the clone when it is created.</p>
+
+ <p>The second is a flag indicating whether the element was
<dfn>"parser-inserted"</dfn>. This flag is set by the <span>HTML
parser</span> and is used to handle <code
- title="dom-document-write">document.write()</code> calls. The third
- and fourth pieces of metadata are <dfn><var>the script block's
- type</var></dfn> and <dfn><var>the script block's character
+ title="dom-document-write">document.write()</code> calls.</p>
+
+ <p>The third is a flag indicating whether or not the script block is
+ <dfn>"ready to be parser-executed"</dfn>. Initially,
+ <code>script</code> elements must have this flag unset (script
+ blocks, when created, are not "ready to be parser-executed"). This
+ flag is used only for elements that are also
+ <span>"parser-inserted"</span>, to let the parser know when to
+ execute the script.</p>
+
+ <p>The fourth and fifth pieces of state are <dfn><var>the script
+ block's type</var></dfn> and <dfn><var>the script block's character
encoding</var></dfn>. They are determined when the script is run,
based on the attributes on the element at that time.</p>
<p>When a <code>script</code> element that is neither marked as
- having <span>"already executed"</span> nor marked as being
+ having <span>"already started"</span> nor marked as being
<span>"parser-inserted"</span> experiences one of the events listed
- in the following list, the user agent must <span title="running a
- script">run</span> the <code>script</code> element:</p>
+ in the following list, the user agent must synchronously <span
+ title="running a script">run</span> the <code>script</code>
+ element:</p>
<ul>
@@ -12935,7 +12979,7 @@
<li>
<p>The user agent must set the element's <span>"already
- executed"</span> flag.</p>
+ started"</span> flag.</p>
</li>
@@ -12964,13 +13008,6 @@
user agent supports that encoding, then let <var>the script
block's character encoding</var> be that encoding.</p>
- <p>Once the fetching process has completed, and the script has
- <dfn>completed loading</dfn>, the user agent will have to complete
- <span title="when a script completes loading">the steps described
- below</span>. (If the parser is still active at that time, those
- steps defer to the parser to handle the execution of pending
- scripts.)</p>
-
<p>For performance reasons, user agents may start fetching the
script as soon as the attribute is set, instead, in the hope that
the element will be inserted into the document. Either way, once
@@ -12999,27 +13036,77 @@
element does not have an <code
title="attr-script-async">async</code> attribute</dt>
- <dd>The element must be added to the end of the <span>list of
- scripts that will execute when the document has finished
- parsing</span>.</dd>
+ <dd>
+ <p>The element must be added to the end of the <dfn>list of
+ scripts that will execute when the document has finished
+ parsing</dfn>.</p>
+ <p>The <span title="concept-task">task</span> that the
+ <span>networking task source</span> places on the <span>task
+ queue</span> once the <span title="fetch">fetching
+ algorithm</span> has completed must set the element's
+ <span>"ready to be parser-executed"</span> flag. The parser will
+ handle executing the script.</p>
+
+ </dd>
+
+
<dt>If the element has a <code title="attr-script-src">src</code>
attribute, and the element has been flagged as
<span>"parser-inserted"</span>, and the element does not have an
- <code title="attr-script-async">async</code> attribute</dt>
+ <code title="attr-script-async">async</code> attribute, or</dt>
- <dd>The element is the <dfn>pending external script</dfn>. (There
- can only be one such script at a time.)</dd>
+ <dd>
+ <p>The element is the <span>pending parsing-blocking
+ script</span>. (There can only be one such script at a
+ time.)</p>
+ <p>The <span title="concept-task">task</span> that the
+ <span>networking task source</span> places on the <span>task
+ queue</span> once the <span title="fetch">fetching
+ algorithm</span> has completed must set the element's
+ <span>"ready to be parser-executed"</span> flag. The parser will
+ handle executing the script.</p>
+
+ </dd>
+
+
+ <dt>If the element does not have a <code
+ title="attr-script-src">src</code> attribute, but there is
+ <span>a style sheet blocking scripts</span>, and the element has
+ been flagged as <span>"parser-inserted"</span></dt>
+
+ <dd>
+
+ <p>The element is the <span>pending parsing-blocking
+ script</span>. (There can only be one such script at a
+ time.)</p>
+
+ <p>Set the element's <span>"ready to be parser-executed"</span>
+ flag. The parser will handle executing the script.</p>
+
+ </dd>
+
+
<dt>If the element has a <code title="attr-script-src">src</code>
attribute</dt>
- <dd>The element must be added to the end of the <span>list of
- scripts that will execute as soon as possible</span>.</dd>
+ <dd>
+ <p>The element must be added to the end of the <dfn>list of
+ scripts that will execute as soon as possible</dfn>.</p>
+ <p>The <span title="concept-task">task</span> that the
+ <span>networking task source</span> places on the <span>task
+ queue</span> once the <span title="fetch">fetching
+ algorithm</span> has completed must <span title="executing a
+ script block">execute the script block</span>.
+
+ </dd>
+
+
<dt>Otherwise</dt>
<dd>The user agent must immediately <span title="executing a
@@ -13038,90 +13125,11 @@
title="concept-task">task</span> that is <span title="queue a
task">queued</span> by the <span>networking task source</span> once
the resource has been <span title="fetch">fetched</span> (defined
- below) has been run.</p>
+ above) has been run.</p>
- <p><dfn>When a script completes loading</dfn>: The UA must run the
- following steps as the <span title="concept-task">task</span> that
- the <span>networking task source</span> places on the <span>task
- queue</span>:</p>
+ <p>The <dfn>pending parsing-blocking script</dfn> is used by the
+ parser.</p>
- <dl class="switch">
-
- <dt>If the <code>script</code> element was added to the <dfn>list
- of scripts that will execute when the document has finished
- parsing</dfn>:</dt>
-
- <dd>
-
- <ol>
-
- <li>
-
- <p>If the script's <code>Document</code> is still being parsed,
- then the parser handles it. Abort these steps.</p>
-
- </li>
-
- <li>
-
- <p>If the <code>script</code> element is not the first element
- in the list, then do nothing yet. Stop going through these
- steps.</p>
-
- </li>
-
- <li>
-
- <p>Otherwise, <span title="executing a script block">execute the
- script block</span> (the first element in the list).</p>
-
- </li>
-
- <li>
-
- <p>Remove the <code>script</code> element from the list
- (i.e. shift out the first entry in the list).</p>
-
- </li>
-
- <li>
-
- <p>If there are any more entries in the list, and if the script
- associated with the element that is now the first in the list is
- already loaded, then jump back to step 2 to execute it.</p>
-
- </li>
-
- </ol>
-
- </dd>
-
- <dt>If the <code>script</code> element was added to the <dfn>list
- of scripts that will execute as soon as possible</dfn>:</dt>
-
- <dd>
-
- <ol>
-
- <li>
-
- <p><span title="executing a script block">Execute the
- script block</span>.</p>
-
- </li>
-
- <li>
-
- <p>Remove the <code>script</code> element from the list.</p>
-
- </li>
-
- </ol>
-
- </dd>
-
- </dl>
-
<p><dfn title="executing a script block">Executing a script
block</dfn>: When the steps above require that the script block be
executed, the user agent must act as follows:</p>
@@ -56860,6 +56868,35 @@
<hr>
+ <p>When an algorithm says to <dfn>spin the event loop</dfn> until
+ a condition <var title="">goal</var> is met, the user agent must run
+ the following steps:</p>
+
+ <ol>
+
+ <li><p>Let <var title="">task source</var> be the <span>task
+ source</span> of the currently running <span
+ title="concept-task">task</span>.</p></li>
+
+ <li><p>Stop the currently running <span
+ title="concept-task">task</span>, allowing the <span>event
+ loop</span> to resume, but continue these steps
+ asynchronously.</p></li>
+
+ <li><p>Wait until the condition <var title="">goal</var> is
+ met.</p></li>
+
+ <li><p><span>Queue a task</span> to continue running these steps,
+ using the <span>task source</span> <var title="">task
+ source</var>. Wait until this task runs before continuing these
+ steps.</p></li>
+
+ <li><p>Return to the caller.</p></li>
+
+ </ol>
+
+ <hr>
+
<p>Some of the algorithms in this specification, for historical
reasons, require the user agent to <dfn>pause</dfn> while running a
<span title="concept-task">task</span> until some condition has been
@@ -81390,7 +81427,7 @@
<li><p>If the parser was originally created for the <span>HTML
fragment parsing algorithm</span>, then mark the
<code>script</code> element as <span>"already
- executed"</span>. (<span>fragment case</span>)</p></li>
+ started"</span>. (<span>fragment case</span>)</p></li>
<li><p>Append the new element to the <span>current node</span>
and push it onto the <span>stack of open
@@ -82948,7 +82985,7 @@
<p>If the <span>current node</span> is a <code>script</code>
element, mark the <code>script</code> element as <span>"already
- executed"</span>.</p>
+ started"</span>.</p>
<p>Pop the <span>current node</span> off the <span>stack of open
elements</span>.</p>
@@ -82995,7 +83032,7 @@
might be the "undefined" value.)</p>
<p id="scriptTagParserResumes">At this stage, if there is a
- <span>pending external script</span>, then:</p>
+ <span>pending parsing-blocking script</span>, then:</p>
<dl class="switch">
@@ -83025,12 +83062,26 @@
<ol>
<li><p>Let <var title="">the script</var> be the <span>pending
- external script</span>. There is no longer a <span>pending
- external script</span>.</p></li>
+ parsing-blocking script</span>. There is no longer a <span>pending
+ parsing-blocking script</span>.</p></li>
- <li><p><span>Pause</span> until the script has <span>completed
- loading</span>.</p></li>
+ <li><p>Block the <span title="tokenization">tokenizer</span>
+ for this instance of the <span>HTML parser</span>, such that
+ the <span>event loop</span> will not run <span
+ title="concept-task">tasks</span> that invoke the <span
+ title="tokenization">tokenizer</span>.</p></li>
+ <li><p><span>Spin the event loop</span> until there is no <span
+ title="a style sheet blocking scripts">style sheet blocking
+ scripts</span> and <var title="">the script</var>'s
+ <span>"ready to be parser-executed"</span> flag is set.</p></li>
+
+ <li><p>Unblock the <span title="tokenization">tokenizer</span>
+ for this instance of the <span>HTML parser</span>, such that
+ <span title="concept-task">tasks</span> that invoke the <span
+ title="tokenization">tokenizer</span> can again be
+ run.</p></li>
+
<li><p>Let the <span>insertion point</span> be just before the
<span>next input character</span>.</p></li>
@@ -83038,8 +83089,8 @@
by one (it should be zero before this step, so this sets it to
one).</p></li>
- <li><p><span title="executing a script block">Execute the
- script</span>.</p></li>
+ <li><p><span title="executing a script block">Execute</span>
+ <var title="">the script</var>.</p></li>
<li><p>Decrement the parser's <span>script nesting level</span>
by one. If the parser's <span>script nesting level</span> is
@@ -83049,7 +83100,7 @@
<li><p>Let the <span>insertion point</span> be undefined
again.</p></li>
- <li><p>If there is once again a <span>pending external
+ <li><p>If there is once again a <span>pending parsing-blocking
script</span>, then repeat these steps from step 1.</p></li>
</ol>
@@ -84490,86 +84541,87 @@
<h4>The end</h4>
<p>Once the user agent <dfn title="stop parsing">stops parsing</dfn>
- the document, the user agent must follow the steps in this
- section.</p>
+ the document, the user agent must run the following steps:</p>
- <!-- this happens as part of one of the tasks that runs the parser -->
+ <ol>
- <p>First, the user agent must set the <span>current document
- readiness</span> to "interactive" and the <span>insertion
- point</span> to undefined.</p> <!-- this also synchronously fires an
- event -->
+ <!-- this happens as part of one of the tasks that runs the parser -->
- <p>Then, the user agent must then make a list of all the scripts
- that are in the <span>list of scripts that will execute when the
- document has finished parsing</span> and the <span>list of scripts
- that will execute as soon as possible</span>. This is the <dfn>list
- of scripts pending after the parser stopped</dfn>.</p>
+ <li><p>Set the <span>current document readiness</span> to
+ "interactive" <!-- this also synchronously fires an event --> and
+ the <span>insertion point</span> to undefined.</p></li>
- <p>The document is no longer being parsed, so the rules for
- <span>when a script completes loading</span> for the <span>list of
- scripts that will execute when the document has finished
- parsing</span> start applying (script execution for that list is no
- longer managed by the parser).</p>
+ <li><p>If the <span>list of scripts that will execute when the
+ document has finished parsing</span> is not empty, run these
+ substeps:</p>
- <p>If the <span>list of scripts that will execute when the document
- has finished parsing</span> is not empty, and the first item in this
- list has already <span>completed loading</span>, then the user agent
- must act as if that script just finished loading.</p>
+ <ol>
- <p class="note">By this point, there will be no scripts that have
- loaded but have not yet been executed.</p>
+ <li><p><span>Spin the event loop</span> until the first
+ <code>script</code> in the <span>list of scripts that will
+ execute when the document has finished parsing</span> has its
+ <span>"ready to be parser-executed"</span> flag set <em>and</em> there
+ is no <span title="a style sheet blocking scripts">style sheet
+ blocking scripts</span>.</p></li>
- <hr>
+ <li><p><span title="executing a script block">Execute</span> the
+ first <code>script</code> in the <span>list of scripts that will
+ execute when the document has finished parsing</span>.</p></li>
- <!-- async -->
+ <li><p>Remove the first <code>script</code> element from the
+ <span>list of scripts that will execute when the document has
+ finished parsing</span> (i.e. shift out the first entry in the
+ list).</p></li>
+
+ <li><p>If the <span>list of scripts that will execute when the
+ document has finished parsing</span> is still not empty, repeat
+ these substeps again from substep 1.</p>
- <p>Once all the scripts on the <span>list of scripts pending after
- the parser stopped</span> have <span>completed loading</span> and
- been <span title="executing a script block">executed</span>, the
- user agent must <span>queue a task</span> to <span>fire a simple
- event</span> named <code
- title="event-DOMContentLoaded">DOMContentLoaded</code> at the
- <code>Document</code>. (If the list is empty, this happens
- immediately.)</p>
+ </ol>
- <hr>
+ </li>
- <!-- async -->
+ <li><p><span>Spin the event loop</span> until the the <span>list of
+ scripts that will execute as soon as possible</span> is
+ empty.</p></li>
- <p>Once everything that <dfn title="delay the load event">delays the
- load event</dfn> of the document has completed, the user agent must
- run the following steps:</p>
+ <li><p><span>Queue a task</span> to <span>fire a simple
+ event</span> named <code
+ title="event-DOMContentLoaded">DOMContentLoaded</code> at the
+ <code>Document</code>.</p></li>
- <ol>
+ <li><p><span>Spin the event loop</span> until there is nothing that
+ <dfn title="delay the load event">delays the load event</dfn> in
+ the <code>Document</code>.</p></li>
- <li><span>Queue a task</span> to set the <span>current document
- readiness</span> to "complete".</li> <!-- this also fires an event
- synchronously during the task -->
+ <li><p><span>Queue a task</span> to set the <span>current document
+ readiness</span> to "complete". <!-- this also fires an event
+ synchronously during the task --></p></li>
- <li>If the <code>Document</code> is in a <span>browsing
+ <li><p>If the <code>Document</code> is in a <span>browsing
context</span>, then <span>queue a task</span> to <span>fire a
simple event</span> named <code title="event-load">load</code> at
the <code>Document</code>'s <code>Window</code> object, but with
its <code title="dom-event-target">target</code> set to the
<code>Document</code> object (and the <code
title="dom-event-currentTarget">currentTarget</code> set to the
- <code>Window</code> object).</li>
+ <code>Window</code> object).</p></li>
- <li>If the <code>Document</code> has a <span>pending state
+ <li><p>If the <code>Document</code> has a <span>pending state
object</span>, then <span>queue a task</span> to fire a <code
title="event-popstate">popstate</code> event in no namespace on the
<code>Document</code>'s <code>Window</code> object using the
<code>PopStateEvent</code> interface, with the <code
title="dom-PopStateEvent-state">state</code> attribute set to the
current value of the <span>pending state object</span>. This event
- must bubble but not be cancelable and has no default action.</li>
+ must bubble but not be cancelable and has no default
+ action.</p></li>
</ol>
- <p>The <span>task source</span> for these <span
- title="concept-task">tasks</span> is the <span>DOM manipulation
- task source</span>.</p>
+ <p>The <span>task source</span> for the <span
+ title="concept-task">tasks</span> mentioned in this section is the
+ <span>DOM manipulation task source</span>.</p>
</div>
@@ -85496,14 +85548,36 @@
element, it must be marked as being <span>"parser-inserted"</span>.
If the parser was originally created for the <span>XML fragment
parsing algorithm</span>, then the element must be marked as
- <span>"already executed"</span> also. When the element's end tag is
+ <span>"already started"</span> also. When the element's end tag is
parsed, the user agent must <span title="running a
script">run</span> the <code>script</code> element. If this causes
- there to be a <span>pending external script</span>, then the user
- agent must <span>pause</span> until that script has <span>completed
- loading</span>, and then <span title="executing a script
- block">execute it</span>.</p>
+ there to be a <span>pending parsing-blocking script</span>, then the
+ user agent must run the following steps:</p>
+ <ol>
+
+ <li><p>Block this instance of the <span>XML parser</span>, such
+ that the <span>event loop</span> will not run <span
+ title="concept-task">tasks</span> that invoke it.</p></li>
+
+ <li><p><span>Spin the event loop</span> until there is no <span
+ title="a style sheet blocking scripts">style sheet blocking
+ scripts</span> and the <span>pending parsing-blocking
+ script</span>'s <span>"ready to be parser-executed"</span> flag is
+ set.</p></li>
+
+ <li><p>Unblock this instance of the <span>XML parser</span>, such
+ that <span title="concept-task">tasks</span> that invoke it can
+ again be run.</p></li>
+
+ <li><p><span title="executing a script block">Execute</span> the
+ <span>pending parsing-blocking script</span>.</p></li>
+
+ <li><p>There is no longer a <span>pending parsing-blocking
+ script</span>.</p></li>
+
+ </ol>
+
<p class="note">Since the <code
title="dom-document-write">document.write()</code> API is not
available for <span>XML documents</span>, much of the complexity in
More information about the Commit-Watchers
mailing list