Minor code cleanup/maintenance on generated cdp protocol
This commit is contained in:
parent
ab80f4c5bc
commit
4c16faa34d
|
@ -1434,6 +1434,9 @@ func (fs FrameState) String() string {
|
|||
return "[" + strings.Join(s, " ") + "]"
|
||||
}
|
||||
|
||||
// EmptyFrameID is the "non-existent" frame id.
|
||||
const EmptyFrameID = FrameID("")
|
||||
|
||||
// LoaderID unique loader identifier.
|
||||
type LoaderID string
|
||||
|
||||
|
@ -1808,6 +1811,9 @@ func (ns NodeState) String() string {
|
|||
return "[" + strings.Join(s, " ") + "]"
|
||||
}
|
||||
|
||||
// EmptyNodeID is the "non-existent" node id.
|
||||
const EmptyNodeID = NodeID(0)
|
||||
|
||||
// RGBA a structure holding an RGBA color.
|
||||
type RGBA struct {
|
||||
R int64 `json:"r,omitempty"` // The red component, in the [0-255] range.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package util
|
||||
package cdputil
|
||||
|
||||
// AUTOGENERATED. DO NOT EDIT.
|
||||
|
|
@ -161,8 +161,7 @@ func (c *CDP) ListTargets() []string {
|
|||
c.RLock()
|
||||
defer c.RUnlock()
|
||||
|
||||
targets := make([]string, len(c.handlers))
|
||||
i := 0
|
||||
i, targets := 0, make([]string, len(c.handlers))
|
||||
for k := range c.handlerMap {
|
||||
targets[i] = k
|
||||
i++
|
||||
|
|
|
@ -528,7 +528,7 @@ func addEnumValues(d *internal.Domain, n string, p *internal.Type) {
|
|||
v[z] = false
|
||||
}
|
||||
|
||||
i := 0
|
||||
var i int
|
||||
typ.Enum = make([]string, len(v))
|
||||
for _, z := range all {
|
||||
if !v[z] {
|
||||
|
|
|
@ -110,7 +110,7 @@ func (fb fileBuffers) generateUtilPackage(domains []*internal.Domain) {
|
|||
importMap[*internal.FlagPkg+"/"+d.PackageName()] = d.PackageImportAlias()
|
||||
}
|
||||
|
||||
w := fb.get("util/util.go", "util", nil)
|
||||
w := fb.get("cdputil/cdputil.go", "cdputil", nil)
|
||||
templates.StreamFileImportTemplate(w, importMap)
|
||||
templates.StreamExtraUtilTemplate(w, domains)
|
||||
fb.release(w)
|
||||
|
|
|
@ -95,7 +95,7 @@ func (p {%s= typ %}) {%s= optName %}({%s= v %} {%s= t.GoType(d, domains) %}) *{%
|
|||
|
||||
// determine if there's a conditional that indicates whether or not the
|
||||
// returned value is b64 encoded.
|
||||
b64cond := false
|
||||
var b64cond bool
|
||||
for _, p := range c.Returns {
|
||||
if p.Name == internal.Base64EncodedParamName {
|
||||
b64cond = true
|
||||
|
|
|
@ -433,7 +433,7 @@ func StreamCommandDoFuncTemplate(qw422016 *qt422016.Writer, c *internal.Type, d
|
|||
|
||||
// determine if there's a conditional that indicates whether or not the
|
||||
// returned value is b64 encoded.
|
||||
b64cond := false
|
||||
var b64cond bool
|
||||
for _, p := range c.Returns {
|
||||
if p.Name == internal.Base64EncodedParamName {
|
||||
b64cond = true
|
||||
|
|
|
@ -63,6 +63,9 @@ func (fs FrameState) String() string {
|
|||
}
|
||||
return "[" + strings.Join(s, " ") + "]"
|
||||
}
|
||||
|
||||
// EmptyFrameID is the "non-existent" frame id.
|
||||
const EmptyFrameID = FrameID("")
|
||||
{% endfunc %}
|
||||
|
||||
// ExtraNodeTemplate is a special template for the DOM.Node type, adding NodeState.
|
||||
|
@ -177,6 +180,9 @@ func (ns NodeState) String() string {
|
|||
}
|
||||
return "[" + strings.Join(s, " ") + "]"
|
||||
}
|
||||
|
||||
// EmptyNodeID is the "non-existent" node id.
|
||||
const EmptyNodeID = NodeID(0)
|
||||
{% endfunc %}
|
||||
|
||||
// ExtraFixStringUnmarshaler is a template that forces values to be parsed properly.
|
||||
|
|
|
@ -140,41 +140,44 @@ func (fs FrameState) String() string {
|
|||
}
|
||||
return "[" + strings.Join(s, " ") + "]"
|
||||
}
|
||||
|
||||
// EmptyFrameID is the "non-existent" frame id.
|
||||
const EmptyFrameID = FrameID("")
|
||||
`)
|
||||
//line templates/extra.qtpl:66
|
||||
//line templates/extra.qtpl:69
|
||||
}
|
||||
|
||||
//line templates/extra.qtpl:66
|
||||
//line templates/extra.qtpl:69
|
||||
func WriteExtraFrameTemplate(qq422016 qtio422016.Writer) {
|
||||
//line templates/extra.qtpl:66
|
||||
//line templates/extra.qtpl:69
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line templates/extra.qtpl:66
|
||||
//line templates/extra.qtpl:69
|
||||
StreamExtraFrameTemplate(qw422016)
|
||||
//line templates/extra.qtpl:66
|
||||
//line templates/extra.qtpl:69
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line templates/extra.qtpl:66
|
||||
//line templates/extra.qtpl:69
|
||||
}
|
||||
|
||||
//line templates/extra.qtpl:66
|
||||
//line templates/extra.qtpl:69
|
||||
func ExtraFrameTemplate() string {
|
||||
//line templates/extra.qtpl:66
|
||||
//line templates/extra.qtpl:69
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line templates/extra.qtpl:66
|
||||
//line templates/extra.qtpl:69
|
||||
WriteExtraFrameTemplate(qb422016)
|
||||
//line templates/extra.qtpl:66
|
||||
//line templates/extra.qtpl:69
|
||||
qs422016 := string(qb422016.B)
|
||||
//line templates/extra.qtpl:66
|
||||
//line templates/extra.qtpl:69
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line templates/extra.qtpl:66
|
||||
//line templates/extra.qtpl:69
|
||||
return qs422016
|
||||
//line templates/extra.qtpl:66
|
||||
//line templates/extra.qtpl:69
|
||||
}
|
||||
|
||||
// ExtraNodeTemplate is a special template for the DOM.Node type, adding NodeState.
|
||||
|
||||
//line templates/extra.qtpl:69
|
||||
//line templates/extra.qtpl:72
|
||||
func StreamExtraNodeTemplate(qw422016 *qt422016.Writer) {
|
||||
//line templates/extra.qtpl:69
|
||||
//line templates/extra.qtpl:72
|
||||
qw422016.N().S(`
|
||||
// AttributeValue returns the named attribute for the node.
|
||||
func (n *Node) AttributeValue(name string) string {
|
||||
|
@ -208,21 +211,21 @@ func (n *Node) xpath(stopAtDocument, stopAtID bool) string {
|
|||
case stopAtID && id != "":
|
||||
p = "/"
|
||||
pos = `)
|
||||
//line templates/extra.qtpl:69
|
||||
//line templates/extra.qtpl:72
|
||||
qw422016.N().S("`")
|
||||
//line templates/extra.qtpl:69
|
||||
//line templates/extra.qtpl:72
|
||||
qw422016.N().S(`[@id='`)
|
||||
//line templates/extra.qtpl:69
|
||||
//line templates/extra.qtpl:72
|
||||
qw422016.N().S("`")
|
||||
//line templates/extra.qtpl:69
|
||||
//line templates/extra.qtpl:72
|
||||
qw422016.N().S(`+id+`)
|
||||
//line templates/extra.qtpl:69
|
||||
//line templates/extra.qtpl:72
|
||||
qw422016.N().S("`")
|
||||
//line templates/extra.qtpl:69
|
||||
//line templates/extra.qtpl:72
|
||||
qw422016.N().S(`']`)
|
||||
//line templates/extra.qtpl:69
|
||||
//line templates/extra.qtpl:72
|
||||
qw422016.N().S("`")
|
||||
//line templates/extra.qtpl:69
|
||||
//line templates/extra.qtpl:72
|
||||
qw422016.N().S(`
|
||||
|
||||
case n.Parent != nil:
|
||||
|
@ -302,137 +305,140 @@ func (ns NodeState) String() string {
|
|||
}
|
||||
return "[" + strings.Join(s, " ") + "]"
|
||||
}
|
||||
|
||||
// EmptyNodeID is the "non-existent" node id.
|
||||
const EmptyNodeID = NodeID(0)
|
||||
`)
|
||||
//line templates/extra.qtpl:180
|
||||
//line templates/extra.qtpl:186
|
||||
}
|
||||
|
||||
//line templates/extra.qtpl:180
|
||||
//line templates/extra.qtpl:186
|
||||
func WriteExtraNodeTemplate(qq422016 qtio422016.Writer) {
|
||||
//line templates/extra.qtpl:180
|
||||
//line templates/extra.qtpl:186
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line templates/extra.qtpl:180
|
||||
//line templates/extra.qtpl:186
|
||||
StreamExtraNodeTemplate(qw422016)
|
||||
//line templates/extra.qtpl:180
|
||||
//line templates/extra.qtpl:186
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line templates/extra.qtpl:180
|
||||
//line templates/extra.qtpl:186
|
||||
}
|
||||
|
||||
//line templates/extra.qtpl:180
|
||||
//line templates/extra.qtpl:186
|
||||
func ExtraNodeTemplate() string {
|
||||
//line templates/extra.qtpl:180
|
||||
//line templates/extra.qtpl:186
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line templates/extra.qtpl:180
|
||||
//line templates/extra.qtpl:186
|
||||
WriteExtraNodeTemplate(qb422016)
|
||||
//line templates/extra.qtpl:180
|
||||
//line templates/extra.qtpl:186
|
||||
qs422016 := string(qb422016.B)
|
||||
//line templates/extra.qtpl:180
|
||||
//line templates/extra.qtpl:186
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line templates/extra.qtpl:180
|
||||
//line templates/extra.qtpl:186
|
||||
return qs422016
|
||||
//line templates/extra.qtpl:180
|
||||
//line templates/extra.qtpl:186
|
||||
}
|
||||
|
||||
// ExtraFixStringUnmarshaler is a template that forces values to be parsed properly.
|
||||
|
||||
//line templates/extra.qtpl:183
|
||||
//line templates/extra.qtpl:189
|
||||
func StreamExtraFixStringUnmarshaler(qw422016 *qt422016.Writer, typ, parseFunc, extra string) {
|
||||
//line templates/extra.qtpl:183
|
||||
//line templates/extra.qtpl:189
|
||||
qw422016.N().S(`
|
||||
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
|
||||
func (t *`)
|
||||
//line templates/extra.qtpl:185
|
||||
//line templates/extra.qtpl:191
|
||||
qw422016.N().S(typ)
|
||||
//line templates/extra.qtpl:185
|
||||
//line templates/extra.qtpl:191
|
||||
qw422016.N().S(`) UnmarshalEasyJSON(in *jlexer.Lexer) {
|
||||
buf := in.Raw()
|
||||
if l := len(buf); l > 2 && buf[0] == '"' && buf[l-1] == '"' {
|
||||
buf = buf[1:l-1]
|
||||
}
|
||||
`)
|
||||
//line templates/extra.qtpl:190
|
||||
//line templates/extra.qtpl:196
|
||||
if parseFunc != "" {
|
||||
//line templates/extra.qtpl:190
|
||||
//line templates/extra.qtpl:196
|
||||
qw422016.N().S(`
|
||||
v, err := strconv.`)
|
||||
//line templates/extra.qtpl:191
|
||||
//line templates/extra.qtpl:197
|
||||
qw422016.N().S(parseFunc)
|
||||
//line templates/extra.qtpl:191
|
||||
//line templates/extra.qtpl:197
|
||||
qw422016.N().S(`(string(buf)`)
|
||||
//line templates/extra.qtpl:191
|
||||
//line templates/extra.qtpl:197
|
||||
qw422016.N().S(extra)
|
||||
//line templates/extra.qtpl:191
|
||||
//line templates/extra.qtpl:197
|
||||
qw422016.N().S(`)
|
||||
if err != nil {
|
||||
in.AddError(err)
|
||||
}
|
||||
`)
|
||||
//line templates/extra.qtpl:195
|
||||
//line templates/extra.qtpl:201
|
||||
}
|
||||
//line templates/extra.qtpl:195
|
||||
//line templates/extra.qtpl:201
|
||||
qw422016.N().S(`
|
||||
*t = `)
|
||||
//line templates/extra.qtpl:196
|
||||
//line templates/extra.qtpl:202
|
||||
qw422016.N().S(typ)
|
||||
//line templates/extra.qtpl:196
|
||||
//line templates/extra.qtpl:202
|
||||
qw422016.N().S(`(`)
|
||||
//line templates/extra.qtpl:196
|
||||
//line templates/extra.qtpl:202
|
||||
if parseFunc != "" {
|
||||
//line templates/extra.qtpl:196
|
||||
//line templates/extra.qtpl:202
|
||||
qw422016.N().S(`v`)
|
||||
//line templates/extra.qtpl:196
|
||||
//line templates/extra.qtpl:202
|
||||
} else {
|
||||
//line templates/extra.qtpl:196
|
||||
//line templates/extra.qtpl:202
|
||||
qw422016.N().S(`buf`)
|
||||
//line templates/extra.qtpl:196
|
||||
//line templates/extra.qtpl:202
|
||||
}
|
||||
//line templates/extra.qtpl:196
|
||||
//line templates/extra.qtpl:202
|
||||
qw422016.N().S(`)
|
||||
}
|
||||
|
||||
// UnmarshalJSON satisfies json.Unmarshaler.
|
||||
func (t *`)
|
||||
//line templates/extra.qtpl:200
|
||||
//line templates/extra.qtpl:206
|
||||
qw422016.N().S(typ)
|
||||
//line templates/extra.qtpl:200
|
||||
//line templates/extra.qtpl:206
|
||||
qw422016.N().S(`) UnmarshalJSON(buf []byte) error {
|
||||
return easyjson.Unmarshal(buf, t)
|
||||
}
|
||||
`)
|
||||
//line templates/extra.qtpl:203
|
||||
//line templates/extra.qtpl:209
|
||||
}
|
||||
|
||||
//line templates/extra.qtpl:203
|
||||
//line templates/extra.qtpl:209
|
||||
func WriteExtraFixStringUnmarshaler(qq422016 qtio422016.Writer, typ, parseFunc, extra string) {
|
||||
//line templates/extra.qtpl:203
|
||||
//line templates/extra.qtpl:209
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line templates/extra.qtpl:203
|
||||
//line templates/extra.qtpl:209
|
||||
StreamExtraFixStringUnmarshaler(qw422016, typ, parseFunc, extra)
|
||||
//line templates/extra.qtpl:203
|
||||
//line templates/extra.qtpl:209
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line templates/extra.qtpl:203
|
||||
//line templates/extra.qtpl:209
|
||||
}
|
||||
|
||||
//line templates/extra.qtpl:203
|
||||
//line templates/extra.qtpl:209
|
||||
func ExtraFixStringUnmarshaler(typ, parseFunc, extra string) string {
|
||||
//line templates/extra.qtpl:203
|
||||
//line templates/extra.qtpl:209
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line templates/extra.qtpl:203
|
||||
//line templates/extra.qtpl:209
|
||||
WriteExtraFixStringUnmarshaler(qb422016, typ, parseFunc, extra)
|
||||
//line templates/extra.qtpl:203
|
||||
//line templates/extra.qtpl:209
|
||||
qs422016 := string(qb422016.B)
|
||||
//line templates/extra.qtpl:203
|
||||
//line templates/extra.qtpl:209
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line templates/extra.qtpl:203
|
||||
//line templates/extra.qtpl:209
|
||||
return qs422016
|
||||
//line templates/extra.qtpl:203
|
||||
//line templates/extra.qtpl:209
|
||||
}
|
||||
|
||||
// ExtraExceptionDetailsTemplate is a special template for the Runtime.ExceptionDetails type that
|
||||
// defines the standard error interface.
|
||||
|
||||
//line templates/extra.qtpl:207
|
||||
//line templates/extra.qtpl:213
|
||||
func StreamExtraExceptionDetailsTemplate(qw422016 *qt422016.Writer) {
|
||||
//line templates/extra.qtpl:207
|
||||
//line templates/extra.qtpl:213
|
||||
qw422016.N().S(`
|
||||
// Error satisfies the error interface.
|
||||
func (e *ExceptionDetails) Error() string {
|
||||
|
@ -441,41 +447,41 @@ func (e *ExceptionDetails) Error() string {
|
|||
return fmt.Sprintf("encountered exception '%s' (%d:%d)", e.Text, e.LineNumber, e.ColumnNumber)
|
||||
}
|
||||
`)
|
||||
//line templates/extra.qtpl:214
|
||||
//line templates/extra.qtpl:220
|
||||
}
|
||||
|
||||
//line templates/extra.qtpl:214
|
||||
//line templates/extra.qtpl:220
|
||||
func WriteExtraExceptionDetailsTemplate(qq422016 qtio422016.Writer) {
|
||||
//line templates/extra.qtpl:214
|
||||
//line templates/extra.qtpl:220
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line templates/extra.qtpl:214
|
||||
//line templates/extra.qtpl:220
|
||||
StreamExtraExceptionDetailsTemplate(qw422016)
|
||||
//line templates/extra.qtpl:214
|
||||
//line templates/extra.qtpl:220
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line templates/extra.qtpl:214
|
||||
//line templates/extra.qtpl:220
|
||||
}
|
||||
|
||||
//line templates/extra.qtpl:214
|
||||
//line templates/extra.qtpl:220
|
||||
func ExtraExceptionDetailsTemplate() string {
|
||||
//line templates/extra.qtpl:214
|
||||
//line templates/extra.qtpl:220
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line templates/extra.qtpl:214
|
||||
//line templates/extra.qtpl:220
|
||||
WriteExtraExceptionDetailsTemplate(qb422016)
|
||||
//line templates/extra.qtpl:214
|
||||
//line templates/extra.qtpl:220
|
||||
qs422016 := string(qb422016.B)
|
||||
//line templates/extra.qtpl:214
|
||||
//line templates/extra.qtpl:220
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line templates/extra.qtpl:214
|
||||
//line templates/extra.qtpl:220
|
||||
return qs422016
|
||||
//line templates/extra.qtpl:214
|
||||
//line templates/extra.qtpl:220
|
||||
}
|
||||
|
||||
// ExtraCDPTypes is the template for additional internal type
|
||||
// declarations.
|
||||
|
||||
//line templates/extra.qtpl:218
|
||||
//line templates/extra.qtpl:224
|
||||
func StreamExtraCDPTypes(qw422016 *qt422016.Writer) {
|
||||
//line templates/extra.qtpl:218
|
||||
//line templates/extra.qtpl:224
|
||||
qw422016.N().S(`
|
||||
|
||||
// Error satisfies the error interface.
|
||||
|
@ -509,40 +515,40 @@ type Handler interface {
|
|||
Release(<-chan interface{})
|
||||
}
|
||||
`)
|
||||
//line templates/extra.qtpl:250
|
||||
//line templates/extra.qtpl:256
|
||||
}
|
||||
|
||||
//line templates/extra.qtpl:250
|
||||
//line templates/extra.qtpl:256
|
||||
func WriteExtraCDPTypes(qq422016 qtio422016.Writer) {
|
||||
//line templates/extra.qtpl:250
|
||||
//line templates/extra.qtpl:256
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line templates/extra.qtpl:250
|
||||
//line templates/extra.qtpl:256
|
||||
StreamExtraCDPTypes(qw422016)
|
||||
//line templates/extra.qtpl:250
|
||||
//line templates/extra.qtpl:256
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line templates/extra.qtpl:250
|
||||
//line templates/extra.qtpl:256
|
||||
}
|
||||
|
||||
//line templates/extra.qtpl:250
|
||||
//line templates/extra.qtpl:256
|
||||
func ExtraCDPTypes() string {
|
||||
//line templates/extra.qtpl:250
|
||||
//line templates/extra.qtpl:256
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line templates/extra.qtpl:250
|
||||
//line templates/extra.qtpl:256
|
||||
WriteExtraCDPTypes(qb422016)
|
||||
//line templates/extra.qtpl:250
|
||||
//line templates/extra.qtpl:256
|
||||
qs422016 := string(qb422016.B)
|
||||
//line templates/extra.qtpl:250
|
||||
//line templates/extra.qtpl:256
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line templates/extra.qtpl:250
|
||||
//line templates/extra.qtpl:256
|
||||
return qs422016
|
||||
//line templates/extra.qtpl:250
|
||||
//line templates/extra.qtpl:256
|
||||
}
|
||||
|
||||
// ExtraUtilTemplate generates the decode func for the Message type.
|
||||
|
||||
//line templates/extra.qtpl:253
|
||||
//line templates/extra.qtpl:259
|
||||
func StreamExtraUtilTemplate(qw422016 *qt422016.Writer, domains []*internal.Domain) {
|
||||
//line templates/extra.qtpl:253
|
||||
//line templates/extra.qtpl:259
|
||||
qw422016.N().S(`
|
||||
type empty struct{}
|
||||
var emptyVal = &empty{}
|
||||
|
@ -551,66 +557,66 @@ var emptyVal = &empty{}
|
|||
func UnmarshalMessage(msg *cdp.Message) (interface{}, error) {
|
||||
var v easyjson.Unmarshaler
|
||||
switch msg.Method {`)
|
||||
//line templates/extra.qtpl:260
|
||||
//line templates/extra.qtpl:266
|
||||
for _, d := range domains {
|
||||
//line templates/extra.qtpl:260
|
||||
//line templates/extra.qtpl:266
|
||||
for _, c := range d.Commands {
|
||||
//line templates/extra.qtpl:260
|
||||
//line templates/extra.qtpl:266
|
||||
qw422016.N().S(`
|
||||
case cdp.`)
|
||||
//line templates/extra.qtpl:261
|
||||
//line templates/extra.qtpl:267
|
||||
qw422016.N().S(c.CommandMethodType(d))
|
||||
//line templates/extra.qtpl:261
|
||||
//line templates/extra.qtpl:267
|
||||
qw422016.N().S(`:`)
|
||||
//line templates/extra.qtpl:261
|
||||
//line templates/extra.qtpl:267
|
||||
if len(c.Returns) == 0 {
|
||||
//line templates/extra.qtpl:261
|
||||
//line templates/extra.qtpl:267
|
||||
qw422016.N().S(`
|
||||
return emptyVal, nil`)
|
||||
//line templates/extra.qtpl:262
|
||||
//line templates/extra.qtpl:268
|
||||
} else {
|
||||
//line templates/extra.qtpl:262
|
||||
//line templates/extra.qtpl:268
|
||||
qw422016.N().S(`
|
||||
v = new(`)
|
||||
//line templates/extra.qtpl:263
|
||||
//line templates/extra.qtpl:269
|
||||
qw422016.N().S(d.PackageRefName())
|
||||
//line templates/extra.qtpl:263
|
||||
//line templates/extra.qtpl:269
|
||||
qw422016.N().S(`.`)
|
||||
//line templates/extra.qtpl:263
|
||||
//line templates/extra.qtpl:269
|
||||
qw422016.N().S(c.CommandReturnsType())
|
||||
//line templates/extra.qtpl:263
|
||||
//line templates/extra.qtpl:269
|
||||
qw422016.N().S(`)`)
|
||||
//line templates/extra.qtpl:263
|
||||
//line templates/extra.qtpl:269
|
||||
}
|
||||
//line templates/extra.qtpl:263
|
||||
//line templates/extra.qtpl:269
|
||||
qw422016.N().S(`
|
||||
`)
|
||||
//line templates/extra.qtpl:264
|
||||
//line templates/extra.qtpl:270
|
||||
}
|
||||
//line templates/extra.qtpl:264
|
||||
//line templates/extra.qtpl:270
|
||||
for _, e := range d.Events {
|
||||
//line templates/extra.qtpl:264
|
||||
//line templates/extra.qtpl:270
|
||||
qw422016.N().S(`
|
||||
case cdp.`)
|
||||
//line templates/extra.qtpl:265
|
||||
//line templates/extra.qtpl:271
|
||||
qw422016.N().S(e.EventMethodType(d))
|
||||
//line templates/extra.qtpl:265
|
||||
//line templates/extra.qtpl:271
|
||||
qw422016.N().S(`:
|
||||
v = new(`)
|
||||
//line templates/extra.qtpl:266
|
||||
//line templates/extra.qtpl:272
|
||||
qw422016.N().S(d.PackageRefName())
|
||||
//line templates/extra.qtpl:266
|
||||
//line templates/extra.qtpl:272
|
||||
qw422016.N().S(`.`)
|
||||
//line templates/extra.qtpl:266
|
||||
//line templates/extra.qtpl:272
|
||||
qw422016.N().S(e.EventType())
|
||||
//line templates/extra.qtpl:266
|
||||
//line templates/extra.qtpl:272
|
||||
qw422016.N().S(`)
|
||||
`)
|
||||
//line templates/extra.qtpl:267
|
||||
//line templates/extra.qtpl:273
|
||||
}
|
||||
//line templates/extra.qtpl:267
|
||||
//line templates/extra.qtpl:273
|
||||
}
|
||||
//line templates/extra.qtpl:267
|
||||
//line templates/extra.qtpl:273
|
||||
qw422016.N().S(`}
|
||||
|
||||
var buf easyjson.RawMessage
|
||||
|
@ -633,69 +639,69 @@ func UnmarshalMessage(msg *cdp.Message) (interface{}, error) {
|
|||
return v, nil
|
||||
}
|
||||
`)
|
||||
//line templates/extra.qtpl:288
|
||||
//line templates/extra.qtpl:294
|
||||
}
|
||||
|
||||
//line templates/extra.qtpl:288
|
||||
//line templates/extra.qtpl:294
|
||||
func WriteExtraUtilTemplate(qq422016 qtio422016.Writer, domains []*internal.Domain) {
|
||||
//line templates/extra.qtpl:288
|
||||
//line templates/extra.qtpl:294
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line templates/extra.qtpl:288
|
||||
//line templates/extra.qtpl:294
|
||||
StreamExtraUtilTemplate(qw422016, domains)
|
||||
//line templates/extra.qtpl:288
|
||||
//line templates/extra.qtpl:294
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line templates/extra.qtpl:288
|
||||
//line templates/extra.qtpl:294
|
||||
}
|
||||
|
||||
//line templates/extra.qtpl:288
|
||||
//line templates/extra.qtpl:294
|
||||
func ExtraUtilTemplate(domains []*internal.Domain) string {
|
||||
//line templates/extra.qtpl:288
|
||||
//line templates/extra.qtpl:294
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line templates/extra.qtpl:288
|
||||
//line templates/extra.qtpl:294
|
||||
WriteExtraUtilTemplate(qb422016, domains)
|
||||
//line templates/extra.qtpl:288
|
||||
//line templates/extra.qtpl:294
|
||||
qs422016 := string(qb422016.B)
|
||||
//line templates/extra.qtpl:288
|
||||
//line templates/extra.qtpl:294
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line templates/extra.qtpl:288
|
||||
//line templates/extra.qtpl:294
|
||||
return qs422016
|
||||
//line templates/extra.qtpl:288
|
||||
//line templates/extra.qtpl:294
|
||||
}
|
||||
|
||||
//line templates/extra.qtpl:290
|
||||
//line templates/extra.qtpl:296
|
||||
func StreamExtraMethodTypeDomainDecoder(qw422016 *qt422016.Writer) {
|
||||
//line templates/extra.qtpl:290
|
||||
//line templates/extra.qtpl:296
|
||||
qw422016.N().S(`
|
||||
// Domain returns the Chrome Debugging Protocol domain of the event or command.
|
||||
func (t MethodType) Domain() string {
|
||||
return string(t[:strings.IndexByte(string(t), '.')])
|
||||
}
|
||||
`)
|
||||
//line templates/extra.qtpl:295
|
||||
//line templates/extra.qtpl:301
|
||||
}
|
||||
|
||||
//line templates/extra.qtpl:295
|
||||
//line templates/extra.qtpl:301
|
||||
func WriteExtraMethodTypeDomainDecoder(qq422016 qtio422016.Writer) {
|
||||
//line templates/extra.qtpl:295
|
||||
//line templates/extra.qtpl:301
|
||||
qw422016 := qt422016.AcquireWriter(qq422016)
|
||||
//line templates/extra.qtpl:295
|
||||
//line templates/extra.qtpl:301
|
||||
StreamExtraMethodTypeDomainDecoder(qw422016)
|
||||
//line templates/extra.qtpl:295
|
||||
//line templates/extra.qtpl:301
|
||||
qt422016.ReleaseWriter(qw422016)
|
||||
//line templates/extra.qtpl:295
|
||||
//line templates/extra.qtpl:301
|
||||
}
|
||||
|
||||
//line templates/extra.qtpl:295
|
||||
//line templates/extra.qtpl:301
|
||||
func ExtraMethodTypeDomainDecoder() string {
|
||||
//line templates/extra.qtpl:295
|
||||
//line templates/extra.qtpl:301
|
||||
qb422016 := qt422016.AcquireByteBuffer()
|
||||
//line templates/extra.qtpl:295
|
||||
//line templates/extra.qtpl:301
|
||||
WriteExtraMethodTypeDomainDecoder(qb422016)
|
||||
//line templates/extra.qtpl:295
|
||||
//line templates/extra.qtpl:301
|
||||
qs422016 := string(qb422016.B)
|
||||
//line templates/extra.qtpl:295
|
||||
//line templates/extra.qtpl:301
|
||||
qt422016.ReleaseByteBuffer(qb422016)
|
||||
//line templates/extra.qtpl:295
|
||||
//line templates/extra.qtpl:301
|
||||
return qs422016
|
||||
//line templates/extra.qtpl:295
|
||||
//line templates/extra.qtpl:301
|
||||
}
|
||||
|
|
11
handler.go
11
handler.go
|
@ -12,6 +12,7 @@ import (
|
|||
"github.com/mailru/easyjson"
|
||||
|
||||
"github.com/knq/chromedp/cdp"
|
||||
"github.com/knq/chromedp/cdp/cdputil"
|
||||
"github.com/knq/chromedp/cdp/css"
|
||||
"github.com/knq/chromedp/cdp/dom"
|
||||
"github.com/knq/chromedp/cdp/inspector"
|
||||
|
@ -230,7 +231,7 @@ func (h *TargetHandler) processEvent(ctxt context.Context, msg *cdp.Message) err
|
|||
}
|
||||
|
||||
// unmarshal
|
||||
ev, err := UnmarshalMessage(msg)
|
||||
ev, err := cdputil.UnmarshalMessage(msg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -269,7 +270,7 @@ func (h *TargetHandler) processEvent(ctxt context.Context, msg *cdp.Message) err
|
|||
// documentUpdated handles the document updated event, retrieving the document
|
||||
// root for the root frame.
|
||||
func (h *TargetHandler) documentUpdated(ctxt context.Context) {
|
||||
f, err := h.WaitFrame(ctxt, EmptyFrameID)
|
||||
f, err := h.WaitFrame(ctxt, cdp.EmptyFrameID)
|
||||
if err != nil {
|
||||
h.errorf("could not get current frame: %v", err)
|
||||
return
|
||||
|
@ -459,7 +460,7 @@ loop:
|
|||
var ok bool
|
||||
|
||||
h.RLock()
|
||||
if id == EmptyFrameID {
|
||||
if id == cdp.EmptyFrameID {
|
||||
f, ok = h.cur, h.cur != nil
|
||||
} else {
|
||||
f, ok = h.frames[id]
|
||||
|
@ -580,7 +581,7 @@ func (h *TargetHandler) domEvent(ctxt context.Context, ev interface{}) {
|
|||
defer h.domWaitGroup.Done()
|
||||
|
||||
// wait current frame
|
||||
f, err := h.WaitFrame(ctxt, EmptyFrameID)
|
||||
f, err := h.WaitFrame(ctxt, cdp.EmptyFrameID)
|
||||
if err != nil {
|
||||
h.errorf("could not process DOM event %s: %v", reflect.TypeOf(ev), err)
|
||||
return
|
||||
|
@ -609,7 +610,7 @@ func (h *TargetHandler) domEvent(ctxt context.Context, ev interface{}) {
|
|||
id, op = e.NodeID, childNodeCountUpdated(e.ChildNodeCount)
|
||||
|
||||
case *dom.EventChildNodeInserted:
|
||||
if e.PreviousNodeID != EmptyNodeID {
|
||||
if e.PreviousNodeID != cdp.EmptyNodeID {
|
||||
_, err = h.WaitNode(ctxt, f, e.PreviousNodeID)
|
||||
if err != nil {
|
||||
return
|
||||
|
|
|
@ -343,7 +343,7 @@ var nameRE = regexp.MustCompile(`[A-Z][a-z]+:`)
|
|||
func processKeys(keys map[rune]kb.Key) ([]byte, []byte, error) {
|
||||
// order rune keys
|
||||
idx := make([]rune, len(keys))
|
||||
i := 0
|
||||
var i int
|
||||
for c := range keys {
|
||||
idx[i] = c
|
||||
i++
|
||||
|
|
2
nav.go
2
nav.go
|
@ -47,7 +47,7 @@ func NavigateBack(ctxt context.Context, h cdp.Handler) error {
|
|||
return err
|
||||
}
|
||||
|
||||
i := 0
|
||||
var i int
|
||||
for ; i < len(entries); i++ {
|
||||
if entries[i].ID == cur {
|
||||
break
|
||||
|
|
3
query.go
3
query.go
|
@ -236,8 +236,7 @@ func SetAttributes(sel interface{}, attributes map[string]string, opts ...QueryO
|
|||
return errors.New("expected at least one element")
|
||||
}
|
||||
|
||||
attrs := make([]string, len(attributes))
|
||||
i := 0
|
||||
i, attrs := 0, make([]string, len(attributes))
|
||||
for k, v := range attributes {
|
||||
attrs[i] = fmt.Sprintf(`%s=%s`, k, strconv.Quote(v))
|
||||
i++
|
||||
|
|
4
sel.go
4
sel.go
|
@ -164,7 +164,7 @@ func ByQuery(s *Selector) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
if nodeID == EmptyNodeID {
|
||||
if nodeID == cdp.EmptyNodeID {
|
||||
return []cdp.NodeID{}, nil
|
||||
}
|
||||
|
||||
|
@ -230,7 +230,7 @@ func ByNodeID(s *Selector) {
|
|||
// waitReady waits for the specified nodes to be ready.
|
||||
func (s *Selector) waitReady(check func(context.Context, cdp.Handler, *cdp.Node) error) func(context.Context, cdp.Handler, *cdp.Node, ...cdp.NodeID) ([]*cdp.Node, error) {
|
||||
return func(ctxt context.Context, h cdp.Handler, n *cdp.Node, ids ...cdp.NodeID) ([]*cdp.Node, error) {
|
||||
f, err := h.WaitFrame(ctxt, EmptyFrameID)
|
||||
f, err := h.WaitFrame(ctxt, cdp.EmptyFrameID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
20
util.go
20
util.go
|
@ -4,7 +4,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/knq/chromedp/cdp"
|
||||
"github.com/knq/chromedp/cdp/util"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -21,12 +20,6 @@ const (
|
|||
// DefaultPoolEndPort is the default end port number.
|
||||
DefaultPoolEndPort = 10000
|
||||
|
||||
// EmptyFrameID is the "non-existent" (ie current) frame.
|
||||
EmptyFrameID cdp.FrameID = cdp.FrameID("")
|
||||
|
||||
// EmptyNodeID is the "non-existent" node id.
|
||||
EmptyNodeID cdp.NodeID = cdp.NodeID(0)
|
||||
|
||||
// textJS is a javascript snippet that returns the concatenated textContent
|
||||
// of all visible (ie, offsetParent !== null) children.
|
||||
textJS = `(function(a) {
|
||||
|
@ -98,11 +91,6 @@ const (
|
|||
})($x('%s'))`
|
||||
)
|
||||
|
||||
// UnmarshalMessage unmarshals the message result or params.
|
||||
func UnmarshalMessage(msg *cdp.Message) (interface{}, error) {
|
||||
return util.UnmarshalMessage(msg)
|
||||
}
|
||||
|
||||
// frameOp is a frame manipulation operation.
|
||||
type frameOp func(*cdp.Frame)
|
||||
|
||||
|
@ -124,7 +112,7 @@ func frameAttached(id cdp.FrameID) frameOp {
|
|||
}*/
|
||||
|
||||
func frameDetached(f *cdp.Frame) {
|
||||
f.ParentID = EmptyFrameID
|
||||
f.ParentID = cdp.EmptyFrameID
|
||||
clearFrameState(f, cdp.FrameAttached)
|
||||
}
|
||||
|
||||
|
@ -353,8 +341,8 @@ func nodeHighlightRequested(n *cdp.Node) {
|
|||
}
|
||||
|
||||
func insertNode(n []*cdp.Node, prevID cdp.NodeID, c *cdp.Node) []*cdp.Node {
|
||||
i := 0
|
||||
found := false
|
||||
var i int
|
||||
var found bool
|
||||
for ; i < len(n); i++ {
|
||||
if n[i].NodeID == prevID {
|
||||
found = true
|
||||
|
@ -380,7 +368,7 @@ func removeNode(n []*cdp.Node, id cdp.NodeID) []*cdp.Node {
|
|||
}
|
||||
|
||||
var found bool
|
||||
i := 0
|
||||
var i int
|
||||
for ; i < len(n); i++ {
|
||||
if n[i].NodeID == id {
|
||||
found = true
|
||||
|
|
Loading…
Reference in New Issue
Block a user