Skip to content

Commit 1d29fce

Browse files
committed
[worklets][css-paint-api] Remove renderWorker, and add paintWorklet specifically for paint.
1 parent e89279a commit 1d29fce

File tree

2 files changed

+22
-27
lines changed

2 files changed

+22
-27
lines changed

css-paint-api/Overview.bs

+22-8
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,32 @@ When the computed style for an element changes, the user agent must run the foll
6464
Note: In a future version of the spec, support may be added for partial invalidation.
6565
The user agent will be able to specify a region of the rendering context which needs to be re-painted by the paint class.
6666

67-
Registering Custom Paint {#registering-custom-paint}
68-
====================================================
67+
Paint Worklet {#paint-worklet}
68+
==============================
69+
70+
The {{paintWorklet}} attribute allows access to the {{Worklet}} responsible for all the classes
71+
which are related to painting.
72+
73+
<pre class='idl'>
74+
partial interface Window {
75+
[SameObject] readonly attribute Worklet paintWorklet;
76+
};
77+
</pre>
78+
79+
The {{PaintWorkletGlobalScope}} is the global execution context of the {{paintWorklet}}.
6980

7081
<pre class='idl'>
7182
callback VoidFunction = void ();
7283

73-
partial interface RenderWorkletGlobalScope {
84+
interface PaintWorkletGlobalScope : WorkletGlobalScope {
7485
void registerPaint(DOMString name, VoidFunction paintCtor);
7586
};
7687
</pre>
7788

78-
The {{RenderWorkletGlobalScope}} has a map of <b>name to paint instance map</b>. Initially this map is empty; it is populated when {{registerPaint(name, paintCtor)}} is called.
89+
Registering Custom Paint {#registering-custom-paint}
90+
====================================================
91+
92+
The {{PaintWorkletGlobalScope}} has a map of <b>name to paint instance map</b>. Initially this map is empty; it is populated when {{registerPaint(name, paintCtor)}} is called.
7993

8094
<div class='note'>
8195
Note: This is how the class should look.
@@ -87,7 +101,7 @@ The {{RenderWorkletGlobalScope}} has a map of <b>name to paint instance map</b>.
87101
</pre>
88102
</div>
89103

90-
When the <dfn method for=RenderWorkletGlobalScope>registerPaint(<var>name</var>, <var>paintCtor</var>)</dfn> method is called, the user agent <em>must</em> run the following steps:
104+
When the <dfn method for=PaintWorkletGlobalScope>registerPaint(<var>name</var>, <var>paintCtor</var>)</dfn> method is called, the user agent <em>must</em> run the following steps:
91105
1. If the |name| is not a valid <<ident>>, <a>throw</a> a <a>NotSupportedError</a> and abort all these steps.
92106
2. If the |name| exists as a key in the <b>name to paint instance map</b>, <a>throw</a> a <a>NotSupportedError</a> and abort all these steps.
93107
3. If the result of <a>IsConstructor</a>(argument=|paintCtor|) is false, <a>throw</a> a <a>NotSupportedError</a> and abort all these steps.
@@ -97,7 +111,7 @@ When the <dfn method for=RenderWorkletGlobalScope>registerPaint(<var>name</var>,
97111
7. If the result of <a>IsArray</a>(argument=|inputProperties|) is false, <a>throw</a> a <a>NotSupportedError</a> and abort all these steps.
98112
8. Add the key-value pair (|name| - |inputProperties|) to the <b>paint name to input properties map</b> of the associated <a>document</a>.
99113
9. Let <var>paintInstance</var> be the result of <a>Construct</a>(|paintCtor|).
100-
10. Add the key-value pair (|name| - |paintInstance|) to the <b>name to paint instance map</b> of the {{RenderWorkletGlobalScope}}.
114+
10. Add the key-value pair (|name| - |paintInstance|) to the <b>name to paint instance map</b> of the {{PaintWorkletGlobalScope}}.
101115

102116
Note: The list of CSS properties provided by the input properties getter can either be custom or native CSS properties.
103117

@@ -212,7 +226,7 @@ When the user agent wants to <dfn>draw an image</dfn> of a <<paint()>> for a <va
212226
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:
213227
- To <a>create a worklet global scope</a> the user agent will:
214228

215-
Return a new {{RenderWorkletGlobalScope}}.
229+
Return a new {{PaintWorkletGlobalScope}}.
216230
- To <a>lookup a class instance on a worklet global scope</a> given a |workletGlobalScope|, the user agent will:
217231

218232
Return the result of looking up |name| on the |workletGlobalScope|'s <b>name to paint instance map</b>.
@@ -247,7 +261,7 @@ Example 1: A colored circle. {#example-1}
247261
-----------------------------------------
248262

249263
<pre class='lang-javascript'>
250-
// Inside RenderWorkletGlobalScope.
264+
// Inside PaintWorkletGlobalScope.
251265
registerPaint('circle', class {
252266
static get inputProperties() { return ['--circle-color']; }
253267
paint(ctx, geom, properties) {

worklets/Overview.bs

-19
Original file line numberDiff line numberDiff line change
@@ -326,25 +326,6 @@ When a user agent is to <dfn export>invoke a method on a class inside a Worklet<
326326

327327
Note: It is up to the user agent to select a appropriate {{WorkletGlobalScope}} to invoke the method in.
328328

329-
Rendering Worklet {#rendering-worklet}
330-
--------------------------------------
331-
332-
The {{renderWorklet}} attribute allows access to the {{Worklet}} responsible for all the classes
333-
which are related to rendering.
334-
335-
<pre class='idl'>
336-
partial interface Window {
337-
[SameObject] readonly attribute Worklet renderWorklet;
338-
};
339-
</pre>
340-
341-
The {{RenderWorkletGlobalScope}} is the global execution context of the {{renderWorklet}}.
342-
343-
<pre class='idl'>
344-
interface RenderWorkletGlobalScope : WorkletGlobalScope {
345-
};
346-
</pre>
347-
348329
Examples {#examples}
349330
====================
350331

0 commit comments

Comments
 (0)