Skip to content

Commit 647dbd4

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents aef7af0 + 58703f1 commit 647dbd4

File tree

4 files changed

+92
-28
lines changed

4 files changed

+92
-28
lines changed

README.markdown

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
### [CSS-TAG Houdini Task Force](https://wiki.css-houdini.org/) Specifications
22

3-
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/).
44

55
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.
66

css-paint-api/Overview.bs

+70-25
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ urlPrefix: https://heycam.github.io/webidl/; type: dfn;
2424
url: throw; text: thrown
2525
urlPrefix: https://html.spec.whatwg.org/multipage/scripting.html; type: dfn;
2626
text: reset the rendering context to its default state
27+
text: scratch bitmap
28+
text: set bitmap dimensions
2729
urlPrefix: http://www.ecma-international.org/ecma-262/6.0/#sec-; type: dfn;
2830
text: Construct
2931
text: IsArray
@@ -68,26 +70,26 @@ Registering Custom Paint {#registering-custom-paint}
6870
<pre class='idl'>
6971
callback VoidFunction = void ();
7072

71-
interface PaintWorkletGlobalScope : WorkletGlobalScope {
73+
partial interface RenderWorkletGlobalScope {
7274
void registerPaint(DOMString name, VoidFunction paintCtor);
7375
void unregisterPaint(DOMString name);
7476
};
7577
</pre>
7678

77-
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.
7880

7981
<div class='note'>
8082
Note: This is how the class should look.
8183
<pre class='idl'>
8284
callback interface PaintClass {
8385
readonly attribute sequence&lt;DOMString&gt; inputProperties;
84-
void paint(PaintRenderingContext2d ctx, Geometry geom, StylePropertyMap inputProperties);
86+
void paint(PaintRenderingContext2D ctx, Geometry geom, StylePropertyMap inputProperties);
8587
void overflow(StylePropertyMap inputProperties);
8688
};
8789
</pre>
8890
</div>
8991

90-
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:
9193
1. If the |name| is not a valid <<ident>>, <a>throw</a> a <a>NotSupportedError</a> and abort all these steps.
9294
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.
9395
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>,
98100
8. If the result of <a>IsArray</a>(argument=|inputProperties|) is false, <a>throw</a> a <a>NotSupportedError</a> and abort all these steps.
99101
9. Add the key-value pair (|name| - |inputProperties|) to the <b>paint name to input properties map</b> of the associated <a>document</a>.
100102
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}}.
102104

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

@@ -110,9 +112,9 @@ Note: In a future version of the spec, the author may be able to set an option t
110112

111113
Issue(w3c/css-houdini-drafts#31): Allow author to specify the intrinsic size.
112114

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:
114116
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}}.
116118

