Permalink
Browse files

Be explicit about image request state

This also changes createImageBitmap() to use fully decodeable rather than completely available.

Tests: web-platform-tests/wpt#8389.

Fixes #3158.
  • Loading branch information...
annevk committed Nov 23, 2017
1 parent 19f5cce commit 12b4187feaa98e67886074ff1bd29d865fe56178
Showing with 44 additions and 36 deletions.
  1. +44 −36 source
View
80 source
@@ -25794,9 +25794,11 @@ interface <dfn>HTMLImageElement</dfn> : <span>HTMLElement</span> {
task">queued</span> by the <span>networking task source</span> once the resource has been fetched
has been <span data-x="queue a task">queued</span>.
<li>The <code>img</code> element is <span data-x="img-all">completely available</span>.
<li>The <code>img</code> element's <span>current request</span>'s <span
data-x="img-req-state">state</span> is <span data-x="img-all">completely available</span>.
<li>The <code>img</code> element is <span data-x="img-error">broken</span>.
<li>The <code>img</code> element's <span>current request</span>'s <span
data-x="img-req-state">state</span> is <span data-x="img-error">broken</span>.
</ul>
@@ -25862,7 +25864,8 @@ img.decode();</pre>
<code>DOMException</code>.</p>
</dd>
<dt>This <code>img</code> element becomes <span data-x="img-all">completely
<dt>This <code>img</code> element's <span>current request</span>'s <span
data-x="img-req-state">state</span> becomes <span data-x="img-all">completely
available</span></dt>
<dd>
@@ -26796,21 +26799,21 @@ was an English &lt;a href="/wiki/Music_hall">music hall&lt;/a> singer, ...</pre>
<h5 id="images-processing-model">Processing model</h5>
<p>The <span>task source</span> for the <span data-x="concept-task">tasks</span> <span data-x="queue
a task">queued</span> by algorithms in this section is the <span>DOM manipulation task
source</span>.</p>
<p>The <span>task source</span> for the <span data-x="concept-task">tasks</span> <span
data-x="queue a task">queued</span> by algorithms in this section is the <span>DOM manipulation
task source</span>.</p>
<hr>
<p>An <code>img</code> element has a <dfn>current request</dfn> and a <dfn>pending request</dfn>.
The <span>current request</span> is initially set to a new <span>image request</span>.
The <span>pending request</span> is initially set to null.
The <span>current request</span> is usually referred to as the <code>img</code> element itself.</p>
The <span>pending request</span> is initially set to null.</p>
<p>An <dfn>image request</dfn> has a <dfn data-x="img-req-state">state</dfn>, <dfn
data-x="img-req-url">current URL</dfn>, and <dfn data-x="img-req-data">image data</dfn>.</p>
<p>An <span>image request</span>'s <span data-x="img-req-state">state</span> is one of the following:</p>
<p>An <span>image request</span>'s <span data-x="img-req-state">state</span> is one of the
following:</p>
<dl>
@@ -26834,27 +26837,30 @@ was an English &lt;a href="/wiki/Music_hall">music hall&lt;/a> singer, ...</pre>
</dl>
<p>An <span>image request</span>'s <span data-x="img-req-url">current URL</span> is initially the empty string.</p>
<p>An <span>image request</span>'s <span data-x="img-req-url">current URL</span> is initially the
empty string.</p>
<p>An <span>image request</span>'s <span data-x="img-req-data">image data</span> is the decoded image data.</p>
<p>An <span>image request</span>'s <span data-x="img-req-data">image data</span> is the decoded
image data.</p>
<p>When an <span>image request</span>'s <span data-x="img-req-state">state</span> is either <span
data-x="img-inc">partially available</span> or <span data-x="img-all">completely available</span>,
the <span>image request</span> is said to be <dfn data-x="img-available">available</dfn>.</p>
<p>When an <code>img</code> element is in the <span data-x="img-all">completely available</span>
state <em>and</em> the user agent can decode the media data without errors, then the
<code>img</code> element is said to be <dfn data-x="img-good">fully decodable</dfn>.</p>
<!-- TODO: https://github.com/whatwg/html/issues/3158 (img element state) -->
<p>When an <code>img</code> element's <span>current request</span>'s <span
data-x="img-req-state">state</span> is <span data-x="img-all">completely available</span> and the
user agent can decode the media data without errors, then the <code>img</code> element is said to
be <dfn data-x="img-good">fully decodable</dfn>.</p>
<p>An <span>image request</span>'s <span data-x="img-req-state">state</span> is initially <span
data-x="img-none">unavailable</span>.</p>
<p>When an <code>img</code> element is <span data-x="img-available">available</span>,
it provides a <span>paint source</span>
whose width is the image's <span data-x="density-corrected intrinsic width and height">density-corrected intrinsic width</span> (if any),
whose height is the image's <span data-x="density-corrected intrinsic width and height">density-corrected intrinsic height</span> (if any),
and whose appearance is the intrinsic appearance of the image.</p>
<p>When an <code>img</code> element's <span>current request</span> is <span
data-x="img-available">available</span>, the <code>img</code> element provides a <span>paint
source</span> whose width is the image's <span data-x="density-corrected intrinsic width and
height">density-corrected intrinsic width</span> (if any), whose height is the image's <span
data-x="density-corrected intrinsic width and height">density-corrected intrinsic height</span>
(if any), and whose appearance is the intrinsic appearance of the image.</p>
<hr>
@@ -26938,12 +26944,12 @@ was an English &lt;a href="/wiki/Music_hall">music hall&lt;/a> singer, ...</pre>
whenever that element is created or has experienced <span>relevant mutations</span>.</p>
<p>A user agent that obtains images on demand must <span>update the image data</span> of an
<code>img</code> element whenever it needs the image data (i.e. on demand),
but only if the <code>img</code> element is in the
<span data-x="img-none">unavailable</span> state. When an <code>img</code> element
has experienced <span>relevant mutations</span>, if the user
agent only obtains images on demand, the <code>img</code> element must return to the <span
data-x="img-none">unavailable</span> state.</p>
<code>img</code> element whenever it needs the image data (i.e., on demand), but only if the
<code>img</code> element's <span>current request</span>'s <span
data-x="img-req-state">state</span> is <span data-x="img-none">unavailable</span>. When an
<code>img</code> element has experienced <span>relevant mutations</span>, if the user agent only
obtains images on demand, the <code>img</code> element's <span>current request</span>'s <span
data-x="img-req-state">state</span> must return to <span data-x="img-none">unavailable</span>.</p>
<h6>Reacting to DOM mutations</h6>
@@ -27314,11 +27320,12 @@ was an English &lt;a href="/wiki/Music_hall">music hall&lt;/a> singer, ...</pre>
task">queued</span> by the <span>networking task source</span> while the image is being
fetched must update the presentation of the image, but as each new body part comes in, it must
replace the previous image. Once one body part has been completely decoded, the user agent
must set the <code>img</code> element to the <span data-x="img-all">completely
available</span> state and <span>queue a task</span> to <span data-x="concept-event-fire">fire
an event</span> named <code data-x="event-load">load</code> at the <code>img</code>
element.</p>
<!--TODO what if the image is broken? -->
must set the <code>img</code> element's <span>current request</span>'s <span
data-x="img-req-state">state</span> to <span data-x="img-all">completely available</span> and
<span>queue a task</span> to <span data-x="concept-event-fire">fire an event</span> named
<code data-x="event-load">load</code> at the <code>img</code> element.</p>
<!--TODO what if the image is broken?
TODO change state and fire in the same task? -->
<p class="note">The <code data-x="event-progress">progress</code> and <code
data-x="event-loadend">loadend</code> events are not fired for
@@ -62230,9 +62237,10 @@ try {
<ol>
<li><p>If <var>image</var> is an <code>HTMLOrSVGImageElement</code> object that is in the <span
data-x="img-error">broken</span> state, then throw an
<span>"<code>InvalidStateError</code>"</span> <code>DOMException</code>.</p></li>
<li><p>If <var>image</var> is an <code>HTMLOrSVGImageElement</code> object whose <span>current
request</span>'s <span data-x="img-req-state">state</span> is <span
data-x="img-error">broken</span>, then throw an <span>"<code>InvalidStateError</code>"</span>
<code>DOMException</code>.</p></li>
<li><p>If <var>image</var> is an <code>HTMLOrSVGImageElement</code> object that is not <span
data-x="img-good">fully decodable</span>, or if <var>image</var> is an
@@ -92717,8 +92725,8 @@ dictionary <dfn>ImageBitmapOptions</dfn> {
<li><p>If either the <var>sw</var> or <var>sh</var> arguments are specified but zero, return a
promise rejected with a <code data-x="js-RangeError">RangeError</code>.</p></li>
<li><p>If <var>image</var> is not <span data-x="img-all">completely available</span>, then
return a promise rejected with an <span>"<code>InvalidStateError</code>"</span>
<li><p>If <var>image</var> is not <span data-x="img-good">fully decodeable</span>, then return
a promise rejected with an <span>"<code>InvalidStateError</code>"</span>
<code>DOMException</code>.</p></li>
<li><p>If <var>image</var>'s media data has no <span>intrinsic dimensions</span> (e.g. it's a

0 comments on commit 12b4187

Please sign in to comment.