-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathtypes.go
136 lines (117 loc) · 5.54 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
/*
The MIT License (MIT)
Copyright (c) 2017 isaac dawson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
package autogcd
import (
"github.com/wirepair/gcd/gcdapi"
)
// Common node types
type NodeType uint8
const (
ELEMENT_NODE NodeType = 0x1
TEXT_NODE NodeType = 0x3
PROCESSING_INSTRUCTION_NODE NodeType = 0x7
COMMENT_NODE NodeType = 0x8
DOCUMENT_NODE NodeType = 0x9
DOCUMENT_TYPE_NODE NodeType = 0x10
DOCUMENT_FRAGMENT_NODE NodeType = 0x11
)
var nodeTypeMap = map[NodeType]string{
ELEMENT_NODE: "ELEMENT_NODE",
TEXT_NODE: "TEXT_NODE",
PROCESSING_INSTRUCTION_NODE: "PROCESSING_INSTRUCTION_NODE",
COMMENT_NODE: "COMMENT_NODE",
DOCUMENT_NODE: "DOCUMENT_NODE",
DOCUMENT_TYPE_NODE: "DOCUMENT_TYPE_NODE",
DOCUMENT_FRAGMENT_NODE: "DOCUMENT_FRAGMENT_NODE",
}
// Document/Node change event types
type ChangeEventType uint16
const (
DocumentUpdatedEvent ChangeEventType = 0x0
SetChildNodesEvent ChangeEventType = 0x1
AttributeModifiedEvent ChangeEventType = 0x2
AttributeRemovedEvent ChangeEventType = 0x3
InlineStyleInvalidatedEvent ChangeEventType = 0x4
CharacterDataModifiedEvent ChangeEventType = 0x5
ChildNodeCountUpdatedEvent ChangeEventType = 0x6
ChildNodeInsertedEvent ChangeEventType = 0x7
ChildNodeRemovedEvent ChangeEventType = 0x8
)
var changeEventMap = map[ChangeEventType]string{
DocumentUpdatedEvent: "DocumentUpdatedEvent",
SetChildNodesEvent: "SetChildNodesEvent",
AttributeModifiedEvent: "AttributeModifiedEvent",
AttributeRemovedEvent: "AttributeRemovedEvent",
InlineStyleInvalidatedEvent: "InlineStyleInvalidatedEvent",
CharacterDataModifiedEvent: "CharacterDataModifiedEvent",
ChildNodeCountUpdatedEvent: "ChildNodeCountUpdatedEvent",
ChildNodeInsertedEvent: "ChildNodeInsertedEvent",
ChildNodeRemovedEvent: "ChildNodeRemovedEvent",
}
func (evt ChangeEventType) String() string {
if s, ok := changeEventMap[evt]; ok {
return s
}
return ""
}
// For handling DOM updating nodes
type NodeChangeEvent struct {
EventType ChangeEventType // the type of node change event
NodeId int // nodeid of change
NodeIds []int // nodeid of changes for inlinestyleinvalidated
ChildNodeCount int // updated childnodecount event
Nodes []*gcdapi.DOMNode // Child nodes array. for setChildNodesEvent
Node *gcdapi.DOMNode // node for child node inserted event
Name string // attribute name
Value string // attribute value
CharacterData string // new text value for characterDataModified events
ParentNodeId int // node id for setChildNodesEvent, childNodeInsertedEvent and childNodeRemovedEvent
PreviousNodeId int // previous node id for childNodeInsertedEvent
}
// Outbound network requests
type NetworkRequest struct {
RequestId string // Internal chrome request id
FrameId string // frame that the request went out on
LoaderId string // internal chrome loader id
DocumentURL string // url of the frame
Request *gcdapi.NetworkRequest // underlying Request object
Timestamp float64 // time the request was dispatched
Initiator *gcdapi.NetworkInitiator // who initiated the request
RedirectResponse *gcdapi.NetworkResponse // non-nil if it was a redirect
Type string // Document, Stylesheet, Image, Media, Font, Script, TextTrack, XHR, Fetch, EventSource, WebSocket, Other
}
// Inbound network responses
type NetworkResponse struct {
RequestId string // Internal chrome request id
FrameId string // frame that the request went out on
LoaderId string // internal chrome loader id
Response *gcdapi.NetworkResponse // underlying Response object
Timestamp float64 // time the request was received
Type string // Document, Stylesheet, Image, Media, Font, Script, TextTrack, XHR, Fetch, EventSource, WebSocket, Other
}
// For storage related events.
type StorageEventType uint16
type StorageEvent struct {
IsLocalStorage bool // if true, local storage, false session storage
SecurityOrigin string // origin that this event occurred on
Key string // storage key
NewValue string // new storage value
OldValue string // old storage value
}