chromedp/cdp/layertree/layertree.go

607 lines
14 KiB
Go
Raw Normal View History

2017-01-24 15:09:23 +00:00
// Package layertree provides the Chrome Debugging Protocol
// commands, types, and events for the LayerTree domain.
2017-01-24 15:09:23 +00:00
//
// Generated by the chromedp-gen command.
package layertree
// AUTOGENERATED. DO NOT EDIT.
import (
"context"
2017-01-26 07:28:34 +00:00
cdp "github.com/knq/chromedp/cdp"
2017-01-24 15:09:23 +00:00
"github.com/knq/chromedp/cdp/dom"
"github.com/mailru/easyjson"
)
// EnableParams enables compositing tree inspection.
type EnableParams struct{}
// Enable enables compositing tree inspection.
func Enable() *EnableParams {
return &EnableParams{}
}
// Do executes LayerTree.enable against the provided context and
// target handler.
func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
2017-01-24 15:09:23 +00:00
if ctxt == nil {
ctxt = context.Background()
}
// execute
2017-01-26 07:28:34 +00:00
ch := h.Execute(ctxt, cdp.CommandLayerTreeEnable, cdp.Empty)
2017-01-24 15:09:23 +00:00
// read response
select {
case res := <-ch:
if res == nil {
2017-01-26 07:28:34 +00:00
return cdp.ErrChannelClosed
2017-01-24 15:09:23 +00:00
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ctxt.Err()
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
return cdp.ErrUnknownResult
2017-01-24 15:09:23 +00:00
}
// DisableParams disables compositing tree inspection.
type DisableParams struct{}
// Disable disables compositing tree inspection.
func Disable() *DisableParams {
return &DisableParams{}
}
// Do executes LayerTree.disable against the provided context and
// target handler.
func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
2017-01-24 15:09:23 +00:00
if ctxt == nil {
ctxt = context.Background()
}
// execute
2017-01-26 07:28:34 +00:00
ch := h.Execute(ctxt, cdp.CommandLayerTreeDisable, cdp.Empty)
2017-01-24 15:09:23 +00:00
// read response
select {
case res := <-ch:
if res == nil {
2017-01-26 07:28:34 +00:00
return cdp.ErrChannelClosed
2017-01-24 15:09:23 +00:00
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ctxt.Err()
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
return cdp.ErrUnknownResult
2017-01-24 15:09:23 +00:00
}
// CompositingReasonsParams provides the reasons why the given layer was
// composited.
type CompositingReasonsParams struct {
LayerID LayerID `json:"layerId"` // The id of the layer for which we want to get the reasons it was composited.
}
// CompositingReasons provides the reasons why the given layer was
// composited.
//
// parameters:
2017-01-26 07:28:34 +00:00
// layerID - The id of the layer for which we want to get the reasons it was composited.
func CompositingReasons(layerID LayerID) *CompositingReasonsParams {
2017-01-24 15:09:23 +00:00
return &CompositingReasonsParams{
2017-01-26 07:28:34 +00:00
LayerID: layerID,
2017-01-24 15:09:23 +00:00
}
}
// CompositingReasonsReturns return values.
type CompositingReasonsReturns struct {
CompositingReasons []string `json:"compositingReasons,omitempty"` // A list of strings specifying reasons for the given layer to become composited.
}
// Do executes LayerTree.compositingReasons against the provided context and
// target handler.
2017-01-24 15:09:23 +00:00
//
// returns:
// compositingReasons - A list of strings specifying reasons for the given layer to become composited.
func (p *CompositingReasonsParams) Do(ctxt context.Context, h cdp.Handler) (compositingReasons []string, err error) {
2017-01-24 15:09:23 +00:00
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return nil, err
}
// execute
2017-01-26 07:28:34 +00:00
ch := h.Execute(ctxt, cdp.CommandLayerTreeCompositingReasons, easyjson.RawMessage(buf))
2017-01-24 15:09:23 +00:00
// read response
select {
case res := <-ch:
if res == nil {
2017-01-26 07:28:34 +00:00
return nil, cdp.ErrChannelClosed
2017-01-24 15:09:23 +00:00
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r CompositingReasonsReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
2017-01-26 07:28:34 +00:00
return nil, cdp.ErrInvalidResult
2017-01-24 15:09:23 +00:00
}
return r.CompositingReasons, nil
case error:
return nil, v
}
case <-ctxt.Done():
return nil, ctxt.Err()
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
return nil, cdp.ErrUnknownResult
2017-01-24 15:09:23 +00:00
}
// MakeSnapshotParams returns the layer snapshot identifier.
type MakeSnapshotParams struct {
LayerID LayerID `json:"layerId"` // The id of the layer.
}
// MakeSnapshot returns the layer snapshot identifier.
//
// parameters:
2017-01-26 07:28:34 +00:00
// layerID - The id of the layer.
func MakeSnapshot(layerID LayerID) *MakeSnapshotParams {
2017-01-24 15:09:23 +00:00
return &MakeSnapshotParams{
2017-01-26 07:28:34 +00:00
LayerID: layerID,
2017-01-24 15:09:23 +00:00
}
}
// MakeSnapshotReturns return values.
type MakeSnapshotReturns struct {
SnapshotID SnapshotID `json:"snapshotId,omitempty"` // The id of the layer snapshot.
}
// Do executes LayerTree.makeSnapshot against the provided context and
// target handler.
2017-01-24 15:09:23 +00:00
//
// returns:
2017-01-26 07:28:34 +00:00
// snapshotID - The id of the layer snapshot.
func (p *MakeSnapshotParams) Do(ctxt context.Context, h cdp.Handler) (snapshotID SnapshotID, err error) {
2017-01-24 15:09:23 +00:00
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return "", err
}
// execute
2017-01-26 07:28:34 +00:00
ch := h.Execute(ctxt, cdp.CommandLayerTreeMakeSnapshot, easyjson.RawMessage(buf))
2017-01-24 15:09:23 +00:00
// read response
select {
case res := <-ch:
if res == nil {
2017-01-26 07:28:34 +00:00
return "", cdp.ErrChannelClosed
2017-01-24 15:09:23 +00:00
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r MakeSnapshotReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
2017-01-26 07:28:34 +00:00
return "", cdp.ErrInvalidResult
2017-01-24 15:09:23 +00:00
}
return r.SnapshotID, nil
case error:
return "", v
}
case <-ctxt.Done():
return "", ctxt.Err()
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
return "", cdp.ErrUnknownResult
2017-01-24 15:09:23 +00:00
}
// LoadSnapshotParams returns the snapshot identifier.
type LoadSnapshotParams struct {
Tiles []*PictureTile `json:"tiles"` // An array of tiles composing the snapshot.
}
// LoadSnapshot returns the snapshot identifier.
//
// parameters:
// tiles - An array of tiles composing the snapshot.
func LoadSnapshot(tiles []*PictureTile) *LoadSnapshotParams {
return &LoadSnapshotParams{
Tiles: tiles,
}
}
// LoadSnapshotReturns return values.
type LoadSnapshotReturns struct {
SnapshotID SnapshotID `json:"snapshotId,omitempty"` // The id of the snapshot.
}
// Do executes LayerTree.loadSnapshot against the provided context and
// target handler.
2017-01-24 15:09:23 +00:00
//
// returns:
2017-01-26 07:28:34 +00:00
// snapshotID - The id of the snapshot.
func (p *LoadSnapshotParams) Do(ctxt context.Context, h cdp.Handler) (snapshotID SnapshotID, err error) {
2017-01-24 15:09:23 +00:00
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return "", err
}
// execute
2017-01-26 07:28:34 +00:00
ch := h.Execute(ctxt, cdp.CommandLayerTreeLoadSnapshot, easyjson.RawMessage(buf))
2017-01-24 15:09:23 +00:00
// read response
select {
case res := <-ch:
if res == nil {
2017-01-26 07:28:34 +00:00
return "", cdp.ErrChannelClosed
2017-01-24 15:09:23 +00:00
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r LoadSnapshotReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
2017-01-26 07:28:34 +00:00
return "", cdp.ErrInvalidResult
2017-01-24 15:09:23 +00:00
}
return r.SnapshotID, nil
case error:
return "", v
}
case <-ctxt.Done():
return "", ctxt.Err()
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
return "", cdp.ErrUnknownResult
2017-01-24 15:09:23 +00:00
}
// ReleaseSnapshotParams releases layer snapshot captured by the back-end.
type ReleaseSnapshotParams struct {
SnapshotID SnapshotID `json:"snapshotId"` // The id of the layer snapshot.
}
// ReleaseSnapshot releases layer snapshot captured by the back-end.
//
// parameters:
2017-01-26 07:28:34 +00:00
// snapshotID - The id of the layer snapshot.
func ReleaseSnapshot(snapshotID SnapshotID) *ReleaseSnapshotParams {
2017-01-24 15:09:23 +00:00
return &ReleaseSnapshotParams{
2017-01-26 07:28:34 +00:00
SnapshotID: snapshotID,
2017-01-24 15:09:23 +00:00
}
}
// Do executes LayerTree.releaseSnapshot against the provided context and
// target handler.
func (p *ReleaseSnapshotParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
2017-01-24 15:09:23 +00:00
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return err
}
// execute
2017-01-26 07:28:34 +00:00
ch := h.Execute(ctxt, cdp.CommandLayerTreeReleaseSnapshot, easyjson.RawMessage(buf))
2017-01-24 15:09:23 +00:00
// read response
select {
case res := <-ch:
if res == nil {
2017-01-26 07:28:34 +00:00
return cdp.ErrChannelClosed
2017-01-24 15:09:23 +00:00
}
switch v := res.(type) {
case easyjson.RawMessage:
return nil
case error:
return v
}
case <-ctxt.Done():
return ctxt.Err()
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
return cdp.ErrUnknownResult
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
// ProfileSnapshotParams [no description].
2017-01-24 15:09:23 +00:00
type ProfileSnapshotParams struct {
SnapshotID SnapshotID `json:"snapshotId"` // The id of the layer snapshot.
MinRepeatCount int64 `json:"minRepeatCount,omitempty"` // The maximum number of times to replay the snapshot (1, if not specified).
MinDuration float64 `json:"minDuration,omitempty"` // The minimum duration (in seconds) to replay the snapshot.
ClipRect *dom.Rect `json:"clipRect,omitempty"` // The clip rectangle to apply when replaying the snapshot.
}
2017-01-26 07:28:34 +00:00
// ProfileSnapshot [no description].
//
2017-01-24 15:09:23 +00:00
// parameters:
2017-01-26 07:28:34 +00:00
// snapshotID - The id of the layer snapshot.
func ProfileSnapshot(snapshotID SnapshotID) *ProfileSnapshotParams {
2017-01-24 15:09:23 +00:00
return &ProfileSnapshotParams{
2017-01-26 07:28:34 +00:00
SnapshotID: snapshotID,
2017-01-24 15:09:23 +00:00
}
}
// WithMinRepeatCount the maximum number of times to replay the snapshot (1,
// if not specified).
func (p ProfileSnapshotParams) WithMinRepeatCount(minRepeatCount int64) *ProfileSnapshotParams {
p.MinRepeatCount = minRepeatCount
return &p
}
// WithMinDuration the minimum duration (in seconds) to replay the snapshot.
func (p ProfileSnapshotParams) WithMinDuration(minDuration float64) *ProfileSnapshotParams {
p.MinDuration = minDuration
return &p
}
// WithClipRect the clip rectangle to apply when replaying the snapshot.
func (p ProfileSnapshotParams) WithClipRect(clipRect *dom.Rect) *ProfileSnapshotParams {
p.ClipRect = clipRect
return &p
}
// ProfileSnapshotReturns return values.
type ProfileSnapshotReturns struct {
Timings []PaintProfile `json:"timings,omitempty"` // The array of paint profiles, one per run.
}
// Do executes LayerTree.profileSnapshot against the provided context and
// target handler.
2017-01-24 15:09:23 +00:00
//
// returns:
// timings - The array of paint profiles, one per run.
func (p *ProfileSnapshotParams) Do(ctxt context.Context, h cdp.Handler) (timings []PaintProfile, err error) {
2017-01-24 15:09:23 +00:00
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return nil, err
}
// execute
2017-01-26 07:28:34 +00:00
ch := h.Execute(ctxt, cdp.CommandLayerTreeProfileSnapshot, easyjson.RawMessage(buf))
2017-01-24 15:09:23 +00:00
// read response
select {
case res := <-ch:
if res == nil {
2017-01-26 07:28:34 +00:00
return nil, cdp.ErrChannelClosed
2017-01-24 15:09:23 +00:00
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r ProfileSnapshotReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
2017-01-26 07:28:34 +00:00
return nil, cdp.ErrInvalidResult
2017-01-24 15:09:23 +00:00
}
return r.Timings, nil
case error:
return nil, v
}
case <-ctxt.Done():
return nil, ctxt.Err()
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
return nil, cdp.ErrUnknownResult
2017-01-24 15:09:23 +00:00
}
// ReplaySnapshotParams replays the layer snapshot and returns the resulting
// bitmap.
type ReplaySnapshotParams struct {
SnapshotID SnapshotID `json:"snapshotId"` // The id of the layer snapshot.
FromStep int64 `json:"fromStep,omitempty"` // The first step to replay from (replay from the very start if not specified).
ToStep int64 `json:"toStep,omitempty"` // The last step to replay to (replay till the end if not specified).
Scale float64 `json:"scale,omitempty"` // The scale to apply while replaying (defaults to 1).
}
// ReplaySnapshot replays the layer snapshot and returns the resulting
// bitmap.
//
// parameters:
2017-01-26 07:28:34 +00:00
// snapshotID - The id of the layer snapshot.
func ReplaySnapshot(snapshotID SnapshotID) *ReplaySnapshotParams {
2017-01-24 15:09:23 +00:00
return &ReplaySnapshotParams{
2017-01-26 07:28:34 +00:00
SnapshotID: snapshotID,
2017-01-24 15:09:23 +00:00
}
}
// WithFromStep the first step to replay from (replay from the very start if
// not specified).
func (p ReplaySnapshotParams) WithFromStep(fromStep int64) *ReplaySnapshotParams {
p.FromStep = fromStep
return &p
}
// WithToStep the last step to replay to (replay till the end if not
// specified).
func (p ReplaySnapshotParams) WithToStep(toStep int64) *ReplaySnapshotParams {
p.ToStep = toStep
return &p
}
// WithScale the scale to apply while replaying (defaults to 1).
func (p ReplaySnapshotParams) WithScale(scale float64) *ReplaySnapshotParams {
p.Scale = scale
return &p
}
// ReplaySnapshotReturns return values.
type ReplaySnapshotReturns struct {
DataURL string `json:"dataURL,omitempty"` // A data: URL for resulting image.
}
// Do executes LayerTree.replaySnapshot against the provided context and
// target handler.
2017-01-24 15:09:23 +00:00
//
// returns:
// dataURL - A data: URL for resulting image.
func (p *ReplaySnapshotParams) Do(ctxt context.Context, h cdp.Handler) (dataURL string, err error) {
2017-01-24 15:09:23 +00:00
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return "", err
}
// execute
2017-01-26 07:28:34 +00:00
ch := h.Execute(ctxt, cdp.CommandLayerTreeReplaySnapshot, easyjson.RawMessage(buf))
2017-01-24 15:09:23 +00:00
// read response
select {
case res := <-ch:
if res == nil {
2017-01-26 07:28:34 +00:00
return "", cdp.ErrChannelClosed
2017-01-24 15:09:23 +00:00
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r ReplaySnapshotReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
2017-01-26 07:28:34 +00:00
return "", cdp.ErrInvalidResult
2017-01-24 15:09:23 +00:00
}
return r.DataURL, nil
case error:
return "", v
}
case <-ctxt.Done():
return "", ctxt.Err()
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
return "", cdp.ErrUnknownResult
2017-01-24 15:09:23 +00:00
}
// SnapshotCommandLogParams replays the layer snapshot and returns canvas
// log.
type SnapshotCommandLogParams struct {
SnapshotID SnapshotID `json:"snapshotId"` // The id of the layer snapshot.
}
// SnapshotCommandLog replays the layer snapshot and returns canvas log.
//
// parameters:
2017-01-26 07:28:34 +00:00
// snapshotID - The id of the layer snapshot.
func SnapshotCommandLog(snapshotID SnapshotID) *SnapshotCommandLogParams {
2017-01-24 15:09:23 +00:00
return &SnapshotCommandLogParams{
2017-01-26 07:28:34 +00:00
SnapshotID: snapshotID,
2017-01-24 15:09:23 +00:00
}
}
// SnapshotCommandLogReturns return values.
type SnapshotCommandLogReturns struct {
CommandLog []easyjson.RawMessage `json:"commandLog,omitempty"` // The array of canvas function calls.
}
// Do executes LayerTree.snapshotCommandLog against the provided context and
// target handler.
2017-01-24 15:09:23 +00:00
//
// returns:
// commandLog - The array of canvas function calls.
func (p *SnapshotCommandLogParams) Do(ctxt context.Context, h cdp.Handler) (commandLog []easyjson.RawMessage, err error) {
2017-01-24 15:09:23 +00:00
if ctxt == nil {
ctxt = context.Background()
}
// marshal
buf, err := easyjson.Marshal(p)
if err != nil {
return nil, err
}
// execute
2017-01-26 07:28:34 +00:00
ch := h.Execute(ctxt, cdp.CommandLayerTreeSnapshotCommandLog, easyjson.RawMessage(buf))
2017-01-24 15:09:23 +00:00
// read response
select {
case res := <-ch:
if res == nil {
2017-01-26 07:28:34 +00:00
return nil, cdp.ErrChannelClosed
2017-01-24 15:09:23 +00:00
}
switch v := res.(type) {
case easyjson.RawMessage:
// unmarshal
var r SnapshotCommandLogReturns
err = easyjson.Unmarshal(v, &r)
if err != nil {
2017-01-26 07:28:34 +00:00
return nil, cdp.ErrInvalidResult
2017-01-24 15:09:23 +00:00
}
return r.CommandLog, nil
case error:
return nil, v
}
case <-ctxt.Done():
return nil, ctxt.Err()
2017-01-24 15:09:23 +00:00
}
2017-01-26 07:28:34 +00:00
return nil, cdp.ErrUnknownResult
2017-01-24 15:09:23 +00:00
}