/
domain.go
79 lines (70 loc) · 2.87 KB
/
domain.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
// Code generated by cdpgen. DO NOT EDIT.
// Package domsnapshot implements the DOMSnapshot domain. This domain
// facilitates obtaining document snapshots with DOM, layout, and style
// information.
package domsnapshot
import (
"context"
"github.com/mafredri/cdp/protocol/internal"
"github.com/mafredri/cdp/rpcc"
)
// domainClient is a client for the DOMSnapshot domain. This domain
// facilitates obtaining document snapshots with DOM, layout, and style
// information.
type domainClient struct{ conn *rpcc.Conn }
// NewClient returns a client for the DOMSnapshot domain with the connection set to conn.
func NewClient(conn *rpcc.Conn) *domainClient {
return &domainClient{conn: conn}
}
// Disable invokes the DOMSnapshot method. Disables DOM snapshot agent for the
// given page.
func (d *domainClient) Disable(ctx context.Context) (err error) {
err = rpcc.Invoke(ctx, "DOMSnapshot.disable", nil, nil, d.conn)
if err != nil {
err = &internal.OpError{Domain: "DOMSnapshot", Op: "Disable", Err: err}
}
return
}
// Enable invokes the DOMSnapshot method. Enables DOM snapshot agent for the
// given page.
func (d *domainClient) Enable(ctx context.Context) (err error) {
err = rpcc.Invoke(ctx, "DOMSnapshot.enable", nil, nil, d.conn)
if err != nil {
err = &internal.OpError{Domain: "DOMSnapshot", Op: "Enable", Err: err}
}
return
}
// GetSnapshot invokes the DOMSnapshot method. Returns a document snapshot,
// including the full DOM tree of the root node (including iframes, template
// contents, and imported documents) in a flattened array, as well as layout
// and white-listed computed style information for the nodes. Shadow DOM in the
// returned DOM tree is flattened.
func (d *domainClient) GetSnapshot(ctx context.Context, args *GetSnapshotArgs) (reply *GetSnapshotReply, err error) {
reply = new(GetSnapshotReply)
if args != nil {
err = rpcc.Invoke(ctx, "DOMSnapshot.getSnapshot", args, reply, d.conn)
} else {
err = rpcc.Invoke(ctx, "DOMSnapshot.getSnapshot", nil, reply, d.conn)
}
if err != nil {
err = &internal.OpError{Domain: "DOMSnapshot", Op: "GetSnapshot", Err: err}
}
return
}
// CaptureSnapshot invokes the DOMSnapshot method. Returns a document
// snapshot, including the full DOM tree of the root node (including iframes,
// template contents, and imported documents) in a flattened array, as well as
// layout and white-listed computed style information for the nodes. Shadow DOM
// in the returned DOM tree is flattened.
func (d *domainClient) CaptureSnapshot(ctx context.Context, args *CaptureSnapshotArgs) (reply *CaptureSnapshotReply, err error) {
reply = new(CaptureSnapshotReply)
if args != nil {
err = rpcc.Invoke(ctx, "DOMSnapshot.captureSnapshot", args, reply, d.conn)
} else {
err = rpcc.Invoke(ctx, "DOMSnapshot.captureSnapshot", nil, reply, d.conn)
}
if err != nil {
err = &internal.OpError{Domain: "DOMSnapshot", Op: "CaptureSnapshot", Err: err}
}
return
}