forked from chromedp/chromedp
/
css.go
776 lines (673 loc) · 25.8 KB
/
css.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
// Package css provides the Chrome Debugging Protocol
// commands, types, and events for the CSS domain.
//
// This domain exposes CSS read/write operations. All CSS objects
// (stylesheets, rules, and styles) have an associated id used in subsequent
// operations on the related object. Each object type has a specific id
// structure, and those are not interchangeable between objects of different
// kinds. CSS objects can be loaded using the get*ForNode() calls (which accept
// a DOM node id). A client can also keep track of stylesheets via the
// styleSheetAdded/styleSheetRemoved events and subsequently load the required
// stylesheet contents using the getStyleSheet[Text]() methods.
//
// Generated by the chromedp-gen command.
package css
// AUTOGENERATED. DO NOT EDIT.
import (
"context"
cdp "github.com/knq/chromedp/cdp"
)
// EnableParams enables the CSS agent for the given page. Clients should not
// assume that the CSS agent has been enabled until the result of this command
// is received.
type EnableParams struct{}
// Enable enables the CSS agent for the given page. Clients should not assume
// that the CSS agent has been enabled until the result of this command is
// received.
func Enable() *EnableParams {
return &EnableParams{}
}
// Do executes CSS.enable against the provided context and
// target handler.
func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
return h.Execute(ctxt, cdp.CommandCSSEnable, nil, nil)
}
// DisableParams disables the CSS agent for the given page.
type DisableParams struct{}
// Disable disables the CSS agent for the given page.
func Disable() *DisableParams {
return &DisableParams{}
}
// Do executes CSS.disable against the provided context and
// target handler.
func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
return h.Execute(ctxt, cdp.CommandCSSDisable, nil, nil)
}
// GetMatchedStylesForNodeParams returns requested styles for a DOM node
// identified by nodeId.
type GetMatchedStylesForNodeParams struct {
NodeID cdp.NodeID `json:"nodeId"`
}
// GetMatchedStylesForNode returns requested styles for a DOM node identified
// by nodeId.
//
// parameters:
// nodeID
func GetMatchedStylesForNode(nodeID cdp.NodeID) *GetMatchedStylesForNodeParams {
return &GetMatchedStylesForNodeParams{
NodeID: nodeID,
}
}
// GetMatchedStylesForNodeReturns return values.
type GetMatchedStylesForNodeReturns struct {
InlineStyle *Style `json:"inlineStyle,omitempty"` // Inline style for the specified DOM node.
AttributesStyle *Style `json:"attributesStyle,omitempty"` // Attribute-defined element style (e.g. resulting from "width=20 height=100%").
MatchedCSSRules []*RuleMatch `json:"matchedCSSRules,omitempty"` // CSS rules matching this node, from all applicable stylesheets.
PseudoElements []*PseudoElementMatches `json:"pseudoElements,omitempty"` // Pseudo style matches for this node.
Inherited []*InheritedStyleEntry `json:"inherited,omitempty"` // A chain of inherited styles (from the immediate node parent up to the DOM tree root).
CSSKeyframesRules []*KeyframesRule `json:"cssKeyframesRules,omitempty"` // A list of CSS keyframed animations matching this node.
}
// Do executes CSS.getMatchedStylesForNode against the provided context and
// target handler.
//
// returns:
// inlineStyle - Inline style for the specified DOM node.
// attributesStyle - Attribute-defined element style (e.g. resulting from "width=20 height=100%").
// matchedCSSRules - CSS rules matching this node, from all applicable stylesheets.
// pseudoElements - Pseudo style matches for this node.
// inherited - A chain of inherited styles (from the immediate node parent up to the DOM tree root).
// cssKeyframesRules - A list of CSS keyframed animations matching this node.
func (p *GetMatchedStylesForNodeParams) Do(ctxt context.Context, h cdp.Handler) (inlineStyle *Style, attributesStyle *Style, matchedCSSRules []*RuleMatch, pseudoElements []*PseudoElementMatches, inherited []*InheritedStyleEntry, cssKeyframesRules []*KeyframesRule, err error) {
// execute
var res GetMatchedStylesForNodeReturns
err = h.Execute(ctxt, cdp.CommandCSSGetMatchedStylesForNode, p, &res)
if err != nil {
return nil, nil, nil, nil, nil, nil, err
}
return res.InlineStyle, res.AttributesStyle, res.MatchedCSSRules, res.PseudoElements, res.Inherited, res.CSSKeyframesRules, nil
}
// GetInlineStylesForNodeParams returns the styles defined inline (explicitly
// in the "style" attribute and implicitly, using DOM attributes) for a DOM node
// identified by nodeId.
type GetInlineStylesForNodeParams struct {
NodeID cdp.NodeID `json:"nodeId"`
}
// GetInlineStylesForNode returns the styles defined inline (explicitly in
// the "style" attribute and implicitly, using DOM attributes) for a DOM node
// identified by nodeId.
//
// parameters:
// nodeID
func GetInlineStylesForNode(nodeID cdp.NodeID) *GetInlineStylesForNodeParams {
return &GetInlineStylesForNodeParams{
NodeID: nodeID,
}
}
// GetInlineStylesForNodeReturns return values.
type GetInlineStylesForNodeReturns struct {
InlineStyle *Style `json:"inlineStyle,omitempty"` // Inline style for the specified DOM node.
AttributesStyle *Style `json:"attributesStyle,omitempty"` // Attribute-defined element style (e.g. resulting from "width=20 height=100%").
}
// Do executes CSS.getInlineStylesForNode against the provided context and
// target handler.
//
// returns:
// inlineStyle - Inline style for the specified DOM node.
// attributesStyle - Attribute-defined element style (e.g. resulting from "width=20 height=100%").
func (p *GetInlineStylesForNodeParams) Do(ctxt context.Context, h cdp.Handler) (inlineStyle *Style, attributesStyle *Style, err error) {
// execute
var res GetInlineStylesForNodeReturns
err = h.Execute(ctxt, cdp.CommandCSSGetInlineStylesForNode, p, &res)
if err != nil {
return nil, nil, err
}
return res.InlineStyle, res.AttributesStyle, nil
}
// GetComputedStyleForNodeParams returns the computed style for a DOM node
// identified by nodeId.
type GetComputedStyleForNodeParams struct {
NodeID cdp.NodeID `json:"nodeId"`
}
// GetComputedStyleForNode returns the computed style for a DOM node
// identified by nodeId.
//
// parameters:
// nodeID
func GetComputedStyleForNode(nodeID cdp.NodeID) *GetComputedStyleForNodeParams {
return &GetComputedStyleForNodeParams{
NodeID: nodeID,
}
}
// GetComputedStyleForNodeReturns return values.
type GetComputedStyleForNodeReturns struct {
ComputedStyle []*ComputedProperty `json:"computedStyle,omitempty"` // Computed style for the specified DOM node.
}
// Do executes CSS.getComputedStyleForNode against the provided context and
// target handler.
//
// returns:
// computedStyle - Computed style for the specified DOM node.
func (p *GetComputedStyleForNodeParams) Do(ctxt context.Context, h cdp.Handler) (computedStyle []*ComputedProperty, err error) {
// execute
var res GetComputedStyleForNodeReturns
err = h.Execute(ctxt, cdp.CommandCSSGetComputedStyleForNode, p, &res)
if err != nil {
return nil, err
}
return res.ComputedStyle, nil
}
// GetPlatformFontsForNodeParams requests information about platform fonts
// which we used to render child TextNodes in the given node.
type GetPlatformFontsForNodeParams struct {
NodeID cdp.NodeID `json:"nodeId"`
}
// GetPlatformFontsForNode requests information about platform fonts which we
// used to render child TextNodes in the given node.
//
// parameters:
// nodeID
func GetPlatformFontsForNode(nodeID cdp.NodeID) *GetPlatformFontsForNodeParams {
return &GetPlatformFontsForNodeParams{
NodeID: nodeID,
}
}
// GetPlatformFontsForNodeReturns return values.
type GetPlatformFontsForNodeReturns struct {
Fonts []*PlatformFontUsage `json:"fonts,omitempty"` // Usage statistics for every employed platform font.
}
// Do executes CSS.getPlatformFontsForNode against the provided context and
// target handler.
//
// returns:
// fonts - Usage statistics for every employed platform font.
func (p *GetPlatformFontsForNodeParams) Do(ctxt context.Context, h cdp.Handler) (fonts []*PlatformFontUsage, err error) {
// execute
var res GetPlatformFontsForNodeReturns
err = h.Execute(ctxt, cdp.CommandCSSGetPlatformFontsForNode, p, &res)
if err != nil {
return nil, err
}
return res.Fonts, nil
}
// GetStyleSheetTextParams returns the current textual content and the URL
// for a stylesheet.
type GetStyleSheetTextParams struct {
StyleSheetID StyleSheetID `json:"styleSheetId"`
}
// GetStyleSheetText returns the current textual content and the URL for a
// stylesheet.
//
// parameters:
// styleSheetID
func GetStyleSheetText(styleSheetID StyleSheetID) *GetStyleSheetTextParams {
return &GetStyleSheetTextParams{
StyleSheetID: styleSheetID,
}
}
// GetStyleSheetTextReturns return values.
type GetStyleSheetTextReturns struct {
Text string `json:"text,omitempty"` // The stylesheet text.
}
// Do executes CSS.getStyleSheetText against the provided context and
// target handler.
//
// returns:
// text - The stylesheet text.
func (p *GetStyleSheetTextParams) Do(ctxt context.Context, h cdp.Handler) (text string, err error) {
// execute
var res GetStyleSheetTextReturns
err = h.Execute(ctxt, cdp.CommandCSSGetStyleSheetText, p, &res)
if err != nil {
return "", err
}
return res.Text, nil
}
// CollectClassNamesParams returns all class names from specified stylesheet.
type CollectClassNamesParams struct {
StyleSheetID StyleSheetID `json:"styleSheetId"`
}
// CollectClassNames returns all class names from specified stylesheet.
//
// parameters:
// styleSheetID
func CollectClassNames(styleSheetID StyleSheetID) *CollectClassNamesParams {
return &CollectClassNamesParams{
StyleSheetID: styleSheetID,
}
}
// CollectClassNamesReturns return values.
type CollectClassNamesReturns struct {
ClassNames []string `json:"classNames,omitempty"` // Class name list.
}
// Do executes CSS.collectClassNames against the provided context and
// target handler.
//
// returns:
// classNames - Class name list.
func (p *CollectClassNamesParams) Do(ctxt context.Context, h cdp.Handler) (classNames []string, err error) {
// execute
var res CollectClassNamesReturns
err = h.Execute(ctxt, cdp.CommandCSSCollectClassNames, p, &res)
if err != nil {
return nil, err
}
return res.ClassNames, nil
}
// SetStyleSheetTextParams sets the new stylesheet text.
type SetStyleSheetTextParams struct {
StyleSheetID StyleSheetID `json:"styleSheetId"`
Text string `json:"text"`
}
// SetStyleSheetText sets the new stylesheet text.
//
// parameters:
// styleSheetID
// text
func SetStyleSheetText(styleSheetID StyleSheetID, text string) *SetStyleSheetTextParams {
return &SetStyleSheetTextParams{
StyleSheetID: styleSheetID,
Text: text,
}
}
// SetStyleSheetTextReturns return values.
type SetStyleSheetTextReturns struct {
SourceMapURL string `json:"sourceMapURL,omitempty"` // URL of source map associated with script (if any).
}
// Do executes CSS.setStyleSheetText against the provided context and
// target handler.
//
// returns:
// sourceMapURL - URL of source map associated with script (if any).
func (p *SetStyleSheetTextParams) Do(ctxt context.Context, h cdp.Handler) (sourceMapURL string, err error) {
// execute
var res SetStyleSheetTextReturns
err = h.Execute(ctxt, cdp.CommandCSSSetStyleSheetText, p, &res)
if err != nil {
return "", err
}
return res.SourceMapURL, nil
}
// SetRuleSelectorParams modifies the rule selector.
type SetRuleSelectorParams struct {
StyleSheetID StyleSheetID `json:"styleSheetId"`
Range *SourceRange `json:"range"`
Selector string `json:"selector"`
}
// SetRuleSelector modifies the rule selector.
//
// parameters:
// styleSheetID
// range
// selector
func SetRuleSelector(styleSheetID StyleSheetID, rangeVal *SourceRange, selector string) *SetRuleSelectorParams {
return &SetRuleSelectorParams{
StyleSheetID: styleSheetID,
Range: rangeVal,
Selector: selector,
}
}
// SetRuleSelectorReturns return values.
type SetRuleSelectorReturns struct {
SelectorList *SelectorList `json:"selectorList,omitempty"` // The resulting selector list after modification.
}
// Do executes CSS.setRuleSelector against the provided context and
// target handler.
//
// returns:
// selectorList - The resulting selector list after modification.
func (p *SetRuleSelectorParams) Do(ctxt context.Context, h cdp.Handler) (selectorList *SelectorList, err error) {
// execute
var res SetRuleSelectorReturns
err = h.Execute(ctxt, cdp.CommandCSSSetRuleSelector, p, &res)
if err != nil {
return nil, err
}
return res.SelectorList, nil
}
// SetKeyframeKeyParams modifies the keyframe rule key text.
type SetKeyframeKeyParams struct {
StyleSheetID StyleSheetID `json:"styleSheetId"`
Range *SourceRange `json:"range"`
KeyText string `json:"keyText"`
}
// SetKeyframeKey modifies the keyframe rule key text.
//
// parameters:
// styleSheetID
// range
// keyText
func SetKeyframeKey(styleSheetID StyleSheetID, rangeVal *SourceRange, keyText string) *SetKeyframeKeyParams {
return &SetKeyframeKeyParams{
StyleSheetID: styleSheetID,
Range: rangeVal,
KeyText: keyText,
}
}
// SetKeyframeKeyReturns return values.
type SetKeyframeKeyReturns struct {
KeyText *Value `json:"keyText,omitempty"` // The resulting key text after modification.
}
// Do executes CSS.setKeyframeKey against the provided context and
// target handler.
//
// returns:
// keyText - The resulting key text after modification.
func (p *SetKeyframeKeyParams) Do(ctxt context.Context, h cdp.Handler) (keyText *Value, err error) {
// execute
var res SetKeyframeKeyReturns
err = h.Execute(ctxt, cdp.CommandCSSSetKeyframeKey, p, &res)
if err != nil {
return nil, err
}
return res.KeyText, nil
}
// SetStyleTextsParams applies specified style edits one after another in the
// given order.
type SetStyleTextsParams struct {
Edits []*StyleDeclarationEdit `json:"edits"`
}
// SetStyleTexts applies specified style edits one after another in the given
// order.
//
// parameters:
// edits
func SetStyleTexts(edits []*StyleDeclarationEdit) *SetStyleTextsParams {
return &SetStyleTextsParams{
Edits: edits,
}
}
// SetStyleTextsReturns return values.
type SetStyleTextsReturns struct {
Styles []*Style `json:"styles,omitempty"` // The resulting styles after modification.
}
// Do executes CSS.setStyleTexts against the provided context and
// target handler.
//
// returns:
// styles - The resulting styles after modification.
func (p *SetStyleTextsParams) Do(ctxt context.Context, h cdp.Handler) (styles []*Style, err error) {
// execute
var res SetStyleTextsReturns
err = h.Execute(ctxt, cdp.CommandCSSSetStyleTexts, p, &res)
if err != nil {
return nil, err
}
return res.Styles, nil
}
// SetMediaTextParams modifies the rule selector.
type SetMediaTextParams struct {
StyleSheetID StyleSheetID `json:"styleSheetId"`
Range *SourceRange `json:"range"`
Text string `json:"text"`
}
// SetMediaText modifies the rule selector.
//
// parameters:
// styleSheetID
// range
// text
func SetMediaText(styleSheetID StyleSheetID, rangeVal *SourceRange, text string) *SetMediaTextParams {
return &SetMediaTextParams{
StyleSheetID: styleSheetID,
Range: rangeVal,
Text: text,
}
}
// SetMediaTextReturns return values.
type SetMediaTextReturns struct {
Media *Media `json:"media,omitempty"` // The resulting CSS media rule after modification.
}
// Do executes CSS.setMediaText against the provided context and
// target handler.
//
// returns:
// media - The resulting CSS media rule after modification.
func (p *SetMediaTextParams) Do(ctxt context.Context, h cdp.Handler) (media *Media, err error) {
// execute
var res SetMediaTextReturns
err = h.Execute(ctxt, cdp.CommandCSSSetMediaText, p, &res)
if err != nil {
return nil, err
}
return res.Media, nil
}
// CreateStyleSheetParams creates a new special "via-inspector" stylesheet in
// the frame with given frameId.
type CreateStyleSheetParams struct {
FrameID cdp.FrameID `json:"frameId"` // Identifier of the frame where "via-inspector" stylesheet should be created.
}
// CreateStyleSheet creates a new special "via-inspector" stylesheet in the
// frame with given frameId.
//
// parameters:
// frameID - Identifier of the frame where "via-inspector" stylesheet should be created.
func CreateStyleSheet(frameID cdp.FrameID) *CreateStyleSheetParams {
return &CreateStyleSheetParams{
FrameID: frameID,
}
}
// CreateStyleSheetReturns return values.
type CreateStyleSheetReturns struct {
StyleSheetID StyleSheetID `json:"styleSheetId,omitempty"` // Identifier of the created "via-inspector" stylesheet.
}
// Do executes CSS.createStyleSheet against the provided context and
// target handler.
//
// returns:
// styleSheetID - Identifier of the created "via-inspector" stylesheet.
func (p *CreateStyleSheetParams) Do(ctxt context.Context, h cdp.Handler) (styleSheetID StyleSheetID, err error) {
// execute
var res CreateStyleSheetReturns
err = h.Execute(ctxt, cdp.CommandCSSCreateStyleSheet, p, &res)
if err != nil {
return "", err
}
return res.StyleSheetID, nil
}
// AddRuleParams inserts a new rule with the given ruleText in a stylesheet
// with given styleSheetId, at the position specified by location.
type AddRuleParams struct {
StyleSheetID StyleSheetID `json:"styleSheetId"` // The css style sheet identifier where a new rule should be inserted.
RuleText string `json:"ruleText"` // The text of a new rule.
Location *SourceRange `json:"location"` // Text position of a new rule in the target style sheet.
}
// AddRule inserts a new rule with the given ruleText in a stylesheet with
// given styleSheetId, at the position specified by location.
//
// parameters:
// styleSheetID - The css style sheet identifier where a new rule should be inserted.
// ruleText - The text of a new rule.
// location - Text position of a new rule in the target style sheet.
func AddRule(styleSheetID StyleSheetID, ruleText string, location *SourceRange) *AddRuleParams {
return &AddRuleParams{
StyleSheetID: styleSheetID,
RuleText: ruleText,
Location: location,
}
}
// AddRuleReturns return values.
type AddRuleReturns struct {
Rule *Rule `json:"rule,omitempty"` // The newly created rule.
}
// Do executes CSS.addRule against the provided context and
// target handler.
//
// returns:
// rule - The newly created rule.
func (p *AddRuleParams) Do(ctxt context.Context, h cdp.Handler) (rule *Rule, err error) {
// execute
var res AddRuleReturns
err = h.Execute(ctxt, cdp.CommandCSSAddRule, p, &res)
if err != nil {
return nil, err
}
return res.Rule, nil
}
// ForcePseudoStateParams ensures that the given node will have specified
// pseudo-classes whenever its style is computed by the browser.
type ForcePseudoStateParams struct {
NodeID cdp.NodeID `json:"nodeId"` // The element id for which to force the pseudo state.
ForcedPseudoClasses []PseudoClass `json:"forcedPseudoClasses"` // Element pseudo classes to force when computing the element's style.
}
// ForcePseudoState ensures that the given node will have specified
// pseudo-classes whenever its style is computed by the browser.
//
// parameters:
// nodeID - The element id for which to force the pseudo state.
// forcedPseudoClasses - Element pseudo classes to force when computing the element's style.
func ForcePseudoState(nodeID cdp.NodeID, forcedPseudoClasses []PseudoClass) *ForcePseudoStateParams {
return &ForcePseudoStateParams{
NodeID: nodeID,
ForcedPseudoClasses: forcedPseudoClasses,
}
}
// Do executes CSS.forcePseudoState against the provided context and
// target handler.
func (p *ForcePseudoStateParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
return h.Execute(ctxt, cdp.CommandCSSForcePseudoState, p, nil)
}
// GetMediaQueriesParams returns all media queries parsed by the rendering
// engine.
type GetMediaQueriesParams struct{}
// GetMediaQueries returns all media queries parsed by the rendering engine.
func GetMediaQueries() *GetMediaQueriesParams {
return &GetMediaQueriesParams{}
}
// GetMediaQueriesReturns return values.
type GetMediaQueriesReturns struct {
Medias []*Media `json:"medias,omitempty"`
}
// Do executes CSS.getMediaQueries against the provided context and
// target handler.
//
// returns:
// medias
func (p *GetMediaQueriesParams) Do(ctxt context.Context, h cdp.Handler) (medias []*Media, err error) {
// execute
var res GetMediaQueriesReturns
err = h.Execute(ctxt, cdp.CommandCSSGetMediaQueries, nil, &res)
if err != nil {
return nil, err
}
return res.Medias, nil
}
// SetEffectivePropertyValueForNodeParams find a rule with the given active
// property for the given node and set the new value for this property.
type SetEffectivePropertyValueForNodeParams struct {
NodeID cdp.NodeID `json:"nodeId"` // The element id for which to set property.
PropertyName string `json:"propertyName"`
Value string `json:"value"`
}
// SetEffectivePropertyValueForNode find a rule with the given active
// property for the given node and set the new value for this property.
//
// parameters:
// nodeID - The element id for which to set property.
// propertyName
// value
func SetEffectivePropertyValueForNode(nodeID cdp.NodeID, propertyName string, value string) *SetEffectivePropertyValueForNodeParams {
return &SetEffectivePropertyValueForNodeParams{
NodeID: nodeID,
PropertyName: propertyName,
Value: value,
}
}
// Do executes CSS.setEffectivePropertyValueForNode against the provided context and
// target handler.
func (p *SetEffectivePropertyValueForNodeParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
return h.Execute(ctxt, cdp.CommandCSSSetEffectivePropertyValueForNode, p, nil)
}
// GetBackgroundColorsParams [no description].
type GetBackgroundColorsParams struct {
NodeID cdp.NodeID `json:"nodeId"` // Id of the node to get background colors for.
}
// GetBackgroundColors [no description].
//
// parameters:
// nodeID - Id of the node to get background colors for.
func GetBackgroundColors(nodeID cdp.NodeID) *GetBackgroundColorsParams {
return &GetBackgroundColorsParams{
NodeID: nodeID,
}
}
// GetBackgroundColorsReturns return values.
type GetBackgroundColorsReturns struct {
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).
}
// Do executes CSS.getBackgroundColors against the provided context and
// target handler.
//
// returns:
// 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).
func (p *GetBackgroundColorsParams) Do(ctxt context.Context, h cdp.Handler) (backgroundColors []string, err error) {
// execute
var res GetBackgroundColorsReturns
err = h.Execute(ctxt, cdp.CommandCSSGetBackgroundColors, p, &res)
if err != nil {
return nil, err
}
return res.BackgroundColors, nil
}
// StartRuleUsageTrackingParams enables the selector recording.
type StartRuleUsageTrackingParams struct{}
// StartRuleUsageTracking enables the selector recording.
func StartRuleUsageTracking() *StartRuleUsageTrackingParams {
return &StartRuleUsageTrackingParams{}
}
// Do executes CSS.startRuleUsageTracking against the provided context and
// target handler.
func (p *StartRuleUsageTrackingParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
return h.Execute(ctxt, cdp.CommandCSSStartRuleUsageTracking, nil, nil)
}
// TakeCoverageDeltaParams obtain list of rules that became used since last
// call to this method (or since start of coverage instrumentation).
type TakeCoverageDeltaParams struct{}
// TakeCoverageDelta obtain list of rules that became used since last call to
// this method (or since start of coverage instrumentation).
func TakeCoverageDelta() *TakeCoverageDeltaParams {
return &TakeCoverageDeltaParams{}
}
// TakeCoverageDeltaReturns return values.
type TakeCoverageDeltaReturns struct {
Coverage []*RuleUsage `json:"coverage,omitempty"`
}
// Do executes CSS.takeCoverageDelta against the provided context and
// target handler.
//
// returns:
// coverage
func (p *TakeCoverageDeltaParams) Do(ctxt context.Context, h cdp.Handler) (coverage []*RuleUsage, err error) {
// execute
var res TakeCoverageDeltaReturns
err = h.Execute(ctxt, cdp.CommandCSSTakeCoverageDelta, nil, &res)
if err != nil {
return nil, err
}
return res.Coverage, nil
}
// StopRuleUsageTrackingParams the list of rules with an indication of
// whether these were used.
type StopRuleUsageTrackingParams struct{}
// StopRuleUsageTracking the list of rules with an indication of whether
// these were used.
func StopRuleUsageTracking() *StopRuleUsageTrackingParams {
return &StopRuleUsageTrackingParams{}
}
// StopRuleUsageTrackingReturns return values.
type StopRuleUsageTrackingReturns struct {
RuleUsage []*RuleUsage `json:"ruleUsage,omitempty"`
}
// Do executes CSS.stopRuleUsageTracking against the provided context and
// target handler.
//
// returns:
// ruleUsage
func (p *StopRuleUsageTrackingParams) Do(ctxt context.Context, h cdp.Handler) (ruleUsage []*RuleUsage, err error) {
// execute
var res StopRuleUsageTrackingReturns
err = h.Execute(ctxt, cdp.CommandCSSStopRuleUsageTracking, nil, &res)
if err != nil {
return nil, err
}
return res.RuleUsage, nil
}