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