Skip to content

Commit b0a419f

Browse files
authored
[worklets] Adds hook for downstream spec to set the destination. (#388)
Fixes #378.
1 parent 5670a71 commit b0a419f

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

css-paint-api/Overview.bs

+2
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ which are related to painting.
7474

7575
The {{paintWorklet}}'s [=worklet global scope type=] is {{PaintWorkletGlobalScope}}.
7676

77+
The {{paintWorklet}}'s <a>worklet destination type</a> is <code>"paintworklet"</code>.
78+
7779
<pre class='idl'>
7880
partial namespace CSS {
7981
[SameObject] readonly attribute Worklet paintWorklet;

worklets/Overview.bs

+16-11
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,9 @@ Note: As an example the <a>worklet global scope type</a> might be a {{PaintWorkl
349349
A {{Worklet}} has a list of the <dfn export>worklet's WorkletGlobalScopes</dfn>. Initially this list
350350
is empty; it is populated when the user agent chooses to create its {{WorkletGlobalScope}}.
351351

352+
A {{Worklet}} has a <dfn export>worklet destination type</dfn>. This is used for setting the <a
353+
for=request>destination</a> requests from <a>fetch a module worker script graph</a>.
354+
352355
A {{Worklet}} has a <dfn>module responses map</dfn>. This is a ordered map of module URLs to values
353356
that are a <a>fetch</a> responses. The map's entries are ordered based on their insertion order.
354357
Access to this map should be thread-safe.
@@ -394,7 +397,9 @@ When the <dfn method for=Worklet>addModule(|moduleURL|, |options|)</dfn> method
394397

395398
9. Let |workletGlobalScopeType| be |worklet|'s <a>worklet global scope type</a>.
396399

397-
10. If the <a>worklet's WorkletGlobalScopes</a> is empty, run the following steps:
400+
10. Let |destination| be |worklet|'s <a>worklet destination type</a>.
401+
402+
11. If the <a>worklet's WorkletGlobalScopes</a> is empty, run the following steps:
398403

399404
1. <a>Create a WorkletGlobalScope</a> given |workletGlobalScopeType|, |moduleResponsesMap|,
400405
and |outsideSettings|.
@@ -409,22 +414,22 @@ When the <dfn method for=Worklet>addModule(|moduleURL|, |options|)</dfn> method
409414

410415
Wait for this step to complete before continuing.
411416

412-
11. Let |pendingTaskStruct| be a new <a>pending tasks struct</a> with <a
417+
12. Let |pendingTaskStruct| be a new <a>pending tasks struct</a> with <a
413418
for="pending tasks struct">counter</a> initialized to the length of <a>worklet's
414419
WorkletGlobalScopes</a>.
415420

416-
12. For each |workletGlobalScope| in the <a>worklet's WorkletGlobalScopes</a>, <a>queue a
421+
13. For each |workletGlobalScope| in the <a>worklet's WorkletGlobalScopes</a>, <a>queue a
417422
task</a> on the |workletGlobalScope| to <a>fetch and invoke a worklet script</a> given
418-
|workletGlobalScope|, |moduleURLRecord|, |moduleResponsesMap|, |credentialOptions|,
419-
|outsideSettings|, |pendingTaskStruct|, and |promise|.
423+
|workletGlobalScope|, |moduleURLRecord|, |destination|, |moduleResponsesMap|,
424+
|credentialOptions|, |outsideSettings|, |pendingTaskStruct|, and |promise|.
420425

421426
Note: The rejecting and resolving of the |promise| occurs within the <a>fetch and invoke a
422427
worklet script</a> algorithm.
423428
</div>
424429

425430
<div algorithm>
426431
When the user agent is to <dfn>fetch and invoke a worklet script</dfn> given |workletGlobalScope|,
427-
|moduleURLRecord|, |moduleResponsesMap|, |credentialOptions|, |outsideSettings|,
432+
|moduleURLRecord|, |destination|, |moduleResponsesMap|, |credentialOptions|, |outsideSettings|,
428433
|pendingTaskStruct|, and |promise|, the user agent <em>must</em> run the following steps:
429434

430435
Note: This algorithm is to be run within the <a>worklet global scope execution environment</a>.
@@ -433,8 +438,8 @@ When the user agent is to <dfn>fetch and invoke a worklet script</dfn> given |wo
433438
object</a>.
434439

435440
2. Let |script| by the result of <a>fetch a worklet script</a> given |moduleURLRecord|,
436-
|moduleResponsesMap|, |credentialOptions|, |outsideSettings|, and |insideSettings| when it
437-
asynchronously completes.
441+
|destination|, |moduleResponsesMap|, |credentialOptions|, |outsideSettings|, and
442+
|insideSettings| when it asynchronously completes.
438443

439444
3. If |script| is null, then <a>queue a task</a> on |outsideSettings|'s <a>responsible event
440445
loop</a> to run these steps:
@@ -472,14 +477,14 @@ When the user agent is to <dfn>fetch and invoke a worklet script</dfn> given |wo
472477
</div>
473478

474479
<div algorithm>
475-
When the user agent is to <dfn>fetch a worklet script</dfn> given |moduleURLRecord|,
480+
When the user agent is to <dfn>fetch a worklet script</dfn> given |moduleURLRecord|, |destination|,
476481
|moduleResponsesMap|, |credentialOptions|, |outsideSettings|, and |insideSettings|, the user agent
477482
<em>must</em> run the following steps:
478483

479484
Note: This algorithm is to be run within the <a>worklet global scope execution environment</a>.
480485

481-
1. <a>Fetch a module worker script graph</a> given |moduleURLRecord|, |outsideSettings|, "script",
482-
|credentialOptions|, and |insideSettings|.
486+
1. <a>Fetch a module worker script graph</a> given |moduleURLRecord|, |outsideSettings|,
487+
|destination|, |credentialOptions|, and |insideSettings|.
483488

484489
To <a>perform the fetch</a> given |request|, perform the following steps:
485490

0 commit comments

Comments
 (0)