css.go 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522
  1. // Package css provides the Chrome DevTools Protocol
  2. // commands, types, and events for the CSS domain.
  3. //
  4. // This domain exposes CSS read/write operations. All CSS objects
  5. // (stylesheets, rules, and styles) have an associated id used in subsequent
  6. // operations on the related object. Each object type has a specific id
  7. // structure, and those are not interchangeable between objects of different
  8. // kinds. CSS objects can be loaded using the get*ForNode() calls (which accept
  9. // a DOM node id). A client can also keep track of stylesheets via the
  10. // styleSheetAdded/styleSheetRemoved events and subsequently load the required
  11. // stylesheet contents using the getStyleSheet[Text]() methods.
  12. //
  13. // Generated by the cdproto-gen command.
  14. package css
  15. // Code generated by cdproto-gen. DO NOT EDIT.
  16. import (
  17. "context"
  18. "github.com/chromedp/cdproto/cdp"
  19. )
  20. // AddRuleParams inserts a new rule with the given ruleText in a stylesheet
  21. // with given styleSheetId, at the position specified by location.
  22. type AddRuleParams struct {
  23. StyleSheetID StyleSheetID `json:"styleSheetId"` // The css style sheet identifier where a new rule should be inserted.
  24. RuleText string `json:"ruleText"` // The text of a new rule.
  25. Location *SourceRange `json:"location"` // Text position of a new rule in the target style sheet.
  26. NodeForPropertySyntaxValidation cdp.NodeID `json:"nodeForPropertySyntaxValidation,omitempty,omitzero"` // NodeId for the DOM node in whose context custom property declarations for registered properties should be validated. If omitted, declarations in the new rule text can only be validated statically, which may produce incorrect results if the declaration contains a var() for example.
  27. }
  28. // AddRule inserts a new rule with the given ruleText in a stylesheet with
  29. // given styleSheetId, at the position specified by location.
  30. //
  31. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-addRule
  32. //
  33. // parameters:
  34. //
  35. // styleSheetID - The css style sheet identifier where a new rule should be inserted.
  36. // ruleText - The text of a new rule.
  37. // location - Text position of a new rule in the target style sheet.
  38. func AddRule(styleSheetID StyleSheetID, ruleText string, location *SourceRange) *AddRuleParams {
  39. return &AddRuleParams{
  40. StyleSheetID: styleSheetID,
  41. RuleText: ruleText,
  42. Location: location,
  43. }
  44. }
  45. // WithNodeForPropertySyntaxValidation nodeId for the DOM node in whose
  46. // context custom property declarations for registered properties should be
  47. // validated. If omitted, declarations in the new rule text can only be
  48. // validated statically, which may produce incorrect results if the declaration
  49. // contains a var() for example.
  50. func (p AddRuleParams) WithNodeForPropertySyntaxValidation(nodeForPropertySyntaxValidation cdp.NodeID) *AddRuleParams {
  51. p.NodeForPropertySyntaxValidation = nodeForPropertySyntaxValidation
  52. return &p
  53. }
  54. // AddRuleReturns return values.
  55. type AddRuleReturns struct {
  56. Rule *Rule `json:"rule,omitempty,omitzero"` // The newly created rule.
  57. }
  58. // Do executes CSS.addRule against the provided context.
  59. //
  60. // returns:
  61. //
  62. // rule - The newly created rule.
  63. func (p *AddRuleParams) Do(ctx context.Context) (rule *Rule, err error) {
  64. // execute
  65. var res AddRuleReturns
  66. err = cdp.Execute(ctx, CommandAddRule, p, &res)
  67. if err != nil {
  68. return nil, err
  69. }
  70. return res.Rule, nil
  71. }
  72. // CollectClassNamesParams returns all class names from specified stylesheet.
  73. type CollectClassNamesParams struct {
  74. StyleSheetID StyleSheetID `json:"styleSheetId"`
  75. }
  76. // CollectClassNames returns all class names from specified stylesheet.
  77. //
  78. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-collectClassNames
  79. //
  80. // parameters:
  81. //
  82. // styleSheetID
  83. func CollectClassNames(styleSheetID StyleSheetID) *CollectClassNamesParams {
  84. return &CollectClassNamesParams{
  85. StyleSheetID: styleSheetID,
  86. }
  87. }
  88. // CollectClassNamesReturns return values.
  89. type CollectClassNamesReturns struct {
  90. ClassNames []string `json:"classNames,omitempty,omitzero"` // Class name list.
  91. }
  92. // Do executes CSS.collectClassNames against the provided context.
  93. //
  94. // returns:
  95. //
  96. // classNames - Class name list.
  97. func (p *CollectClassNamesParams) Do(ctx context.Context) (classNames []string, err error) {
  98. // execute
  99. var res CollectClassNamesReturns
  100. err = cdp.Execute(ctx, CommandCollectClassNames, p, &res)
  101. if err != nil {
  102. return nil, err
  103. }
  104. return res.ClassNames, nil
  105. }
  106. // CreateStyleSheetParams creates a new special "via-inspector" stylesheet in
  107. // the frame with given frameId.
  108. type CreateStyleSheetParams struct {
  109. FrameID cdp.FrameID `json:"frameId"` // Identifier of the frame where "via-inspector" stylesheet should be created.
  110. Force bool `json:"force"` // If true, creates a new stylesheet for every call. If false, returns a stylesheet previously created by a call with force=false for the frame's document if it exists or creates a new stylesheet (default: false).
  111. }
  112. // CreateStyleSheet creates a new special "via-inspector" stylesheet in the
  113. // frame with given frameId.
  114. //
  115. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-createStyleSheet
  116. //
  117. // parameters:
  118. //
  119. // frameID - Identifier of the frame where "via-inspector" stylesheet should be created.
  120. func CreateStyleSheet(frameID cdp.FrameID) *CreateStyleSheetParams {
  121. return &CreateStyleSheetParams{
  122. FrameID: frameID,
  123. Force: false,
  124. }
  125. }
  126. // WithForce if true, creates a new stylesheet for every call. If false,
  127. // returns a stylesheet previously created by a call with force=false for the
  128. // frame's document if it exists or creates a new stylesheet (default: false).
  129. func (p CreateStyleSheetParams) WithForce(force bool) *CreateStyleSheetParams {
  130. p.Force = force
  131. return &p
  132. }
  133. // CreateStyleSheetReturns return values.
  134. type CreateStyleSheetReturns struct {
  135. StyleSheetID StyleSheetID `json:"styleSheetId,omitempty,omitzero"` // Identifier of the created "via-inspector" stylesheet.
  136. }
  137. // Do executes CSS.createStyleSheet against the provided context.
  138. //
  139. // returns:
  140. //
  141. // styleSheetID - Identifier of the created "via-inspector" stylesheet.
  142. func (p *CreateStyleSheetParams) Do(ctx context.Context) (styleSheetID StyleSheetID, err error) {
  143. // execute
  144. var res CreateStyleSheetReturns
  145. err = cdp.Execute(ctx, CommandCreateStyleSheet, p, &res)
  146. if err != nil {
  147. return "", err
  148. }
  149. return res.StyleSheetID, nil
  150. }
  151. // DisableParams disables the CSS agent for the given page.
  152. type DisableParams struct{}
  153. // Disable disables the CSS agent for the given page.
  154. //
  155. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-disable
  156. func Disable() *DisableParams {
  157. return &DisableParams{}
  158. }
  159. // Do executes CSS.disable against the provided context.
  160. func (p *DisableParams) Do(ctx context.Context) (err error) {
  161. return cdp.Execute(ctx, CommandDisable, nil, nil)
  162. }
  163. // EnableParams enables the CSS agent for the given page. Clients should not
  164. // assume that the CSS agent has been enabled until the result of this command
  165. // is received.
  166. type EnableParams struct{}
  167. // Enable enables the CSS agent for the given page. Clients should not assume
  168. // that the CSS agent has been enabled until the result of this command is
  169. // received.
  170. //
  171. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-enable
  172. func Enable() *EnableParams {
  173. return &EnableParams{}
  174. }
  175. // Do executes CSS.enable against the provided context.
  176. func (p *EnableParams) Do(ctx context.Context) (err error) {
  177. return cdp.Execute(ctx, CommandEnable, nil, nil)
  178. }
  179. // ForcePseudoStateParams ensures that the given node will have specified
  180. // pseudo-classes whenever its style is computed by the browser.
  181. type ForcePseudoStateParams struct {
  182. NodeID cdp.NodeID `json:"nodeId"` // The element id for which to force the pseudo state.
  183. ForcedPseudoClasses []string `json:"forcedPseudoClasses"` // Element pseudo classes to force when computing the element's style.
  184. }
  185. // ForcePseudoState ensures that the given node will have specified
  186. // pseudo-classes whenever its style is computed by the browser.
  187. //
  188. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-forcePseudoState
  189. //
  190. // parameters:
  191. //
  192. // nodeID - The element id for which to force the pseudo state.
  193. // forcedPseudoClasses - Element pseudo classes to force when computing the element's style.
  194. func ForcePseudoState(nodeID cdp.NodeID, forcedPseudoClasses []string) *ForcePseudoStateParams {
  195. return &ForcePseudoStateParams{
  196. NodeID: nodeID,
  197. ForcedPseudoClasses: forcedPseudoClasses,
  198. }
  199. }
  200. // Do executes CSS.forcePseudoState against the provided context.
  201. func (p *ForcePseudoStateParams) Do(ctx context.Context) (err error) {
  202. return cdp.Execute(ctx, CommandForcePseudoState, p, nil)
  203. }
  204. // ForceStartingStyleParams ensures that the given node is in its
  205. // starting-style state.
  206. type ForceStartingStyleParams struct {
  207. NodeID cdp.NodeID `json:"nodeId"` // The element id for which to force the starting-style state.
  208. Forced bool `json:"forced"` // Boolean indicating if this is on or off.
  209. }
  210. // ForceStartingStyle ensures that the given node is in its starting-style
  211. // state.
  212. //
  213. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-forceStartingStyle
  214. //
  215. // parameters:
  216. //
  217. // nodeID - The element id for which to force the starting-style state.
  218. // forced - Boolean indicating if this is on or off.
  219. func ForceStartingStyle(nodeID cdp.NodeID, forced bool) *ForceStartingStyleParams {
  220. return &ForceStartingStyleParams{
  221. NodeID: nodeID,
  222. Forced: forced,
  223. }
  224. }
  225. // Do executes CSS.forceStartingStyle against the provided context.
  226. func (p *ForceStartingStyleParams) Do(ctx context.Context) (err error) {
  227. return cdp.Execute(ctx, CommandForceStartingStyle, p, nil)
  228. }
  229. // GetBackgroundColorsParams [no description].
  230. type GetBackgroundColorsParams struct {
  231. NodeID cdp.NodeID `json:"nodeId"` // Id of the node to get background colors for.
  232. }
  233. // GetBackgroundColors [no description].
  234. //
  235. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-getBackgroundColors
  236. //
  237. // parameters:
  238. //
  239. // nodeID - Id of the node to get background colors for.
  240. func GetBackgroundColors(nodeID cdp.NodeID) *GetBackgroundColorsParams {
  241. return &GetBackgroundColorsParams{
  242. NodeID: nodeID,
  243. }
  244. }
  245. // GetBackgroundColorsReturns return values.
  246. type GetBackgroundColorsReturns struct {
  247. BackgroundColors []string `json:"backgroundColors,omitempty,omitzero"` // The range of background colors behind this element, if it contains any visible text. If no visible text is present, this will be undefined. In the case of a flat background color, this will consist of simply that color. In the case of a gradient, this will consist of each of the color stops. For anything more complicated, this will be an empty array. Images will be ignored (as if the image had failed to load).
  248. ComputedFontSize string `json:"computedFontSize,omitempty,omitzero"` // The computed font size for this node, as a CSS computed value string (e.g. '12px').
  249. ComputedFontWeight string `json:"computedFontWeight,omitempty,omitzero"` // The computed font weight for this node, as a CSS computed value string (e.g. 'normal' or '100').
  250. }
  251. // Do executes CSS.getBackgroundColors against the provided context.
  252. //
  253. // returns:
  254. //
  255. // backgroundColors - The range of background colors behind this element, if it contains any visible text. If no visible text is present, this will be undefined. In the case of a flat background color, this will consist of simply that color. In the case of a gradient, this will consist of each of the color stops. For anything more complicated, this will be an empty array. Images will be ignored (as if the image had failed to load).
  256. // computedFontSize - The computed font size for this node, as a CSS computed value string (e.g. '12px').
  257. // computedFontWeight - The computed font weight for this node, as a CSS computed value string (e.g. 'normal' or '100').
  258. func (p *GetBackgroundColorsParams) Do(ctx context.Context) (backgroundColors []string, computedFontSize string, computedFontWeight string, err error) {
  259. // execute
  260. var res GetBackgroundColorsReturns
  261. err = cdp.Execute(ctx, CommandGetBackgroundColors, p, &res)
  262. if err != nil {
  263. return nil, "", "", err
  264. }
  265. return res.BackgroundColors, res.ComputedFontSize, res.ComputedFontWeight, nil
  266. }
  267. // GetComputedStyleForNodeParams returns the computed style for a DOM node
  268. // identified by nodeId.
  269. type GetComputedStyleForNodeParams struct {
  270. NodeID cdp.NodeID `json:"nodeId"`
  271. }
  272. // GetComputedStyleForNode returns the computed style for a DOM node
  273. // identified by nodeId.
  274. //
  275. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-getComputedStyleForNode
  276. //
  277. // parameters:
  278. //
  279. // nodeID
  280. func GetComputedStyleForNode(nodeID cdp.NodeID) *GetComputedStyleForNodeParams {
  281. return &GetComputedStyleForNodeParams{
  282. NodeID: nodeID,
  283. }
  284. }
  285. // GetComputedStyleForNodeReturns return values.
  286. type GetComputedStyleForNodeReturns struct {
  287. ComputedStyle []*ComputedStyleProperty `json:"computedStyle,omitempty,omitzero"` // Computed style for the specified DOM node.
  288. }
  289. // Do executes CSS.getComputedStyleForNode against the provided context.
  290. //
  291. // returns:
  292. //
  293. // computedStyle - Computed style for the specified DOM node.
  294. func (p *GetComputedStyleForNodeParams) Do(ctx context.Context) (computedStyle []*ComputedStyleProperty, err error) {
  295. // execute
  296. var res GetComputedStyleForNodeReturns
  297. err = cdp.Execute(ctx, CommandGetComputedStyleForNode, p, &res)
  298. if err != nil {
  299. return nil, err
  300. }
  301. return res.ComputedStyle, nil
  302. }
  303. // ResolveValuesParams resolve the specified values in the context of the
  304. // provided element. For example, a value of '1em' is evaluated according to the
  305. // computed 'font-size' of the element and a value 'calc(1px + 2px)' will be
  306. // resolved to '3px'. If the propertyName was specified the values are resolved
  307. // as if they were property's declaration. If a value cannot be parsed according
  308. // to the provided property syntax, the value is parsed using combined syntax as
  309. // if null propertyName was provided. If the value cannot be resolved even then,
  310. // return the provided value without any changes.
  311. type ResolveValuesParams struct {
  312. Values []string `json:"values"` // Substitution functions (var()/env()/attr()) and cascade-dependent keywords (revert/revert-layer) do not work.
  313. NodeID cdp.NodeID `json:"nodeId"` // Id of the node in whose context the expression is evaluated
  314. PropertyName string `json:"propertyName,omitempty,omitzero"` // Only longhands and custom property names are accepted.
  315. PseudoType cdp.PseudoType `json:"pseudoType,omitempty,omitzero"` // Pseudo element type, only works for pseudo elements that generate elements in the tree, such as ::before and ::after.
  316. PseudoIdentifier string `json:"pseudoIdentifier,omitempty,omitzero"` // Pseudo element custom ident.
  317. }
  318. // ResolveValues resolve the specified values in the context of the provided
  319. // element. For example, a value of '1em' is evaluated according to the computed
  320. // 'font-size' of the element and a value 'calc(1px + 2px)' will be resolved to
  321. // '3px'. If the propertyName was specified the values are resolved as if they
  322. // were property's declaration. If a value cannot be parsed according to the
  323. // provided property syntax, the value is parsed using combined syntax as if
  324. // null propertyName was provided. If the value cannot be resolved even then,
  325. // return the provided value without any changes.
  326. //
  327. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-resolveValues
  328. //
  329. // parameters:
  330. //
  331. // values - Substitution functions (var()/env()/attr()) and cascade-dependent keywords (revert/revert-layer) do not work.
  332. // nodeID - Id of the node in whose context the expression is evaluated
  333. func ResolveValues(values []string, nodeID cdp.NodeID) *ResolveValuesParams {
  334. return &ResolveValuesParams{
  335. Values: values,
  336. NodeID: nodeID,
  337. }
  338. }
  339. // WithPropertyName only longhands and custom property names are accepted.
  340. func (p ResolveValuesParams) WithPropertyName(propertyName string) *ResolveValuesParams {
  341. p.PropertyName = propertyName
  342. return &p
  343. }
  344. // WithPseudoType pseudo element type, only works for pseudo elements that
  345. // generate elements in the tree, such as ::before and ::after.
  346. func (p ResolveValuesParams) WithPseudoType(pseudoType cdp.PseudoType) *ResolveValuesParams {
  347. p.PseudoType = pseudoType
  348. return &p
  349. }
  350. // WithPseudoIdentifier pseudo element custom ident.
  351. func (p ResolveValuesParams) WithPseudoIdentifier(pseudoIdentifier string) *ResolveValuesParams {
  352. p.PseudoIdentifier = pseudoIdentifier
  353. return &p
  354. }
  355. // ResolveValuesReturns return values.
  356. type ResolveValuesReturns struct {
  357. Results []string `json:"results,omitempty,omitzero"`
  358. }
  359. // Do executes CSS.resolveValues against the provided context.
  360. //
  361. // returns:
  362. //
  363. // results
  364. func (p *ResolveValuesParams) Do(ctx context.Context) (results []string, err error) {
  365. // execute
  366. var res ResolveValuesReturns
  367. err = cdp.Execute(ctx, CommandResolveValues, p, &res)
  368. if err != nil {
  369. return nil, err
  370. }
  371. return res.Results, nil
  372. }
  373. // GetLonghandPropertiesParams [no description].
  374. type GetLonghandPropertiesParams struct {
  375. ShorthandName string `json:"shorthandName"`
  376. Value string `json:"value"`
  377. }
  378. // GetLonghandProperties [no description].
  379. //
  380. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-getLonghandProperties
  381. //
  382. // parameters:
  383. //
  384. // shorthandName
  385. // value
  386. func GetLonghandProperties(shorthandName string, value string) *GetLonghandPropertiesParams {
  387. return &GetLonghandPropertiesParams{
  388. ShorthandName: shorthandName,
  389. Value: value,
  390. }
  391. }
  392. // GetLonghandPropertiesReturns return values.
  393. type GetLonghandPropertiesReturns struct {
  394. LonghandProperties []*Property `json:"longhandProperties,omitempty,omitzero"`
  395. }
  396. // Do executes CSS.getLonghandProperties against the provided context.
  397. //
  398. // returns:
  399. //
  400. // longhandProperties
  401. func (p *GetLonghandPropertiesParams) Do(ctx context.Context) (longhandProperties []*Property, err error) {
  402. // execute
  403. var res GetLonghandPropertiesReturns
  404. err = cdp.Execute(ctx, CommandGetLonghandProperties, p, &res)
  405. if err != nil {
  406. return nil, err
  407. }
  408. return res.LonghandProperties, nil
  409. }
  410. // GetInlineStylesForNodeParams returns the styles defined inline (explicitly
  411. // in the "style" attribute and implicitly, using DOM attributes) for a DOM node
  412. // identified by nodeId.
  413. type GetInlineStylesForNodeParams struct {
  414. NodeID cdp.NodeID `json:"nodeId"`
  415. }
  416. // GetInlineStylesForNode returns the styles defined inline (explicitly in
  417. // the "style" attribute and implicitly, using DOM attributes) for a DOM node
  418. // identified by nodeId.
  419. //
  420. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-getInlineStylesForNode
  421. //
  422. // parameters:
  423. //
  424. // nodeID
  425. func GetInlineStylesForNode(nodeID cdp.NodeID) *GetInlineStylesForNodeParams {
  426. return &GetInlineStylesForNodeParams{
  427. NodeID: nodeID,
  428. }
  429. }
  430. // GetInlineStylesForNodeReturns return values.
  431. type GetInlineStylesForNodeReturns struct {
  432. InlineStyle *Style `json:"inlineStyle,omitempty,omitzero"` // Inline style for the specified DOM node.
  433. AttributesStyle *Style `json:"attributesStyle,omitempty,omitzero"` // Attribute-defined element style (e.g. resulting from "width=20 height=100%").
  434. }
  435. // Do executes CSS.getInlineStylesForNode against the provided context.
  436. //
  437. // returns:
  438. //
  439. // inlineStyle - Inline style for the specified DOM node.
  440. // attributesStyle - Attribute-defined element style (e.g. resulting from "width=20 height=100%").
  441. func (p *GetInlineStylesForNodeParams) Do(ctx context.Context) (inlineStyle *Style, attributesStyle *Style, err error) {
  442. // execute
  443. var res GetInlineStylesForNodeReturns
  444. err = cdp.Execute(ctx, CommandGetInlineStylesForNode, p, &res)
  445. if err != nil {
  446. return nil, nil, err
  447. }
  448. return res.InlineStyle, res.AttributesStyle, nil
  449. }
  450. // GetAnimatedStylesForNodeParams returns the styles coming from animations &
  451. // transitions including the animation & transition styles coming from
  452. // inheritance chain.
  453. type GetAnimatedStylesForNodeParams struct {
  454. NodeID cdp.NodeID `json:"nodeId"`
  455. }
  456. // GetAnimatedStylesForNode returns the styles coming from animations &
  457. // transitions including the animation & transition styles coming from
  458. // inheritance chain.
  459. //
  460. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-getAnimatedStylesForNode
  461. //
  462. // parameters:
  463. //
  464. // nodeID
  465. func GetAnimatedStylesForNode(nodeID cdp.NodeID) *GetAnimatedStylesForNodeParams {
  466. return &GetAnimatedStylesForNodeParams{
  467. NodeID: nodeID,
  468. }
  469. }
  470. // GetAnimatedStylesForNodeReturns return values.
  471. type GetAnimatedStylesForNodeReturns struct {
  472. AnimationStyles []*AnimationStyle `json:"animationStyles,omitempty,omitzero"` // Styles coming from animations.
  473. TransitionsStyle *Style `json:"transitionsStyle,omitempty,omitzero"` // Style coming from transitions.
  474. Inherited []*InheritedAnimatedStyleEntry `json:"inherited,omitempty,omitzero"` // Inherited style entries for animationsStyle and transitionsStyle from the inheritance chain of the element.
  475. }
  476. // Do executes CSS.getAnimatedStylesForNode against the provided context.
  477. //
  478. // returns:
  479. //
  480. // animationStyles - Styles coming from animations.
  481. // transitionsStyle - Style coming from transitions.
  482. // inherited - Inherited style entries for animationsStyle and transitionsStyle from the inheritance chain of the element.
  483. func (p *GetAnimatedStylesForNodeParams) Do(ctx context.Context) (animationStyles []*AnimationStyle, transitionsStyle *Style, inherited []*InheritedAnimatedStyleEntry, err error) {
  484. // execute
  485. var res GetAnimatedStylesForNodeReturns
  486. err = cdp.Execute(ctx, CommandGetAnimatedStylesForNode, p, &res)
  487. if err != nil {
  488. return nil, nil, nil, err
  489. }
  490. return res.AnimationStyles, res.TransitionsStyle, res.Inherited, nil
  491. }
  492. // GetMatchedStylesForNodeParams returns requested styles for a DOM node
  493. // identified by nodeId.
  494. type GetMatchedStylesForNodeParams struct {
  495. NodeID cdp.NodeID `json:"nodeId"`
  496. }
  497. // GetMatchedStylesForNode returns requested styles for a DOM node identified
  498. // by nodeId.
  499. //
  500. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-getMatchedStylesForNode
  501. //
  502. // parameters:
  503. //
  504. // nodeID
  505. func GetMatchedStylesForNode(nodeID cdp.NodeID) *GetMatchedStylesForNodeParams {
  506. return &GetMatchedStylesForNodeParams{
  507. NodeID: nodeID,
  508. }
  509. }
  510. // GetMatchedStylesForNodeReturns return values.
  511. type GetMatchedStylesForNodeReturns struct {
  512. InlineStyle *Style `json:"inlineStyle,omitempty,omitzero"` // Inline style for the specified DOM node.
  513. AttributesStyle *Style `json:"attributesStyle,omitempty,omitzero"` // Attribute-defined element style (e.g. resulting from "width=20 height=100%").
  514. MatchedCSSRules []*RuleMatch `json:"matchedCSSRules,omitempty,omitzero"` // CSS rules matching this node, from all applicable stylesheets.
  515. PseudoElements []*PseudoElementMatches `json:"pseudoElements,omitempty,omitzero"` // Pseudo style matches for this node.
  516. Inherited []*InheritedStyleEntry `json:"inherited,omitempty,omitzero"` // A chain of inherited styles (from the immediate node parent up to the DOM tree root).
  517. InheritedPseudoElements []*InheritedPseudoElementMatches `json:"inheritedPseudoElements,omitempty,omitzero"` // A chain of inherited pseudo element styles (from the immediate node parent up to the DOM tree root).
  518. CSSKeyframesRules []*KeyframesRule `json:"cssKeyframesRules,omitempty,omitzero"` // A list of CSS keyframed animations matching this node.
  519. CSSPositionTryRules []*PositionTryRule `json:"cssPositionTryRules,omitempty,omitzero"` // A list of CSS @position-try rules matching this node, based on the position-try-fallbacks property.
  520. ActivePositionFallbackIndex int64 `json:"activePositionFallbackIndex,omitempty,omitzero"` // Index of the active fallback in the applied position-try-fallback property, will not be set if there is no active position-try fallback.
  521. CSSPropertyRules []*PropertyRule `json:"cssPropertyRules,omitempty,omitzero"` // A list of CSS at-property rules matching this node.
  522. CSSPropertyRegistrations []*PropertyRegistration `json:"cssPropertyRegistrations,omitempty,omitzero"` // A list of CSS property registrations matching this node.
  523. CSSFontPaletteValuesRule *FontPaletteValuesRule `json:"cssFontPaletteValuesRule,omitempty,omitzero"` // A font-palette-values rule matching this node.
  524. ParentLayoutNodeID cdp.NodeID `json:"parentLayoutNodeId,omitempty,omitzero"` // Id of the first parent element that does not have display: contents.
  525. CSSFunctionRules []*FunctionRule `json:"cssFunctionRules,omitempty,omitzero"` // A list of CSS at-function rules referenced by styles of this node.
  526. }
  527. // Do executes CSS.getMatchedStylesForNode against the provided context.
  528. //
  529. // returns:
  530. //
  531. // inlineStyle - Inline style for the specified DOM node.
  532. // attributesStyle - Attribute-defined element style (e.g. resulting from "width=20 height=100%").
  533. // matchedCSSRules - CSS rules matching this node, from all applicable stylesheets.
  534. // pseudoElements - Pseudo style matches for this node.
  535. // inherited - A chain of inherited styles (from the immediate node parent up to the DOM tree root).
  536. // inheritedPseudoElements - A chain of inherited pseudo element styles (from the immediate node parent up to the DOM tree root).
  537. // cssKeyframesRules - A list of CSS keyframed animations matching this node.
  538. // cssPositionTryRules - A list of CSS @position-try rules matching this node, based on the position-try-fallbacks property.
  539. // activePositionFallbackIndex - Index of the active fallback in the applied position-try-fallback property, will not be set if there is no active position-try fallback.
  540. // cssPropertyRules - A list of CSS at-property rules matching this node.
  541. // cssPropertyRegistrations - A list of CSS property registrations matching this node.
  542. // cssFontPaletteValuesRule - A font-palette-values rule matching this node.
  543. // parentLayoutNodeID - Id of the first parent element that does not have display: contents.
  544. // cssFunctionRules - A list of CSS at-function rules referenced by styles of this node.
  545. func (p *GetMatchedStylesForNodeParams) Do(ctx context.Context) (inlineStyle *Style, attributesStyle *Style, matchedCSSRules []*RuleMatch, pseudoElements []*PseudoElementMatches, inherited []*InheritedStyleEntry, inheritedPseudoElements []*InheritedPseudoElementMatches, cssKeyframesRules []*KeyframesRule, cssPositionTryRules []*PositionTryRule, activePositionFallbackIndex int64, cssPropertyRules []*PropertyRule, cssPropertyRegistrations []*PropertyRegistration, cssFontPaletteValuesRule *FontPaletteValuesRule, parentLayoutNodeID cdp.NodeID, cssFunctionRules []*FunctionRule, err error) {
  546. // execute
  547. var res GetMatchedStylesForNodeReturns
  548. err = cdp.Execute(ctx, CommandGetMatchedStylesForNode, p, &res)
  549. if err != nil {
  550. return nil, nil, nil, nil, nil, nil, nil, nil, 0, nil, nil, nil, 0, nil, err
  551. }
  552. return res.InlineStyle, res.AttributesStyle, res.MatchedCSSRules, res.PseudoElements, res.Inherited, res.InheritedPseudoElements, res.CSSKeyframesRules, res.CSSPositionTryRules, res.ActivePositionFallbackIndex, res.CSSPropertyRules, res.CSSPropertyRegistrations, res.CSSFontPaletteValuesRule, res.ParentLayoutNodeID, res.CSSFunctionRules, nil
  553. }
  554. // GetMediaQueriesParams returns all media queries parsed by the rendering
  555. // engine.
  556. type GetMediaQueriesParams struct{}
  557. // GetMediaQueries returns all media queries parsed by the rendering engine.
  558. //
  559. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-getMediaQueries
  560. func GetMediaQueries() *GetMediaQueriesParams {
  561. return &GetMediaQueriesParams{}
  562. }
  563. // GetMediaQueriesReturns return values.
  564. type GetMediaQueriesReturns struct {
  565. Medias []*Media `json:"medias,omitempty,omitzero"`
  566. }
  567. // Do executes CSS.getMediaQueries against the provided context.
  568. //
  569. // returns:
  570. //
  571. // medias
  572. func (p *GetMediaQueriesParams) Do(ctx context.Context) (medias []*Media, err error) {
  573. // execute
  574. var res GetMediaQueriesReturns
  575. err = cdp.Execute(ctx, CommandGetMediaQueries, nil, &res)
  576. if err != nil {
  577. return nil, err
  578. }
  579. return res.Medias, nil
  580. }
  581. // GetPlatformFontsForNodeParams requests information about platform fonts
  582. // which we used to render child TextNodes in the given node.
  583. type GetPlatformFontsForNodeParams struct {
  584. NodeID cdp.NodeID `json:"nodeId"`
  585. }
  586. // GetPlatformFontsForNode requests information about platform fonts which we
  587. // used to render child TextNodes in the given node.
  588. //
  589. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-getPlatformFontsForNode
  590. //
  591. // parameters:
  592. //
  593. // nodeID
  594. func GetPlatformFontsForNode(nodeID cdp.NodeID) *GetPlatformFontsForNodeParams {
  595. return &GetPlatformFontsForNodeParams{
  596. NodeID: nodeID,
  597. }
  598. }
  599. // GetPlatformFontsForNodeReturns return values.
  600. type GetPlatformFontsForNodeReturns struct {
  601. Fonts []*PlatformFontUsage `json:"fonts,omitempty,omitzero"` // Usage statistics for every employed platform font.
  602. }
  603. // Do executes CSS.getPlatformFontsForNode against the provided context.
  604. //
  605. // returns:
  606. //
  607. // fonts - Usage statistics for every employed platform font.
  608. func (p *GetPlatformFontsForNodeParams) Do(ctx context.Context) (fonts []*PlatformFontUsage, err error) {
  609. // execute
  610. var res GetPlatformFontsForNodeReturns
  611. err = cdp.Execute(ctx, CommandGetPlatformFontsForNode, p, &res)
  612. if err != nil {
  613. return nil, err
  614. }
  615. return res.Fonts, nil
  616. }
  617. // GetStyleSheetTextParams returns the current textual content for a
  618. // stylesheet.
  619. type GetStyleSheetTextParams struct {
  620. StyleSheetID StyleSheetID `json:"styleSheetId"`
  621. }
  622. // GetStyleSheetText returns the current textual content for a stylesheet.
  623. //
  624. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-getStyleSheetText
  625. //
  626. // parameters:
  627. //
  628. // styleSheetID
  629. func GetStyleSheetText(styleSheetID StyleSheetID) *GetStyleSheetTextParams {
  630. return &GetStyleSheetTextParams{
  631. StyleSheetID: styleSheetID,
  632. }
  633. }
  634. // GetStyleSheetTextReturns return values.
  635. type GetStyleSheetTextReturns struct {
  636. Text string `json:"text,omitempty,omitzero"` // The stylesheet text.
  637. }
  638. // Do executes CSS.getStyleSheetText against the provided context.
  639. //
  640. // returns:
  641. //
  642. // text - The stylesheet text.
  643. func (p *GetStyleSheetTextParams) Do(ctx context.Context) (text string, err error) {
  644. // execute
  645. var res GetStyleSheetTextReturns
  646. err = cdp.Execute(ctx, CommandGetStyleSheetText, p, &res)
  647. if err != nil {
  648. return "", err
  649. }
  650. return res.Text, nil
  651. }
  652. // GetLayersForNodeParams returns all layers parsed by the rendering engine
  653. // for the tree scope of a node. Given a DOM element identified by nodeId,
  654. // getLayersForNode returns the root layer for the nearest ancestor document or
  655. // shadow root. The layer root contains the full layer tree for the tree scope
  656. // and their ordering.
  657. type GetLayersForNodeParams struct {
  658. NodeID cdp.NodeID `json:"nodeId"`
  659. }
  660. // GetLayersForNode returns all layers parsed by the rendering engine for the
  661. // tree scope of a node. Given a DOM element identified by nodeId,
  662. // getLayersForNode returns the root layer for the nearest ancestor document or
  663. // shadow root. The layer root contains the full layer tree for the tree scope
  664. // and their ordering.
  665. //
  666. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-getLayersForNode
  667. //
  668. // parameters:
  669. //
  670. // nodeID
  671. func GetLayersForNode(nodeID cdp.NodeID) *GetLayersForNodeParams {
  672. return &GetLayersForNodeParams{
  673. NodeID: nodeID,
  674. }
  675. }
  676. // GetLayersForNodeReturns return values.
  677. type GetLayersForNodeReturns struct {
  678. RootLayer *LayerData `json:"rootLayer,omitempty,omitzero"`
  679. }
  680. // Do executes CSS.getLayersForNode against the provided context.
  681. //
  682. // returns:
  683. //
  684. // rootLayer
  685. func (p *GetLayersForNodeParams) Do(ctx context.Context) (rootLayer *LayerData, err error) {
  686. // execute
  687. var res GetLayersForNodeReturns
  688. err = cdp.Execute(ctx, CommandGetLayersForNode, p, &res)
  689. if err != nil {
  690. return nil, err
  691. }
  692. return res.RootLayer, nil
  693. }
  694. // GetLocationForSelectorParams given a CSS selector text and a style sheet
  695. // ID, getLocationForSelector returns an array of locations of the CSS selector
  696. // in the style sheet.
  697. type GetLocationForSelectorParams struct {
  698. StyleSheetID StyleSheetID `json:"styleSheetId"`
  699. SelectorText string `json:"selectorText"`
  700. }
  701. // GetLocationForSelector given a CSS selector text and a style sheet ID,
  702. // getLocationForSelector returns an array of locations of the CSS selector in
  703. // the style sheet.
  704. //
  705. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-getLocationForSelector
  706. //
  707. // parameters:
  708. //
  709. // styleSheetID
  710. // selectorText
  711. func GetLocationForSelector(styleSheetID StyleSheetID, selectorText string) *GetLocationForSelectorParams {
  712. return &GetLocationForSelectorParams{
  713. StyleSheetID: styleSheetID,
  714. SelectorText: selectorText,
  715. }
  716. }
  717. // GetLocationForSelectorReturns return values.
  718. type GetLocationForSelectorReturns struct {
  719. Ranges []*SourceRange `json:"ranges,omitempty,omitzero"`
  720. }
  721. // Do executes CSS.getLocationForSelector against the provided context.
  722. //
  723. // returns:
  724. //
  725. // ranges
  726. func (p *GetLocationForSelectorParams) Do(ctx context.Context) (ranges []*SourceRange, err error) {
  727. // execute
  728. var res GetLocationForSelectorReturns
  729. err = cdp.Execute(ctx, CommandGetLocationForSelector, p, &res)
  730. if err != nil {
  731. return nil, err
  732. }
  733. return res.Ranges, nil
  734. }
  735. // TrackComputedStyleUpdatesForNodeParams starts tracking the given node for
  736. // the computed style updates and whenever the computed style is updated for
  737. // node, it queues a computedStyleUpdated event with throttling. There can only
  738. // be 1 node tracked for computed style updates so passing a new node id removes
  739. // tracking from the previous node. Pass undefined to disable tracking.
  740. type TrackComputedStyleUpdatesForNodeParams struct {
  741. NodeID cdp.NodeID `json:"nodeId,omitempty,omitzero"`
  742. }
  743. // TrackComputedStyleUpdatesForNode starts tracking the given node for the
  744. // computed style updates and whenever the computed style is updated for node,
  745. // it queues a computedStyleUpdated event with throttling. There can only be 1
  746. // node tracked for computed style updates so passing a new node id removes
  747. // tracking from the previous node. Pass undefined to disable tracking.
  748. //
  749. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-trackComputedStyleUpdatesForNode
  750. //
  751. // parameters:
  752. func TrackComputedStyleUpdatesForNode() *TrackComputedStyleUpdatesForNodeParams {
  753. return &TrackComputedStyleUpdatesForNodeParams{}
  754. }
  755. // WithNodeID [no description].
  756. func (p TrackComputedStyleUpdatesForNodeParams) WithNodeID(nodeID cdp.NodeID) *TrackComputedStyleUpdatesForNodeParams {
  757. p.NodeID = nodeID
  758. return &p
  759. }
  760. // Do executes CSS.trackComputedStyleUpdatesForNode against the provided context.
  761. func (p *TrackComputedStyleUpdatesForNodeParams) Do(ctx context.Context) (err error) {
  762. return cdp.Execute(ctx, CommandTrackComputedStyleUpdatesForNode, p, nil)
  763. }
  764. // TrackComputedStyleUpdatesParams starts tracking the given computed styles
  765. // for updates. The specified array of properties replaces the one previously
  766. // specified. Pass empty array to disable tracking. Use takeComputedStyleUpdates
  767. // to retrieve the list of nodes that had properties modified. The changes to
  768. // computed style properties are only tracked for nodes pushed to the front-end
  769. // by the DOM agent. If no changes to the tracked properties occur after the
  770. // node has been pushed to the front-end, no updates will be issued for the
  771. // node.
  772. type TrackComputedStyleUpdatesParams struct {
  773. PropertiesToTrack []*ComputedStyleProperty `json:"propertiesToTrack"`
  774. }
  775. // TrackComputedStyleUpdates starts tracking the given computed styles for
  776. // updates. The specified array of properties replaces the one previously
  777. // specified. Pass empty array to disable tracking. Use takeComputedStyleUpdates
  778. // to retrieve the list of nodes that had properties modified. The changes to
  779. // computed style properties are only tracked for nodes pushed to the front-end
  780. // by the DOM agent. If no changes to the tracked properties occur after the
  781. // node has been pushed to the front-end, no updates will be issued for the
  782. // node.
  783. //
  784. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-trackComputedStyleUpdates
  785. //
  786. // parameters:
  787. //
  788. // propertiesToTrack
  789. func TrackComputedStyleUpdates(propertiesToTrack []*ComputedStyleProperty) *TrackComputedStyleUpdatesParams {
  790. return &TrackComputedStyleUpdatesParams{
  791. PropertiesToTrack: propertiesToTrack,
  792. }
  793. }
  794. // Do executes CSS.trackComputedStyleUpdates against the provided context.
  795. func (p *TrackComputedStyleUpdatesParams) Do(ctx context.Context) (err error) {
  796. return cdp.Execute(ctx, CommandTrackComputedStyleUpdates, p, nil)
  797. }
  798. // TakeComputedStyleUpdatesParams polls the next batch of computed style
  799. // updates.
  800. type TakeComputedStyleUpdatesParams struct{}
  801. // TakeComputedStyleUpdates polls the next batch of computed style updates.
  802. //
  803. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-takeComputedStyleUpdates
  804. func TakeComputedStyleUpdates() *TakeComputedStyleUpdatesParams {
  805. return &TakeComputedStyleUpdatesParams{}
  806. }
  807. // TakeComputedStyleUpdatesReturns return values.
  808. type TakeComputedStyleUpdatesReturns struct {
  809. NodeIDs []cdp.NodeID `json:"nodeIds,omitempty,omitzero"` // The list of node Ids that have their tracked computed styles updated.
  810. }
  811. // Do executes CSS.takeComputedStyleUpdates against the provided context.
  812. //
  813. // returns:
  814. //
  815. // nodeIDs - The list of node Ids that have their tracked computed styles updated.
  816. func (p *TakeComputedStyleUpdatesParams) Do(ctx context.Context) (nodeIDs []cdp.NodeID, err error) {
  817. // execute
  818. var res TakeComputedStyleUpdatesReturns
  819. err = cdp.Execute(ctx, CommandTakeComputedStyleUpdates, nil, &res)
  820. if err != nil {
  821. return nil, err
  822. }
  823. return res.NodeIDs, nil
  824. }
  825. // SetEffectivePropertyValueForNodeParams find a rule with the given active
  826. // property for the given node and set the new value for this property.
  827. type SetEffectivePropertyValueForNodeParams struct {
  828. NodeID cdp.NodeID `json:"nodeId"` // The element id for which to set property.
  829. PropertyName string `json:"propertyName"`
  830. Value string `json:"value"`
  831. }
  832. // SetEffectivePropertyValueForNode find a rule with the given active
  833. // property for the given node and set the new value for this property.
  834. //
  835. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-setEffectivePropertyValueForNode
  836. //
  837. // parameters:
  838. //
  839. // nodeID - The element id for which to set property.
  840. // propertyName
  841. // value
  842. func SetEffectivePropertyValueForNode(nodeID cdp.NodeID, propertyName string, value string) *SetEffectivePropertyValueForNodeParams {
  843. return &SetEffectivePropertyValueForNodeParams{
  844. NodeID: nodeID,
  845. PropertyName: propertyName,
  846. Value: value,
  847. }
  848. }
  849. // Do executes CSS.setEffectivePropertyValueForNode against the provided context.
  850. func (p *SetEffectivePropertyValueForNodeParams) Do(ctx context.Context) (err error) {
  851. return cdp.Execute(ctx, CommandSetEffectivePropertyValueForNode, p, nil)
  852. }
  853. // SetPropertyRulePropertyNameParams modifies the property rule property
  854. // name.
  855. type SetPropertyRulePropertyNameParams struct {
  856. StyleSheetID StyleSheetID `json:"styleSheetId"`
  857. Range *SourceRange `json:"range"`
  858. PropertyName string `json:"propertyName"`
  859. }
  860. // SetPropertyRulePropertyName modifies the property rule property name.
  861. //
  862. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-setPropertyRulePropertyName
  863. //
  864. // parameters:
  865. //
  866. // styleSheetID
  867. // range
  868. // propertyName
  869. func SetPropertyRulePropertyName(styleSheetID StyleSheetID, rangeVal *SourceRange, propertyName string) *SetPropertyRulePropertyNameParams {
  870. return &SetPropertyRulePropertyNameParams{
  871. StyleSheetID: styleSheetID,
  872. Range: rangeVal,
  873. PropertyName: propertyName,
  874. }
  875. }
  876. // SetPropertyRulePropertyNameReturns return values.
  877. type SetPropertyRulePropertyNameReturns struct {
  878. PropertyName *Value `json:"propertyName,omitempty,omitzero"` // The resulting key text after modification.
  879. }
  880. // Do executes CSS.setPropertyRulePropertyName against the provided context.
  881. //
  882. // returns:
  883. //
  884. // propertyName - The resulting key text after modification.
  885. func (p *SetPropertyRulePropertyNameParams) Do(ctx context.Context) (propertyName *Value, err error) {
  886. // execute
  887. var res SetPropertyRulePropertyNameReturns
  888. err = cdp.Execute(ctx, CommandSetPropertyRulePropertyName, p, &res)
  889. if err != nil {
  890. return nil, err
  891. }
  892. return res.PropertyName, nil
  893. }
  894. // SetKeyframeKeyParams modifies the keyframe rule key text.
  895. type SetKeyframeKeyParams struct {
  896. StyleSheetID StyleSheetID `json:"styleSheetId"`
  897. Range *SourceRange `json:"range"`
  898. KeyText string `json:"keyText"`
  899. }
  900. // SetKeyframeKey modifies the keyframe rule key text.
  901. //
  902. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-setKeyframeKey
  903. //
  904. // parameters:
  905. //
  906. // styleSheetID
  907. // range
  908. // keyText
  909. func SetKeyframeKey(styleSheetID StyleSheetID, rangeVal *SourceRange, keyText string) *SetKeyframeKeyParams {
  910. return &SetKeyframeKeyParams{
  911. StyleSheetID: styleSheetID,
  912. Range: rangeVal,
  913. KeyText: keyText,
  914. }
  915. }
  916. // SetKeyframeKeyReturns return values.
  917. type SetKeyframeKeyReturns struct {
  918. KeyText *Value `json:"keyText,omitempty,omitzero"` // The resulting key text after modification.
  919. }
  920. // Do executes CSS.setKeyframeKey against the provided context.
  921. //
  922. // returns:
  923. //
  924. // keyText - The resulting key text after modification.
  925. func (p *SetKeyframeKeyParams) Do(ctx context.Context) (keyText *Value, err error) {
  926. // execute
  927. var res SetKeyframeKeyReturns
  928. err = cdp.Execute(ctx, CommandSetKeyframeKey, p, &res)
  929. if err != nil {
  930. return nil, err
  931. }
  932. return res.KeyText, nil
  933. }
  934. // SetMediaTextParams modifies the rule selector.
  935. type SetMediaTextParams struct {
  936. StyleSheetID StyleSheetID `json:"styleSheetId"`
  937. Range *SourceRange `json:"range"`
  938. Text string `json:"text"`
  939. }
  940. // SetMediaText modifies the rule selector.
  941. //
  942. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-setMediaText
  943. //
  944. // parameters:
  945. //
  946. // styleSheetID
  947. // range
  948. // text
  949. func SetMediaText(styleSheetID StyleSheetID, rangeVal *SourceRange, text string) *SetMediaTextParams {
  950. return &SetMediaTextParams{
  951. StyleSheetID: styleSheetID,
  952. Range: rangeVal,
  953. Text: text,
  954. }
  955. }
  956. // SetMediaTextReturns return values.
  957. type SetMediaTextReturns struct {
  958. Media *Media `json:"media,omitempty,omitzero"` // The resulting CSS media rule after modification.
  959. }
  960. // Do executes CSS.setMediaText against the provided context.
  961. //
  962. // returns:
  963. //
  964. // media - The resulting CSS media rule after modification.
  965. func (p *SetMediaTextParams) Do(ctx context.Context) (media *Media, err error) {
  966. // execute
  967. var res SetMediaTextReturns
  968. err = cdp.Execute(ctx, CommandSetMediaText, p, &res)
  969. if err != nil {
  970. return nil, err
  971. }
  972. return res.Media, nil
  973. }
  974. // SetContainerQueryTextParams modifies the expression of a container query.
  975. type SetContainerQueryTextParams struct {
  976. StyleSheetID StyleSheetID `json:"styleSheetId"`
  977. Range *SourceRange `json:"range"`
  978. Text string `json:"text"`
  979. }
  980. // SetContainerQueryText modifies the expression of a container query.
  981. //
  982. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-setContainerQueryText
  983. //
  984. // parameters:
  985. //
  986. // styleSheetID
  987. // range
  988. // text
  989. func SetContainerQueryText(styleSheetID StyleSheetID, rangeVal *SourceRange, text string) *SetContainerQueryTextParams {
  990. return &SetContainerQueryTextParams{
  991. StyleSheetID: styleSheetID,
  992. Range: rangeVal,
  993. Text: text,
  994. }
  995. }
  996. // SetContainerQueryTextReturns return values.
  997. type SetContainerQueryTextReturns struct {
  998. ContainerQuery *ContainerQuery `json:"containerQuery,omitempty,omitzero"` // The resulting CSS container query rule after modification.
  999. }
  1000. // Do executes CSS.setContainerQueryText against the provided context.
  1001. //
  1002. // returns:
  1003. //
  1004. // containerQuery - The resulting CSS container query rule after modification.
  1005. func (p *SetContainerQueryTextParams) Do(ctx context.Context) (containerQuery *ContainerQuery, err error) {
  1006. // execute
  1007. var res SetContainerQueryTextReturns
  1008. err = cdp.Execute(ctx, CommandSetContainerQueryText, p, &res)
  1009. if err != nil {
  1010. return nil, err
  1011. }
  1012. return res.ContainerQuery, nil
  1013. }
  1014. // SetSupportsTextParams modifies the expression of a supports at-rule.
  1015. type SetSupportsTextParams struct {
  1016. StyleSheetID StyleSheetID `json:"styleSheetId"`
  1017. Range *SourceRange `json:"range"`
  1018. Text string `json:"text"`
  1019. }
  1020. // SetSupportsText modifies the expression of a supports at-rule.
  1021. //
  1022. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-setSupportsText
  1023. //
  1024. // parameters:
  1025. //
  1026. // styleSheetID
  1027. // range
  1028. // text
  1029. func SetSupportsText(styleSheetID StyleSheetID, rangeVal *SourceRange, text string) *SetSupportsTextParams {
  1030. return &SetSupportsTextParams{
  1031. StyleSheetID: styleSheetID,
  1032. Range: rangeVal,
  1033. Text: text,
  1034. }
  1035. }
  1036. // SetSupportsTextReturns return values.
  1037. type SetSupportsTextReturns struct {
  1038. Supports *Supports `json:"supports,omitempty,omitzero"` // The resulting CSS Supports rule after modification.
  1039. }
  1040. // Do executes CSS.setSupportsText against the provided context.
  1041. //
  1042. // returns:
  1043. //
  1044. // supports - The resulting CSS Supports rule after modification.
  1045. func (p *SetSupportsTextParams) Do(ctx context.Context) (supports *Supports, err error) {
  1046. // execute
  1047. var res SetSupportsTextReturns
  1048. err = cdp.Execute(ctx, CommandSetSupportsText, p, &res)
  1049. if err != nil {
  1050. return nil, err
  1051. }
  1052. return res.Supports, nil
  1053. }
  1054. // SetScopeTextParams modifies the expression of a scope at-rule.
  1055. type SetScopeTextParams struct {
  1056. StyleSheetID StyleSheetID `json:"styleSheetId"`
  1057. Range *SourceRange `json:"range"`
  1058. Text string `json:"text"`
  1059. }
  1060. // SetScopeText modifies the expression of a scope at-rule.
  1061. //
  1062. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-setScopeText
  1063. //
  1064. // parameters:
  1065. //
  1066. // styleSheetID
  1067. // range
  1068. // text
  1069. func SetScopeText(styleSheetID StyleSheetID, rangeVal *SourceRange, text string) *SetScopeTextParams {
  1070. return &SetScopeTextParams{
  1071. StyleSheetID: styleSheetID,
  1072. Range: rangeVal,
  1073. Text: text,
  1074. }
  1075. }
  1076. // SetScopeTextReturns return values.
  1077. type SetScopeTextReturns struct {
  1078. Scope *Scope `json:"scope,omitempty,omitzero"` // The resulting CSS Scope rule after modification.
  1079. }
  1080. // Do executes CSS.setScopeText against the provided context.
  1081. //
  1082. // returns:
  1083. //
  1084. // scope - The resulting CSS Scope rule after modification.
  1085. func (p *SetScopeTextParams) Do(ctx context.Context) (scope *Scope, err error) {
  1086. // execute
  1087. var res SetScopeTextReturns
  1088. err = cdp.Execute(ctx, CommandSetScopeText, p, &res)
  1089. if err != nil {
  1090. return nil, err
  1091. }
  1092. return res.Scope, nil
  1093. }
  1094. // SetRuleSelectorParams modifies the rule selector.
  1095. type SetRuleSelectorParams struct {
  1096. StyleSheetID StyleSheetID `json:"styleSheetId"`
  1097. Range *SourceRange `json:"range"`
  1098. Selector string `json:"selector"`
  1099. }
  1100. // SetRuleSelector modifies the rule selector.
  1101. //
  1102. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-setRuleSelector
  1103. //
  1104. // parameters:
  1105. //
  1106. // styleSheetID
  1107. // range
  1108. // selector
  1109. func SetRuleSelector(styleSheetID StyleSheetID, rangeVal *SourceRange, selector string) *SetRuleSelectorParams {
  1110. return &SetRuleSelectorParams{
  1111. StyleSheetID: styleSheetID,
  1112. Range: rangeVal,
  1113. Selector: selector,
  1114. }
  1115. }
  1116. // SetRuleSelectorReturns return values.
  1117. type SetRuleSelectorReturns struct {
  1118. SelectorList *SelectorList `json:"selectorList,omitempty,omitzero"` // The resulting selector list after modification.
  1119. }
  1120. // Do executes CSS.setRuleSelector against the provided context.
  1121. //
  1122. // returns:
  1123. //
  1124. // selectorList - The resulting selector list after modification.
  1125. func (p *SetRuleSelectorParams) Do(ctx context.Context) (selectorList *SelectorList, err error) {
  1126. // execute
  1127. var res SetRuleSelectorReturns
  1128. err = cdp.Execute(ctx, CommandSetRuleSelector, p, &res)
  1129. if err != nil {
  1130. return nil, err
  1131. }
  1132. return res.SelectorList, nil
  1133. }
  1134. // SetStyleSheetTextParams sets the new stylesheet text.
  1135. type SetStyleSheetTextParams struct {
  1136. StyleSheetID StyleSheetID `json:"styleSheetId"`
  1137. Text string `json:"text"`
  1138. }
  1139. // SetStyleSheetText sets the new stylesheet text.
  1140. //
  1141. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-setStyleSheetText
  1142. //
  1143. // parameters:
  1144. //
  1145. // styleSheetID
  1146. // text
  1147. func SetStyleSheetText(styleSheetID StyleSheetID, text string) *SetStyleSheetTextParams {
  1148. return &SetStyleSheetTextParams{
  1149. StyleSheetID: styleSheetID,
  1150. Text: text,
  1151. }
  1152. }
  1153. // SetStyleSheetTextReturns return values.
  1154. type SetStyleSheetTextReturns struct {
  1155. SourceMapURL string `json:"sourceMapURL,omitempty,omitzero"` // URL of source map associated with script (if any).
  1156. }
  1157. // Do executes CSS.setStyleSheetText against the provided context.
  1158. //
  1159. // returns:
  1160. //
  1161. // sourceMapURL - URL of source map associated with script (if any).
  1162. func (p *SetStyleSheetTextParams) Do(ctx context.Context) (sourceMapURL string, err error) {
  1163. // execute
  1164. var res SetStyleSheetTextReturns
  1165. err = cdp.Execute(ctx, CommandSetStyleSheetText, p, &res)
  1166. if err != nil {
  1167. return "", err
  1168. }
  1169. return res.SourceMapURL, nil
  1170. }
  1171. // SetStyleTextsParams applies specified style edits one after another in the
  1172. // given order.
  1173. type SetStyleTextsParams struct {
  1174. Edits []*StyleDeclarationEdit `json:"edits"`
  1175. NodeForPropertySyntaxValidation cdp.NodeID `json:"nodeForPropertySyntaxValidation,omitempty,omitzero"` // NodeId for the DOM node in whose context custom property declarations for registered properties should be validated. If omitted, declarations in the new rule text can only be validated statically, which may produce incorrect results if the declaration contains a var() for example.
  1176. }
  1177. // SetStyleTexts applies specified style edits one after another in the given
  1178. // order.
  1179. //
  1180. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-setStyleTexts
  1181. //
  1182. // parameters:
  1183. //
  1184. // edits
  1185. func SetStyleTexts(edits []*StyleDeclarationEdit) *SetStyleTextsParams {
  1186. return &SetStyleTextsParams{
  1187. Edits: edits,
  1188. }
  1189. }
  1190. // WithNodeForPropertySyntaxValidation nodeId for the DOM node in whose
  1191. // context custom property declarations for registered properties should be
  1192. // validated. If omitted, declarations in the new rule text can only be
  1193. // validated statically, which may produce incorrect results if the declaration
  1194. // contains a var() for example.
  1195. func (p SetStyleTextsParams) WithNodeForPropertySyntaxValidation(nodeForPropertySyntaxValidation cdp.NodeID) *SetStyleTextsParams {
  1196. p.NodeForPropertySyntaxValidation = nodeForPropertySyntaxValidation
  1197. return &p
  1198. }
  1199. // SetStyleTextsReturns return values.
  1200. type SetStyleTextsReturns struct {
  1201. Styles []*Style `json:"styles,omitempty,omitzero"` // The resulting styles after modification.
  1202. }
  1203. // Do executes CSS.setStyleTexts against the provided context.
  1204. //
  1205. // returns:
  1206. //
  1207. // styles - The resulting styles after modification.
  1208. func (p *SetStyleTextsParams) Do(ctx context.Context) (styles []*Style, err error) {
  1209. // execute
  1210. var res SetStyleTextsReturns
  1211. err = cdp.Execute(ctx, CommandSetStyleTexts, p, &res)
  1212. if err != nil {
  1213. return nil, err
  1214. }
  1215. return res.Styles, nil
  1216. }
  1217. // StartRuleUsageTrackingParams enables the selector recording.
  1218. type StartRuleUsageTrackingParams struct{}
  1219. // StartRuleUsageTracking enables the selector recording.
  1220. //
  1221. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-startRuleUsageTracking
  1222. func StartRuleUsageTracking() *StartRuleUsageTrackingParams {
  1223. return &StartRuleUsageTrackingParams{}
  1224. }
  1225. // Do executes CSS.startRuleUsageTracking against the provided context.
  1226. func (p *StartRuleUsageTrackingParams) Do(ctx context.Context) (err error) {
  1227. return cdp.Execute(ctx, CommandStartRuleUsageTracking, nil, nil)
  1228. }
  1229. // StopRuleUsageTrackingParams stop tracking rule usage and return the list
  1230. // of rules that were used since last call to takeCoverageDelta (or since start
  1231. // of coverage instrumentation).
  1232. type StopRuleUsageTrackingParams struct{}
  1233. // StopRuleUsageTracking stop tracking rule usage and return the list of
  1234. // rules that were used since last call to takeCoverageDelta (or since start of
  1235. // coverage instrumentation).
  1236. //
  1237. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-stopRuleUsageTracking
  1238. func StopRuleUsageTracking() *StopRuleUsageTrackingParams {
  1239. return &StopRuleUsageTrackingParams{}
  1240. }
  1241. // StopRuleUsageTrackingReturns return values.
  1242. type StopRuleUsageTrackingReturns struct {
  1243. RuleUsage []*RuleUsage `json:"ruleUsage,omitempty,omitzero"`
  1244. }
  1245. // Do executes CSS.stopRuleUsageTracking against the provided context.
  1246. //
  1247. // returns:
  1248. //
  1249. // ruleUsage
  1250. func (p *StopRuleUsageTrackingParams) Do(ctx context.Context) (ruleUsage []*RuleUsage, err error) {
  1251. // execute
  1252. var res StopRuleUsageTrackingReturns
  1253. err = cdp.Execute(ctx, CommandStopRuleUsageTracking, nil, &res)
  1254. if err != nil {
  1255. return nil, err
  1256. }
  1257. return res.RuleUsage, nil
  1258. }
  1259. // TakeCoverageDeltaParams obtain list of rules that became used since last
  1260. // call to this method (or since start of coverage instrumentation).
  1261. type TakeCoverageDeltaParams struct{}
  1262. // TakeCoverageDelta obtain list of rules that became used since last call to
  1263. // this method (or since start of coverage instrumentation).
  1264. //
  1265. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-takeCoverageDelta
  1266. func TakeCoverageDelta() *TakeCoverageDeltaParams {
  1267. return &TakeCoverageDeltaParams{}
  1268. }
  1269. // TakeCoverageDeltaReturns return values.
  1270. type TakeCoverageDeltaReturns struct {
  1271. Coverage []*RuleUsage `json:"coverage,omitempty,omitzero"`
  1272. Timestamp float64 `json:"timestamp,omitempty,omitzero"` // Monotonically increasing time, in seconds.
  1273. }
  1274. // Do executes CSS.takeCoverageDelta against the provided context.
  1275. //
  1276. // returns:
  1277. //
  1278. // coverage
  1279. // timestamp - Monotonically increasing time, in seconds.
  1280. func (p *TakeCoverageDeltaParams) Do(ctx context.Context) (coverage []*RuleUsage, timestamp float64, err error) {
  1281. // execute
  1282. var res TakeCoverageDeltaReturns
  1283. err = cdp.Execute(ctx, CommandTakeCoverageDelta, nil, &res)
  1284. if err != nil {
  1285. return nil, 0, err
  1286. }
  1287. return res.Coverage, res.Timestamp, nil
  1288. }
  1289. // SetLocalFontsEnabledParams enables/disables rendering of local CSS fonts
  1290. // (enabled by default).
  1291. type SetLocalFontsEnabledParams struct {
  1292. Enabled bool `json:"enabled"` // Whether rendering of local fonts is enabled.
  1293. }
  1294. // SetLocalFontsEnabled enables/disables rendering of local CSS fonts
  1295. // (enabled by default).
  1296. //
  1297. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-setLocalFontsEnabled
  1298. //
  1299. // parameters:
  1300. //
  1301. // enabled - Whether rendering of local fonts is enabled.
  1302. func SetLocalFontsEnabled(enabled bool) *SetLocalFontsEnabledParams {
  1303. return &SetLocalFontsEnabledParams{
  1304. Enabled: enabled,
  1305. }
  1306. }
  1307. // Do executes CSS.setLocalFontsEnabled against the provided context.
  1308. func (p *SetLocalFontsEnabledParams) Do(ctx context.Context) (err error) {
  1309. return cdp.Execute(ctx, CommandSetLocalFontsEnabled, p, nil)
  1310. }
  1311. // Command names.
  1312. const (
  1313. CommandAddRule = "CSS.addRule"
  1314. CommandCollectClassNames = "CSS.collectClassNames"
  1315. CommandCreateStyleSheet = "CSS.createStyleSheet"
  1316. CommandDisable = "CSS.disable"
  1317. CommandEnable = "CSS.enable"
  1318. CommandForcePseudoState = "CSS.forcePseudoState"
  1319. CommandForceStartingStyle = "CSS.forceStartingStyle"
  1320. CommandGetBackgroundColors = "CSS.getBackgroundColors"
  1321. CommandGetComputedStyleForNode = "CSS.getComputedStyleForNode"
  1322. CommandResolveValues = "CSS.resolveValues"
  1323. CommandGetLonghandProperties = "CSS.getLonghandProperties"
  1324. CommandGetInlineStylesForNode = "CSS.getInlineStylesForNode"
  1325. CommandGetAnimatedStylesForNode = "CSS.getAnimatedStylesForNode"
  1326. CommandGetMatchedStylesForNode = "CSS.getMatchedStylesForNode"
  1327. CommandGetMediaQueries = "CSS.getMediaQueries"
  1328. CommandGetPlatformFontsForNode = "CSS.getPlatformFontsForNode"
  1329. CommandGetStyleSheetText = "CSS.getStyleSheetText"
  1330. CommandGetLayersForNode = "CSS.getLayersForNode"
  1331. CommandGetLocationForSelector = "CSS.getLocationForSelector"
  1332. CommandTrackComputedStyleUpdatesForNode = "CSS.trackComputedStyleUpdatesForNode"
  1333. CommandTrackComputedStyleUpdates = "CSS.trackComputedStyleUpdates"
  1334. CommandTakeComputedStyleUpdates = "CSS.takeComputedStyleUpdates"
  1335. CommandSetEffectivePropertyValueForNode = "CSS.setEffectivePropertyValueForNode"
  1336. CommandSetPropertyRulePropertyName = "CSS.setPropertyRulePropertyName"
  1337. CommandSetKeyframeKey = "CSS.setKeyframeKey"
  1338. CommandSetMediaText = "CSS.setMediaText"
  1339. CommandSetContainerQueryText = "CSS.setContainerQueryText"
  1340. CommandSetSupportsText = "CSS.setSupportsText"
  1341. CommandSetScopeText = "CSS.setScopeText"
  1342. CommandSetRuleSelector = "CSS.setRuleSelector"
  1343. CommandSetStyleSheetText = "CSS.setStyleSheetText"
  1344. CommandSetStyleTexts = "CSS.setStyleTexts"
  1345. CommandStartRuleUsageTracking = "CSS.startRuleUsageTracking"
  1346. CommandStopRuleUsageTracking = "CSS.stopRuleUsageTracking"
  1347. CommandTakeCoverageDelta = "CSS.takeCoverageDelta"
  1348. CommandSetLocalFontsEnabled = "CSS.setLocalFontsEnabled"
  1349. )