Skip to content

Commit

Permalink
[gow] (2) Simplify the way messages in ports are handled when the des…
Browse files Browse the repository at this point in the history
…tination's document is not available.

git-svn-id: http://svn.whatwg.org/webapps@2531 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Dec 16, 2008
1 parent a28e107 commit 98c3586
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 116 deletions.
66 changes: 12 additions & 54 deletions index
Expand Up @@ -874,8 +874,7 @@
<li><a href=#message-channels><span class=secno>7.5.2 </span>Message channels</a></li>
<li><a href=#message-ports><span class=secno>7.5.3 </span>Message ports</a>
<ol>
<li><a href=#message-port-discarding><span class=secno>7.5.3.1 </span>Ports and browsing contexts</a></li>
<li><a href=#ports-and-garbage-collection><span class=secno>7.5.3.2 </span>Ports and garbage collection</a></ol></ol></ol></li>
<li><a href=#ports-and-garbage-collection><span class=secno>7.5.3.1 </span>Ports and garbage collection</a></ol></ol></ol></li>
<li><a href=#syntax><span class=secno>8 </span>The HTML syntax</a>
<ol>
<li><a href=#writing-html-documents><span class=secno>8.1 </span>Writing HTML documents</a>
Expand Down Expand Up @@ -44634,31 +44633,15 @@ interface <dfn id=messagechannel>MessageChannel</dfn> {
method must open its port's <a href=#port-message-queue>port message queue</a>, if it
is not already open.</p>

<p>When a port's <a href=#port-message-queue>port message queue</a> is open, contains
an event, and its owner is <a href=#port-owner-available title="port owner
available">available</a>, the user agent must <a href=#queue-a-task>queue a
task</a> in the <a href=#event-loop>event loop</a> to dispatch the first
event in the queue on the <code><a href=#messageport>MessagePort</a></code> object, and
remove the event from the queue. The <a href=#task-source>task source</a> for
this <a href=#concept-task title=concept-task>task</a> is the <a href=#posted-message-task-source>posted
message task source</a>.</p>

<p>A <code><a href=#messageport>MessagePort</a></code>'s owner is <dfn id=port-owner-available title="port owner
available">available</dfn> if the <code><a href=#messageport>MessagePort</a></code> is owned
by an object other than a <code><a href=#window>Window</a></code> object, or if it is
owned by a <code><a href=#window>Window</a></code> object and the <code>Document</code>
that was the <a href=#active-document>active document</a> in that <a href=#browsing-context>browsing
context</a> when the <code><a href=#messageport>MessagePort</a></code> was created is
<a href=#fully-active>fully active</a>. If that <code>Document</code> is
discarded before the port's owner becomes available, then the events
are lost.</p>

<!-- XXX when we have sorted out the global object mess, if that
makes this easier to fix, then fix it better. (e.g. maybe just say
that callback tasks aren't processed if they involve firing a
callback that wouldn't fire because the code is swapped out? not
sure how you'd handle prioritisation, i guess you'd just pretend
those events weren't there for the time being) -->
<p>When a port's <a href=#port-message-queue>port message queue</a> is open and
contains an event, the user agent must <a href=#queue-a-task>queue a task</a> in
the <a href=#event-loop>event loop</a> to dispatch the first event in the queue
on the <code><a href=#messageport>MessagePort</a></code> object, and remove the event from
the queue. The <a href=#task-source>task source</a> for this <a href=#concept-task title=concept-task>task</a> is the <a href=#posted-message-task-source>posted message task
source</a>.</p>

<p class=note>If the <a href=#script-group>script group</a> of the port's event
handlers is <i>frozen</i>, then the messages are lost.</p>

<hr><p>The <dfn id=dom-messageport-close title=dom-MessagePort-close><code>close()</code></dfn>
method, when called on a port <var title="">local port</var> that is
Expand Down Expand Up @@ -44701,35 +44684,10 @@ interface <dfn id=messagechannel>MessageChannel</dfn> {

<dt><dfn id=handler-messageport-onclose title=handler-MessagePort-onclose><code>onclose</code></dfn></dt>

<dd><p>Must be invoked whenever an <code title=event-close>close</code> event is targeted at or bubbles
<dd><p>Must be invoked whenever a <code title=event-close>close</code> event is targeted at or bubbles
through the <code><a href=#messageport>MessagePort</a></code> object.</dd>

</dl><h5 id=message-port-discarding><span class=secno>7.5.3.1 </span>Ports and browsing contexts</h5>

<p>When a <code>Document</code> is <a href=#discard-a-document title="discard a
document">discarded</a>, if there are any
<code><a href=#messageport>MessagePort</a></code> objects that:</p>

<ul class=brief><li>are entangled, and</li>
<li>are owned by the <a href=#browsing-context>browsing context</a> that contained that <code>Document</code>, and</li>
<li>were created while that <code>Document</code> was the <a href=#active-document>active document</a> of that <a href=#browsing-context>browsing context</a>, and</li>
<li>are entangled with a port that is either not owned by that <a href=#browsing-context>browsing context</a>, or were not created while that <code>Document</code> was the <a href=#active-document>active document</a> of that <a href=#browsing-context>browsing context</a>,</li>
</ul><p>...then the user agent must run the following steps for each such
port:</p>

<ol><li><p>Let <var title="">surviving port</var> be the port with
which the <code><a href=#messageport>MessagePort</a></code> object in question is
entangled.</li>

<li><p>Unentangle the two ports.</li>

<li><p><a href=#queue-a-task>Queue a task</a> to <a href=#fire-a-simple-event>fire a simple
event</a> called <code title=event-close>close</code> at
<var title="">surviving port</var>. The <a href=#task-source>task source</a>
for this <a href=#concept-task title=concept-task>task</a> is the <a href=#posted-message-task-source>posted
message task source</a>.</li>

</ol><h5 id=ports-and-garbage-collection><span class=secno>7.5.3.2 </span>Ports and garbage collection</h5>
</dl><h5 id=ports-and-garbage-collection><span class=secno>7.5.3.1 </span>Ports and garbage collection</h5>

<p>User agents must act as if <code><a href=#messageport>MessagePort</a></code> objects have
a strong reference to their entangled <code><a href=#messageport>MessagePort</a></code>
Expand Down
73 changes: 11 additions & 62 deletions source
Expand Up @@ -50979,31 +50979,16 @@ interface <dfn>MessageChannel</dfn> {
method must open its port's <span>port message queue</span>, if it
is not already open.</p>

<p>When a port's <span>port message queue</span> is open, contains
an event, and its owner is <span title="port owner
available">available</span>, the user agent must <span>queue a
task</span> in the <span>event loop</span> to dispatch the first
event in the queue on the <code>MessagePort</code> object, and
remove the event from the queue. The <span>task source</span> for
this <span title="concept-task">task</span> is the <span>posted
message task source</span>.</p>

<p>A <code>MessagePort</code>'s owner is <dfn title="port owner
available">available</dfn> if the <code>MessagePort</code> is owned
by an object other than a <code>Window</code> object, or if it is
owned by a <code>Window</code> object and the <code>Document</code>
that was the <span>active document</span> in that <span>browsing
context</span> when the <code>MessagePort</code> was created is
<span>fully active</span>. If that <code>Document</code> is
discarded before the port's owner becomes available, then the events
are lost.</p>

<!-- XXX when we have sorted out the global object mess, if that
makes this easier to fix, then fix it better. (e.g. maybe just say
that callback tasks aren't processed if they involve firing a
callback that wouldn't fire because the code is swapped out? not
sure how you'd handle prioritisation, i guess you'd just pretend
those events weren't there for the time being) -->
<p>When a port's <span>port message queue</span> is open and
contains an event, the user agent must <span>queue a task</span> in
the <span>event loop</span> to dispatch the first event in the queue
on the <code>MessagePort</code> object, and remove the event from
the queue. The <span>task source</span> for this <span
title="concept-task">task</span> is the <span>posted message task
source</span>.</p>

<p class="note">If the <span>script group</span> of the port's event
handlers is <i>frozen</i>, then the messages are lost.</p>

<hr>

Expand Down Expand Up @@ -51059,50 +51044,14 @@ interface <dfn>MessageChannel</dfn> {

<dt><dfn title="handler-MessagePort-onclose"><code>onclose</code></dfn></dt>

<dd><p>Must be invoked whenever an <code
<dd><p>Must be invoked whenever a <code
title="event-close">close</code> event is targeted at or bubbles
through the <code>MessagePort</code> object.</p></dd>

</dl>





<h5 id="message-port-discarding">Ports and browsing contexts</h5>

<p>When a <code>Document</code> is <span title="discard a
document">discarded</span>, if there are any
<code>MessagePort</code> objects that:</p>

<ul class="brief">
<li>are entangled, and</li>
<li>are owned by the <span>browsing context</span> that contained that <code>Document</code>, and</li>
<li>were created while that <code>Document</code> was the <span>active document</span> of that <span>browsing context</span>, and</li>
<li>are entangled with a port that is either not owned by that <span>browsing context</span>, or were not created while that <code>Document</code> was the <span>active document</span> of that <span>browsing context</span>,</li>
</ul>

<p>...then the user agent must run the following steps for each such
port:</p>

<ol>

<li><p>Let <var title="">surviving port</var> be the port with
which the <code>MessagePort</code> object in question is
entangled.</p></li>

<li><p>Unentangle the two ports.</p></li>

<li><p><span>Queue a task</span> to <span>fire a simple
event</span> called <code title="event-close">close</code> at
<var title="">surviving port</var>. The <span>task source</span>
for this <span title="concept-task">task</span> is the <span>posted
message task source</span>.</p></li>

</ol>



<h5>Ports and garbage collection</h5>

<p>User agents must act as if <code>MessagePort</code> objects have
Expand Down

0 comments on commit 98c3586

Please sign in to comment.