/
types.go
136 lines (116 loc) · 6.36 KB
/
types.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
package layertree
// Code generated by cdproto-gen. DO NOT EDIT.
import (
"fmt"
"github.com/chromedp/cdproto/cdp"
"github.com/chromedp/cdproto/dom"
"github.com/mailru/easyjson"
"github.com/mailru/easyjson/jlexer"
"github.com/mailru/easyjson/jwriter"
)
// LayerID unique Layer identifier.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/LayerTree#type-LayerId
type LayerID string
// String returns the LayerID as string value.
func (t LayerID) String() string {
return string(t)
}
// SnapshotID unique snapshot identifier.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/LayerTree#type-SnapshotId
type SnapshotID string
// String returns the SnapshotID as string value.
func (t SnapshotID) String() string {
return string(t)
}
// ScrollRect rectangle where scrolling happens on the main thread.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/LayerTree#type-ScrollRect
type ScrollRect struct {
Rect *dom.Rect `json:"rect"` // Rectangle itself.
Type ScrollRectType `json:"type"` // Reason for rectangle to force scrolling on the main thread
}
// StickyPositionConstraint sticky position constraints.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/LayerTree#type-StickyPositionConstraint
type StickyPositionConstraint struct {
StickyBoxRect *dom.Rect `json:"stickyBoxRect"` // Layout rectangle of the sticky element before being shifted
ContainingBlockRect *dom.Rect `json:"containingBlockRect"` // Layout rectangle of the containing block of the sticky element
NearestLayerShiftingStickyBox LayerID `json:"nearestLayerShiftingStickyBox,omitempty"` // The nearest sticky layer that shifts the sticky box
NearestLayerShiftingContainingBlock LayerID `json:"nearestLayerShiftingContainingBlock,omitempty"` // The nearest sticky layer that shifts the containing block
}
// PictureTile serialized fragment of layer picture along with its offset
// within the layer.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/LayerTree#type-PictureTile
type PictureTile struct {
X float64 `json:"x"` // Offset from owning layer left boundary
Y float64 `json:"y"` // Offset from owning layer top boundary
Picture string `json:"picture"` // Base64-encoded snapshot data.
}
// Layer information about a compositing layer.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/LayerTree#type-Layer
type Layer struct {
LayerID LayerID `json:"layerId"` // The unique id for this layer.
ParentLayerID LayerID `json:"parentLayerId,omitempty"` // The id of parent (not present for root).
BackendNodeID cdp.BackendNodeID `json:"backendNodeId,omitempty"` // The backend id for the node associated with this layer.
OffsetX float64 `json:"offsetX"` // Offset from parent layer, X coordinate.
OffsetY float64 `json:"offsetY"` // Offset from parent layer, Y coordinate.
Width float64 `json:"width"` // Layer width.
Height float64 `json:"height"` // Layer height.
Transform []float64 `json:"transform,omitempty"` // Transformation matrix for layer, default is identity matrix
AnchorX float64 `json:"anchorX,omitempty"` // Transform anchor point X, absent if no transform specified
AnchorY float64 `json:"anchorY,omitempty"` // Transform anchor point Y, absent if no transform specified
AnchorZ float64 `json:"anchorZ,omitempty"` // Transform anchor point Z, absent if no transform specified
PaintCount int64 `json:"paintCount"` // Indicates how many time this layer has painted.
DrawsContent bool `json:"drawsContent"` // Indicates whether this layer hosts any content, rather than being used for transform/scrolling purposes only.
Invisible bool `json:"invisible,omitempty"` // Set if layer is not visible.
ScrollRects []*ScrollRect `json:"scrollRects,omitempty"` // Rectangles scrolling on main thread only.
StickyPositionConstraint *StickyPositionConstraint `json:"stickyPositionConstraint,omitempty"` // Sticky position constraint information
}
// PaintProfile array of timings, one per paint step.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/LayerTree#type-PaintProfile
type PaintProfile []float64
// ScrollRectType reason for rectangle to force scrolling on the main thread.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/LayerTree#type-ScrollRect
type ScrollRectType string
// String returns the ScrollRectType as string value.
func (t ScrollRectType) String() string {
return string(t)
}
// ScrollRectType values.
const (
ScrollRectTypeRepaintsOnScroll ScrollRectType = "RepaintsOnScroll"
ScrollRectTypeTouchEventHandler ScrollRectType = "TouchEventHandler"
ScrollRectTypeWheelEventHandler ScrollRectType = "WheelEventHandler"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t ScrollRectType) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t ScrollRectType) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *ScrollRectType) UnmarshalEasyJSON(in *jlexer.Lexer) {
v := in.String()
switch ScrollRectType(v) {
case ScrollRectTypeRepaintsOnScroll:
*t = ScrollRectTypeRepaintsOnScroll
case ScrollRectTypeTouchEventHandler:
*t = ScrollRectTypeTouchEventHandler
case ScrollRectTypeWheelEventHandler:
*t = ScrollRectTypeWheelEventHandler
default:
in.AddError(fmt.Errorf("unknown ScrollRectType value: %v", v))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *ScrollRectType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}