layertree.go 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. // Package layertree provides the Chrome DevTools Protocol
  2. // commands, types, and events for the LayerTree domain.
  3. //
  4. // Generated by the cdproto-gen command.
  5. package layertree
  6. // Code generated by cdproto-gen. DO NOT EDIT.
  7. import (
  8. "context"
  9. "github.com/chromedp/cdproto/cdp"
  10. "github.com/chromedp/cdproto/dom"
  11. "github.com/mailru/easyjson"
  12. )
  13. // CompositingReasonsParams provides the reasons why the given layer was
  14. // composited.
  15. type CompositingReasonsParams struct {
  16. LayerID LayerID `json:"layerId"` // The id of the layer for which we want to get the reasons it was composited.
  17. }
  18. // CompositingReasons provides the reasons why the given layer was
  19. // composited.
  20. //
  21. // See: https://chromedevtools.github.io/devtools-protocol/tot/LayerTree#method-compositingReasons
  22. //
  23. // parameters:
  24. //
  25. // layerID - The id of the layer for which we want to get the reasons it was composited.
  26. func CompositingReasons(layerID LayerID) *CompositingReasonsParams {
  27. return &CompositingReasonsParams{
  28. LayerID: layerID,
  29. }
  30. }
  31. // CompositingReasonsReturns return values.
  32. type CompositingReasonsReturns struct {
  33. CompositingReasons []string `json:"compositingReasons,omitempty"` // A list of strings specifying reasons for the given layer to become composited.
  34. CompositingReasonIDs []string `json:"compositingReasonIds,omitempty"` // A list of strings specifying reason IDs for the given layer to become composited.
  35. }
  36. // Do executes LayerTree.compositingReasons against the provided context.
  37. //
  38. // returns:
  39. //
  40. // compositingReasons - A list of strings specifying reasons for the given layer to become composited.
  41. // compositingReasonIDs - A list of strings specifying reason IDs for the given layer to become composited.
  42. func (p *CompositingReasonsParams) Do(ctx context.Context) (compositingReasons []string, compositingReasonIDs []string, err error) {
  43. // execute
  44. var res CompositingReasonsReturns
  45. err = cdp.Execute(ctx, CommandCompositingReasons, p, &res)
  46. if err != nil {
  47. return nil, nil, err
  48. }
  49. return res.CompositingReasons, res.CompositingReasonIDs, nil
  50. }
  51. // DisableParams disables compositing tree inspection.
  52. type DisableParams struct{}
  53. // Disable disables compositing tree inspection.
  54. //
  55. // See: https://chromedevtools.github.io/devtools-protocol/tot/LayerTree#method-disable
  56. func Disable() *DisableParams {
  57. return &DisableParams{}
  58. }
  59. // Do executes LayerTree.disable against the provided context.
  60. func (p *DisableParams) Do(ctx context.Context) (err error) {
  61. return cdp.Execute(ctx, CommandDisable, nil, nil)
  62. }
  63. // EnableParams enables compositing tree inspection.
  64. type EnableParams struct{}
  65. // Enable enables compositing tree inspection.
  66. //
  67. // See: https://chromedevtools.github.io/devtools-protocol/tot/LayerTree#method-enable
  68. func Enable() *EnableParams {
  69. return &EnableParams{}
  70. }
  71. // Do executes LayerTree.enable against the provided context.
  72. func (p *EnableParams) Do(ctx context.Context) (err error) {
  73. return cdp.Execute(ctx, CommandEnable, nil, nil)
  74. }
  75. // LoadSnapshotParams returns the snapshot identifier.
  76. type LoadSnapshotParams struct {
  77. Tiles []*PictureTile `json:"tiles"` // An array of tiles composing the snapshot.
  78. }
  79. // LoadSnapshot returns the snapshot identifier.
  80. //
  81. // See: https://chromedevtools.github.io/devtools-protocol/tot/LayerTree#method-loadSnapshot
  82. //
  83. // parameters:
  84. //
  85. // tiles - An array of tiles composing the snapshot.
  86. func LoadSnapshot(tiles []*PictureTile) *LoadSnapshotParams {
  87. return &LoadSnapshotParams{
  88. Tiles: tiles,
  89. }
  90. }
  91. // LoadSnapshotReturns return values.
  92. type LoadSnapshotReturns struct {
  93. SnapshotID SnapshotID `json:"snapshotId,omitempty"` // The id of the snapshot.
  94. }
  95. // Do executes LayerTree.loadSnapshot against the provided context.
  96. //
  97. // returns:
  98. //
  99. // snapshotID - The id of the snapshot.
  100. func (p *LoadSnapshotParams) Do(ctx context.Context) (snapshotID SnapshotID, err error) {
  101. // execute
  102. var res LoadSnapshotReturns
  103. err = cdp.Execute(ctx, CommandLoadSnapshot, p, &res)
  104. if err != nil {
  105. return "", err
  106. }
  107. return res.SnapshotID, nil
  108. }
  109. // MakeSnapshotParams returns the layer snapshot identifier.
  110. type MakeSnapshotParams struct {
  111. LayerID LayerID `json:"layerId"` // The id of the layer.
  112. }
  113. // MakeSnapshot returns the layer snapshot identifier.
  114. //
  115. // See: https://chromedevtools.github.io/devtools-protocol/tot/LayerTree#method-makeSnapshot
  116. //
  117. // parameters:
  118. //
  119. // layerID - The id of the layer.
  120. func MakeSnapshot(layerID LayerID) *MakeSnapshotParams {
  121. return &MakeSnapshotParams{
  122. LayerID: layerID,
  123. }
  124. }
  125. // MakeSnapshotReturns return values.
  126. type MakeSnapshotReturns struct {
  127. SnapshotID SnapshotID `json:"snapshotId,omitempty"` // The id of the layer snapshot.
  128. }
  129. // Do executes LayerTree.makeSnapshot against the provided context.
  130. //
  131. // returns:
  132. //
  133. // snapshotID - The id of the layer snapshot.
  134. func (p *MakeSnapshotParams) Do(ctx context.Context) (snapshotID SnapshotID, err error) {
  135. // execute
  136. var res MakeSnapshotReturns
  137. err = cdp.Execute(ctx, CommandMakeSnapshot, p, &res)
  138. if err != nil {
  139. return "", err
  140. }
  141. return res.SnapshotID, nil
  142. }
  143. // ProfileSnapshotParams [no description].
  144. type ProfileSnapshotParams struct {
  145. SnapshotID SnapshotID `json:"snapshotId"` // The id of the layer snapshot.
  146. MinRepeatCount int64 `json:"minRepeatCount,omitempty"` // The maximum number of times to replay the snapshot (1, if not specified).
  147. MinDuration float64 `json:"minDuration,omitempty"` // The minimum duration (in seconds) to replay the snapshot.
  148. ClipRect *dom.Rect `json:"clipRect,omitempty"` // The clip rectangle to apply when replaying the snapshot.
  149. }
  150. // ProfileSnapshot [no description].
  151. //
  152. // See: https://chromedevtools.github.io/devtools-protocol/tot/LayerTree#method-profileSnapshot
  153. //
  154. // parameters:
  155. //
  156. // snapshotID - The id of the layer snapshot.
  157. func ProfileSnapshot(snapshotID SnapshotID) *ProfileSnapshotParams {
  158. return &ProfileSnapshotParams{
  159. SnapshotID: snapshotID,
  160. }
  161. }
  162. // WithMinRepeatCount the maximum number of times to replay the snapshot (1,
  163. // if not specified).
  164. func (p ProfileSnapshotParams) WithMinRepeatCount(minRepeatCount int64) *ProfileSnapshotParams {
  165. p.MinRepeatCount = minRepeatCount
  166. return &p
  167. }
  168. // WithMinDuration the minimum duration (in seconds) to replay the snapshot.
  169. func (p ProfileSnapshotParams) WithMinDuration(minDuration float64) *ProfileSnapshotParams {
  170. p.MinDuration = minDuration
  171. return &p
  172. }
  173. // WithClipRect the clip rectangle to apply when replaying the snapshot.
  174. func (p ProfileSnapshotParams) WithClipRect(clipRect *dom.Rect) *ProfileSnapshotParams {
  175. p.ClipRect = clipRect
  176. return &p
  177. }
  178. // ProfileSnapshotReturns return values.
  179. type ProfileSnapshotReturns struct {
  180. Timings []PaintProfile `json:"timings,omitempty"` // The array of paint profiles, one per run.
  181. }
  182. // Do executes LayerTree.profileSnapshot against the provided context.
  183. //
  184. // returns:
  185. //
  186. // timings - The array of paint profiles, one per run.
  187. func (p *ProfileSnapshotParams) Do(ctx context.Context) (timings []PaintProfile, err error) {
  188. // execute
  189. var res ProfileSnapshotReturns
  190. err = cdp.Execute(ctx, CommandProfileSnapshot, p, &res)
  191. if err != nil {
  192. return nil, err
  193. }
  194. return res.Timings, nil
  195. }
  196. // ReleaseSnapshotParams releases layer snapshot captured by the back-end.
  197. type ReleaseSnapshotParams struct {
  198. SnapshotID SnapshotID `json:"snapshotId"` // The id of the layer snapshot.
  199. }
  200. // ReleaseSnapshot releases layer snapshot captured by the back-end.
  201. //
  202. // See: https://chromedevtools.github.io/devtools-protocol/tot/LayerTree#method-releaseSnapshot
  203. //
  204. // parameters:
  205. //
  206. // snapshotID - The id of the layer snapshot.
  207. func ReleaseSnapshot(snapshotID SnapshotID) *ReleaseSnapshotParams {
  208. return &ReleaseSnapshotParams{
  209. SnapshotID: snapshotID,
  210. }
  211. }
  212. // Do executes LayerTree.releaseSnapshot against the provided context.
  213. func (p *ReleaseSnapshotParams) Do(ctx context.Context) (err error) {
  214. return cdp.Execute(ctx, CommandReleaseSnapshot, p, nil)
  215. }
  216. // ReplaySnapshotParams replays the layer snapshot and returns the resulting
  217. // bitmap.
  218. type ReplaySnapshotParams struct {
  219. SnapshotID SnapshotID `json:"snapshotId"` // The id of the layer snapshot.
  220. FromStep int64 `json:"fromStep,omitempty"` // The first step to replay from (replay from the very start if not specified).
  221. ToStep int64 `json:"toStep,omitempty"` // The last step to replay to (replay till the end if not specified).
  222. Scale float64 `json:"scale,omitempty"` // The scale to apply while replaying (defaults to 1).
  223. }
  224. // ReplaySnapshot replays the layer snapshot and returns the resulting
  225. // bitmap.
  226. //
  227. // See: https://chromedevtools.github.io/devtools-protocol/tot/LayerTree#method-replaySnapshot
  228. //
  229. // parameters:
  230. //
  231. // snapshotID - The id of the layer snapshot.
  232. func ReplaySnapshot(snapshotID SnapshotID) *ReplaySnapshotParams {
  233. return &ReplaySnapshotParams{
  234. SnapshotID: snapshotID,
  235. }
  236. }
  237. // WithFromStep the first step to replay from (replay from the very start if
  238. // not specified).
  239. func (p ReplaySnapshotParams) WithFromStep(fromStep int64) *ReplaySnapshotParams {
  240. p.FromStep = fromStep
  241. return &p
  242. }
  243. // WithToStep the last step to replay to (replay till the end if not
  244. // specified).
  245. func (p ReplaySnapshotParams) WithToStep(toStep int64) *ReplaySnapshotParams {
  246. p.ToStep = toStep
  247. return &p
  248. }
  249. // WithScale the scale to apply while replaying (defaults to 1).
  250. func (p ReplaySnapshotParams) WithScale(scale float64) *ReplaySnapshotParams {
  251. p.Scale = scale
  252. return &p
  253. }
  254. // ReplaySnapshotReturns return values.
  255. type ReplaySnapshotReturns struct {
  256. DataURL string `json:"dataURL,omitempty"` // A data: URL for resulting image.
  257. }
  258. // Do executes LayerTree.replaySnapshot against the provided context.
  259. //
  260. // returns:
  261. //
  262. // dataURL - A data: URL for resulting image.
  263. func (p *ReplaySnapshotParams) Do(ctx context.Context) (dataURL string, err error) {
  264. // execute
  265. var res ReplaySnapshotReturns
  266. err = cdp.Execute(ctx, CommandReplaySnapshot, p, &res)
  267. if err != nil {
  268. return "", err
  269. }
  270. return res.DataURL, nil
  271. }
  272. // SnapshotCommandLogParams replays the layer snapshot and returns canvas
  273. // log.
  274. type SnapshotCommandLogParams struct {
  275. SnapshotID SnapshotID `json:"snapshotId"` // The id of the layer snapshot.
  276. }
  277. // SnapshotCommandLog replays the layer snapshot and returns canvas log.
  278. //
  279. // See: https://chromedevtools.github.io/devtools-protocol/tot/LayerTree#method-snapshotCommandLog
  280. //
  281. // parameters:
  282. //
  283. // snapshotID - The id of the layer snapshot.
  284. func SnapshotCommandLog(snapshotID SnapshotID) *SnapshotCommandLogParams {
  285. return &SnapshotCommandLogParams{
  286. SnapshotID: snapshotID,
  287. }
  288. }
  289. // SnapshotCommandLogReturns return values.
  290. type SnapshotCommandLogReturns struct {
  291. CommandLog []easyjson.RawMessage `json:"commandLog,omitempty"` // The array of canvas function calls.
  292. }
  293. // Do executes LayerTree.snapshotCommandLog against the provided context.
  294. //
  295. // returns:
  296. //
  297. // commandLog - The array of canvas function calls.
  298. func (p *SnapshotCommandLogParams) Do(ctx context.Context) (commandLog []easyjson.RawMessage, err error) {
  299. // execute
  300. var res SnapshotCommandLogReturns
  301. err = cdp.Execute(ctx, CommandSnapshotCommandLog, p, &res)
  302. if err != nil {
  303. return nil, err
  304. }
  305. return res.CommandLog, nil
  306. }
  307. // Command names.
  308. const (
  309. CommandCompositingReasons = "LayerTree.compositingReasons"
  310. CommandDisable = "LayerTree.disable"
  311. CommandEnable = "LayerTree.enable"
  312. CommandLoadSnapshot = "LayerTree.loadSnapshot"
  313. CommandMakeSnapshot = "LayerTree.makeSnapshot"
  314. CommandProfileSnapshot = "LayerTree.profileSnapshot"
  315. CommandReleaseSnapshot = "LayerTree.releaseSnapshot"
  316. CommandReplaySnapshot = "LayerTree.replaySnapshot"
  317. CommandSnapshotCommandLog = "LayerTree.snapshotCommandLog"
  318. )