You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is the repository containing all the CSS/TAG Houdini Task Force specifications.
3
+
This is the repository containing all the [CSS/TAG Houdini Task Force specifications](https://drafts.css-houdini.org/).
4
4
5
5
In addition to this git repository, a Mercurial mirror is maintained at `https://hg.css-houdini.org/drafts`, if for whatever reason you prefer Mercurial.
A{{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.
79
+
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.
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:
92
+
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:
91
93
1. If the |name| is not a valid <<ident>>, <a>throw</a> a <a>NotSupportedError</a> and abort all these steps.
92
94
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.
93
95
3. If the result of <a>IsConstructor</a>(argument=|paintCtor|) is false, <a>throw</a> a <a>NotSupportedError</a> and abort all these steps.
@@ -98,7 +100,7 @@ When the <dfn method for=PaintWorkletGlobalScope>registerPaint(<var>name</var>,
98
100
8. If the result of <a>IsArray</a>(argument=|inputProperties|) is false, <a>throw</a> a <a>NotSupportedError</a> and abort all these steps.
99
101
9. Add the key-value pair (|name| - |inputProperties|) to the <b>paint name to input properties map</b> of the associated <a>document</a>.
100
102
10. Let <var>paintInstance</var> be the result of <a>Construct</a>(|paintCtor|).
101
-
11. Add the key-value pair (|name| - |paintInstance|) to the <b>name to paint instance map</b> of the {{PaintWorkletGlobalScope}}.
103
+
11. Add the key-value pair (|name| - |paintInstance|) to the <b>name to paint instance map</b> of the {{RenderWorkletGlobalScope}}.
102
104
103
105
Note: The list of CSS properties provided by the input properties getter can either be custom or native CSS properties.
104
106
@@ -110,9 +112,9 @@ Note: In a future version of the spec, the author may be able to set an option t
110
112
111
113
Issue(w3c/css-houdini-drafts#31): Allow author to specify the intrinsic size.
112
114
113
-
When the <dfn method for=PaintWorkletGlobalScope>unregisterPaint(<var>name</var>)</dfn> method is called, the user agent <em>must</em> run the following steps:
115
+
When the <dfn method for=RenderWorkletGlobalScope>unregisterPaint(<var>name</var>)</dfn> method is called, the user agent <em>must</em> run the following steps:
114
116
1. Remove the key-value pair associated with the |name| key in the <b>paint name to input properties map</b> of the associated <a>document</a>.
115
-
2. Remove the key-value pair associated with the |name| key in the <b>name to paint instance map</b> of the {{PaintWorkletGlobalScope}}.
117
+
2. Remove the key-value pair associated with the |name| key in the <b>name to paint instance map</b> of the {{RenderWorkletGlobalScope}}.
116
118
117
119
Paint Notation {#paint-notation}
118
120
================================
@@ -131,22 +133,70 @@ Issue(w3c/css-houdini-drafts#33): What to do about cursor.
131
133
132
134
Issue: How do we do things like conic-gradient? I.e. paint functions which accept arguments as inputs?
Note: The {{PaintRenderingContext2D}} implements a subset of the {{CanvasRenderingContext2D}} API.
159
+
Specifically it doesn't implement the {{CanvasHitRegion}}, {{CanvasImageData}} or
160
+
{{CanvasUserInterface}} APIs.
161
+
162
+
A {{PaintRenderingContext2D}} object has a <a>scratch bitmap</a>. This is initialised when the
163
+
object is created. The size of the <a>scratch bitmap</a> is the size of the fragment it is rendering
164
+
plus the size specified by the overflow method.
165
+
166
+
The logical origin (0,0) is not necessarily placed at the origin of the <a>scratch bitmap</a>. If
167
+
the fragment which is being painted has an associated overflow, the logical origin is placed at
168
+
(overflow-left,overflow-top) of the <a>scratch bitmap</a>.
169
+
170
+
Issue: Add image explaining origin vs. logical origin.
171
+
172
+
The size of the <a>scratch bitmap</a> does not necessarily represent the size of the actual bitmap
173
+
that the user agent will use internally or during rendering. For example, if the visual viewport is
174
+
zoomed the user agent may internally use bitmaps which correspond to the number of device pixels in
175
+
the coordinate space, so that the resulting rendering is of high quality.
176
+
177
+
Additionally the user agent may record the sequence of drawing operations which have been applied to
178
+
the <a>scratch bitmap</a> such that the user agent can subsequently draw onto a device bitmap at the
179
+
correct resolution. This also allows user agents to re-use the same output of the <a>scratch
180
+
bitmap</a> repeatably while the visual viewport is being zoomed for example.
181
+
182
+
When the user agent is to <dfn>create a {{PaintRenderingContext2D}} object</dfn> for a given
183
+
|width|, |height| and |overflowOffset| it <em>must</em> run the following steps:
184
+
1. Create a new {{PaintRenderingContext2D}}.
185
+
2. <a>Set bitmap dimensions</a> for the context's <a>scratch bitmap</a> to |width| and |height|.
186
+
3. Set the logical origin of the <a>scratch bitmap</a> to |overflowOffset|.
187
+
4. Return the new {{PaintRenderingContext2D}}.
141
188
189
+
Drawing an image {#drawing-an-image}
190
+
====================================
191
+
192
+
<pre class='idl'>
193
+
[Exposed=Worklet]
142
194
interface Geometry {
143
195
readonly attribute double width;
144
196
readonly attribute double height;
145
197
};
146
198
</pre>
147
199
148
-
Issue: Create a new interface which uses IDL mixins to share methods with CanvasRenderingContext2d.
149
-
150
200
If a <<paint()>> function for a fragment is <a>paint-invalid</a> and the fragment is within the visual viewport,
151
201
then user agent <em>must</em><a>draw an image</a> for the current frame.
152
202
@@ -169,23 +219,18 @@ When the user agent wants to <dfn>draw an image</dfn> of a <<paint()>> for a <va
169
219
6. Let <var>overflow</var> be the result <a>invoke a method on a class inside a Worklet</a> given "overflow" as the <em>methodPropertyKey</em> and [|styleMap|] as the <em>arguments</em> with the following options:
170
220
- To <a>create a worklet global scope</a> the user agent will:
171
221
172
-
Return a new {{PaintWorkletGlobalScope}}.
222
+
Return a new {{RenderWorkletGlobalScope}}.
173
223
- To <a>lookup a class instance on a worklet global scope</a> given a |workletGlobalScope|, the user agent will:
174
224
175
225
Return the result of looking up |name| on the |workletGlobalScope|'s <b>name to paint instance map</b>.
176
226
177
227
Note: User agents may have to compute overflow before entering their paint phase in order to determine which fragments to paint (overflow changes what could be seen on the output device).
178
228
User agents may opt into running the steps up to this point, to determine overflow, then continuing later to determine the drawn image for the fragments which need painting.
179
229
180
-
7. Let <var>renderingContext</var> be a new {{PaintRenderingContext2d}}.
181
-
182
-
The backing size of the |renderingContext| must be the size of the |fragment| plus the size specified by |overflow|.
183
-
184
-
The user agent must ensure to <a>reset the rendering context to its default state</a>.
185
-
186
-
The origin of the |renderingContext| must be offset by the left, top size specified by |overflow|.
187
-
188
-
Note: (0,0) is the top-left of the |fragment|, (-offsetLeft,-offsetTop) is the top-left of the |overflow|.
230
+
7. Let <var>renderingContext</var> be the result of <a>create a {{PaintRenderingContext2D}} object</a> given:
231
+
- "overflowOffset" - The logical offset for the <a>scratch bitmap</a> specified by |overflow|.
232
+
- "width" - The width of the |fragment| plus the additional width specified by |overflow|.
233
+
- "height" - The height of the |fragment| plus the additional height specified by |overflow|.
189
234
190
235
Note: The |renderingContext| must not be re-used between invocations of paint. Implicitly this means that there is no stored data, or state on the |renderingContext| between invocations.
191
236
For example you can't setup a clip on the context, and expect the same clip to be applied next time the paint method is called.
@@ -199,7 +244,7 @@ When the user agent wants to <dfn>draw an image</dfn> of a <<paint()>> for a <va
199
244
9. 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:
200
245
- To <a>create a worklet global scope</a> the user agent will:
201
246
202
-
Return a new {{PaintWorkletGlobalScope}}.
247
+
Return a new {{RenderWorkletGlobalScope}}.
203
248
- To <a>lookup a class instance on a worklet global scope</a> given a |workletGlobalScope|, the user agent will:
204
249
205
250
Return the result of looking up |name| on the |workletGlobalScope|'s <b>name to paint instance map</b>.
@@ -234,7 +279,7 @@ Example 1: A colored circle. {#example-1}
234
279
-----------------------------------------
235
280
236
281
<pre class='lang-javascript'>
237
-
// Inside PaintWorkletGlobalScope.
282
+
// Inside RenderWorkletGlobalScope.
238
283
registerPaint('circle', class {
239
284
static get inputProperties() { return ['--circle-color']; }
0 commit comments