Skip to content

Commit

Permalink
[giow] (3) pushing <embed>'s specification further towards its reality
Browse files Browse the repository at this point in the history
Fixing https://www.w3.org/Bugs/Public/show_bug.cgi?id=16136
Affected topics: HTML

git-svn-id: http://svn.whatwg.org/webapps@7914 340c8d12-0b0e-0410-8428-c7bf67bfef74
  • Loading branch information
Hixie committed Jun 5, 2013
1 parent d30c2dd commit d4b6a25
Show file tree
Hide file tree
Showing 3 changed files with 335 additions and 184 deletions.
165 changes: 106 additions & 59 deletions complete.html
Expand Up @@ -24983,7 +24983,7 @@ <h4 id=the-embed-element><span class=secno>4.8.3 </span>The <dfn><code>embed</co
interfaces.</p>
</div>
</dd>
</dl><!--TOPIC:HTML--><p>The <code><a href=#the-embed-element>embed</a></code> element <a href=#represents>represents</a> an integration point for an external
</dl><!--TOPIC:HTML--><!--CLEANUP--><p>The <code><a href=#the-embed-element>embed</a></code> element provides an integration point for an external
(typically non-HTML) application or interactive content.</p>

<p>The <dfn id=attr-embed-src title=attr-embed-src><code>src</code></dfn> attribute gives the address of the
Expand All @@ -25004,8 +25004,8 @@ <h4 id=the-embed-element><span class=secno>4.8.3 </span>The <dfn><code>embed</co
nor a <code title=attr-embed-type><a href=#attr-embed-type>type</a></code> attribute, and when attributes are removed such
that neither attribute is present on the element anymore, and when the element has a <a href=#media-element>media
element</a> ancestor, and when the element has an ancestor <code><a href=#the-object-element>object</a></code> element that is
<em>not</em> showing its <a href=#fallback-content>fallback content</a>, any plugins instantiated for the element
must be removed, and the <code><a href=#the-embed-element>embed</a></code> element represents nothing.</p>
<em>not</em> showing its <a href=#fallback-content>fallback content</a>, any <a href=#plugin>plugin</a> instantiated for
the element must be removed, and the <code><a href=#the-embed-element>embed</a></code> element then represents nothing.</p>

<p>An <code><a href=#the-embed-element>embed</a></code> element is said to be <dfn id=concept-embed-active title=concept-embed-active>potentially
active</dfn> when the following conditions are all met simultaneously:</p>
Expand All @@ -25030,10 +25030,13 @@ <h4 id=the-embed-element><span class=secno>4.8.3 </span>The <dfn><code>embed</co

</ul><p>Whenever an <code><a href=#the-embed-element>embed</a></code> element that was not <a href=#concept-embed-active title=concept-embed-active>potentially active</a> becomes <a href=#concept-embed-active title=concept-embed-active>potentially active</a>, and whenever a <a href=#concept-embed-active title=concept-embed-active>potentially active</a> <code><a href=#the-embed-element>embed</a></code> element that is
remaining <a href=#concept-embed-active title=concept-embed-active>potentially active</a> and has its <code title=attr-embed-type><a href=#attr-embed-type>src</a></code> attribute set, changed, or removed or its <code title=attr-embed-type><a href=#attr-embed-type>type</a></code> attribute set, changed, or removed, the user agent must
<a href=#queue-a-task>queue a task</a> using the <dfn id=embed-task-source>embed task source</dfn> to run the following steps:</p>
<a href=#queue-a-task>queue a task</a> using the <dfn id=embed-task-source>embed task source</dfn> to run
<a href=#the-embed-element-setup-steps>the <code>embed</code> element setup steps</a>.</p>

<ol><li><p>If another <a href=#concept-task title=concept-task>task</a> has since been queued to run these steps
for this element, then abort these steps.</li>
<p><dfn id=the-embed-element-setup-steps>The <code>embed</code> element setup steps</dfn> are as follows:</p>

