Skip to content

Commit 8214315

Browse files
committed
[worklets][css-paint-api] Fix invoking methods on classes.
1 parent 13571ed commit 8214315

File tree

2 files changed

+42
-45
lines changed

2 files changed

+42
-45
lines changed

css-paint-api/Overview.bs

+16-9
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ Paint Worklet {#paint-worklet}
7070
The {{paintWorklet}} attribute allows access to the {{Worklet}} responsible for all the classes
7171
which are related to painting.
7272

73+
The {{paintWorklet}}'s <b>worklet global scope type</b> is {{PaintWorkletGlobalScope}}.
74+
7375
<pre class='idl'>
7476
partial interface Window {
7577
[SameObject] readonly attribute Worklet paintWorklet;
@@ -223,21 +225,26 @@ When the user agent wants to <dfn>draw an image</dfn> of a <<paint()>> for a <va
223225

224226
7. Let <var>geometry</var> be a new {{Geometry}} initialized to the width and height of the |fragment|.
225227

226-
8. To produce the image output, <a>invoke a method on a class inside a Worklet</a> given "paint" as the <em>methodPropertyKey</em> and [|renderingContext|, |geometry|, |styleMap|] as the <em>arguments</em> with the following options:
227-
- To <a>create a worklet global scope</a> the user agent will:
228+
8. Let |workletGlobalScope| be a {{PaintWorkletGlobalScope}} from the list of <b>worklet's
229+
WorkletGlobalScopes</b> from the paint {{Worklet}}.
228230

229-
Return a new {{PaintWorkletGlobalScope}}.
230-
- To <a>lookup a class instance on a worklet global scope</a> given a |workletGlobalScope|, the user agent will:
231+
The user agent <em>may</em> also <a>create a WorkletGlobalScope</a> given the paint
232+
{{Worklet}} and use that.
231233

232-
Return the result of looking up |name| on the |workletGlobalScope|'s <b>name to paint instance map</b>.
234+
Note: The user agent <em>may</em> use any policy for which {{PaintWorkletGlobalScope}} to
235+
select or create.
233236

234-
If an exception is <a>thrown</a> the resulting image output will be an <a>invalid image</a>.
237+
9. Let |classInstance| be the result of performing a lookup in <b>name to paint instance map</b>
238+
with |name| as the key.
235239

236-
Otherwise the image output should be produced from the |renderingContext| given to the paint method.
240+
10. Perform <a>Invoke</a>(O=|classInstance|, P="paint", Arguments=[|renderingContext|,
241+
|geometry|, |styleMap|).
237242

238-
Note: User agents should provide tooling within their debugging tools to show authors a partial output of the image, if an exception is thrown.
243+
11. The image output should be produced from the |renderingContext| given to the method.
244+
245+
If an exception is <a>thrown</a> the resulting image output will be an <a>invalid image</a>.
239246

240-
9. Set the <b>paint valid flag</b> for the <<paint()>> function on the |fragment| to <a>paint-valid</a>.
247+
12. Set the <b>paint valid flag</b> for the <<paint()>> function on the |fragment| to <a>paint-valid</a>.
241248

242249
Note: The user agent should consider long running paint functions similar to long running script in the main execution context.
243250
For example, they should show a "unresponsive script" dialog or similar.

worklets/Overview.bs

+26-36
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Editor: Ian Kilpatrick, ikilpatrick@chromium.org
1010
</pre>
1111

1212
<pre class="anchors">
13+
urlPrefix: http://heycam.github.io/webidl/#dfn-; type: dfn;
14+
text: inherit
1315
urlPrefix: https://html.spec.whatwg.org/multipage/browsers.html; type: dfn;
1416
text: effective script origin
1517
url: #origin-2; text: origin
@@ -150,10 +152,12 @@ WorkletGlobalScope</a> algorithm.
150152

151153
### Creating a WorkletGlobalScope ### {#creating-a-workletglobalscope}
152154

153-
When a user agent is to <dfn>create a WorkletGlobalScope</dfn>, for a given |workletGlobalScopeType|
154-
and |worklet|, it <em>must</em> run the following steps:
155+
When a user agent is to <dfn>create a WorkletGlobalScope</dfn>, for a given |worklet|, it
156+
<em>must</em> run the following steps:
155157

156-
1. Call the JavaScript <a>InitializeHostDefinedRealm</a> abstract operation with the following
158+
1. Let |workletGlobalScopeType| be the |worklet|'s <b>worklet global scope type</b>.
159+
160+
2. Call the JavaScript <a>InitializeHostDefinedRealm</a> abstract operation with the following
157161
customizations:
158162

159163
- For the global object, create a new |workletGlobalScopeType| object. Let
@@ -163,18 +167,19 @@ and |worklet|, it <em>must</em> run the following steps:
163167

164168
- Do not obtain any source texts for scripts or modules.
165169

166-
2. Let |settingsObject| be the result of <a>set up a worklet environment settings object</a>
170+
3. Let |settingsObject| be the result of <a>set up a worklet environment settings object</a>
167171
with |realmExecutionContext|.
168172

169-
2. Associate the |settingsObject| with |workletGlobalScope|.
173+
4. Associate the |settingsObject| with |workletGlobalScope|.
170174

171-
3. For each |resolvedModuleURL| in the given |worklet|'s <b>worklet's resolved module URLs</b>,
175+
5. For each |resolvedModuleURL| in the given |worklet|'s <b>worklet's resolved module URLs</b>,
172176
run the following substeps:
173177
1. Let |script| be the result of <a>fetch a module script tree</a> given
174178
|resolvedModuleURL|, "anonymous" for the <a>CORS setting attribute</a>, and
175179
|settingsObject|.
176180

177-
Issue: Decide if "use-credientials" should be valid for worklets.
181+
Note: Worklets follow <a>web workers</a> here in not allowing "use-credientials" for
182+
fetching resources.
178183

179184
2. <a>Run a module script</a> given |script|.
180185

@@ -244,6 +249,11 @@ interface Worklet {
244249
};
245250
</pre>
246251

252+
A {{Worklet}} has a <b>worklet global scope type</b>. This is used for creating new
253+
{{WorkletGlobalScope}} and the type must <a>inherit</a> from {{WorkletGlobalScope}}.
254+
255+
Note: As an example the <b>worklet global scope type</b> might be a {{PaintWorkletGlobalScope}}.
256+
247257
A {{Worklet}} has a list of the <b>worklet's WorkletGlobalScopes</b>. Initially this list is empty;
248258
it is populated when the user agent chooses to create its {{WorkletGlobalScope}}.
249259

@@ -265,19 +275,24 @@ the user agent <em>must</em> run the following steps:
265275

266276
4. Add |resolvedModuleURL| to the list of <b>worklet's resolved module URLs</b>.
267277

268-
5. For each {{WorkletGlobalScope}} in the <b>worklet's WorkletGlobalScopes</b>, run these
278+
5. Ensure that there is at least one {{WorkletGlobalScope}} in the <b>worklet's
279+
WorkletGlobalScopes</b>. If not <a>create a WorkletGlobalScope</a> given the current
280+
{{Worklet}}.
281+
282+
6. For each {{WorkletGlobalScope}} in the <b>worklet's WorkletGlobalScopes</b>, run these
269283
substeps:
270284
1. Let |settings| be the {{WorkletGlobalScope}}'s associated
271285
<a>environment settings object</a>.
272286

273287
2. Let |script| be the result of <a>fetch a module script tree</a> given
274288
|resolvedModuleURL|, "anonymous" for the <a>CORS setting attribute</a>, and |settings|.
275289

276-
Issue: Decide if "use-credientials" should be valid for worklets.
290+
Note: Worklets follow <a>web workers</a> here in not allowing "use-credientials" for
291+
fetching resources.
277292

278293
3. <a>Run a module script</a> given |script|.
279294

280-
6. If <em>all</em> the steps above succeeded (in particular, if all of the scripts parsed and
295+
7. If <em>all</em> the steps above succeeded (in particular, if all of the scripts parsed and
281296
loaded into the global scopes), resolve |promise|
282297
<br>Otherwise, reject |promise|.
283298

@@ -306,26 +321,6 @@ Issue(w3c/css-houdini-drafts#53): Worth adding dispose to classes to allow clean
306321
Processing Model {#processing-model}
307322
------------------------------------
308323

309-
Issue: Split this up.
310-
311-
The <a>invoke a method on a class inside a Worklet</a> has two hooks for algorithm steps that may be customized by any callers:
312-
- <dfn export>lookup a class instance on a worklet global scope</dfn>
313-
314-
When a user agent is to <dfn export>invoke a method on a class inside a Worklet</dfn> given a
315-
|methodPropertyKey|, |workletGlobalScopeType|, some |arguments|, it must run the following steps:
316-
317-
1. Let |workletGlobalScope| be a {{WorkletGlobalScope}} from the list of the <b>worklet's {{WorkletGlobalScope}}s</b>.
318-
319-
If none exist or a new {{WorkletGlobalScope}} is required, the user agent <em>must</em> run the following substeps:
320-
1. Let |workletGlobalScope| be the result of <a>Create a WorkletGlobalScope</a>, given |workletGlobalScopeType| and |worklet|.
321-
2. Add |workletGlobalScope| to the |worklet|'s list of the <b>worklet's {{WorkletGlobalScope}}s</b>.
322-
323-
2. Let |classInstance| be the result of <a>lookup a class instance on a worklet global scope</a> given |workletGlobalScope|.
324-
3. Let |result| be the result of <a>Invoke</a>(O=|classInstance|, P=|methodPropertyKey|, Arguments=|arguments|).
325-
4. Return |result|.
326-
327-
Note: It is up to the user agent to select a appropriate {{WorkletGlobalScope}} to invoke the method in.
328-
329324
Examples {#examples}
330325
====================
331326

@@ -390,9 +385,4 @@ registerAnArbitaryClass('foo', class FooClass {
390385
});
391386
</pre>
392387

393-
When the user agent wants to invoke <b>process</b> on an instance of class with key <b>foo</b> it will:
394-
1. Call <a>invoke a method on a class inside a Worklet</a> given <b>process</b> as the
395-
|methodPropertyKey|, FakeWorkletGlobalScope as |workletGlobalScopeType| and some |arguments| with the following options:
396-
- To <a>lookup a class instance on a worklet global scope</a> given a |workletGlobalScope|, the user agent will:
397-
1. Let |classConstructor| be the result of looking up <b>foo</b> on the |workletGlobalScope|'s map of <b>registered class constructors</b>.
398-
2. Return the result of <a>Construct</a>(|classConstructor|).
388+
Issue: Add example prose for invoking "process".

0 commit comments

Comments
 (0)