Skip to content

Commit 1d01087

Browse files
committed
[worklets] Add boxes around algorithms - no funcitonal change.
1 parent 7c5c4f8 commit 1d01087

File tree

1 file changed

+44
-23
lines changed

1 file changed

+44
-23
lines changed

worklets/Overview.bs

+44-23
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@ Abstract: This specification defines an API for running scripts in stages of th
1010
Editor: Ian Kilpatrick, ikilpatrick@chromium.org
1111
</pre>
1212

13+
<style>
14+
/* Put nice boxes around each algorithm. */
15+
[data-algorithm]:not(.heading) {
16+
padding: .5em;
17+
border: thin solid #ddd; border-radius: .5em;
18+
margin: .5em calc(-0.5em - 1px);
19+
}
20+
[data-algorithm]:not(.heading) > :first-child {
21+
margin-top: 0;
22+
}
23+
[data-algorithm]:not(.heading) > :last-child {
24+
margin-bottom: 0;
25+
}
26+
</style>
27+
1328
<pre class="anchors">
1429
urlPrefix: http://heycam.github.io/webidl/; type: dfn;
1530
text: AbortError
@@ -175,6 +190,7 @@ Note:
175190

176191
### Creating a WorkletGlobalScope ### {#creating-a-workletglobalscope}
177192

193+
<div algorithm>
178194
When a user agent is to <dfn>create a WorkletGlobalScope</dfn>, given |workletGlobalScopeType|,
179195
|moduleResponsesMap|, and |outsideSettings|, it <em>must</em> run the following steps:
180196

@@ -213,9 +229,11 @@ When a user agent is to <dfn>create a WorkletGlobalScope</dfn>, given |workletGl
213229
|script| should never be <em>null</em> here.
214230

215231
6. Run the <a>responsible event loop</a> specified by |insideSettings|.
232+
</div>
216233

217234
### Script settings for worklets ### {#script-settings-for-worklets}
218235

236+
<div algorithm>
219237
When a user agent is to <dfn>set up a worklet environment settings object</dfn>, given a
220238
|executionContext|, it must run the following steps:
221239
1. Let |inheritedResponsibleBrowsingContext| be the <a>responsible browsing context</a>
@@ -264,6 +282,7 @@ When a user agent is to <dfn>set up a worklet environment settings object</dfn>,
264282
:: Return |workletGlobalScope|'s <a>HTTPS state</a>.
265283

266284
7. Return |settingsObject|.
285+
</div>
267286

268287
Issue: Merge this with https://html.spec.whatwg.org/multipage/workers.html#set-up-a-worker-environment-settings-object
269288

@@ -310,8 +329,7 @@ A <dfn>pending tasks struct</dfn> is a <a>struct</a> consiting of:
310329
- A <dfn for="pending tasks struct">counter</dfn>.
311330
This is used by the algorithms below.
312331

313-
<hr>
314-
332+
<div algorithm>
315333
When the <dfn method for=Worklet>import(|moduleURL|)</dfn> method is called on a {{Worklet}} object,
316334
the user agent <em>must</em> run the following steps:
317335
1. Let |promise| be <a>a new promise</a>.
@@ -354,44 +372,46 @@ the user agent <em>must</em> run the following steps:
354372

355373
Note: The rejecting and resolving of the |promise| occurs within the <a>fetch and invoke a
356374
worklet script</a> algorithm.
375+
</div>
357376

358-
<hr>
359-
377+
<div algorithm>
360378
When the user agent is to <dfn>fetch and invoke a worklet script</dfn> given |workletGlobalScope|,
361379
|moduleURLRecord|, |moduleResponsesMap|, |outsideSettings|, |pendingTaskStruct|, and |promise|, the
362380
user agent <em>must</em> run the following steps:
363381

364-
Note: This algorithm is to be run within the <a>worklet global scope execution environment</a>.
365-
366-
1. Let |insideSettings| be the |workletGlobalScope|'s associated <a>environment settings object</a>.
382+
Note: This algorithm is to be run within the <a>worklet global scope execution environment</a>.
367383

368-
2. Let |script| by the result of <a>fetch a worklet script</a> given |moduleURLRecord|,
369-
|moduleResponsesMap|, |outsideSettings|, and |insideSettings| when it asynchronously completes.
384+
1. Let |insideSettings| be the |workletGlobalScope|'s associated <a>environment settings
385+
object</a>.
370386

371-
3. If |script| is <em>null</em>, then <a>queue a task</a> on |outsideSettings|'s <a>responsible
372-
event loop</a> to run these steps:
387+
2. Let |script| by the result of <a>fetch a worklet script</a> given |moduleURLRecord|,
388+
|moduleResponsesMap|, |outsideSettings|, and |insideSettings| when it asynchronously completes.
373389

374-
1. If |pendingTaskStruct|'s <a for="pending tasks struct">counter</a> is not <b>-1</b>, then
375-
run these steps:
390+
3. If |script| is <em>null</em>, then <a>queue a task</a> on |outsideSettings|'s <a>responsible
391+
event loop</a> to run these steps:
376392

377-
1. Set |pendingTaskStruct|'s <a for="pending tasks struct">counter</a> to <b>-1</b>.
393+
1. If |pendingTaskStruct|'s <a for="pending tasks struct">counter</a> is not <b>-1</b>, then
394+
run these steps:
378395

379-
2. Reject |promise| with an "<a>AbortError</a>" <a>DOMException</a>.
396+
1. Set |pendingTaskStruct|'s <a for="pending tasks struct">counter</a> to <b>-1</b>.
380397

381-
4. <a>Run a module script</a> given |script|.
398+
2. Reject |promise| with an "<a>AbortError</a>" <a>DOMException</a>.
382399

383-
5. <a>Queue a task</a> on |outsideSettings|'s <a>responsible event loop</a> to run these steps:
400+
4. <a>Run a module script</a> given |script|.
384401

385-
1. If |pendingTaskStruct|'s <a for="pending tasks struct">counter</a> is not <b>-1</b>, then run
386-
these steps:
402+
5. <a>Queue a task</a> on |outsideSettings|'s <a>responsible event loop</a> to run these steps:
387403

388-
1. Decrement |pendingTaskStruct|'s <a for="pending tasks struct">counter</a> by <b>1</b>.
404+
1. If |pendingTaskStruct|'s <a for="pending tasks struct">counter</a> is not <b>-1</b>, then
405+
run these steps:
389406

390-
1. If |pendingTaskStruct|'s <a for="pending tasks struct">counter</a> is <b>0</b>, then
391-
resolve |promise|.
407+
1. Decrement |pendingTaskStruct|'s <a for="pending tasks struct">counter</a> by
408+
<b>1</b>.
392409

393-
<hr>
410+
2. If |pendingTaskStruct|'s <a for="pending tasks struct">counter</a> is <b>0</b>, then
411+
resolve |promise|.
412+
</div>
394413

414+
<div algorithm>
395415
When the user agent is to <dfn>fetch a worklet script</dfn> given |moduleURLRecord|,
396416
|moduleResponsesMap|, |outsideSettings|, and |insideSettings|, the user agent <em>must</em>
397417
run the following steps:
@@ -454,6 +474,7 @@ Note: Specifically, if a script fails to parse or fails to load over the network
454474
it would print <code class='lang-javascript'>[paintWorklet#3] Hello from a
455475
WorkletGlobalScope!</code> again in the debugging tools when this occurs.
456476
</div>
477+
</div>
457478

458479
Issue(w3c/css-houdini-drafts#47): Need ability to load code into a {{WorkletGlobalScope}}
459480
declaratively.

0 commit comments

Comments
 (0)