<ol><li><p>If another <a href=#concept-task title=concept-task>task</a> has since been queued to run <a href=#the-embed-element-setup-steps>the
<code>embed</code> element setup steps</a> for this element, then abort these steps.</li>

<li>

Expand All @@ -25047,12 +25050,90 @@ <h4 id=the-embed-element><span class=secno>4.8.3 </span>The <dfn><code>embed</co
URL</a>, from the element's <a href=#browsing-context-scope-origin>browsing context scope origin</a> if it has one<!--
potentially http-origin privacy sensitive -->. 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 find and instantiate an
appropriate <a href=#plugin>plugin</a> based on the <a href=#concept-embed-type title=concept-embed-type>content's
type</a>, and hand that <a href=#plugin>plugin</a> the content of the resource, replacing any
previously instantiated plugin for the element.</p>
the resource has been <a href=#fetch title=fetch>fetched</a> must run the following steps:</p>
<!-- Note that this doesn't happen when the base URL changes. -->

<ol><li><p>If another <a href=#concept-task title=concept-task>task</a> has since been queued to run
<a href=#the-embed-element-setup-steps>the <code>embed</code> element setup steps</a> for this element, then abort these
steps.</li>

<li>

<p>Determine the <dfn id=concept-embed-type title=concept-embed-type>type of the content</dfn> being embedded, as
follows (stopping at the first substep that determines the type):</p>

<ol><li><p>If the element has a <code title=attr-embed-type><a href=#attr-embed-type>type</a></code> attribute, and that
attribute's value is a type that a <a href=#plugin>plugin</a> supports, then the value of the <code title=attr-embed-type><a href=#attr-embed-type>type</a></code> attribute is the <a href=#concept-embed-type title=concept-embed-type>content's
type</a>.</li>

<li>

<!-- if we get to this point we know we can successfully parsed the URL, since this algorithm is
only used after fetching the resource in the steps above -->

<p>Otherwise, if applying the <a href=#url-parser>URL parser</a> algorithm to the <a href=#url>URL</a> of the
specified resource (after any redirects) results in a <a href=#parsed-url>parsed URL</a> whose <a href=#concept-url-path title=concept-url-path>path</a> component matches a pattern that a <a href=#plugin>plugin</a>
supports, then the <a href=#concept-embed-type title=concept-embed-type>content's type</a> is the type that that
plugin can handle.</p>

<p class=example>For example, a plugin might say that it can handle resources with <a href=#concept-url-path title=concept-url-path>path</a> components that end with the four character string "<code title="">.swf</code>".</p>

<!-- it's sad that we have to do extension sniffing. sigh. -->
<!-- see also <object> which has a similar step -->

</li>

<li><p>Otherwise, if the specified resource has <a href=#content-type title=Content-Type>explicit Content-Type
metadata</a>, then that is the <a href=#concept-embed-type title=concept-embed-type>content's
type</a>.</li>

<li><p>Otherwise, the content has no <a href=#concept-embed-type title=concept-embed-type>type</a> and there can
be no appropriate <a href=#plugin>plugin</a> for it.</li>

<!-- This algorithm is a monument to bad design. Go legacy! -->

</ol></li>

<li>

<p>If the previous step determined that the <a href=#concept-embed-type title=concept-embed-type>content's
type</a> is <code title="">image/svg+xml</code>, then run the following substeps:</p>

<ol><li><p>If the <code><a href=#the-embed-element>embed</a></code> element is not associated with a <a href=#nested-browsing-context>nested browsing
context</a>, associate the element with a newly created <a href=#nested-browsing-context>nested browsing
context</a>, and, if the element has a <code title=attr-embed-name><a href=#attr-embed-name>name</a></code>
attribute, set the <a href=#browsing-context-name>browsing context name</a> of the element's <a href=#nested-browsing-context>nested
browsing context</a> to the value of this attribute.</p>
<!-- http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=2291 - dynamic changes to 'name' don't do anything -->

