forked from chromedp/chromedp
/
overlay.go
449 lines (385 loc) · 15.5 KB
/
overlay.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
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
// Package overlay provides the Chrome Debugging Protocol
// commands, types, and events for the Overlay domain.
//
// This domain provides various functionality related to drawing atop the
// inspected page.
//
// Generated by the chromedp-gen command.
package overlay
// AUTOGENERATED. DO NOT EDIT.
import (
"context"
cdp "github.com/knq/chromedp/cdp"
"github.com/knq/chromedp/cdp/dom"
"github.com/knq/chromedp/cdp/runtime"
"github.com/mailru/easyjson"
)
// EnableParams enables domain notifications.
type EnableParams struct{}
// Enable enables domain notifications.
func Enable() *EnableParams {
return &EnableParams{}
}
// Do executes Overlay.enable against the provided context and
// target handler.
func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
return h.Execute(ctxt, cdp.CommandOverlayEnable, nil, nil)
}
// DisableParams disables domain notifications.
type DisableParams struct{}
// Disable disables domain notifications.
func Disable() *DisableParams {
return &DisableParams{}
}
// Do executes Overlay.disable against the provided context and
// target handler.
func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
return h.Execute(ctxt, cdp.CommandOverlayDisable, nil, nil)
}
// SetShowPaintRectsParams requests that backend shows paint rectangles.
type SetShowPaintRectsParams struct {
Result bool `json:"result"` // True for showing paint rectangles
}
// SetShowPaintRects requests that backend shows paint rectangles.
//
// parameters:
// result - True for showing paint rectangles
func SetShowPaintRects(result bool) *SetShowPaintRectsParams {
return &SetShowPaintRectsParams{
Result: result,
}
}
// Do executes Overlay.setShowPaintRects against the provided context and
// target handler.
func (p *SetShowPaintRectsParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
return h.Execute(ctxt, cdp.CommandOverlaySetShowPaintRects, p, nil)
}
// SetShowDebugBordersParams requests that backend shows debug borders on
// layers.
type SetShowDebugBordersParams struct {
Show bool `json:"show"` // True for showing debug borders
}
// SetShowDebugBorders requests that backend shows debug borders on layers.
//
// parameters:
// show - True for showing debug borders
func SetShowDebugBorders(show bool) *SetShowDebugBordersParams {
return &SetShowDebugBordersParams{
Show: show,
}
}
// Do executes Overlay.setShowDebugBorders against the provided context and
// target handler.
func (p *SetShowDebugBordersParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
return h.Execute(ctxt, cdp.CommandOverlaySetShowDebugBorders, p, nil)
}
// SetShowFPSCounterParams requests that backend shows the FPS counter.
type SetShowFPSCounterParams struct {
Show bool `json:"show"` // True for showing the FPS counter
}
// SetShowFPSCounter requests that backend shows the FPS counter.
//
// parameters:
// show - True for showing the FPS counter
func SetShowFPSCounter(show bool) *SetShowFPSCounterParams {
return &SetShowFPSCounterParams{
Show: show,
}
}
// Do executes Overlay.setShowFPSCounter against the provided context and
// target handler.
func (p *SetShowFPSCounterParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
return h.Execute(ctxt, cdp.CommandOverlaySetShowFPSCounter, p, nil)
}
// SetShowScrollBottleneckRectsParams requests that backend shows scroll
// bottleneck rects.
type SetShowScrollBottleneckRectsParams struct {
Show bool `json:"show"` // True for showing scroll bottleneck rects
}
// SetShowScrollBottleneckRects requests that backend shows scroll bottleneck
// rects.
//
// parameters:
// show - True for showing scroll bottleneck rects
func SetShowScrollBottleneckRects(show bool) *SetShowScrollBottleneckRectsParams {
return &SetShowScrollBottleneckRectsParams{
Show: show,
}
}
// Do executes Overlay.setShowScrollBottleneckRects against the provided context and
// target handler.
func (p *SetShowScrollBottleneckRectsParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
return h.Execute(ctxt, cdp.CommandOverlaySetShowScrollBottleneckRects, p, nil)
}
// SetShowViewportSizeOnResizeParams paints viewport size upon main frame
// resize.
type SetShowViewportSizeOnResizeParams struct {
Show bool `json:"show"` // Whether to paint size or not.
}
// SetShowViewportSizeOnResize paints viewport size upon main frame resize.
//
// parameters:
// show - Whether to paint size or not.
func SetShowViewportSizeOnResize(show bool) *SetShowViewportSizeOnResizeParams {
return &SetShowViewportSizeOnResizeParams{
Show: show,
}
}
// Do executes Overlay.setShowViewportSizeOnResize against the provided context and
// target handler.
func (p *SetShowViewportSizeOnResizeParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
return h.Execute(ctxt, cdp.CommandOverlaySetShowViewportSizeOnResize, p, nil)
}
// SetPausedInDebuggerMessageParams [no description].
type SetPausedInDebuggerMessageParams struct {
Message string `json:"message,omitempty"` // The message to display, also triggers resume and step over controls.
}
// SetPausedInDebuggerMessage [no description].
//
// parameters:
func SetPausedInDebuggerMessage() *SetPausedInDebuggerMessageParams {
return &SetPausedInDebuggerMessageParams{}
}
// WithMessage the message to display, also triggers resume and step over
// controls.
func (p SetPausedInDebuggerMessageParams) WithMessage(message string) *SetPausedInDebuggerMessageParams {
p.Message = message
return &p
}
// Do executes Overlay.setPausedInDebuggerMessage against the provided context and
// target handler.
func (p *SetPausedInDebuggerMessageParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
return h.Execute(ctxt, cdp.CommandOverlaySetPausedInDebuggerMessage, p, nil)
}
// SetSuspendedParams [no description].
type SetSuspendedParams struct {
Suspended bool `json:"suspended"` // Whether overlay should be suspended and not consume any resources until resumed.
}
// SetSuspended [no description].
//
// parameters:
// suspended - Whether overlay should be suspended and not consume any resources until resumed.
func SetSuspended(suspended bool) *SetSuspendedParams {
return &SetSuspendedParams{
Suspended: suspended,
}
}
// Do executes Overlay.setSuspended against the provided context and
// target handler.
func (p *SetSuspendedParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
return h.Execute(ctxt, cdp.CommandOverlaySetSuspended, p, nil)
}
// SetInspectModeParams enters the 'inspect' mode. In this mode, elements
// that user is hovering over are highlighted. Backend then generates
// 'inspectNodeRequested' event upon element selection.
type SetInspectModeParams struct {
Mode InspectMode `json:"mode"` // Set an inspection mode.
HighlightConfig *HighlightConfig `json:"highlightConfig,omitempty"` // A descriptor for the highlight appearance of hovered-over nodes. May be omitted if enabled == false.
}
// SetInspectMode enters the 'inspect' mode. In this mode, elements that user
// is hovering over are highlighted. Backend then generates
// 'inspectNodeRequested' event upon element selection.
//
// parameters:
// mode - Set an inspection mode.
func SetInspectMode(mode InspectMode) *SetInspectModeParams {
return &SetInspectModeParams{
Mode: mode,
}
}
// WithHighlightConfig a descriptor for the highlight appearance of
// hovered-over nodes. May be omitted if enabled == false.
func (p SetInspectModeParams) WithHighlightConfig(highlightConfig *HighlightConfig) *SetInspectModeParams {
p.HighlightConfig = highlightConfig
return &p
}
// Do executes Overlay.setInspectMode against the provided context and
// target handler.
func (p *SetInspectModeParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
return h.Execute(ctxt, cdp.CommandOverlaySetInspectMode, p, nil)
}
// HighlightRectParams highlights given rectangle. Coordinates are absolute
// with respect to the main frame viewport.
type HighlightRectParams struct {
X int64 `json:"x"` // X coordinate
Y int64 `json:"y"` // Y coordinate
Width int64 `json:"width"` // Rectangle width
Height int64 `json:"height"` // Rectangle height
Color *cdp.RGBA `json:"color,omitempty"` // The highlight fill color (default: transparent).
OutlineColor *cdp.RGBA `json:"outlineColor,omitempty"` // The highlight outline color (default: transparent).
}
// HighlightRect highlights given rectangle. Coordinates are absolute with
// respect to the main frame viewport.
//
// parameters:
// x - X coordinate
// y - Y coordinate
// width - Rectangle width
// height - Rectangle height
func HighlightRect(x int64, y int64, width int64, height int64) *HighlightRectParams {
return &HighlightRectParams{
X: x,
Y: y,
Width: width,
Height: height,
}
}
// WithColor the highlight fill color (default: transparent).
func (p HighlightRectParams) WithColor(color *cdp.RGBA) *HighlightRectParams {
p.Color = color
return &p
}
// WithOutlineColor the highlight outline color (default: transparent).
func (p HighlightRectParams) WithOutlineColor(outlineColor *cdp.RGBA) *HighlightRectParams {
p.OutlineColor = outlineColor
return &p
}
// Do executes Overlay.highlightRect against the provided context and
// target handler.
func (p *HighlightRectParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
return h.Execute(ctxt, cdp.CommandOverlayHighlightRect, p, nil)
}
// HighlightQuadParams highlights given quad. Coordinates are absolute with
// respect to the main frame viewport.
type HighlightQuadParams struct {
Quad dom.Quad `json:"quad"` // Quad to highlight
Color *cdp.RGBA `json:"color,omitempty"` // The highlight fill color (default: transparent).
OutlineColor *cdp.RGBA `json:"outlineColor,omitempty"` // The highlight outline color (default: transparent).
}
// HighlightQuad highlights given quad. Coordinates are absolute with respect
// to the main frame viewport.
//
// parameters:
// quad - Quad to highlight
func HighlightQuad(quad dom.Quad) *HighlightQuadParams {
return &HighlightQuadParams{
Quad: quad,
}
}
// WithColor the highlight fill color (default: transparent).
func (p HighlightQuadParams) WithColor(color *cdp.RGBA) *HighlightQuadParams {
p.Color = color
return &p
}
// WithOutlineColor the highlight outline color (default: transparent).
func (p HighlightQuadParams) WithOutlineColor(outlineColor *cdp.RGBA) *HighlightQuadParams {
p.OutlineColor = outlineColor
return &p
}
// Do executes Overlay.highlightQuad against the provided context and
// target handler.
func (p *HighlightQuadParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
return h.Execute(ctxt, cdp.CommandOverlayHighlightQuad, p, nil)
}
// HighlightNodeParams highlights DOM node with given id or with the given
// JavaScript object wrapper. Either nodeId or objectId must be specified.
type HighlightNodeParams struct {
HighlightConfig *HighlightConfig `json:"highlightConfig"` // A descriptor for the highlight appearance.
NodeID cdp.NodeID `json:"nodeId,omitempty"` // Identifier of the node to highlight.
BackendNodeID cdp.BackendNodeID `json:"backendNodeId,omitempty"` // Identifier of the backend node to highlight.
ObjectID runtime.RemoteObjectID `json:"objectId,omitempty"` // JavaScript object id of the node to be highlighted.
}
// HighlightNode highlights DOM node with given id or with the given
// JavaScript object wrapper. Either nodeId or objectId must be specified.
//
// parameters:
// highlightConfig - A descriptor for the highlight appearance.
func HighlightNode(highlightConfig *HighlightConfig) *HighlightNodeParams {
return &HighlightNodeParams{
HighlightConfig: highlightConfig,
}
}
// WithNodeID identifier of the node to highlight.
func (p HighlightNodeParams) WithNodeID(nodeID cdp.NodeID) *HighlightNodeParams {
p.NodeID = nodeID
return &p
}
// WithBackendNodeID identifier of the backend node to highlight.
func (p HighlightNodeParams) WithBackendNodeID(backendNodeID cdp.BackendNodeID) *HighlightNodeParams {
p.BackendNodeID = backendNodeID
return &p
}
// WithObjectID javaScript object id of the node to be highlighted.
func (p HighlightNodeParams) WithObjectID(objectID runtime.RemoteObjectID) *HighlightNodeParams {
p.ObjectID = objectID
return &p
}
// Do executes Overlay.highlightNode against the provided context and
// target handler.
func (p *HighlightNodeParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
return h.Execute(ctxt, cdp.CommandOverlayHighlightNode, p, nil)
}
// HighlightFrameParams highlights owner element of the frame with given id.
type HighlightFrameParams struct {
FrameID cdp.FrameID `json:"frameId"` // Identifier of the frame to highlight.
ContentColor *cdp.RGBA `json:"contentColor,omitempty"` // The content box highlight fill color (default: transparent).
ContentOutlineColor *cdp.RGBA `json:"contentOutlineColor,omitempty"` // The content box highlight outline color (default: transparent).
}
// HighlightFrame highlights owner element of the frame with given id.
//
// parameters:
// frameID - Identifier of the frame to highlight.
func HighlightFrame(frameID cdp.FrameID) *HighlightFrameParams {
return &HighlightFrameParams{
FrameID: frameID,
}
}
// WithContentColor the content box highlight fill color (default:
// transparent).
func (p HighlightFrameParams) WithContentColor(contentColor *cdp.RGBA) *HighlightFrameParams {
p.ContentColor = contentColor
return &p
}
// WithContentOutlineColor the content box highlight outline color (default:
// transparent).
func (p HighlightFrameParams) WithContentOutlineColor(contentOutlineColor *cdp.RGBA) *HighlightFrameParams {
p.ContentOutlineColor = contentOutlineColor
return &p
}
// Do executes Overlay.highlightFrame against the provided context and
// target handler.
func (p *HighlightFrameParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
return h.Execute(ctxt, cdp.CommandOverlayHighlightFrame, p, nil)
}
// HideHighlightParams hides any highlight.
type HideHighlightParams struct{}
// HideHighlight hides any highlight.
func HideHighlight() *HideHighlightParams {
return &HideHighlightParams{}
}
// Do executes Overlay.hideHighlight against the provided context and
// target handler.
func (p *HideHighlightParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
return h.Execute(ctxt, cdp.CommandOverlayHideHighlight, nil, nil)
}
// GetHighlightObjectForTestParams for testing.
type GetHighlightObjectForTestParams struct {
NodeID cdp.NodeID `json:"nodeId"` // Id of the node to get highlight object for.
}
// GetHighlightObjectForTest for testing.
//
// parameters:
// nodeID - Id of the node to get highlight object for.
func GetHighlightObjectForTest(nodeID cdp.NodeID) *GetHighlightObjectForTestParams {
return &GetHighlightObjectForTestParams{
NodeID: nodeID,
}
}
// GetHighlightObjectForTestReturns return values.
type GetHighlightObjectForTestReturns struct {
Highlight easyjson.RawMessage `json:"highlight,omitempty"`
}
// Do executes Overlay.getHighlightObjectForTest against the provided context and
// target handler.
//
// returns:
// highlight - Highlight data for the node.
func (p *GetHighlightObjectForTestParams) Do(ctxt context.Context, h cdp.Handler) (highlight easyjson.RawMessage, err error) {
// execute
var res GetHighlightObjectForTestReturns
err = h.Execute(ctxt, cdp.CommandOverlayGetHighlightObjectForTest, p, &res)
if err != nil {
return nil, err
}
return res.Highlight, nil
}