@@ -14,6 +14,7 @@ Editor: Dean Jackson, dino@apple.com
14
14
15
15
<pre class="link-defaults">
16
16
spec:css-break-3; type:dfn; text:fragment
17
+ spec:css-ui-3; type:property; text:cursor
17
18
</pre>
18
19
19
20
<pre class="anchors">
@@ -50,6 +51,8 @@ urlPrefix: https://infra.spec.whatwg.org/#; type: dfn;
50
51
urlPrefix: map-
51
52
url: exists; text: exist
52
53
url: set; text: set
54
+ urlPrefix: list-
55
+ url: iterate; text: for each
53
56
</pre>
54
57
55
58
Introduction {#intro}
@@ -70,6 +73,9 @@ Paint Invalidation {#paint-invalidation}
70
73
A <a>document</a> has a <a>map</a> of <dfn>paint input properties</dfn> . Initially it is empty and
71
74
is populated when {{registerPaint(name, paintCtor)}} is called.
72
75
76
+ A <a>document</a> has a <a>map</a> of <dfn>paint input argument types</dfn> . Initially it is empty
77
+ and is populated when {{registerPaint(name, paintCtor)}} is called.
78
+
73
79
Each <<paint()>> function for a box has an associated <dfn>paint valid flag</dfn> . It may be either
74
80
<dfn>paint-valid</dfn> or <dfn>paint-invalid</dfn> . It is initially set to <a>paint-invalid</a> .
75
81
@@ -124,8 +130,9 @@ interface PaintWorkletGlobalScope : WorkletGlobalScope {
124
130
Note: The shape of the class should be:
125
131
<pre class='lang-javascript'>
126
132
class MyPaint {
127
- static get inputProperties() { return ['--foo'] ; }
128
133
static get alpha() { return true; }
134
+ static get inputArguments() { return ['<color>'] ; }
135
+ static get inputProperties() { return ['--foo'] ; }
129
136
paint(ctx, size, styleMap) {
130
137
// Paint code goes here.
131
138
}
@@ -143,12 +150,14 @@ the <<paint()>> function. It consists of:
143
150
144
151
- A <dfn>paint class constructor</dfn> which is the class <a>constructor</a> .
145
152
146
- - A <dfn>paint function</dfn> which is the paint <a>function</a> callback.
153
+ - A <dfn>paint function callback </dfn> which is the paint <a>function</a> callback.
147
154
148
155
- A <dfn>paint constructor valid flag</dfn> .
149
156
150
157
- A <dfn>paint input property list</dfn> .
151
158
159
+ - A <dfn>paint input argument types</dfn> <a>list</a> .
160
+
152
161
- A <dfn>paint context alpha flag</dfn> .
153
162
154
163
Registering Custom Paint {#registering-custom-paint}
@@ -191,49 +200,74 @@ called, the user agent <em>must</em> run the following steps:
191
200
also contains currently invalid properties for the user agent. For example
192
201
<code> margin-bikeshed-property</code> .
193
202
194
- 7. Let |alphaValue| be the result of <a>Get</a> (|paintCtor|, "alpha").
203
+ 7. Let |inputArguments| be an empty <code> sequence<DOMString></code> .
204
+
205
+ 8. Let |inputArgumentsIterable| be the result of <a>Get</a> (|paintCtor|, "inputArguments").
206
+
207
+ 9. If |inputArgumentsIterable| is not undefined, then set |inputArguments| to the result of
208
+ <a>converting</a> |inputArgumentsIterable| to a <code> sequence<DOMString></code> . If an
209
+ execption is thrown, rethrow the execption and abort all these steps.
195
210
196
- 8. Let |alpha| be <code> true</code> if |alphaValue| is undefined, otherwise let it be the result
211
+ 10. Let |inputArgumentTypes| be an empty <a>list</a> .
212
+
213
+ 11. <a>For each</a> |item| in |inputArguments| perform the following substeps:
214
+
215
+ 1. Let |parsedItem| be the result of parsing |item| according to the rules in
216
+ [[css-properties-values-api-1#supported-syntax-strings]] . If it fails to parse
217
+ <a>throw</a> a <a>TypeError</a> and abort all these steps.
218
+
219
+ 2. <a>Append</a> |parsedItem| to |inputArgumentTypes|.
220
+
221
+ 12. Let |alphaValue| be the result of <a>Get</a> (|paintCtor|, "alpha").
222
+
223
+ 13. Let |alpha| be <code> true</code> if |alphaValue| is undefined, otherwise let it be the result
197
224
of <a>converting</a> |alphaValue| to a <a>boolean</a> . If an exception is thrown, rethrow
198
225
the exception and abort all these steps.
199
226
200
227
Note: Setting <code> alpha</code> is <code> false</code> allows user agents to anti-alias text
201
228
an addition to performing "visibility" optimizations, e.g. not painting an image behind
202
229
the paint image as the paint image is opaque.
203
230
204
- 9 . If the result of <a>IsConstructor</a> (|paintCtor|) is false, <a>throw</a> a <a>TypeError</a>
231
+ 14 . If the result of <a>IsConstructor</a> (|paintCtor|) is false, <a>throw</a> a <a>TypeError</a>
205
232
and abort all these steps.
206
233
207
- 10 . Let |prototype| be the result of <a>Get</a> (|paintCtor|, "prototype").
234
+ 15 . Let |prototype| be the result of <a>Get</a> (|paintCtor|, "prototype").
208
235
209
- 11 . If the result of <a>Type</a> (|prototype|) is not Object, <a>throw</a> a <a>TypeError</a> and
236
+ 16 . If the result of <a>Type</a> (|prototype|) is not Object, <a>throw</a> a <a>TypeError</a> and
210
237
abort all these steps.
211
238
212
- 12 . Let |paint| be the result of <a>Get</a> (|prototype|, "paint").
239
+ 17 . Let |paint| be the result of <a>Get</a> (|prototype|, "paint").
213
240
214
- 13 . If the result of <a>IsCallable</a> (|paint|) is false, <a>throw</a> a <a>TypeError</a> and
241
+ 18 . If the result of <a>IsCallable</a> (|paint|) is false, <a>throw</a> a <a>TypeError</a> and
215
242
abort all these steps.
216
243
217
- 14 . Let |definition| be a new <a>paint image definition</a> with:
244
+ 19 . Let |definition| be a new <a>paint image definition</a> with:
218
245
219
246
- <a>paint image name</a> being |name|
220
247
221
248
- <a>paint class constructor</a> being |paintCtor|
222
249
223
- - <a>paint function</a> being |paint|
250
+ - <a>paint function callback </a> being |paint|
224
251
225
252
- <a>paint constructor valid flag</a> being true
226
253
227
254
- <a>paint input property list</a> being |inputProperties|.
228
255
256
+ - <a>paint input argument types</a> being |inputArgumentTypes|.
257
+
229
258
- <a>paint context alpha flag</a> being |alpha|.
230
259
231
- 15 . <a>Set</a> |paintImageDefinitionMap|[|name|] to |definition|.
260
+ 20 . <a>Set</a> |paintImageDefinitionMap|[|name|] to |definition|.
232
261
233
- 16 . Let |paintInputPropertiesMap| be the associated <a>document</a> 's <a>paint input
262
+ 21 . Let |paintInputPropertiesMap| be the associated <a>document</a> 's <a>paint input
234
263
properties</a> map.
235
264
236
- 17. <a>Set</a> |paintInputPropertiesMap|[|name|] to |inputProperties|.
265
+ 22. <a>Set</a> |paintInputPropertiesMap|[|name|] to |inputProperties|.
266
+
267
+ 23. Let |paintInputArgumentsMap| be the associated <a>document</a> 's <a>paint input argument
268
+ types</a> map.
269
+
270
+ 24. <a>Set</a> |paintInputArgumentsMap|[|name|] to |inputArgumentTypes|.
237
271
238
272
Note: The list of input properties should only be looked up once, the class doesn't have the
239
273
opportunity to dynamically change its input properties.
@@ -247,23 +281,32 @@ Paint Notation {#paint-notation}
247
281
================================
248
282
249
283
<pre class='prod'>
250
- <dfn>paint()</dfn> = paint( <<ident>> )
284
+ <dfn>paint()</dfn> = paint( <<ident>> [, <<custom-value>> ]* )
251
285
</pre>
252
286
253
287
The <<paint()>> function is an additional notation to be supported by the <<image>> type.
254
288
255
289
<div class="example">
256
290
<pre> background-image: paint(my_logo);</pre>
291
+ <pre> border-image: paint(gradient, 100);</pre>
257
292
</div>
258
293
294
+ <<custom-value>> is the set of types listed in
295
+ [[css-properties-values-api-1#supported-syntax-strings]] .
296
+
297
+ When computing the <a>declared value</a> of the <<paint()>> function the user agent must lookup the
298
+ <a>document</a> 's <a>paint input argument types</a> map and validate that the syntax of the
299
+ <<paint()>> function matches the syntax described by the author. If it doesn't the user agent should
300
+ treat it as an invalid property value.
301
+
302
+ When the <a>current global object's</a> associated <a>document</a> 's <a>paint input argument
303
+ types</a> map changes a previously syntactically invalid property values can become valid and vice
304
+ versa. This can change the set of <a>declared values</a> which requires the <a>cascade</a> to be
305
+ recomputed.
306
+
259
307
For the 'cursor' property, the <<paint()>> function should be treated as an <a>invalid image</a> and
260
308
fallback to the next supported <<image>> .
261
309
262
- Issue(w3c/css-houdini-drafts#100): Support additional arbitrary arguments for the paint function.
263
- This is difficult to specify, as you need to define a sane grammar. A better way would be to
264
- expose a token stream which you can parse into Typed OM objects. This would allow a full
265
- arbitrary set of function arguments, and be future proof.
266
-
267
310
The 2D rendering context {#2d-rendering-context}
268
311
================================================
269
312
@@ -430,16 +473,31 @@ following steps:
430
473
12. Let |paintSize| be a new {{PaintSize}} initialized to the width and height defined by
431
474
|concreteObjectSize|.
432
475
433
- 13. Let |paintFunctionCallback| be |definition|'s <a>paint function</a> .
476
+ 13. Let |inputArgumentTypes| be |definition|'s <a>paint input argument types</a> .
477
+
478
+ 14. Let |inputArguments| be an empty <a>list</a> .
479
+
480
+ 15. For each argument of the |paintFunction| after the "paint name" argument run the
481
+ [[css-typed-om-1#stylevalue-normalization]] to construct the appropriate {{CSSStyleValue}} .
482
+
483
+ The syntax to use is given by the parsed syntax object in the corresponding position of the
484
+ |inputArgumentTypes| list.
485
+
486
+ The resulting {{CSSStyleValue}} should be appended to the |inputArguments| array.
487
+
488
+ Note: This step should succeed as an invalid argument should have been rejected when
489
+ computing the <a>declared value</a> of the |paintFunction|.
490
+
491
+ 16. Let |paintFunctionCallback| be |definition|'s <a>paint function callback</a> .
434
492
435
- 14 . <a>Invoke</a> |paintFunctionCallback| with arguments «|renderingContext|, |paintSize|,
436
- |styleMap|», and with |paintInstance| as the <a>callback this value</a> .
493
+ 17 . <a>Invoke</a> |paintFunctionCallback| with arguments «|renderingContext|, |paintSize|,
494
+ |styleMap|, |arguments| », and with |paintInstance| as the <a>callback this value</a> .
437
495
438
- 15 . The image output is to be produced from the |renderingContext| given to the method.
496
+ 18 . The image output is to be produced from the |renderingContext| given to the method.
439
497
440
498
If an exception is <a>thrown</a> the let the image output be an <a>invalid image</a> .
441
499
442
- 16 . Set the <a>paint valid flag</a> for the |paintFunction| to <a>paint-valid</a> .
500
+ 19 . Set the <a>paint valid flag</a> for the |paintFunction| to <a>paint-valid</a> .
443
501
444
502
Note: The user agent <em> should</em> consider long running paint functions similar to long running
445
503
script in the main execution context. For example, they <em> should</em> show a "unresponsive
0 commit comments