forked from go-rod/rod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
layer_tree.go
353 lines (252 loc) · 11 KB
/
layer_tree.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
// This file is generated by "./lib/proto/generate"
package proto
import (
"github.com/ysmood/gson"
)
/*
LayerTree
*/
// LayerTreeLayerID Unique Layer identifier.
type LayerTreeLayerID string
// LayerTreeSnapshotID Unique snapshot identifier.
type LayerTreeSnapshotID string
// LayerTreeScrollRectType enum
type LayerTreeScrollRectType string
const (
// LayerTreeScrollRectTypeRepaintsOnScroll enum const
LayerTreeScrollRectTypeRepaintsOnScroll LayerTreeScrollRectType = "RepaintsOnScroll"
// LayerTreeScrollRectTypeTouchEventHandler enum const
LayerTreeScrollRectTypeTouchEventHandler LayerTreeScrollRectType = "TouchEventHandler"
// LayerTreeScrollRectTypeWheelEventHandler enum const
LayerTreeScrollRectTypeWheelEventHandler LayerTreeScrollRectType = "WheelEventHandler"
)
// LayerTreeScrollRect Rectangle where scrolling happens on the main thread.
type LayerTreeScrollRect struct {
// Rect Rectangle itself.
Rect *DOMRect `json:"rect"`
// Type Reason for rectangle to force scrolling on the main thread
Type LayerTreeScrollRectType `json:"type"`
}
// LayerTreeStickyPositionConstraint Sticky position constraints.
type LayerTreeStickyPositionConstraint struct {
// StickyBoxRect Layout rectangle of the sticky element before being shifted
StickyBoxRect *DOMRect `json:"stickyBoxRect"`
// ContainingBlockRect Layout rectangle of the containing block of the sticky element
ContainingBlockRect *DOMRect `json:"containingBlockRect"`
// NearestLayerShiftingStickyBox (optional) The nearest sticky layer that shifts the sticky box
NearestLayerShiftingStickyBox LayerTreeLayerID `json:"nearestLayerShiftingStickyBox,omitempty"`
// NearestLayerShiftingContainingBlock (optional) The nearest sticky layer that shifts the containing block
NearestLayerShiftingContainingBlock LayerTreeLayerID `json:"nearestLayerShiftingContainingBlock,omitempty"`
}
// LayerTreePictureTile Serialized fragment of layer picture along with its offset within the layer.
type LayerTreePictureTile struct {
// X Offset from owning layer left boundary
X float64 `json:"x"`
// Y Offset from owning layer top boundary
Y float64 `json:"y"`
// Picture Base64-encoded snapshot data.
Picture []byte `json:"picture"`
}
// LayerTreeLayer Information about a compositing layer.
type LayerTreeLayer struct {
// LayerID The unique id for this layer.
LayerID LayerTreeLayerID `json:"layerId"`
// ParentLayerID (optional) The id of parent (not present for root).
ParentLayerID LayerTreeLayerID `json:"parentLayerId,omitempty"`
// BackendNodeID (optional) The backend id for the node associated with this layer.
BackendNodeID DOMBackendNodeID `json:"backendNodeId,omitempty"`
// OffsetX Offset from parent layer, X coordinate.
OffsetX float64 `json:"offsetX"`
// OffsetY Offset from parent layer, Y coordinate.
OffsetY float64 `json:"offsetY"`
// Width Layer width.
Width float64 `json:"width"`
// Height Layer height.
Height float64 `json:"height"`
// Transform (optional) Transformation matrix for layer, default is identity matrix
Transform []float64 `json:"transform,omitempty"`
// AnchorX (optional) Transform anchor point X, absent if no transform specified
AnchorX *float64 `json:"anchorX,omitempty"`
// AnchorY (optional) Transform anchor point Y, absent if no transform specified
AnchorY *float64 `json:"anchorY,omitempty"`
// AnchorZ (optional) Transform anchor point Z, absent if no transform specified
AnchorZ *float64 `json:"anchorZ,omitempty"`
// PaintCount Indicates how many time this layer has painted.
PaintCount int `json:"paintCount"`
// DrawsContent Indicates whether this layer hosts any content, rather than being used for
// transform/scrolling purposes only.
DrawsContent bool `json:"drawsContent"`
// Invisible (optional) Set if layer is not visible.
Invisible bool `json:"invisible,omitempty"`
// ScrollRects (optional) Rectangles scrolling on main thread only.
ScrollRects []*LayerTreeScrollRect `json:"scrollRects,omitempty"`
// StickyPositionConstraint (optional) Sticky position constraint information
StickyPositionConstraint *LayerTreeStickyPositionConstraint `json:"stickyPositionConstraint,omitempty"`
}
// LayerTreePaintProfile Array of timings, one per paint step.
type LayerTreePaintProfile []float64
// LayerTreeCompositingReasons Provides the reasons why the given layer was composited.
type LayerTreeCompositingReasons struct {
// LayerID The id of the layer for which we want to get the reasons it was composited.
LayerID LayerTreeLayerID `json:"layerId"`
}
// ProtoReq name
func (m LayerTreeCompositingReasons) ProtoReq() string { return "LayerTree.compositingReasons" }
// Call the request
func (m LayerTreeCompositingReasons) Call(c Client) (*LayerTreeCompositingReasonsResult, error) {
var res LayerTreeCompositingReasonsResult
return &res, call(m.ProtoReq(), m, &res, c)
}
// LayerTreeCompositingReasonsResult ...
type LayerTreeCompositingReasonsResult struct {
// CompositingReasons (deprecated) A list of strings specifying reasons for the given layer to become composited.
CompositingReasons []string `json:"compositingReasons"`
// CompositingReasonIds A list of strings specifying reason IDs for the given layer to become composited.
CompositingReasonIds []string `json:"compositingReasonIds"`
}
// LayerTreeDisable Disables compositing tree inspection.
type LayerTreeDisable struct {
}
// ProtoReq name
func (m LayerTreeDisable) ProtoReq() string { return "LayerTree.disable" }
// Call sends the request
func (m LayerTreeDisable) Call(c Client) error {
return call(m.ProtoReq(), m, nil, c)
}
// LayerTreeEnable Enables compositing tree inspection.
type LayerTreeEnable struct {
}
// ProtoReq name
func (m LayerTreeEnable) ProtoReq() string { return "LayerTree.enable" }
// Call sends the request
func (m LayerTreeEnable) Call(c Client) error {
return call(m.ProtoReq(), m, nil, c)
}
// LayerTreeLoadSnapshot Returns the snapshot identifier.
type LayerTreeLoadSnapshot struct {
// Tiles An array of tiles composing the snapshot.
Tiles []*LayerTreePictureTile `json:"tiles"`
}
// ProtoReq name
func (m LayerTreeLoadSnapshot) ProtoReq() string { return "LayerTree.loadSnapshot" }
// Call the request
func (m LayerTreeLoadSnapshot) Call(c Client) (*LayerTreeLoadSnapshotResult, error) {
var res LayerTreeLoadSnapshotResult
return &res, call(m.ProtoReq(), m, &res, c)
}
// LayerTreeLoadSnapshotResult ...
type LayerTreeLoadSnapshotResult struct {
// SnapshotID The id of the snapshot.
SnapshotID LayerTreeSnapshotID `json:"snapshotId"`
}
// LayerTreeMakeSnapshot Returns the layer snapshot identifier.
type LayerTreeMakeSnapshot struct {
// LayerID The id of the layer.
LayerID LayerTreeLayerID `json:"layerId"`
}
// ProtoReq name
func (m LayerTreeMakeSnapshot) ProtoReq() string { return "LayerTree.makeSnapshot" }
// Call the request
func (m LayerTreeMakeSnapshot) Call(c Client) (*LayerTreeMakeSnapshotResult, error) {
var res LayerTreeMakeSnapshotResult
return &res, call(m.ProtoReq(), m, &res, c)
}
// LayerTreeMakeSnapshotResult ...
type LayerTreeMakeSnapshotResult struct {
// SnapshotID The id of the layer snapshot.
SnapshotID LayerTreeSnapshotID `json:"snapshotId"`
}
// LayerTreeProfileSnapshot ...
type LayerTreeProfileSnapshot struct {
// SnapshotID The id of the layer snapshot.
SnapshotID LayerTreeSnapshotID `json:"snapshotId"`
// MinRepeatCount (optional) The maximum number of times to replay the snapshot (1, if not specified).
MinRepeatCount *int `json:"minRepeatCount,omitempty"`
// MinDuration (optional) The minimum duration (in seconds) to replay the snapshot.
MinDuration *float64 `json:"minDuration,omitempty"`
// ClipRect (optional) The clip rectangle to apply when replaying the snapshot.
ClipRect *DOMRect `json:"clipRect,omitempty"`
}
// ProtoReq name
func (m LayerTreeProfileSnapshot) ProtoReq() string { return "LayerTree.profileSnapshot" }
// Call the request
func (m LayerTreeProfileSnapshot) Call(c Client) (*LayerTreeProfileSnapshotResult, error) {
var res LayerTreeProfileSnapshotResult
return &res, call(m.ProtoReq(), m, &res, c)
}
// LayerTreeProfileSnapshotResult ...
type LayerTreeProfileSnapshotResult struct {
// Timings The array of paint profiles, one per run.
Timings []LayerTreePaintProfile `json:"timings"`
}
// LayerTreeReleaseSnapshot Releases layer snapshot captured by the back-end.
type LayerTreeReleaseSnapshot struct {
// SnapshotID The id of the layer snapshot.
SnapshotID LayerTreeSnapshotID `json:"snapshotId"`
}
// ProtoReq name
func (m LayerTreeReleaseSnapshot) ProtoReq() string { return "LayerTree.releaseSnapshot" }
// Call sends the request
func (m LayerTreeReleaseSnapshot) Call(c Client) error {
return call(m.ProtoReq(), m, nil, c)
}
// LayerTreeReplaySnapshot Replays the layer snapshot and returns the resulting bitmap.
type LayerTreeReplaySnapshot struct {
// SnapshotID The id of the layer snapshot.
SnapshotID LayerTreeSnapshotID `json:"snapshotId"`
// FromStep (optional) The first step to replay from (replay from the very start if not specified).
FromStep *int `json:"fromStep,omitempty"`
// ToStep (optional) The last step to replay to (replay till the end if not specified).
ToStep *int `json:"toStep,omitempty"`
// Scale (optional) The scale to apply while replaying (defaults to 1).
Scale *float64 `json:"scale,omitempty"`
}
// ProtoReq name
func (m LayerTreeReplaySnapshot) ProtoReq() string { return "LayerTree.replaySnapshot" }
// Call the request
func (m LayerTreeReplaySnapshot) Call(c Client) (*LayerTreeReplaySnapshotResult, error) {
var res LayerTreeReplaySnapshotResult
return &res, call(m.ProtoReq(), m, &res, c)
}
// LayerTreeReplaySnapshotResult ...
type LayerTreeReplaySnapshotResult struct {
// DataURL A data: URL for resulting image.
DataURL string `json:"dataURL"`
}
// LayerTreeSnapshotCommandLog Replays the layer snapshot and returns canvas log.
type LayerTreeSnapshotCommandLog struct {
// SnapshotID The id of the layer snapshot.
SnapshotID LayerTreeSnapshotID `json:"snapshotId"`
}
// ProtoReq name
func (m LayerTreeSnapshotCommandLog) ProtoReq() string { return "LayerTree.snapshotCommandLog" }
// Call the request
func (m LayerTreeSnapshotCommandLog) Call(c Client) (*LayerTreeSnapshotCommandLogResult, error) {
var res LayerTreeSnapshotCommandLogResult
return &res, call(m.ProtoReq(), m, &res, c)
}
// LayerTreeSnapshotCommandLogResult ...
type LayerTreeSnapshotCommandLogResult struct {
// CommandLog The array of canvas function calls.
CommandLog []map[string]gson.JSON `json:"commandLog"`
}
// LayerTreeLayerPainted ...
type LayerTreeLayerPainted struct {
// LayerID The id of the painted layer.
LayerID LayerTreeLayerID `json:"layerId"`
// Clip Clip rectangle.
Clip *DOMRect `json:"clip"`
}
// ProtoEvent name
func (evt LayerTreeLayerPainted) ProtoEvent() string {
return "LayerTree.layerPainted"
}
// LayerTreeLayerTreeDidChange ...
type LayerTreeLayerTreeDidChange struct {
// Layers (optional) Layer tree, absent if not in the comspositing mode.
Layers []*LayerTreeLayer `json:"layers,omitempty"`
}
// ProtoEvent name
func (evt LayerTreeLayerTreeDidChange) ProtoEvent() string {
return "LayerTree.layerTreeDidChange"
}