css.go 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275
  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"` // 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"` // 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"` // 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. }
  111. // CreateStyleSheet creates a new special "via-inspector" stylesheet in the
  112. // frame with given frameId.
  113. //
  114. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-createStyleSheet
  115. //
  116. // parameters:
  117. //
  118. // frameID - Identifier of the frame where "via-inspector" stylesheet should be created.
  119. func CreateStyleSheet(frameID cdp.FrameID) *CreateStyleSheetParams {
  120. return &CreateStyleSheetParams{
  121. FrameID: frameID,
  122. }
  123. }
  124. // CreateStyleSheetReturns return values.
  125. type CreateStyleSheetReturns struct {
  126. StyleSheetID StyleSheetID `json:"styleSheetId,omitempty"` // Identifier of the created "via-inspector" stylesheet.
  127. }
  128. // Do executes CSS.createStyleSheet against the provided context.
  129. //
  130. // returns:
  131. //
  132. // styleSheetID - Identifier of the created "via-inspector" stylesheet.
  133. func (p *CreateStyleSheetParams) Do(ctx context.Context) (styleSheetID StyleSheetID, err error) {
  134. // execute
  135. var res CreateStyleSheetReturns
  136. err = cdp.Execute(ctx, CommandCreateStyleSheet, p, &res)
  137. if err != nil {
  138. return "", err
  139. }
  140. return res.StyleSheetID, nil
  141. }
  142. // DisableParams disables the CSS agent for the given page.
  143. type DisableParams struct{}
  144. // Disable disables the CSS agent for the given page.
  145. //
  146. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-disable
  147. func Disable() *DisableParams {
  148. return &DisableParams{}
  149. }
  150. // Do executes CSS.disable against the provided context.
  151. func (p *DisableParams) Do(ctx context.Context) (err error) {
  152. return cdp.Execute(ctx, CommandDisable, nil, nil)
  153. }
  154. // EnableParams enables the CSS agent for the given page. Clients should not
  155. // assume that the CSS agent has been enabled until the result of this command
  156. // is received.
  157. type EnableParams struct{}
  158. // Enable enables the CSS agent for the given page. Clients should not assume
  159. // that the CSS agent has been enabled until the result of this command is
  160. // received.
  161. //
  162. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-enable
  163. func Enable() *EnableParams {
  164. return &EnableParams{}
  165. }
  166. // Do executes CSS.enable against the provided context.
  167. func (p *EnableParams) Do(ctx context.Context) (err error) {
  168. return cdp.Execute(ctx, CommandEnable, nil, nil)
  169. }
  170. // ForcePseudoStateParams ensures that the given node will have specified
  171. // pseudo-classes whenever its style is computed by the browser.
  172. type ForcePseudoStateParams struct {
  173. NodeID cdp.NodeID `json:"nodeId"` // The element id for which to force the pseudo state.
  174. ForcedPseudoClasses []string `json:"forcedPseudoClasses"` // Element pseudo classes to force when computing the element's style.
  175. }
  176. // ForcePseudoState ensures that the given node will have specified
  177. // pseudo-classes whenever its style is computed by the browser.
  178. //
  179. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-forcePseudoState
  180. //
  181. // parameters:
  182. //
  183. // nodeID - The element id for which to force the pseudo state.
  184. // forcedPseudoClasses - Element pseudo classes to force when computing the element's style.
  185. func ForcePseudoState(nodeID cdp.NodeID, forcedPseudoClasses []string) *ForcePseudoStateParams {
  186. return &ForcePseudoStateParams{
  187. NodeID: nodeID,
  188. ForcedPseudoClasses: forcedPseudoClasses,
  189. }
  190. }
  191. // Do executes CSS.forcePseudoState against the provided context.
  192. func (p *ForcePseudoStateParams) Do(ctx context.Context) (err error) {
  193. return cdp.Execute(ctx, CommandForcePseudoState, p, nil)
  194. }
  195. // GetBackgroundColorsParams [no description].
  196. type GetBackgroundColorsParams struct {
  197. NodeID cdp.NodeID `json:"nodeId"` // Id of the node to get background colors for.
  198. }
  199. // GetBackgroundColors [no description].
  200. //
  201. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-getBackgroundColors
  202. //
  203. // parameters:
  204. //
  205. // nodeID - Id of the node to get background colors for.
  206. func GetBackgroundColors(nodeID cdp.NodeID) *GetBackgroundColorsParams {
  207. return &GetBackgroundColorsParams{
  208. NodeID: nodeID,
  209. }
  210. }
  211. // GetBackgroundColorsReturns return values.
  212. type GetBackgroundColorsReturns struct {
  213. BackgroundColors []string `json:"backgroundColors,omitempty"` // 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).
  214. ComputedFontSize string `json:"computedFontSize,omitempty"` // The computed font size for this node, as a CSS computed value string (e.g. '12px').
  215. ComputedFontWeight string `json:"computedFontWeight,omitempty"` // The computed font weight for this node, as a CSS computed value string (e.g. 'normal' or '100').
  216. }
  217. // Do executes CSS.getBackgroundColors against the provided context.
  218. //
  219. // returns:
  220. //
  221. // 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).
  222. // computedFontSize - The computed font size for this node, as a CSS computed value string (e.g. '12px').
  223. // computedFontWeight - The computed font weight for this node, as a CSS computed value string (e.g. 'normal' or '100').
  224. func (p *GetBackgroundColorsParams) Do(ctx context.Context) (backgroundColors []string, computedFontSize string, computedFontWeight string, err error) {
  225. // execute
  226. var res GetBackgroundColorsReturns
  227. err = cdp.Execute(ctx, CommandGetBackgroundColors, p, &res)
  228. if err != nil {
  229. return nil, "", "", err
  230. }
  231. return res.BackgroundColors, res.ComputedFontSize, res.ComputedFontWeight, nil
  232. }
  233. // GetComputedStyleForNodeParams returns the computed style for a DOM node
  234. // identified by nodeId.
  235. type GetComputedStyleForNodeParams struct {
  236. NodeID cdp.NodeID `json:"nodeId"`
  237. }
  238. // GetComputedStyleForNode returns the computed style for a DOM node
  239. // identified by nodeId.
  240. //
  241. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-getComputedStyleForNode
  242. //
  243. // parameters:
  244. //
  245. // nodeID
  246. func GetComputedStyleForNode(nodeID cdp.NodeID) *GetComputedStyleForNodeParams {
  247. return &GetComputedStyleForNodeParams{
  248. NodeID: nodeID,
  249. }
  250. }
  251. // GetComputedStyleForNodeReturns return values.
  252. type GetComputedStyleForNodeReturns struct {
  253. ComputedStyle []*ComputedStyleProperty `json:"computedStyle,omitempty"` // Computed style for the specified DOM node.
  254. }
  255. // Do executes CSS.getComputedStyleForNode against the provided context.
  256. //
  257. // returns:
  258. //
  259. // computedStyle - Computed style for the specified DOM node.
  260. func (p *GetComputedStyleForNodeParams) Do(ctx context.Context) (computedStyle []*ComputedStyleProperty, err error) {
  261. // execute
  262. var res GetComputedStyleForNodeReturns
  263. err = cdp.Execute(ctx, CommandGetComputedStyleForNode, p, &res)
  264. if err != nil {
  265. return nil, err
  266. }
  267. return res.ComputedStyle, nil
  268. }
  269. // GetInlineStylesForNodeParams returns the styles defined inline (explicitly
  270. // in the "style" attribute and implicitly, using DOM attributes) for a DOM node
  271. // identified by nodeId.
  272. type GetInlineStylesForNodeParams struct {
  273. NodeID cdp.NodeID `json:"nodeId"`
  274. }
  275. // GetInlineStylesForNode returns the styles defined inline (explicitly in
  276. // the "style" attribute and implicitly, using DOM attributes) for a DOM node
  277. // identified by nodeId.
  278. //
  279. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-getInlineStylesForNode
  280. //
  281. // parameters:
  282. //
  283. // nodeID
  284. func GetInlineStylesForNode(nodeID cdp.NodeID) *GetInlineStylesForNodeParams {
  285. return &GetInlineStylesForNodeParams{
  286. NodeID: nodeID,
  287. }
  288. }
  289. // GetInlineStylesForNodeReturns return values.
  290. type GetInlineStylesForNodeReturns struct {
  291. InlineStyle *Style `json:"inlineStyle,omitempty"` // Inline style for the specified DOM node.
  292. AttributesStyle *Style `json:"attributesStyle,omitempty"` // Attribute-defined element style (e.g. resulting from "width=20 height=100%").
  293. }
  294. // Do executes CSS.getInlineStylesForNode against the provided context.
  295. //
  296. // returns:
  297. //
  298. // inlineStyle - Inline style for the specified DOM node.
  299. // attributesStyle - Attribute-defined element style (e.g. resulting from "width=20 height=100%").
  300. func (p *GetInlineStylesForNodeParams) Do(ctx context.Context) (inlineStyle *Style, attributesStyle *Style, err error) {
  301. // execute
  302. var res GetInlineStylesForNodeReturns
  303. err = cdp.Execute(ctx, CommandGetInlineStylesForNode, p, &res)
  304. if err != nil {
  305. return nil, nil, err
  306. }
  307. return res.InlineStyle, res.AttributesStyle, nil
  308. }
  309. // GetMatchedStylesForNodeParams returns requested styles for a DOM node
  310. // identified by nodeId.
  311. type GetMatchedStylesForNodeParams struct {
  312. NodeID cdp.NodeID `json:"nodeId"`
  313. }
  314. // GetMatchedStylesForNode returns requested styles for a DOM node identified
  315. // by nodeId.
  316. //
  317. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-getMatchedStylesForNode
  318. //
  319. // parameters:
  320. //
  321. // nodeID
  322. func GetMatchedStylesForNode(nodeID cdp.NodeID) *GetMatchedStylesForNodeParams {
  323. return &GetMatchedStylesForNodeParams{
  324. NodeID: nodeID,
  325. }
  326. }
  327. // GetMatchedStylesForNodeReturns return values.
  328. type GetMatchedStylesForNodeReturns struct {
  329. InlineStyle *Style `json:"inlineStyle,omitempty"` // Inline style for the specified DOM node.
  330. AttributesStyle *Style `json:"attributesStyle,omitempty"` // Attribute-defined element style (e.g. resulting from "width=20 height=100%").
  331. MatchedCSSRules []*RuleMatch `json:"matchedCSSRules,omitempty"` // CSS rules matching this node, from all applicable stylesheets.
  332. PseudoElements []*PseudoElementMatches `json:"pseudoElements,omitempty"` // Pseudo style matches for this node.
  333. Inherited []*InheritedStyleEntry `json:"inherited,omitempty"` // A chain of inherited styles (from the immediate node parent up to the DOM tree root).
  334. InheritedPseudoElements []*InheritedPseudoElementMatches `json:"inheritedPseudoElements,omitempty"` // A chain of inherited pseudo element styles (from the immediate node parent up to the DOM tree root).
  335. CSSKeyframesRules []*KeyframesRule `json:"cssKeyframesRules,omitempty"` // A list of CSS keyframed animations matching this node.
  336. CSSPositionTryRules []*PositionTryRule `json:"cssPositionTryRules,omitempty"` // A list of CSS @position-try rules matching this node, based on the position-try-options property.
  337. CSSPropertyRules []*PropertyRule `json:"cssPropertyRules,omitempty"` // A list of CSS at-property rules matching this node.
  338. CSSPropertyRegistrations []*PropertyRegistration `json:"cssPropertyRegistrations,omitempty"` // A list of CSS property registrations matching this node.
  339. CSSFontPaletteValuesRule *FontPaletteValuesRule `json:"cssFontPaletteValuesRule,omitempty"` // A font-palette-values rule matching this node.
  340. ParentLayoutNodeID cdp.NodeID `json:"parentLayoutNodeId,omitempty"` // Id of the first parent element that does not have display: contents.
  341. }
  342. // Do executes CSS.getMatchedStylesForNode against the provided context.
  343. //
  344. // returns:
  345. //
  346. // inlineStyle - Inline style for the specified DOM node.
  347. // attributesStyle - Attribute-defined element style (e.g. resulting from "width=20 height=100%").
  348. // matchedCSSRules - CSS rules matching this node, from all applicable stylesheets.
  349. // pseudoElements - Pseudo style matches for this node.
  350. // inherited - A chain of inherited styles (from the immediate node parent up to the DOM tree root).
  351. // inheritedPseudoElements - A chain of inherited pseudo element styles (from the immediate node parent up to the DOM tree root).
  352. // cssKeyframesRules - A list of CSS keyframed animations matching this node.
  353. // cssPositionTryRules - A list of CSS @position-try rules matching this node, based on the position-try-options property.
  354. // cssPropertyRules - A list of CSS at-property rules matching this node.
  355. // cssPropertyRegistrations - A list of CSS property registrations matching this node.
  356. // cssFontPaletteValuesRule - A font-palette-values rule matching this node.
  357. // parentLayoutNodeID - Id of the first parent element that does not have display: contents.
  358. func (p *GetMatchedStylesForNodeParams) Do(ctx context.Context) (inlineStyle *Style, attributesStyle *Style, matchedCSSRules []*RuleMatch, pseudoElements []*PseudoElementMatches, inherited []*InheritedStyleEntry, inheritedPseudoElements []*InheritedPseudoElementMatches, cssKeyframesRules []*KeyframesRule, cssPositionTryRules []*PositionTryRule, cssPropertyRules []*PropertyRule, cssPropertyRegistrations []*PropertyRegistration, cssFontPaletteValuesRule *FontPaletteValuesRule, parentLayoutNodeID cdp.NodeID, err error) {
  359. // execute
  360. var res GetMatchedStylesForNodeReturns
  361. err = cdp.Execute(ctx, CommandGetMatchedStylesForNode, p, &res)
  362. if err != nil {
  363. return nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 0, err
  364. }
  365. return res.InlineStyle, res.AttributesStyle, res.MatchedCSSRules, res.PseudoElements, res.Inherited, res.InheritedPseudoElements, res.CSSKeyframesRules, res.CSSPositionTryRules, res.CSSPropertyRules, res.CSSPropertyRegistrations, res.CSSFontPaletteValuesRule, res.ParentLayoutNodeID, nil
  366. }
  367. // GetMediaQueriesParams returns all media queries parsed by the rendering
  368. // engine.
  369. type GetMediaQueriesParams struct{}
  370. // GetMediaQueries returns all media queries parsed by the rendering engine.
  371. //
  372. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-getMediaQueries
  373. func GetMediaQueries() *GetMediaQueriesParams {
  374. return &GetMediaQueriesParams{}
  375. }
  376. // GetMediaQueriesReturns return values.
  377. type GetMediaQueriesReturns struct {
  378. Medias []*Media `json:"medias,omitempty"`
  379. }
  380. // Do executes CSS.getMediaQueries against the provided context.
  381. //
  382. // returns:
  383. //
  384. // medias
  385. func (p *GetMediaQueriesParams) Do(ctx context.Context) (medias []*Media, err error) {
  386. // execute
  387. var res GetMediaQueriesReturns
  388. err = cdp.Execute(ctx, CommandGetMediaQueries, nil, &res)
  389. if err != nil {
  390. return nil, err
  391. }
  392. return res.Medias, nil
  393. }
  394. // GetPlatformFontsForNodeParams requests information about platform fonts
  395. // which we used to render child TextNodes in the given node.
  396. type GetPlatformFontsForNodeParams struct {
  397. NodeID cdp.NodeID `json:"nodeId"`
  398. }
  399. // GetPlatformFontsForNode requests information about platform fonts which we
  400. // used to render child TextNodes in the given node.
  401. //
  402. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-getPlatformFontsForNode
  403. //
  404. // parameters:
  405. //
  406. // nodeID
  407. func GetPlatformFontsForNode(nodeID cdp.NodeID) *GetPlatformFontsForNodeParams {
  408. return &GetPlatformFontsForNodeParams{
  409. NodeID: nodeID,
  410. }
  411. }
  412. // GetPlatformFontsForNodeReturns return values.
  413. type GetPlatformFontsForNodeReturns struct {
  414. Fonts []*PlatformFontUsage `json:"fonts,omitempty"` // Usage statistics for every employed platform font.
  415. }
  416. // Do executes CSS.getPlatformFontsForNode against the provided context.
  417. //
  418. // returns:
  419. //
  420. // fonts - Usage statistics for every employed platform font.
  421. func (p *GetPlatformFontsForNodeParams) Do(ctx context.Context) (fonts []*PlatformFontUsage, err error) {
  422. // execute
  423. var res GetPlatformFontsForNodeReturns
  424. err = cdp.Execute(ctx, CommandGetPlatformFontsForNode, p, &res)
  425. if err != nil {
  426. return nil, err
  427. }
  428. return res.Fonts, nil
  429. }
  430. // GetStyleSheetTextParams returns the current textual content for a
  431. // stylesheet.
  432. type GetStyleSheetTextParams struct {
  433. StyleSheetID StyleSheetID `json:"styleSheetId"`
  434. }
  435. // GetStyleSheetText returns the current textual content for a stylesheet.
  436. //
  437. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-getStyleSheetText
  438. //
  439. // parameters:
  440. //
  441. // styleSheetID
  442. func GetStyleSheetText(styleSheetID StyleSheetID) *GetStyleSheetTextParams {
  443. return &GetStyleSheetTextParams{
  444. StyleSheetID: styleSheetID,
  445. }
  446. }
  447. // GetStyleSheetTextReturns return values.
  448. type GetStyleSheetTextReturns struct {
  449. Text string `json:"text,omitempty"` // The stylesheet text.
  450. }
  451. // Do executes CSS.getStyleSheetText against the provided context.
  452. //
  453. // returns:
  454. //
  455. // text - The stylesheet text.
  456. func (p *GetStyleSheetTextParams) Do(ctx context.Context) (text string, err error) {
  457. // execute
  458. var res GetStyleSheetTextReturns
  459. err = cdp.Execute(ctx, CommandGetStyleSheetText, p, &res)
  460. if err != nil {
  461. return "", err
  462. }
  463. return res.Text, nil
  464. }
  465. // GetLayersForNodeParams returns all layers parsed by the rendering engine
  466. // for the tree scope of a node. Given a DOM element identified by nodeId,
  467. // getLayersForNode returns the root layer for the nearest ancestor document or
  468. // shadow root. The layer root contains the full layer tree for the tree scope
  469. // and their ordering.
  470. type GetLayersForNodeParams struct {
  471. NodeID cdp.NodeID `json:"nodeId"`
  472. }
  473. // GetLayersForNode returns all layers parsed by the rendering engine for the
  474. // tree scope of a node. Given a DOM element identified by nodeId,
  475. // getLayersForNode returns the root layer for the nearest ancestor document or
  476. // shadow root. The layer root contains the full layer tree for the tree scope
  477. // and their ordering.
  478. //
  479. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-getLayersForNode
  480. //
  481. // parameters:
  482. //
  483. // nodeID
  484. func GetLayersForNode(nodeID cdp.NodeID) *GetLayersForNodeParams {
  485. return &GetLayersForNodeParams{
  486. NodeID: nodeID,
  487. }
  488. }
  489. // GetLayersForNodeReturns return values.
  490. type GetLayersForNodeReturns struct {
  491. RootLayer *LayerData `json:"rootLayer,omitempty"`
  492. }
  493. // Do executes CSS.getLayersForNode against the provided context.
  494. //
  495. // returns:
  496. //
  497. // rootLayer
  498. func (p *GetLayersForNodeParams) Do(ctx context.Context) (rootLayer *LayerData, err error) {
  499. // execute
  500. var res GetLayersForNodeReturns
  501. err = cdp.Execute(ctx, CommandGetLayersForNode, p, &res)
  502. if err != nil {
  503. return nil, err
  504. }
  505. return res.RootLayer, nil
  506. }
  507. // GetLocationForSelectorParams given a CSS selector text and a style sheet
  508. // ID, getLocationForSelector returns an array of locations of the CSS selector
  509. // in the style sheet.
  510. type GetLocationForSelectorParams struct {
  511. StyleSheetID StyleSheetID `json:"styleSheetId"`
  512. SelectorText string `json:"selectorText"`
  513. }
  514. // GetLocationForSelector given a CSS selector text and a style sheet ID,
  515. // getLocationForSelector returns an array of locations of the CSS selector in
  516. // the style sheet.
  517. //
  518. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-getLocationForSelector
  519. //
  520. // parameters:
  521. //
  522. // styleSheetID
  523. // selectorText
  524. func GetLocationForSelector(styleSheetID StyleSheetID, selectorText string) *GetLocationForSelectorParams {
  525. return &GetLocationForSelectorParams{
  526. StyleSheetID: styleSheetID,
  527. SelectorText: selectorText,
  528. }
  529. }
  530. // GetLocationForSelectorReturns return values.
  531. type GetLocationForSelectorReturns struct {
  532. Ranges []*SourceRange `json:"ranges,omitempty"`
  533. }
  534. // Do executes CSS.getLocationForSelector against the provided context.
  535. //
  536. // returns:
  537. //
  538. // ranges
  539. func (p *GetLocationForSelectorParams) Do(ctx context.Context) (ranges []*SourceRange, err error) {
  540. // execute
  541. var res GetLocationForSelectorReturns
  542. err = cdp.Execute(ctx, CommandGetLocationForSelector, p, &res)
  543. if err != nil {
  544. return nil, err
  545. }
  546. return res.Ranges, nil
  547. }
  548. // TrackComputedStyleUpdatesParams starts tracking the given computed styles
  549. // for updates. The specified array of properties replaces the one previously
  550. // specified. Pass empty array to disable tracking. Use takeComputedStyleUpdates
  551. // to retrieve the list of nodes that had properties modified. The changes to
  552. // computed style properties are only tracked for nodes pushed to the front-end
  553. // by the DOM agent. If no changes to the tracked properties occur after the
  554. // node has been pushed to the front-end, no updates will be issued for the
  555. // node.
  556. type TrackComputedStyleUpdatesParams struct {
  557. PropertiesToTrack []*ComputedStyleProperty `json:"propertiesToTrack"`
  558. }
  559. // TrackComputedStyleUpdates starts tracking the given computed styles for
  560. // updates. The specified array of properties replaces the one previously
  561. // specified. Pass empty array to disable tracking. Use takeComputedStyleUpdates
  562. // to retrieve the list of nodes that had properties modified. The changes to
  563. // computed style properties are only tracked for nodes pushed to the front-end
  564. // by the DOM agent. If no changes to the tracked properties occur after the
  565. // node has been pushed to the front-end, no updates will be issued for the
  566. // node.
  567. //
  568. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-trackComputedStyleUpdates
  569. //
  570. // parameters:
  571. //
  572. // propertiesToTrack
  573. func TrackComputedStyleUpdates(propertiesToTrack []*ComputedStyleProperty) *TrackComputedStyleUpdatesParams {
  574. return &TrackComputedStyleUpdatesParams{
  575. PropertiesToTrack: propertiesToTrack,
  576. }
  577. }
  578. // Do executes CSS.trackComputedStyleUpdates against the provided context.
  579. func (p *TrackComputedStyleUpdatesParams) Do(ctx context.Context) (err error) {
  580. return cdp.Execute(ctx, CommandTrackComputedStyleUpdates, p, nil)
  581. }
  582. // TakeComputedStyleUpdatesParams polls the next batch of computed style
  583. // updates.
  584. type TakeComputedStyleUpdatesParams struct{}
  585. // TakeComputedStyleUpdates polls the next batch of computed style updates.
  586. //
  587. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-takeComputedStyleUpdates
  588. func TakeComputedStyleUpdates() *TakeComputedStyleUpdatesParams {
  589. return &TakeComputedStyleUpdatesParams{}
  590. }
  591. // TakeComputedStyleUpdatesReturns return values.
  592. type TakeComputedStyleUpdatesReturns struct {
  593. NodeIDs []cdp.NodeID `json:"nodeIds,omitempty"` // The list of node Ids that have their tracked computed styles updated.
  594. }
  595. // Do executes CSS.takeComputedStyleUpdates against the provided context.
  596. //
  597. // returns:
  598. //
  599. // nodeIDs - The list of node Ids that have their tracked computed styles updated.
  600. func (p *TakeComputedStyleUpdatesParams) Do(ctx context.Context) (nodeIDs []cdp.NodeID, err error) {
  601. // execute
  602. var res TakeComputedStyleUpdatesReturns
  603. err = cdp.Execute(ctx, CommandTakeComputedStyleUpdates, nil, &res)
  604. if err != nil {
  605. return nil, err
  606. }
  607. return res.NodeIDs, nil
  608. }
  609. // SetEffectivePropertyValueForNodeParams find a rule with the given active
  610. // property for the given node and set the new value for this property.
  611. type SetEffectivePropertyValueForNodeParams struct {
  612. NodeID cdp.NodeID `json:"nodeId"` // The element id for which to set property.
  613. PropertyName string `json:"propertyName"`
  614. Value string `json:"value"`
  615. }
  616. // SetEffectivePropertyValueForNode find a rule with the given active
  617. // property for the given node and set the new value for this property.
  618. //
  619. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-setEffectivePropertyValueForNode
  620. //
  621. // parameters:
  622. //
  623. // nodeID - The element id for which to set property.
  624. // propertyName
  625. // value
  626. func SetEffectivePropertyValueForNode(nodeID cdp.NodeID, propertyName string, value string) *SetEffectivePropertyValueForNodeParams {
  627. return &SetEffectivePropertyValueForNodeParams{
  628. NodeID: nodeID,
  629. PropertyName: propertyName,
  630. Value: value,
  631. }
  632. }
  633. // Do executes CSS.setEffectivePropertyValueForNode against the provided context.
  634. func (p *SetEffectivePropertyValueForNodeParams) Do(ctx context.Context) (err error) {
  635. return cdp.Execute(ctx, CommandSetEffectivePropertyValueForNode, p, nil)
  636. }
  637. // SetPropertyRulePropertyNameParams modifies the property rule property
  638. // name.
  639. type SetPropertyRulePropertyNameParams struct {
  640. StyleSheetID StyleSheetID `json:"styleSheetId"`
  641. Range *SourceRange `json:"range"`
  642. PropertyName string `json:"propertyName"`
  643. }
  644. // SetPropertyRulePropertyName modifies the property rule property name.
  645. //
  646. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-setPropertyRulePropertyName
  647. //
  648. // parameters:
  649. //
  650. // styleSheetID
  651. // range
  652. // propertyName
  653. func SetPropertyRulePropertyName(styleSheetID StyleSheetID, rangeVal *SourceRange, propertyName string) *SetPropertyRulePropertyNameParams {
  654. return &SetPropertyRulePropertyNameParams{
  655. StyleSheetID: styleSheetID,
  656. Range: rangeVal,
  657. PropertyName: propertyName,
  658. }
  659. }
  660. // SetPropertyRulePropertyNameReturns return values.
  661. type SetPropertyRulePropertyNameReturns struct {
  662. PropertyName *Value `json:"propertyName,omitempty"` // The resulting key text after modification.
  663. }
  664. // Do executes CSS.setPropertyRulePropertyName against the provided context.
  665. //
  666. // returns:
  667. //
  668. // propertyName - The resulting key text after modification.
  669. func (p *SetPropertyRulePropertyNameParams) Do(ctx context.Context) (propertyName *Value, err error) {
  670. // execute
  671. var res SetPropertyRulePropertyNameReturns
  672. err = cdp.Execute(ctx, CommandSetPropertyRulePropertyName, p, &res)
  673. if err != nil {
  674. return nil, err
  675. }
  676. return res.PropertyName, nil
  677. }
  678. // SetKeyframeKeyParams modifies the keyframe rule key text.
  679. type SetKeyframeKeyParams struct {
  680. StyleSheetID StyleSheetID `json:"styleSheetId"`
  681. Range *SourceRange `json:"range"`
  682. KeyText string `json:"keyText"`
  683. }
  684. // SetKeyframeKey modifies the keyframe rule key text.
  685. //
  686. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-setKeyframeKey
  687. //
  688. // parameters:
  689. //
  690. // styleSheetID
  691. // range
  692. // keyText
  693. func SetKeyframeKey(styleSheetID StyleSheetID, rangeVal *SourceRange, keyText string) *SetKeyframeKeyParams {
  694. return &SetKeyframeKeyParams{
  695. StyleSheetID: styleSheetID,
  696. Range: rangeVal,
  697. KeyText: keyText,
  698. }
  699. }
  700. // SetKeyframeKeyReturns return values.
  701. type SetKeyframeKeyReturns struct {
  702. KeyText *Value `json:"keyText,omitempty"` // The resulting key text after modification.
  703. }
  704. // Do executes CSS.setKeyframeKey against the provided context.
  705. //
  706. // returns:
  707. //
  708. // keyText - The resulting key text after modification.
  709. func (p *SetKeyframeKeyParams) Do(ctx context.Context) (keyText *Value, err error) {
  710. // execute
  711. var res SetKeyframeKeyReturns
  712. err = cdp.Execute(ctx, CommandSetKeyframeKey, p, &res)
  713. if err != nil {
  714. return nil, err
  715. }
  716. return res.KeyText, nil
  717. }
  718. // SetMediaTextParams modifies the rule selector.
  719. type SetMediaTextParams struct {
  720. StyleSheetID StyleSheetID `json:"styleSheetId"`
  721. Range *SourceRange `json:"range"`
  722. Text string `json:"text"`
  723. }
  724. // SetMediaText modifies the rule selector.
  725. //
  726. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-setMediaText
  727. //
  728. // parameters:
  729. //
  730. // styleSheetID
  731. // range
  732. // text
  733. func SetMediaText(styleSheetID StyleSheetID, rangeVal *SourceRange, text string) *SetMediaTextParams {
  734. return &SetMediaTextParams{
  735. StyleSheetID: styleSheetID,
  736. Range: rangeVal,
  737. Text: text,
  738. }
  739. }
  740. // SetMediaTextReturns return values.
  741. type SetMediaTextReturns struct {
  742. Media *Media `json:"media,omitempty"` // The resulting CSS media rule after modification.
  743. }
  744. // Do executes CSS.setMediaText against the provided context.
  745. //
  746. // returns:
  747. //
  748. // media - The resulting CSS media rule after modification.
  749. func (p *SetMediaTextParams) Do(ctx context.Context) (media *Media, err error) {
  750. // execute
  751. var res SetMediaTextReturns
  752. err = cdp.Execute(ctx, CommandSetMediaText, p, &res)
  753. if err != nil {
  754. return nil, err
  755. }
  756. return res.Media, nil
  757. }
  758. // SetContainerQueryTextParams modifies the expression of a container query.
  759. type SetContainerQueryTextParams struct {
  760. StyleSheetID StyleSheetID `json:"styleSheetId"`
  761. Range *SourceRange `json:"range"`
  762. Text string `json:"text"`
  763. }
  764. // SetContainerQueryText modifies the expression of a container query.
  765. //
  766. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-setContainerQueryText
  767. //
  768. // parameters:
  769. //
  770. // styleSheetID
  771. // range
  772. // text
  773. func SetContainerQueryText(styleSheetID StyleSheetID, rangeVal *SourceRange, text string) *SetContainerQueryTextParams {
  774. return &SetContainerQueryTextParams{
  775. StyleSheetID: styleSheetID,
  776. Range: rangeVal,
  777. Text: text,
  778. }
  779. }
  780. // SetContainerQueryTextReturns return values.
  781. type SetContainerQueryTextReturns struct {
  782. ContainerQuery *ContainerQuery `json:"containerQuery,omitempty"` // The resulting CSS container query rule after modification.
  783. }
  784. // Do executes CSS.setContainerQueryText against the provided context.
  785. //
  786. // returns:
  787. //
  788. // containerQuery - The resulting CSS container query rule after modification.
  789. func (p *SetContainerQueryTextParams) Do(ctx context.Context) (containerQuery *ContainerQuery, err error) {
  790. // execute
  791. var res SetContainerQueryTextReturns
  792. err = cdp.Execute(ctx, CommandSetContainerQueryText, p, &res)
  793. if err != nil {
  794. return nil, err
  795. }
  796. return res.ContainerQuery, nil
  797. }
  798. // SetSupportsTextParams modifies the expression of a supports at-rule.
  799. type SetSupportsTextParams struct {
  800. StyleSheetID StyleSheetID `json:"styleSheetId"`
  801. Range *SourceRange `json:"range"`
  802. Text string `json:"text"`
  803. }
  804. // SetSupportsText modifies the expression of a supports at-rule.
  805. //
  806. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-setSupportsText
  807. //
  808. // parameters:
  809. //
  810. // styleSheetID
  811. // range
  812. // text
  813. func SetSupportsText(styleSheetID StyleSheetID, rangeVal *SourceRange, text string) *SetSupportsTextParams {
  814. return &SetSupportsTextParams{
  815. StyleSheetID: styleSheetID,
  816. Range: rangeVal,
  817. Text: text,
  818. }
  819. }
  820. // SetSupportsTextReturns return values.
  821. type SetSupportsTextReturns struct {
  822. Supports *Supports `json:"supports,omitempty"` // The resulting CSS Supports rule after modification.
  823. }
  824. // Do executes CSS.setSupportsText against the provided context.
  825. //
  826. // returns:
  827. //
  828. // supports - The resulting CSS Supports rule after modification.
  829. func (p *SetSupportsTextParams) Do(ctx context.Context) (supports *Supports, err error) {
  830. // execute
  831. var res SetSupportsTextReturns
  832. err = cdp.Execute(ctx, CommandSetSupportsText, p, &res)
  833. if err != nil {
  834. return nil, err
  835. }
  836. return res.Supports, nil
  837. }
  838. // SetScopeTextParams modifies the expression of a scope at-rule.
  839. type SetScopeTextParams struct {
  840. StyleSheetID StyleSheetID `json:"styleSheetId"`
  841. Range *SourceRange `json:"range"`
  842. Text string `json:"text"`
  843. }
  844. // SetScopeText modifies the expression of a scope at-rule.
  845. //
  846. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-setScopeText
  847. //
  848. // parameters:
  849. //
  850. // styleSheetID
  851. // range
  852. // text
  853. func SetScopeText(styleSheetID StyleSheetID, rangeVal *SourceRange, text string) *SetScopeTextParams {
  854. return &SetScopeTextParams{
  855. StyleSheetID: styleSheetID,
  856. Range: rangeVal,
  857. Text: text,
  858. }
  859. }
  860. // SetScopeTextReturns return values.
  861. type SetScopeTextReturns struct {
  862. Scope *Scope `json:"scope,omitempty"` // The resulting CSS Scope rule after modification.
  863. }
  864. // Do executes CSS.setScopeText against the provided context.
  865. //
  866. // returns:
  867. //
  868. // scope - The resulting CSS Scope rule after modification.
  869. func (p *SetScopeTextParams) Do(ctx context.Context) (scope *Scope, err error) {
  870. // execute
  871. var res SetScopeTextReturns
  872. err = cdp.Execute(ctx, CommandSetScopeText, p, &res)
  873. if err != nil {
  874. return nil, err
  875. }
  876. return res.Scope, nil
  877. }
  878. // SetRuleSelectorParams modifies the rule selector.
  879. type SetRuleSelectorParams struct {
  880. StyleSheetID StyleSheetID `json:"styleSheetId"`
  881. Range *SourceRange `json:"range"`
  882. Selector string `json:"selector"`
  883. }
  884. // SetRuleSelector modifies the rule selector.
  885. //
  886. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-setRuleSelector
  887. //
  888. // parameters:
  889. //
  890. // styleSheetID
  891. // range
  892. // selector
  893. func SetRuleSelector(styleSheetID StyleSheetID, rangeVal *SourceRange, selector string) *SetRuleSelectorParams {
  894. return &SetRuleSelectorParams{
  895. StyleSheetID: styleSheetID,
  896. Range: rangeVal,
  897. Selector: selector,
  898. }
  899. }
  900. // SetRuleSelectorReturns return values.
  901. type SetRuleSelectorReturns struct {
  902. SelectorList *SelectorList `json:"selectorList,omitempty"` // The resulting selector list after modification.
  903. }
  904. // Do executes CSS.setRuleSelector against the provided context.
  905. //
  906. // returns:
  907. //
  908. // selectorList - The resulting selector list after modification.
  909. func (p *SetRuleSelectorParams) Do(ctx context.Context) (selectorList *SelectorList, err error) {
  910. // execute
  911. var res SetRuleSelectorReturns
  912. err = cdp.Execute(ctx, CommandSetRuleSelector, p, &res)
  913. if err != nil {
  914. return nil, err
  915. }
  916. return res.SelectorList, nil
  917. }
  918. // SetStyleSheetTextParams sets the new stylesheet text.
  919. type SetStyleSheetTextParams struct {
  920. StyleSheetID StyleSheetID `json:"styleSheetId"`
  921. Text string `json:"text"`
  922. }
  923. // SetStyleSheetText sets the new stylesheet text.
  924. //
  925. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-setStyleSheetText
  926. //
  927. // parameters:
  928. //
  929. // styleSheetID
  930. // text
  931. func SetStyleSheetText(styleSheetID StyleSheetID, text string) *SetStyleSheetTextParams {
  932. return &SetStyleSheetTextParams{
  933. StyleSheetID: styleSheetID,
  934. Text: text,
  935. }
  936. }
  937. // SetStyleSheetTextReturns return values.
  938. type SetStyleSheetTextReturns struct {
  939. SourceMapURL string `json:"sourceMapURL,omitempty"` // URL of source map associated with script (if any).
  940. }
  941. // Do executes CSS.setStyleSheetText against the provided context.
  942. //
  943. // returns:
  944. //
  945. // sourceMapURL - URL of source map associated with script (if any).
  946. func (p *SetStyleSheetTextParams) Do(ctx context.Context) (sourceMapURL string, err error) {
  947. // execute
  948. var res SetStyleSheetTextReturns
  949. err = cdp.Execute(ctx, CommandSetStyleSheetText, p, &res)
  950. if err != nil {
  951. return "", err
  952. }
  953. return res.SourceMapURL, nil
  954. }
  955. // SetStyleTextsParams applies specified style edits one after another in the
  956. // given order.
  957. type SetStyleTextsParams struct {
  958. Edits []*StyleDeclarationEdit `json:"edits"`
  959. NodeForPropertySyntaxValidation cdp.NodeID `json:"nodeForPropertySyntaxValidation,omitempty"` // 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.
  960. }
  961. // SetStyleTexts applies specified style edits one after another in the given
  962. // order.
  963. //
  964. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-setStyleTexts
  965. //
  966. // parameters:
  967. //
  968. // edits
  969. func SetStyleTexts(edits []*StyleDeclarationEdit) *SetStyleTextsParams {
  970. return &SetStyleTextsParams{
  971. Edits: edits,
  972. }
  973. }
  974. // WithNodeForPropertySyntaxValidation nodeId for the DOM node in whose
  975. // context custom property declarations for registered properties should be
  976. // validated. If omitted, declarations in the new rule text can only be
  977. // validated statically, which may produce incorrect results if the declaration
  978. // contains a var() for example.
  979. func (p SetStyleTextsParams) WithNodeForPropertySyntaxValidation(nodeForPropertySyntaxValidation cdp.NodeID) *SetStyleTextsParams {
  980. p.NodeForPropertySyntaxValidation = nodeForPropertySyntaxValidation
  981. return &p
  982. }
  983. // SetStyleTextsReturns return values.
  984. type SetStyleTextsReturns struct {
  985. Styles []*Style `json:"styles,omitempty"` // The resulting styles after modification.
  986. }
  987. // Do executes CSS.setStyleTexts against the provided context.
  988. //
  989. // returns:
  990. //
  991. // styles - The resulting styles after modification.
  992. func (p *SetStyleTextsParams) Do(ctx context.Context) (styles []*Style, err error) {
  993. // execute
  994. var res SetStyleTextsReturns
  995. err = cdp.Execute(ctx, CommandSetStyleTexts, p, &res)
  996. if err != nil {
  997. return nil, err
  998. }
  999. return res.Styles, nil
  1000. }
  1001. // StartRuleUsageTrackingParams enables the selector recording.
  1002. type StartRuleUsageTrackingParams struct{}
  1003. // StartRuleUsageTracking enables the selector recording.
  1004. //
  1005. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-startRuleUsageTracking
  1006. func StartRuleUsageTracking() *StartRuleUsageTrackingParams {
  1007. return &StartRuleUsageTrackingParams{}
  1008. }
  1009. // Do executes CSS.startRuleUsageTracking against the provided context.
  1010. func (p *StartRuleUsageTrackingParams) Do(ctx context.Context) (err error) {
  1011. return cdp.Execute(ctx, CommandStartRuleUsageTracking, nil, nil)
  1012. }
  1013. // StopRuleUsageTrackingParams stop tracking rule usage and return the list
  1014. // of rules that were used since last call to takeCoverageDelta (or since start
  1015. // of coverage instrumentation).
  1016. type StopRuleUsageTrackingParams struct{}
  1017. // StopRuleUsageTracking stop tracking rule usage and return the list of
  1018. // rules that were used since last call to takeCoverageDelta (or since start of
  1019. // coverage instrumentation).
  1020. //
  1021. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-stopRuleUsageTracking
  1022. func StopRuleUsageTracking() *StopRuleUsageTrackingParams {
  1023. return &StopRuleUsageTrackingParams{}
  1024. }
  1025. // StopRuleUsageTrackingReturns return values.
  1026. type StopRuleUsageTrackingReturns struct {
  1027. RuleUsage []*RuleUsage `json:"ruleUsage,omitempty"`
  1028. }
  1029. // Do executes CSS.stopRuleUsageTracking against the provided context.
  1030. //
  1031. // returns:
  1032. //
  1033. // ruleUsage
  1034. func (p *StopRuleUsageTrackingParams) Do(ctx context.Context) (ruleUsage []*RuleUsage, err error) {
  1035. // execute
  1036. var res StopRuleUsageTrackingReturns
  1037. err = cdp.Execute(ctx, CommandStopRuleUsageTracking, nil, &res)
  1038. if err != nil {
  1039. return nil, err
  1040. }
  1041. return res.RuleUsage, nil
  1042. }
  1043. // TakeCoverageDeltaParams obtain list of rules that became used since last
  1044. // call to this method (or since start of coverage instrumentation).
  1045. type TakeCoverageDeltaParams struct{}
  1046. // TakeCoverageDelta obtain list of rules that became used since last call to
  1047. // this method (or since start of coverage instrumentation).
  1048. //
  1049. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-takeCoverageDelta
  1050. func TakeCoverageDelta() *TakeCoverageDeltaParams {
  1051. return &TakeCoverageDeltaParams{}
  1052. }
  1053. // TakeCoverageDeltaReturns return values.
  1054. type TakeCoverageDeltaReturns struct {
  1055. Coverage []*RuleUsage `json:"coverage,omitempty"`
  1056. Timestamp float64 `json:"timestamp,omitempty"` // Monotonically increasing time, in seconds.
  1057. }
  1058. // Do executes CSS.takeCoverageDelta against the provided context.
  1059. //
  1060. // returns:
  1061. //
  1062. // coverage
  1063. // timestamp - Monotonically increasing time, in seconds.
  1064. func (p *TakeCoverageDeltaParams) Do(ctx context.Context) (coverage []*RuleUsage, timestamp float64, err error) {
  1065. // execute
  1066. var res TakeCoverageDeltaReturns
  1067. err = cdp.Execute(ctx, CommandTakeCoverageDelta, nil, &res)
  1068. if err != nil {
  1069. return nil, 0, err
  1070. }
  1071. return res.Coverage, res.Timestamp, nil
  1072. }
  1073. // SetLocalFontsEnabledParams enables/disables rendering of local CSS fonts
  1074. // (enabled by default).
  1075. type SetLocalFontsEnabledParams struct {
  1076. Enabled bool `json:"enabled"` // Whether rendering of local fonts is enabled.
  1077. }
  1078. // SetLocalFontsEnabled enables/disables rendering of local CSS fonts
  1079. // (enabled by default).
  1080. //
  1081. // See: https://chromedevtools.github.io/devtools-protocol/tot/CSS#method-setLocalFontsEnabled
  1082. //
  1083. // parameters:
  1084. //
  1085. // enabled - Whether rendering of local fonts is enabled.
  1086. func SetLocalFontsEnabled(enabled bool) *SetLocalFontsEnabledParams {
  1087. return &SetLocalFontsEnabledParams{
  1088. Enabled: enabled,
  1089. }
  1090. }
  1091. // Do executes CSS.setLocalFontsEnabled against the provided context.
  1092. func (p *SetLocalFontsEnabledParams) Do(ctx context.Context) (err error) {
  1093. return cdp.Execute(ctx, CommandSetLocalFontsEnabled, p, nil)
  1094. }
  1095. // Command names.
  1096. const (
  1097. CommandAddRule = "CSS.addRule"
  1098. CommandCollectClassNames = "CSS.collectClassNames"
  1099. CommandCreateStyleSheet = "CSS.createStyleSheet"
  1100. CommandDisable = "CSS.disable"
  1101. CommandEnable = "CSS.enable"
  1102. CommandForcePseudoState = "CSS.forcePseudoState"
  1103. CommandGetBackgroundColors = "CSS.getBackgroundColors"
  1104. CommandGetComputedStyleForNode = "CSS.getComputedStyleForNode"
  1105. CommandGetInlineStylesForNode = "CSS.getInlineStylesForNode"
  1106. CommandGetMatchedStylesForNode = "CSS.getMatchedStylesForNode"
  1107. CommandGetMediaQueries = "CSS.getMediaQueries"
  1108. CommandGetPlatformFontsForNode = "CSS.getPlatformFontsForNode"
  1109. CommandGetStyleSheetText = "CSS.getStyleSheetText"
  1110. CommandGetLayersForNode = "CSS.getLayersForNode"
  1111. CommandGetLocationForSelector = "CSS.getLocationForSelector"
  1112. CommandTrackComputedStyleUpdates = "CSS.trackComputedStyleUpdates"
  1113. CommandTakeComputedStyleUpdates = "CSS.takeComputedStyleUpdates"
  1114. CommandSetEffectivePropertyValueForNode = "CSS.setEffectivePropertyValueForNode"
  1115. CommandSetPropertyRulePropertyName = "CSS.setPropertyRulePropertyName"
  1116. CommandSetKeyframeKey = "CSS.setKeyframeKey"
  1117. CommandSetMediaText = "CSS.setMediaText"
  1118. CommandSetContainerQueryText = "CSS.setContainerQueryText"
  1119. CommandSetSupportsText = "CSS.setSupportsText"
  1120. CommandSetScopeText = "CSS.setScopeText"
  1121. CommandSetRuleSelector = "CSS.setRuleSelector"
  1122. CommandSetStyleSheetText = "CSS.setStyleSheetText"
  1123. CommandSetStyleTexts = "CSS.setStyleTexts"
  1124. CommandStartRuleUsageTracking = "CSS.startRuleUsageTracking"
  1125. CommandStopRuleUsageTracking = "CSS.stopRuleUsageTracking"
  1126. CommandTakeCoverageDelta = "CSS.takeCoverageDelta"
  1127. CommandSetLocalFontsEnabled = "CSS.setLocalFontsEnabled"
  1128. )