Skip to content

Commit e288a0e

Browse files
authored
Queue a task to resolve createImageBitmap()
Fixes whatwg#5329. Fixes whatwg#10611. Now, early errors reject synchronously, while everything rejecting or resolving "in parallel" is run from a task. This matches Firefox's behavior.
1 parent 8eaf940 commit e288a0e

File tree

1 file changed

+32
-57
lines changed

1 file changed

+32
-57
lines changed

source

Lines changed: 32 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -114083,11 +114083,10 @@ import "https://example.com/foo/../module2.mjs";</code></pre>
114083114083
<p>This <span>task source</span> is used for features that react to user interaction, for
114084114084
example keyboard or mouse input.</p>
114085114085

114086-
<p>Events sent in response to user input (e.g. <code
114087-
data-x="event-click">click</code> events) must be fired using <span
114088-
data-x="concept-task">tasks</span> <span data-x="queue a task">queued</span> with the <span>user
114089-
interaction task source</span>. <ref>UIEVENTS</ref></p> <!-- user
114090-
interaction events integration point -->
114086+
<p>Events sent in response to user input (e.g., <code data-x="event-click">click</code> events)
114087+
must be fired using <span data-x="concept-task">tasks</span> <span data-x="queue a
114088+
task">queued</span> with the <span>user interaction task source</span>. <ref>UIEVENTS</ref></p>
114089+
<!-- user interaction events integration point -->
114091114090
</dd>
114092114091

114093114092
<dt>The <dfn export>networking task source</dfn></dt>
@@ -114108,7 +114107,7 @@ import "https://example.com/foo/../module2.mjs";</code></pre>
114108114107
<dt>The <dfn>rendering task source</dfn></dt>
114109114108

114110114109
<dd>
114111-
<p>This <span>task source</span> is used solely to <span>update the rendering</span>.
114110+
<p>This <span>task source</span> is used solely to <span>update the rendering</span>.</p>
114112114111
</dd>
114113114112
</dl>
114114114113

