File: types.go

package info (click to toggle)
golang-github-chromedp-cdproto 0.0~git20230109.6b041c6-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 4,584 kB
  • sloc: makefile: 2
file content (108 lines) | stat: -rw-r--r-- 4,142 bytes parent folder | download | duplicates (3)
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
package animation

// Code generated by cdproto-gen. DO NOT EDIT.

import (
	"fmt"

	"github.com/chromedp/cdproto/cdp"
	"github.com/mailru/easyjson"
	"github.com/mailru/easyjson/jlexer"
	"github.com/mailru/easyjson/jwriter"
)

// Animation animation instance.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Animation#type-Animation
type Animation struct {
	ID           string  `json:"id"`               // Animation's id.
	Name         string  `json:"name"`             // Animation's name.
	PausedState  bool    `json:"pausedState"`      // Animation's internal paused state.
	PlayState    string  `json:"playState"`        // Animation's play state.
	PlaybackRate float64 `json:"playbackRate"`     // Animation's playback rate.
	StartTime    float64 `json:"startTime"`        // Animation's start time.
	CurrentTime  float64 `json:"currentTime"`      // Animation's current time.
	Type         Type    `json:"type"`             // Animation type of Animation.
	Source       *Effect `json:"source,omitempty"` // Animation's source animation node.
	CSSID        string  `json:"cssId,omitempty"`  // A unique ID for Animation representing the sources that triggered this CSS animation/transition.
}

// Effect animationEffect instance.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Animation#type-AnimationEffect
type Effect struct {
	Delay          float64           `json:"delay"`                   // AnimationEffect's delay.
	EndDelay       float64           `json:"endDelay"`                // AnimationEffect's end delay.
	IterationStart float64           `json:"iterationStart"`          // AnimationEffect's iteration start.
	Iterations     float64           `json:"iterations"`              // AnimationEffect's iterations.
	Duration       float64           `json:"duration"`                // AnimationEffect's iteration duration.
	Direction      string            `json:"direction"`               // AnimationEffect's playback direction.
	Fill           string            `json:"fill"`                    // AnimationEffect's fill mode.
	BackendNodeID  cdp.BackendNodeID `json:"backendNodeId,omitempty"` // AnimationEffect's target node.
	KeyframesRule  *KeyframesRule    `json:"keyframesRule,omitempty"` // AnimationEffect's keyframes.
	Easing         string            `json:"easing"`                  // AnimationEffect's timing function.
}

// KeyframesRule keyframes Rule.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Animation#type-KeyframesRule
type KeyframesRule struct {
	Name      string           `json:"name,omitempty"` // CSS keyframed animation's name.
	Keyframes []*KeyframeStyle `json:"keyframes"`      // List of animation keyframes.
}

// KeyframeStyle keyframe Style.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Animation#type-KeyframeStyle
type KeyframeStyle struct {
	Offset string `json:"offset"` // Keyframe's time offset.
	Easing string `json:"easing"` // AnimationEffect's timing function.
}

// Type animation type of Animation.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/Animation#type-Animation
type Type string

// String returns the Type as string value.
func (t Type) String() string {
	return string(t)
}

// Type values.
const (
	TypeCSSTransition Type = "CSSTransition"
	TypeCSSAnimation  Type = "CSSAnimation"
	TypeWebAnimation  Type = "WebAnimation"
)

// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t Type) MarshalEasyJSON(out *jwriter.Writer) {
	out.String(string(t))
}

// MarshalJSON satisfies json.Marshaler.
func (t Type) MarshalJSON() ([]byte, error) {
	return easyjson.Marshal(t)
}

// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *Type) UnmarshalEasyJSON(in *jlexer.Lexer) {
	v := in.String()
	switch Type(v) {
	case TypeCSSTransition:
		*t = TypeCSSTransition
	case TypeCSSAnimation:
		*t = TypeCSSAnimation
	case TypeWebAnimation:
		*t = TypeWebAnimation

	default:
		in.AddError(fmt.Errorf("unknown Type value: %v", v))
	}
}

// UnmarshalJSON satisfies json.Unmarshaler.
func (t *Type) UnmarshalJSON(buf []byte) error {
	return easyjson.Unmarshal(buf, t)
}