<li><p><a href=#navigate>Navigate</a><!--DONAV object--> the <a href=#nested-browsing-context>nested browsing context</a> to
the fetched resource, with <a href=#replacement-enabled>replacement enabled</a>, and with the
<code><a href=#the-embed-element>embed</a></code> element's document's <a href=#browsing-context>browsing context</a> as the <a href=#source-browsing-context>source
browsing context</a>. (The <code title=attr-embed-src><a href=#attr-embed-src>src</a></code> attribute of the
<code><a href=#the-embed-element>embed</a></code> element doesn't get updated if the browsing context gets further
navigated to other locations.)</li>

<li><p>The <code><a href=#the-object-element>object</a></code> element now <a href=#represents>represents</a> its associated
<a href=#nested-browsing-context>nested browsing context</a>.</li>

</ol></li>

<li>

<p>Otherwise, find and instantiate an appropriate <a href=#plugin>plugin</a> based on the <a href=#concept-embed-type title=concept-embed-type>content's type</a>, and hand that <a href=#plugin>plugin</a> the
content of the resource, replacing any previously instantiated plugin for the element. The
<code><a href=#the-embed-element>embed</a></code> element now represents this <a href=#plugin>plugin</a> instance.</p>

</li>

</ol><p>Whether the resource is fetched successfully or not (e.g. whether the response code was a
2xx code <a href=#concept-http-equivalent-codes title=concept-http-equivalent-codes>or equivalent</a>) must be ignored
when determining the <a href=#concept-embed-type title=concept-embed-type>content's type</a> and when handing
the resource to the plugin.</p>

<p class=note>This allows servers to return data for plugins even with error responses (e.g.
HTTP 500 Internal Server Error codes can still contain plugin data).</p>

<p>Fetching the resource must <a href=#delay-the-load-event>delay the load event</a> of the element's document.</p>
<!-- if we add load/error events, then replace the previous paragraph with the text one: -->
<!-- similar text in various places -->
Expand All @@ -25065,12 +25146,22 @@ <h4 id=the-embed-element><span class=secno>4.8.3 </span>The <dfn><code>embed</co

<dt>If the element has no <code title=attr-embed-src><a href=#attr-embed-src>src</a></code> attribute set</dt>

<dd><p>The user agent should find and instantiate an appropriate <a href=#plugin>plugin</a> based on
the value of the <code title=attr-embed-type><a href=#attr-embed-type>type</a></code> attribute.</p>
<dd>

<p>The user agent should find and instantiate an appropriate <a href=#plugin>plugin</a> based on the
value of the <code title=attr-embed-type><a href=#attr-embed-type>type</a></code> attribute. The <code><a href=#the-embed-element>embed</a></code>
element now represents this <a href=#plugin>plugin</a> instance.</p>

</dd>

</dl></li>

</ol><p>Whenever an <code><a href=#the-embed-element>embed</a></code> element that was <a href=#concept-embed-active title=concept-embed-active>potentially
</ol><p>The <code><a href=#the-embed-element>embed</a></code> element has no <a href=#fallback-content>fallback content</a>. If the user agent can't
find a suitable plugin when attempting to find and instantiate one for the algorithm above, then
the user agent must use a default plugin. This default could be as simple as saying "Unsupported
Format".</p>

<p>Whenever an <code><a href=#the-embed-element>embed</a></code> element that was <a href=#concept-embed-active title=concept-embed-active>potentially
active</a> stops being <a href=#concept-embed-active title=concept-embed-active>potentially active</a>, any
<a href=#plugin>plugin</a> that had been instantiated for that element must be unloaded.</p>

Expand All @@ -25088,50 +25179,6 @@ <h4 id=the-embed-element><span class=secno>4.8.3 </span>The <dfn><code>embed</co
agents should convey the danger of overriding the sandbox to the user if an option to do so is
provided.</p>

<p>The <dfn id=concept-embed-type title=concept-embed-type>type of the content</dfn> being embedded is defined as
follows:</p>

<ol><li><p>If the element has a <code title=attr-embed-type><a href=#attr-embed-type>type</a></code> attribute, and that
attribute's value is a type that a <a href=#plugin>plugin</a> supports, then the value of the <code title=attr-embed-type><a href=#attr-embed-type>type</a></code> attribute is the <a href=#concept-embed-type title=concept-embed-type>content's
type</a>.</li>

<li>

<!-- if we get to this point we know we can successfully parsed the URL, since this algorithm is
only used after fetching the resource in the steps above -->

<p>Otherwise, if applying the <a href=#url-parser>URL parser</a> algorithm to the <a href=#url>URL</a> of the
specified resource (after any redirects) results in a <a href=#parsed-url>parsed URL</a> whose <a href=#concept-url-path title=concept-url-path>path</a> component matches a pattern that a <a href=#plugin>plugin</a>
supports, then the <a href=#concept-embed-type title=concept-embed-type>content's type</a> is the type that that
plugin can handle.</p>

<p class=example>For example, a plugin might say that it can handle resources with <a href=#concept-url-path title=concept-url-path>path</a> components that end with the four character string "<code title="">.swf</code>".</p>

<!-- it's sad that we have to do extension sniffing. sigh. -->
<!-- see also <object> which has a similar step -->

</li>

<li><p>Otherwise, if the specified resource has <a href=#content-type title=Content-Type>explicit Content-Type
metadata</a>, then that is the <a href=#concept-embed-type title=concept-embed-type>content's
type</a>.</li>

<li><p>Otherwise, the content has no type and there can be no appropriate <a href=#plugin>plugin</a> for
it.</li>

<!-- This algorithm is a monument to bad design. Go legacy! -->

</ol><p>The <code><a href=#the-embed-element>embed</a></code> element has no <a href=#fallback-content>fallback content</a>. If the user agent can't
find a suitable plugin, then the user agent must use a default plugin. (This default could be as
simple as saying "Unsupported Format".)</p>

<p>Whether the resource is fetched successfully or not (e.g. whether the response code was a 2xx
code <a href=#concept-http-equivalent-codes title=concept-http-equivalent-codes>or equivalent</a>) must be ignored when
determining the resource's type and when handing the resource to the plugin.</p>

<p class=note>This allows servers to return data for plugins even with error responses (e.g.
HTTP 500 Internal Server Error codes can still contain plugin data).</p>

</div>

<p>Any namespace-less attribute other than <code title=attr-embed-name><a href=#attr-embed-name>name</a></code>, <code title=attr-embed-align><a href=#attr-embed-align>align</a></code>, <code title=attr-embed-hspace><a href=#attr-embed-hspace>hspace</a></code>, and <code title=attr-embed-vspace><a href=#attr-embed-vspace>vspace</a></code> <!-- when editing, see also note below --> may be
Expand All @@ -25148,10 +25195,10 @@ <h4 id=the-embed-element><span class=secno>4.8.3 </span>The <dfn><code>embed</co
<div class=impl>

<p>The user agent should pass the names and values of all the attributes of the <code><a href=#the-embed-element>embed</a></code>
element that have no namespace to the <a href=#plugin>plugin</a> used, when it is instantiated.</p>
element that have no namespace to the <a href=#plugin>plugin</a> used, when one is instantiated.</p>

<p>The <code><a href=#htmlembedelement>HTMLEmbedElement</a></code> object representing the element must expose the scriptable
interface of the <a href=#plugin>plugin</a> instantiated for the <code><a href=#the-embed-element>embed</a></code> element. At a
interface of the <a href=#plugin>plugin</a> instantiated for the <code><a href=#the-embed-element>embed</a></code> element, if any. At a
minimum, this interface must implement the <dfn id=dom-embed-caller title=dom-embed-caller>legacy caller
operation</dfn>. (It is suggested that the default behavior of this legacy caller operation, e.g.
the behavior of the default plugin's legacy caller operation, be to throw a
Expand Down

0 comments on commit d4b6a25

Please sign in to comment.