@@ -61,9 +61,6 @@ Note: In a future version of the spec, support may be added for defining the cli
6161Paint Invalidation {#paint-invalidation}
6262========================================
6363
64- A <a>document</a> has a <a>map</a> of <dfn>paint input properties</dfn> . Initially it is empty and
65- is populated when {{registerPaint(name, paintCtor)}} is called.
66-
6764Each <<paint()>> function for a box has an associated <dfn>paint valid flag</dfn> . It may be either
6865<dfn>paint-valid</dfn> or <dfn>paint-invalid</dfn> . It is initially set to <a>paint-invalid</a> .
6966
@@ -76,12 +73,16 @@ When the computed style for a |box| changes, the user agent <em>must</em> run th
7673
7774 2. Let |name| be the first argument of the <<paint()>> function.
7875
79- 3. Let |paintInputPropertiesMap| be the associated <a>document</a> 's <a>paint input
80- properties</a> map.
76+ 3. Let |documentPaintDefinitionMap| be the associated <a>document</a> 's <a>document paint
77+ definitions</a> map.
78+
79+ 4. Let |documentDefinition| be the result of <a>get</a>
80+ |documentPaintDefinitionMap|[|name|] .
8181
82- 4. Let |inputProperties| be the result of <a>get</a> |paintInputPropertiesMap|[|name|] .
82+ 5. Let |inputProperties| be |documentDefinition|'s <a for="document paint definition">input
83+ properties</a> list.
8384
84- 5 . For each |property| in |inputProperties|, if the |property|'s <a>computed value</a> has
85+ 6 . For each |property| in |inputProperties|, if the |property|'s <a>computed value</a> has
8586 changed, set the <a>paint valid flag</a> on the |paintFunction| to <a>paint-invalid</a> .
8687
8788Performing <a>draw a paint image</a> results in the <a>paint valid flag</a> for a <<paint()>>
@@ -119,7 +120,9 @@ interface PaintWorkletGlobalScope : WorkletGlobalScope {
119120 <pre class='lang-javascript'>
120121 class MyPaint {
121122 static get inputProperties() { return ['--foo'] ; }
123+ static get inputArguments() { return ['<color>'] ; }
122124 static get alpha() { return true; }
125+
123126 paint(ctx, size, styleMap) {
124127 // Paint code goes here.
125128 }
@@ -130,25 +133,43 @@ interface PaintWorkletGlobalScope : WorkletGlobalScope {
130133Concepts {#concepts}
131134====================
132135
133- A <dfn>paint image definition</dfn> is a <a>struct</a> which describes an author defined <<image>>
134- which can be referenced by the <<paint()>> function. It consists of:
136+ A <dfn>paint definition</dfn> is a <a>struct</a> which describes the information needed by the
137+ {{PaintWorkletGlobalScope}} about the author defined <<image>> (which can be referenced by the
138+ <<paint()>> function). It consists of:
139+
140+ - <dfn for="paint definition">class constructor</dfn> which is the class <a>constructor</a> .
141+
142+ - <dfn for="paint definition">paint function</dfn> which is the paint <a>function</a> callback.
143+
144+ - <dfn for="paint definition">constructor valid flag</dfn> .
135145
136- - <dfn for="paint image definition">class constructor</dfn> which is the class <a>constructor</a> .
146+ - <dfn for="paint definition">input properties</dfn> which is a <a>list</a> of
147+ <code> DOMStrings</code> .
137148
138- - <dfn for="paint image definition">paint function </dfn> which is the paint <a>function </a>
139- callback .
149+ - A <dfn for="paint definition">input argument types </dfn> which is a <a>list </a> of parsed
150+ [[css-properties-values-api-1#supported-syntax-strings]] .
140151
141- - <dfn for="paint image definition">constructor valid flag</dfn> .
152+ - A <dfn for="paint definition">context alpha flag</dfn> .
142153
143- - <dfn for="paint image definition">input properties</dfn> which is a <a>list</a> of
144- <code> DOMStrings</code> .
154+ A <dfn>document paint definition</dfn> is a <a>struct</a> which describes the information
155+ needed by the <a>document</a> about the author defined <<image>> function (which can be referenced
156+ by the paint function). It consists of:
145157
146- - A <dfn for="paint image definition">context alpha flag</dfn> .
158+ - A <dfn for="document paint definition">input properties</dfn> which is a <a>list</a> of
159+ <code> DOMStrings</code> .
160+
161+ - A <dfn for="document paint definition">input argument types</dfn> which is a <a>list</a> of
162+ parsed [[css-properties-values-api-1#supported-syntax-strings]] .
163+
164+ - A <dfn for="document paint definition">context alpha flag</dfn> .
147165
148166Registering Custom Paint {#registering-custom-paint}
149167====================================================
150168
151- The {{PaintWorkletGlobalScope}} has a <a>map</a> of <dfn>paint image definitions</dfn> . Initially
169+ The <a>document</a> has a <a>map</a> of <dfn>document paint definitions</dfn> . Initially
170+ this map is empty; it is populated when {{registerPaint(name, paintCtor)}} is called.
171+
172+ The {{PaintWorkletGlobalScope}} has a <a>map</a> of <dfn>paint definitions</dfn> . Initially
152173this map is empty; it is populated when {{registerPaint(name, paintCtor)}} is called.
153174
154175The {{PaintWorkletGlobalScope}} has a <a>map</a> of <dfn>paint class instances</dfn> . Initially this
@@ -162,10 +183,9 @@ When the <dfn method for=PaintWorkletGlobalScope>registerPaint(|name|, |paintCto
162183called, the user agent <em> must</em> run the following steps:
163184 1. If the |name| is an empty string, <a>throw</a> a <a>TypeError</a> and abort all these steps.
164185
165- 2. Let |paintImageDefinitionMap| be {{PaintWorkletGlobalScope}} 's <a>paint image definitions</a>
166- map.
186+ 2. Let |paintDefinitionMap| be {{PaintWorkletGlobalScope}} 's <a>paint definitions</a> map.
167187
168- 3. If |paintImageDefinitionMap |[|name|] <a for=map>exists</a> <a>throw</a> a
188+ 3. If |paintDefinitionMap |[|name|] <a for=map>exists</a> <a>throw</a> a
169189 "<a>InvalidModificationError</a> " <a>DOMException</a> and abort all these steps.
170190
171191 4. Let |inputProperties| be an empty <code> sequence<DOMString></code>
@@ -185,60 +205,97 @@ called, the user agent <em>must</em> run the following steps:
185205 also contains currently invalid properties for the user agent. For example
186206 <code> margin-bikeshed-property</code> .
187207
188- 7. Let |alphaValue| be the result of <a>Get</a> (|paintCtor|, "alpha").
208+ 7. Let |inputArguments| be an empty <code> sequence<DOMString></code> .
209+
210+ 8. Let |inputArgumentsIterable| be the result of <a>Get</a> (|paintCtor|, "inputArguments").
211+
212+ 9. If |inputArgumentsIterable| is not undefined, then set |inputArguments| to the result of
213+ <a>converting</a> |inputArgumentsIterable| to a <code> sequence<DOMString></code> . If an
214+ execption is thrown, rethrow the execption and abort all these steps.
189215
190- 8. Let |alpha| be <code> true</code> if |alphaValue| is undefined, otherwise let it be the result
191- of <a>converting</a> |alphaValue| to a <a>boolean</a> . If an exception is <a>thrown</a> ,
192- rethrow the exception and abort all these steps.
216+ 10. Let |inputArgumentTypes| be an <a for=list>empty</a> <a>list</a> .
217+
218+ 11. <a for=list>For each</a> |item| in |inputArguments| perform the following substeps:
219+
220+ 1. Let |parsedItem| be the result of parsing |item| according to the rules in
221+ [[css-properties-values-api-1#supported-syntax-strings]] . If it fails to parse
222+ <a>throw</a> a <a>TypeError</a> and abort all these steps.
223+
224+ 2. <a for=list>Append</a> |parsedItem| to |inputArgumentTypes|.
225+
226+ 12. Let |alphaValue| be the result of <a>Get</a> (|paintCtor|, "alpha").
227+
228+ 13. Let |alpha| be <code> true</code> if |alphaValue| is undefined, otherwise let it be the
229+ result of <a>converting</a> |alphaValue| to a <a>boolean</a> . If an exception is
230+ <a>thrown</a> , rethrow the exception and abort all these steps.
193231
194232 Note: Setting <code> alpha</code> is <code> false</code> allows user agents to anti-alias text
195233 an addition to performing "visibility" optimizations, e.g. not painting an image behind
196234 the paint image as the paint image is opaque.
197235
198- 9 . If the result of <a>IsConstructor</a> (|paintCtor|) is false, <a>throw</a> a <a>TypeError</a>
236+ 14 . If the result of <a>IsConstructor</a> (|paintCtor|) is false, <a>throw</a> a <a>TypeError</a>
199237 and abort all these steps.
200238
201- 10 . Let |prototype| be the result of <a>Get</a> (|paintCtor|, "prototype").
239+ 15 . Let |prototype| be the result of <a>Get</a> (|paintCtor|, "prototype").
202240
203- 11 . If the result of <a>Type</a> (|prototype|) is not Object, <a>throw</a> a <a>TypeError</a> and
241+ 16 . If the result of <a>Type</a> (|prototype|) is not Object, <a>throw</a> a <a>TypeError</a> and
204242 abort all these steps.
205243
206- 12 . Let |paint| be the result of <a>Get</a> (|prototype|, "paint").
244+ 17 . Let |paint| be the result of <a>Get</a> (|prototype|, "paint").
207245
208- 13 . If the result of <a>IsCallable</a> (|paint|) is false, <a>throw</a> a <a>TypeError</a> and
246+ 18 . If the result of <a>IsCallable</a> (|paint|) is false, <a>throw</a> a <a>TypeError</a> and
209247 abort all these steps.
210248
211- 14 . Let |definition| be a new <a>paint image definition</a> with:
249+ 19 . Let |definition| be a new <a>paint definition</a> with:
212250
213251 - <a>class constructor</a> being |paintCtor|.
214252
215253 - <a>paint function</a> being |paint|.
216254
217255 - <a>constructor valid flag</a> being <b> true</b> .
218256
219- - <a>input properties</a> being |inputProperties|.
257+ - <a for="paint definition">input properties</a> being |inputProperties|.
258+
259+ - <a for="paint definition">input argument types</a> being |inputArgumentTypes|.
260+
261+ - <a for="paint definition">context alpha flag</a> being |alpha|.
262+
263+ 20. <a for=map>Set</a> |paintDefinitionMap|[|name|] to |definition|.
264+
265+ 21. <a>Queue a task</a> to run the following steps:
266+
267+ 1. Let |documentPaintDefinitionMap| be the associated <a>document's</a> <a>document paint
268+ definitions</a> <a>map</a> .
269+
270+ 2. Let |documentDefinition| be a new <a>document paint definition</a> with:
271+
272+ - <a for="document paint definition">input properties</a> being |inputProperties|.
220273
221- - <a>context alpha flag</a> being |alpha|.
274+ - <a for="document paint definition">input argument types</a> being
275+ |inputArgumentTypes|.
222276
223- 15. <a for=map>Set </a> |paintImageDefinitionMap| [|name|] to |definition |.
277+ - <a for="document paint definition">context alpha flag </a> being |alpha |.
224278
225- 16. <a>Queue a task </a> to run the following steps:
279+ 3. If |documentPaintDefinitionMap| [|name|] <a for=map>exists </a>, run the following steps:
226280
227- 1. Let |paintInputPropertiesMap | be the associated <a>document </a>'s <a>paint input
228- properties</a> map .
281+ 1. Let |existingDocumentDefinition | be the result of <a for=map>get </a>
282+ |documentPaintDefinitionMap| [|name|] .
229283
230- 2. If |paintInputPropertiesMap| [|name|] <a for=map>exists</a > , run the following steps:
284+ 2. If |existingDocumentDefinition| is <code> "invalid" </code > , abort all these steps.
231285
232- 1. Let |existingInputProperties| be the result of <a>get</a>
233- |paintInputPropertiesMap|[|name|] .
286+ 3. If |existingDocumentDefinition| and |documentDefinition| are not equivalent, (that is
287+ <a for="document paint definition">input properties</a> , <a for="document paint
288+ definition">input argument types</a> , and <a for="document paint definition">context
289+ alpha flag</a> are different), then:
234290
235- 2. If |existingInputProperties| and |inputProperties| are not equivalent, <a
236- for=map> set</a> |paintInputPropertiesMap|[|name|] to <code> "invalid"</code> .
291+ <a for=map>Set</a> |documentPaintDefinitionMap|[|name|] to <code> "invalid"</code> .
237292
238- 3. The user agent <em> should</em> log an error to the debugging console stating that the
239- same class was registered with different <code> inputProperties</code> .
293+ Log an error to the debugging console stating that the same class was registered
294+ with different <code> inputProperties</code> , <code> inputArguments</code> , or
295+ <code> alpha</code> .
240296
241- 3. Otherwise, <a for=map>set</a> |paintInputPropertiesMap|[|name|] to |inputProperties|.
297+ 4. Otherwise, <a for=map>set</a> |documentPaintDefinitionMap|[|name|] to
298+ |documentDefinition|.
242299
243300Note: The list of input properties should only be looked up once, the class doesn't have the
244301 opportunity to dynamically change its input properties.
@@ -365,7 +422,7 @@ When the user agent wants to <dfn>draw a paint image</dfn> of a <<paint()>> func
365422into its appropriate stacking level (as defined by the property the CSS property its associated
366423with), given its |concreteObjectSize| (<a>concrete object size</a> ) it <em> must</em> run the
367424following steps:
368- 1. Let |paintFunction| be the <<paint()>> > function on the |box| which the user agent wants to
425+ 1. Let |paintFunction| be the <<paint()>> function on the |box| which the user agent wants to
369426 draw.
370427
371428 2. If the <a>paint valid flag</a> for the |paintFunction| is <a>paint-valid</a> the user agent
@@ -379,14 +436,14 @@ following steps:
379436
380437 4. Let |name| be the first argument of the |paintFunction|.
381438
382- 5. Let |paintInputPropertiesMap | be the associated <a>document's</a> <a>paint input
383- properties </a> map.
439+ 5. Let |documentPaintDefinitionMap | be the associated <a>document's</a> <a>document paint
440+ definitions </a> map.
384441
385- 6. If |paintInputPropertiesMap |[|name|] does not <a for=map>exist</a> , let the image output be
386- an <a>invalid image</a> and abort all these steps.
442+ 6. If |documentPaintDefinitionMap |[|name|] does not <a for=map>exist</a> , let the image output
443+ be an <a>invalid image</a> and abort all these steps.
387444
388- 7. If the result of <a>get</a> |paintInputPropertiesMap |[|name|] is <code> "invalid"</code> , let
389- the image output be an <a>invalid image</a> and abort all these steps.
445+ 7. If the result of <a>get</a> |documentPaintDefinitionMap |[|name|] is <code> "invalid"</code> ,
446+ let the image output be an <a>invalid image</a> and abort all these steps.
390447
391448 8. Let |workletGlobalScope| be a {{PaintWorkletGlobalScope}} from the list of <a>worklet's
392449 WorkletGlobalScopes</a> from the paint {{Worklet}} .
@@ -407,16 +464,16 @@ following steps:
407464When the user agent wants to <dfn>invoke a paint callback</dfn> given |name|, |concreteObjectSize|,
408465and |workletGlobalScope|, it <em> must</em> run the following steps:
409466
410- 1. Let |paintImageDefinitionMap| be |workletGlobalScope|'s <a>paint image definitions</a> map.
467+ 1. Let |paintImageDefinitionMap| be |workletGlobalScope|'s <a>paint definitions</a> map.
411468
412469 2. If |paintImageDefinitionMap|[|name|] does not <a for=map>exist</a> , run the following steps:
413470
414471 1. <a>Queue a task</a> to run the following steps:
415472
416- 1. Let |paintInputPropertiesMap | be the associated <a>document</a> 's <a>paint input
417- properties </a> map.
473+ 1. Let |documentPaintDefinitionMap | be the associated <a>document</a> 's <a>document
474+ paint definitions </a> map.
418475
419- 2. <a for=map>Set</a> |paintInputPropertiesMap |[|name|] to <code> "invalid"</code> .
476+ 2. <a for=map>Set</a> |documentPaintDefinitionMap |[|name|] to <code> "invalid"</code> .
420477
421478 3. The user agent <em> should</em> log an error to the debugging console stating that a
422479 class wasn't registered in all {{PaintWorkletGlobalScope}} s.
@@ -448,7 +505,7 @@ and |workletGlobalScope|, it <em>must</em> run the following steps:
448505
449506 4. <a for=map>Set</a> |paintClassInstanceMap|[|name|] to |paintInstance|.
450507
451- 6. Let |inputProperties| be |definition|'s <a>input properties</a> .
508+ 6. Let |inputProperties| be |definition|'s <a for="paint definition" >input properties</a> .
452509
453510 7. Let |styleMap| be a new {{StylePropertyMapReadOnly}} populated with <em> only</em> the
454511 <a>computed value</a> 's for properties listed in |inputProperties|.
@@ -457,7 +514,7 @@ and |workletGlobalScope|, it <em>must</em> run the following steps:
457514 given:
458515 - "width" - The width given by |concreteObjectSize|.
459516 - "height" - The height given by |concreteObjectSize|.
460- - "alpha" - The <a>context alpha flag</a> given by |definition|.
517+ - "alpha" - The <a for="paint definition" >context alpha flag</a> given by |definition|.
461518
462519 Note: The |renderingContext| must not be re-used between invocations of paint. Implicitly
463520 this means that there is no stored data, or state on the |renderingContext| between
0 commit comments