@@ -119094,6 +119093,9 @@ dictionary <dfn dictionary>ImageBitmapOptions</dfn> {
119094119093

119095119094
<hr>
119096119095

119096+
<p>The <span data-x="dom-createImageBitmap">createImageBitmap</span> method uses the <dfn>bitmap
119097+
task source</dfn> to settle its returned Promise.</p>
119098+
119097119099
<p>The <dfn method for="WindowOrWorkerGlobalScope"><code
119098119100
data-x="dom-createImageBitmap">createImageBitmap(<var>image</var>,
119099119101
<var>options</var>)</code></dfn> and <code data-x="">createImageBitmap(<var>image</var>,
@@ -119115,7 +119117,7 @@ dictionary <dfn dictionary>ImageBitmapOptions</dfn> {
119115119117
exception or returns <i>bad</i>, then return <span>a promise rejected with</span> an
119116119118
<span>"<code>InvalidStateError</code>"</span> <code>DOMException</code>.
119117119119

119118-
<li><p>Let <var>p</var> be a new promise.</p></li>
119120+
<li><p>Let <var>promise</var> be a new promise.</p></li>
119119119121

119120119122
<li><p>Let <var>imageBitmap</var> be a new <code>ImageBitmap</code> object.</p></li>
119121119123

@@ -119152,13 +119154,8 @@ dictionary <dfn dictionary>ImageBitmapOptions</dfn> {
119152119154
data-x="concept-canvas-origin-clean">origin-clean</span> flag of <var>imageBitmap</var>'s
119153119155
bitmap to false.</p></li>
119154119156

119155-
<li>
119156-
<p>Run this step <span>in parallel</span>:</p>
119157-
119158-
<ol>
119159-
<li><p>Resolve <var>p</var> with <var>imageBitmap</var>.</p></li>
119160-
</ol>
119161-
</li>
119157+
<li><p><span>Queue a global task</span>, using the <span>bitmap task source</span>, to
119158+
resolve <var>promise</var> with <var>imageBitmap</var>.</p></li>
119162119159
</ol>
119163119160
</dd>
119164119161

@@ -119181,13 +119178,8 @@ dictionary <dfn dictionary>ImageBitmapOptions</dfn> {
119181119178
data-x="concept-canvas-origin-clean">origin-clean</span> flag of <var>imageBitmap</var>'s
119182119179
bitmap to false.</p></li>
119183119180

119184-
<li>
119185-
<p>Run this step <span>in parallel</span>:</p>
119186-
119187-
<ol>
119188-
<li><p>Resolve <var>p</var> with <var>imageBitmap</var>.</p></li>
119189-
</ol>
119190-
</li>
119181+
<li><p><span>Queue a global task</span>, using the <span>bitmap task source</span>, to
119182+
resolve <var>promise</var> with <var>imageBitmap</var>.</p></li>
119191119183
</ol>
119192119184
</dd>
119193119185

@@ -119204,13 +119196,8 @@ dictionary <dfn dictionary>ImageBitmapOptions</dfn> {
119204119196
data-x="concept-canvas-origin-clean">origin-clean</span> flag of <var>image</var>'s
119205119197
bitmap.</p></li>
119206119198

119207-
<li>
119208-
<p>Run this step <span>in parallel</span>:</p>
119209-
119210-
<ol>
119211-
<li><p>Resolve <var>p</var> with <var>imageBitmap</var>.</p></li>
119212-
</ol>
119213-
</li>
119199+
<li><p><span>Queue a global task</span>, using the <span>bitmap task source</span>, to
119200+
resolve <var>promise</var> with <var>imageBitmap</var>.</p></li>
119214119201
</ol>
119215119202
</dd>
119216119203

@@ -119220,9 +119207,10 @@ dictionary <dfn dictionary>ImageBitmapOptions</dfn> {
119220119207

119221119208
<ol>
119222119209
<li><p>Let <var>imageData</var> be the result of reading <var>image</var>'s data. If an <span
119223-
data-x="file-error-read">error occurs during reading of the object</span>, then reject
119224-
<var>p</var> with an <span>"<code>InvalidStateError</code>"</span> <code>DOMException</code>
119225-
and abort these steps.</p></li>
119210+
data-x="file-error-read">error occurs during reading of the object</span>, then <span>queue a
119211+
global task</span>, using the <span>bitmap task source</span>, to reject <var>promise</var>
119212+
with an <span>"<code>InvalidStateError</code>"</span> <code>DOMException</code> and abort
119213+
these steps.</p></li>
119226119214

119227119215
<li><p>Apply the <span data-x="Content-Type sniffing: image">image sniffing rules</span> to
119228119216
determine the file format of <var>imageData</var>, with MIME type of <var>image</var> (as
@@ -119231,9 +119219,10 @@ dictionary <dfn dictionary>ImageBitmapOptions</dfn> {
119231119219

119232119220
<li><p>If <var>imageData</var> is not in a supported image file format (e.g., it's not an
119233119221
image at all), or if <var>imageData</var> is corrupted in some fatal way such that the image
119234-
dimensions cannot be obtained (e.g., a vector graphic with no natural size), then reject
119235-
<var>p</var> with an <span>"<code>InvalidStateError</code>"</span> <code>DOMException</code>
119236-
and abort these steps.</p></li>
119222+
dimensions cannot be obtained (e.g., a vector graphic with no natural size), then <span>queue
119223+
a global task</span>, using the <span>bitmap task source</span>, to reject <var>promise</var>
119224+
with an <span>"<code>InvalidStateError</code>"</span> <code>DOMException</code> and abort
119225+
these steps.</p></li>
119237119226

119238119227
<li><p>Set <var>imageBitmap</var>'s <span data-x="concept-ImageBitmap-bitmap-data">bitmap
119239119228
data</span> to <var>imageData</var>, <span>cropped to the source rectangle with
@@ -119243,7 +119232,8 @@ dictionary <dfn dictionary>ImageBitmapOptions</dfn> {
119243119232
is not supported or is disabled), or, if there is no such image, the first frame of the
119244119233
animation.</p></li>
119245119234

119246-
<li><p>Resolve <var>p</var> with <var>imageBitmap</var>.</p></li>
119235+
<li><p><span>Queue a global task</span>, using the <span>bitmap task source</span>, to
119236+
resolve <var>promise</var> with <var>imageBitmap</var>.</p></li>
119247119237
</ol>
119248119238
</dd>
119249119239

@@ -119262,13 +119252,8 @@ dictionary <dfn dictionary>ImageBitmapOptions</dfn> {
119262119252
data</span> to <var>image</var>'s image data, <span>cropped to the source rectangle with
119263119253
formatting</span>.</p></li>
119264119254

119265-
<li>
119266-
<p>Run this step <span>in parallel</span>:</p>
119267-
119268-
<ol>
119269-
<li><p>Resolve <var>p</var> with <var>imageBitmap</var>.</p></li>
119270-
</ol>
119271-
</li>
119255+
<li><p><span>Queue a global task</span>, using the <span>bitmap task source</span>, to
119256+
resolve <var>promise</var> with <var>imageBitmap</var>.</p></li>
119272119257
</ol>
119273119258
</dd>
119274119259

@@ -119285,13 +119270,8 @@ dictionary <dfn dictionary>ImageBitmapOptions</dfn> {
119285119270
data-x="concept-canvas-origin-clean">origin-clean</span> flag of <var>image</var>'s
119286119271
bitmap.</p></li>
119287119272

119288-
<li>
119289-
<p>Run this step <span>in parallel</span>:</p>
119290-
119291-
<ol>
119292-
<li><p>Resolve <var>p</var> with <var>imageBitmap</var>.</p></li>
119293-
</ol>
119294-
</li>
119273+
<li><p><span>Queue a global task</span>, using the <span>bitmap task source</span>, to
119274+
resolve <var>promise</var> with <var>imageBitmap</var>.</p></li>
119295119275
</ol>
119296119276
</dd>
119297119277

@@ -119302,19 +119282,14 @@ dictionary <dfn dictionary>ImageBitmapOptions</dfn> {
119302119282
data</span> to a copy of <var>image</var>'s visible pixel data, <span>cropped to the source
119303119283
rectangle with formatting</span>.</p></li>
119304119284

119305-
<li>
119306-
<p>Run this step <span>in parallel</span>:</p>
119307-
119308-
<ol>
119309-
<li><p>Resolve <var>p</var> with <var>imageBitmap</var>.</p></li>
119310-
</ol>
119311-
</li>
119285+
<li><p><span>Queue a global task</span>, using the <span>bitmap task source</span>, to
119286+
resolve <var>promise</var> with <var>imageBitmap</var>.</p></li>
119312119287
</ol>
119313119288
</dd>
119314119289
</dl>
119315119290
</li>
119316119291

119317-
<li><p>Return <var>p</var>.</p></li>
119292+
<li><p>Return <var>promise</var>.</p></li>
119318119293
</ol>
119319119294

119320119295
<p>When the steps above require that the user agent <dfn data-x="cropped to the source

0 commit comments

Comments
 (0)