117119
Paint Notation {#paint-notation}
118120
================================
@@ -131,22 +133,70 @@ Issue(w3c/css-houdini-drafts#33): What to do about cursor.
131133

132134
Issue: How do we do things like conic-gradient? I.e. paint functions which accept arguments as inputs?
133135

134-
Drawing an image {#drawing-an-image}
135-
====================================
136+
The 2D rendering context {#2d-rendering-context}
137+
================================================
136138

137139
<pre class='idl'>
138-
interface PaintRenderingContext2d {
139-
// TODO link to actual CanvasRenderingContext2d.
140+
[Exposed=Worklet]
141+
interface PaintRenderingContext2D {
140142
};
143+
PaintRenderingContext2D implements CanvasState;
144+
PaintRenderingContext2D implements CanvasTransform;
145+
PaintRenderingContext2D implements CanvasCompositing;
146+
PaintRenderingContext2D implements CanvasImageSmoothing;
147+
PaintRenderingContext2D implements CanvasFillStrokeStyles;
148+
PaintRenderingContext2D implements CanvasShadowStyles;
149+
PaintRenderingContext2D implements CanvasRect;
150+
PaintRenderingContext2D implements CanvasDrawPath;
151+
PaintRenderingContext2D implements CanvasText;
152+
PaintRenderingContext2D implements CanvasDrawImage;
153+
PaintRenderingContext2D implements CanvasPathDrawingStyles;
154+
PaintRenderingContext2D implements CanvasTextDrawingStyles;
155+
PaintRenderingContext2D implements CanvasPath;
156+
</pre>
157+
158+
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}}.
141188

189+
Drawing an image {#drawing-an-image}
190+
====================================
191+
192+
<pre class='idl'>
193+
[Exposed=Worklet]
142194
interface Geometry {
143195
readonly attribute double width;
144196
readonly attribute double height;
145197
};
146198
</pre>
147199

148-
Issue: Create a new interface which uses IDL mixins to share methods with CanvasRenderingContext2d.
149-
150200
If a <<paint()>> function for a fragment is <a>paint-invalid</a> and the fragment is within the visual viewport,
151201
then user agent <em>must</em> <a>draw an image</a> for the current frame.
152202

@@ -169,23 +219,18 @@ When the user agent wants to <dfn>draw an image</dfn> of a <<paint()>> for a <va
169219
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:
170220
- To <a>create a worklet global scope</a> the user agent will:
171221

172-
Return a new {{PaintWorkletGlobalScope}}.
222+
Return a new {{RenderWorkletGlobalScope}}.
173223
- To <a>lookup a class instance on a worklet global scope</a> given a |workletGlobalScope|, the user agent will:
174224

175225
Return the result of looking up |name| on the |workletGlobalScope|'s <b>name to paint instance map</b>.
176226

177227
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).
178228
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.
179229

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|.
189234

190235
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.
191236
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
199244
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:
200245
- To <a>create a worklet global scope</a> the user agent will:
201246

202-
Return a new {{PaintWorkletGlobalScope}}.
247+
Return a new {{RenderWorkletGlobalScope}}.
203248
- To <a>lookup a class instance on a worklet global scope</a> given a |workletGlobalScope|, the user agent will:
204249

205250
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}
234279
-----------------------------------------
235280

236281
<pre class='lang-javascript'>
237-
// Inside PaintWorkletGlobalScope.
282+
// Inside RenderWorkletGlobalScope.
238283
registerPaint('circle', class {
239284
static get inputProperties() { return ['--circle-color']; }
240285
paint(ctx, geom, properties) {

css-typed-om/Overview.bs

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Issue: is it possible to amalgamate this API with value objects once they're spe
4141
<pre class='idl'>
4242
interface StyleValue {
4343
attribute DOMString cssString;
44-
static (StyleValue or sequence&ltStyleValue>)? parse(DOMString property, DOMString cssText);
44+
static (StyleValue or sequence&lt;StyleValue>)? parse(DOMString property, DOMString cssText);
4545
};
4646
</pre>
4747

@@ -355,7 +355,7 @@ Issue: What happens if the provided DOMString or LengthValue for (e.g.) a Simple
355355

356356
<pre class='idl'>
357357
[Constructor(),
358-
Constructor(sequence&lt;TransformComponent>)]
358+
Constructor(sequence&lt;TransformComponent> transforms)]
359359
interface TransformValue : StyleValue {
360360
iterable&lt;TransformComponent>;
361361
Matrix asMatrix();

worklets/Overview.bs

+19
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,25 @@ it must run the following steps:
271271

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

274+
Rendering Worklet {#rendering-worklet}
275+
--------------------------------------
276+
277+
The {{renderWorklet}} attribute allows access to the {{Worklet}} responsible for all the classes
278+
which are related to rendering.
279+
280+
<pre class='idl'>
281+
partial interface Window {
282+
[SameObject] readonly attribute Worklet renderWorklet;
283+
};
284+
</pre>
285+
286+
The {{RenderWorkletGlobalScope}} is the global execution context of the {{renderWorklet}}.
287+
288+
<pre class='idl'>
289+
interface RenderWorkletGlobalScope : WorkletGlobalScope {
290+
};
291+
</pre>
292+
274293
Examples {#examples}
275294
====================
276295

0 commit comments

Comments
 (0)